:root {
  --bg: #14161c;
  --bg-elevated: #1c1f27;
  --bg-card: #20232c;
  --border: #2c303a;
  --text: #f2f3f5;
  --text-muted: #8b909c;
  --gold: #f0c419;
  --green: #2ee6a6;
  --orange: #ff8a3d;
  --red: #ff5566;
  --yellow: #ffce54;
  --strava: #fc4c02;
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1, h2 { margin: 0 0 8px; }
h2 { font-size: 16px; color: var(--text); }
.muted { color: var(--text-muted); font-size: 13px; margin: 0; }

button { font-family: inherit; cursor: pointer; }

/* ---------- מסך כניסה ---------- */
.pin-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, #1c1f27, #0e0f13);
}
.pin-card {
  text-align: center;
  padding: 32px;
  width: 280px;
}
.pin-logo { font-size: 48px; margin-bottom: 8px; }
.pin-input {
  width: 100%;
  font-size: 32px;
  text-align: center;
  letter-spacing: 12px;
  padding: 14px;
  margin: 20px 0 12px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
}
.pin-error { color: var(--red); font-size: 13px; margin-top: 10px; }

/* ---------- כללי אפליקציה ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 700; font-size: 18px; letter-spacing: 1px; color: var(--gold); }
.icon-btn { background: none; border: none; color: var(--text-muted); font-size: 20px; }

.main { flex: 1; padding: 14px 14px 90px; overflow-y: auto; }
.view { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.row { display: flex; gap: 12px; }
.row .card { flex: 1; }

/* ---------- Quest Bar ---------- */
.quest-card { padding: 18px 16px; }
.quest-track {
  position: relative;
  height: 14px;
  border-radius: 10px;
  background: #2a2d38;
  overflow: visible;
  margin: 10px 0 4px;
}
.quest-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--orange), var(--gold), var(--green));
  transition: width 0.6s ease;
}
.quest-runner {
  position: absolute;
  top: -14px;
  right: 0%;
  transform: translateX(50%);
  font-size: 22px;
  transition: right 0.6s ease;
}
.quest-label { display: flex; justify-content: space-between; margin-top: 10px; font-size: 14px; }
#questPercent { color: var(--green); font-weight: 700; font-size: 18px; }

/* ---------- כרטיסי סטטוס ---------- */
.stat-card { text-align: center; }
.stat-icon { font-size: 26px; }
.stat-value { font-size: 18px; font-weight: 700; margin-top: 4px; }
.stat-sub { color: var(--text-muted); font-size: 12px; }

/* ---------- צ'קליסט ---------- */
.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.check-row:last-of-type { border-bottom: none; }
.check-label { font-size: 14px; }

.bottles { display: flex; gap: 4px; flex-wrap: wrap; }
.bottle { font-size: 20px; opacity: 0.3; background: none; border: none; padding: 2px; }
.bottle.filled { opacity: 1; }

.toggle-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--border); background: transparent; color: var(--text-muted); font-size: 16px;
}
.toggle-btn.on { background: var(--green); border-color: var(--green); color: #0c1210; }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper-btn {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); font-size: 16px;
}
.mini-input {
  width: 90px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); text-align: center;
}

.btn {
  border: none; border-radius: 14px; padding: 12px 18px; font-size: 15px; font-weight: 600;
  background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border);
}
.btn-primary { background: var(--gold); color: #1a1204; border: none; }
.btn-block { width: 100%; margin-top: 12px; text-align: center; display: block; text-decoration: none; }
.btn-strava { background: var(--strava); color: #fff; border: none; }

/* ---------- ניווט תחתון ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto;
  display: flex; background: var(--bg-elevated); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; background: none; border: none; color: var(--text-muted); padding: 10px 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 20px;
}
.nav-btn span { font-size: 11px; }
.nav-btn.active { color: var(--gold); }

/* ---------- מדליות ---------- */
.badges-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.badge-cell {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; opacity: 0.35;
}
.badge-cell.unlocked { opacity: 1; border-color: var(--gold); }
.badge-icon { font-size: 34px; }
.badge-title { font-size: 13px; font-weight: 700; margin-top: 6px; }
.badge-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---------- מודל שאלון כאב ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal {
  background: var(--bg-card); width: 100%; max-width: 480px; border-radius: 22px 22px 0 0;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
}
.modal-q { font-size: 14px; margin: 14px 0 8px; }
.choice-row { display: flex; gap: 8px; }
.choice {
  flex: 1; padding: 10px 4px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); font-size: 12px;
}
.choice.selected { outline: 2px solid var(--gold); }
.choice.green.selected { background: var(--green); color: #06231a; }
.choice.yellow.selected { background: var(--yellow); color: #241d06; }
.choice.red.selected { background: var(--red); color: #2a0508; }
.pain-tip {
  margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: #2a2410; color: var(--yellow); font-size: 13px;
}

/* ---------- גרפים ---------- */
.chart-box { width: 100%; }
.chart-box svg { width: 100%; height: auto; display: block; }

/* ---------- טוסט ---------- */
.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: #1a1204; padding: 10px 18px; border-radius: 14px;
  font-weight: 700; z-index: 60; box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
