/* ==========================================================================
   Quizzle — design system
   ========================================================================== */
:root {
  --ink: #24263d;
  --ink-soft: #5a5d7a;
  --ink-faint: #8b8eb0;
  --line: rgba(90, 93, 122, 0.14);
  --card: rgba(255, 255, 255, 0.9);
  --card-solid: #ffffff;
  --coral: #ff6b4a;
  --coral-2: #ff9a6a;
  --coral-soft: #ffe3d8;
  --gold: #f6a94a;
  --gold-2: #ffd166;
  --gold-soft: #ffedcc;
  --green: #2ec98f;
  --green-soft: #d6f7ea;
  --red: #ef5b6b;
  --red-soft: #fde1e5;
  --purple: #6f4fa5;
  --purple-2: #9a7fd0;
  --purple-soft: #ece3f7;
  --blue: #8ecae6;
  --shadow-sm: 0 2px 10px rgba(36, 38, 61, 0.08);
  --shadow-md: 0 16px 44px rgba(36, 38, 61, 0.16);
  --shadow-lg: 0 26px 70px rgba(36, 38, 61, 0.22);
  --radius: 22px;
  --radius-sm: 14px;
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 82% -12%, #dff2fb 0%, transparent 60%),
    radial-gradient(900px 540px at -12% 12%, #fdf3e3 0%, transparent 55%),
    linear-gradient(180deg, #a8d4ec 0%, #cfeaf6 42%, #f9e7cf 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Animated sky behind everything */
#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

h1, h2, h3, .display { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.01em; }
a { color: inherit; }
button { font-family: inherit; }
input { font-size: 16px; } /* ≥16px prevents iOS auto-zoom on focus */

.topbar, #app, .footer, .tabbar, .toast { position: relative; z-index: 1; }

/* ==========================================================================
   Header
   ========================================================================== */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 20px 8px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.brand-word {
  background: linear-gradient(120deg, #6f4fa5 10%, #ff6b4a 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-mark { width: 34px; height: 34px; filter: drop-shadow(0 2px 6px rgba(36, 38, 61, 0.18)); }

.nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow-sm);
}
.nav a {
  text-decoration: none;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink-soft);
  padding: 8px 15px;
  border-radius: 999px;
  transition: background 0.18s, color 0.18s, transform 0.12s;
}
.nav a:hover { background: rgba(111, 79, 165, 0.12); color: var(--ink); }
.nav a:active { transform: scale(0.96); }
.nav a.active { background: linear-gradient(135deg, #9a7fd0, #6f4fa5); color: #fff; box-shadow: 0 4px 14px rgba(111, 79, 165, 0.4); }

.player-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  max-width: 100%;
}
.player-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(46, 201, 143, 0.2); }
.chip-title { font-size: 11px; font-weight: 800; color: var(--purple); background: var(--purple-soft); border-radius: 999px; padding: 2px 8px; }
.player-chip input { background: transparent; border: none; outline: none; font: inherit; font-weight: 800; text-align: center; width: 110px; font-size: 16px; }

/* Mobile bottom tab bar */
.tabbar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 -8px 30px rgba(36, 38, 61, 0.12);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  grid-template-columns: repeat(4, 1fr);
}
.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-faint);
  padding: 6px 4px;
  border-radius: 14px;
  transition: color 0.15s, background 0.15s;
}
.tab-ico { font-size: 20px; line-height: 1; filter: drop-shadow(0 2px 3px rgba(36,38,61,0.15)); }
.tab-item.active { color: var(--purple); background: var(--purple-soft); }

/* ==========================================================================
   Layout
   ========================================================================== */
#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 6px 20px 70px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 20px 40px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
}
.footer .fine { font-size: 12px; }
.footer p { margin: 4px 0; }

.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 26px;
}

/* View transition */
#app.view-anim { animation: viewfade 0.38s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes viewfade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-weight: 900;
  font-size: 15px;
  border-radius: 999px;
  padding: 13px 22px;
  transition: transform 0.1s ease, box-shadow 0.2s ease, filter 0.2s ease;
  text-decoration: none;
  color: #fff;
  will-change: transform;
}
.btn:active { transform: translateY(2px) scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #ff9a6a, #ff6b4a); box-shadow: 0 10px 26px rgba(255, 107, 74, 0.4); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.04); transform: translateY(-1px); }
.btn-purple { background: linear-gradient(135deg, #9a7fd0, #6f4fa5); box-shadow: 0 10px 26px rgba(111, 79, 165, 0.4); }
.btn-purple:hover:not(:disabled) { filter: brightness(1.05); transform: translateY(-1px); }
.btn-ghost { background: rgba(255, 255, 255, 0.7); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.btn-ghost:hover:not(:disabled) { border-color: var(--purple); color: var(--purple); }
.btn-gold { background: linear-gradient(135deg, #ffd166, #f6a94a); color: #5a3d00; box-shadow: 0 10px 26px rgba(246, 169, 74, 0.42); }
.btn-gold:hover:not(:disabled) { transform: translateY(-1px); }
.btn-lg { font-size: 17px; padding: 16px 28px; }
.btn-sm { font-size: 13px; padding: 9px 16px; }

/* ==========================================================================
   Home hero
   ========================================================================== */
.hero { text-align: center; padding: 30px 24px 26px; overflow: hidden; }
.hero > * { animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both; }
.hero > *:nth-child(1) { animation-delay: 0.03s; }
.hero > *:nth-child(2) { animation-delay: 0.09s; }
.hero > *:nth-child(3) { animation-delay: 0.15s; }
.hero > *:nth-child(4) { animation-delay: 0.21s; }
.hero > *:nth-child(5) { animation-delay: 0.27s; }
.hero > *:nth-child(6) { animation-delay: 0.33s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.hero h1 {
  font-size: clamp(34px, 7vw, 54px);
  margin: 6px 0 4px;
  line-height: 1.04;
  font-weight: 700;
  background: linear-gradient(120deg, #43376b 0%, #6f4fa5 38%, #ff6b4a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .tagline { font-size: 18px; font-weight: 800; color: var(--ink-soft); margin: 0 0 14px; }
.hero .sub { color: var(--ink-soft); font-size: 15px; max-width: 520px; margin: 0 auto 18px; line-height: 1.5; }

.mountain-wrap { margin: 6px auto 2px; max-width: 640px; }
.mountain-wrap svg { filter: drop-shadow(0 14px 30px rgba(67, 55, 107, 0.18)); }

.name-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 14px 0 4px; }
.name-row input {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 13px 18px;
  border-radius: 999px;
  border: 2px solid var(--line);
  width: 220px;
  text-align: center;
  outline: none;
  background: rgba(255, 255, 255, 0.8);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.name-row input:focus { border-color: var(--purple); box-shadow: 0 0 0 4px var(--purple-soft); }

.cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 16px 0 20px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-soft);
  font-weight: 800;
  font-size: 13px;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.15s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.chip:hover { border-color: var(--purple); color: var(--purple); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.chip .emoji { margin-right: 4px; }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.step { text-align: center; padding: 8px; }
.step .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd166, #f6a94a);
  color: #5a3d00;
  font-weight: 900;
  font-size: 18px;
  margin-bottom: 10px;
  box-shadow: 0 6px 16px rgba(246, 169, 74, 0.4);
}
.step h3 { margin: 4px 0; font-size: 17px; }
.step p { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }

.section-title { font-size: 20px; margin: 4px 0 12px; }

/* ==========================================================================
   Quiz player
   ========================================================================== */
.quiz-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.quiz-head .qcount { font-weight: 900; font-size: 14px; color: var(--purple); background: var(--purple-soft); border-radius: 999px; padding: 6px 12px; }
.quiz-head .title { font-family: var(--font-display); font-weight: 600; font-size: 18px; flex: 1 1 auto; min-width: 140px; }
.quiz-head .alt-live { display: flex; align-items: baseline; gap: 6px; }
.quiz-head .alt-live .m { font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--coral); }
.quiz-head .alt-live .z { font-size: 13px; font-weight: 800; color: var(--ink-faint); }
.sound-toggle {
  border: none;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  width: 40px; height: 40px;
  font-size: 17px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.12s ease, background 0.15s;
}
.sound-toggle:hover { background: #fff; }
.sound-toggle:active { transform: scale(0.9); }

.timerbar { height: 8px; border-radius: 999px; background: rgba(90, 93, 122, 0.12); overflow: hidden; margin: 2px 0 6px; }
.timerbar .fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--green), var(--gold)); transition: width 0.2s linear; }
.timerbar.urgent .fill { background: linear-gradient(90deg, var(--coral), var(--red)); }
.timer-num { font-weight: 900; font-size: 13px; color: var(--ink-faint); }

/* In-card countdown: full-card drain + seconds pill next to the input */
#questionCard { position: relative; overflow: hidden; }
.q-timer-fill {
  position: absolute; top: 0; bottom: 0; left: 0; width: 100%;
  background: linear-gradient(90deg, rgba(111, 79, 165, 0.12), rgba(142, 202, 230, 0.10));
  border-right: 2px solid rgba(111, 79, 165, 0.28);
  z-index: 0;
  transition: width 0.2s linear;
  pointer-events: none;
}
#questionCard.urgent .q-timer-fill {
  background: linear-gradient(90deg, rgba(255, 107, 74, 0.18), rgba(246, 169, 74, 0.14));
  border-right-color: rgba(255, 107, 74, 0.55);
}
.q-content { position: relative; z-index: 1; }
.q-timer-pill {
  display: inline-flex; align-items: baseline; gap: 3px;
  background: var(--ink); color: #fff; font-weight: 900;
  border-radius: 999px; padding: 8px 14px; font-size: 15px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.q-timer-pill #qTimerNum { font-family: var(--font-display); font-size: 18px; }
.q-timer-pill .qt-unit { font-size: 11px; opacity: 0.75; font-weight: 800; }
.q-timer-pill.urgent { background: var(--red); animation: pulse 0.8s ease-in-out infinite; }
.q-poll-head { display: flex; align-items: center; gap: 8px; }
.q-poll-head .q-timer-pill { margin-left: auto; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

.quiz-grid { display: grid; grid-template-columns: 1fr 230px; gap: 18px; align-items: start; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--coral-soft);
  color: #c14a24;
  font-weight: 900;
  font-size: 12px;
  border-radius: 999px;
  padding: 6px 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.prompt { font-family: var(--font-display); font-size: 26px; font-weight: 600; margin: 14px 0 6px; line-height: 1.18; }
.hint { color: var(--ink-faint); font-size: 14px; font-weight: 700; margin: 0 0 16px; }

.answer-form { display: flex; gap: 10px; flex-wrap: wrap; }
.answer-input {
  flex: 1 1 200px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  outline: none;
  background: rgba(255, 255, 255, 0.85);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.answer-input:focus { border-color: var(--purple); box-shadow: 0 0 0 4px var(--purple-soft); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.option {
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  padding: 20px 16px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
}
.option:hover { border-color: var(--purple); transform: translateY(-2px); box-shadow: var(--shadow-sm); background: #fff; }
.option:active { transform: translateY(0) scale(0.98); }

.feedback { border-radius: var(--radius); padding: 18px 20px; margin-top: 18px; display: none; }
.feedback.show { display: block; animation: pop 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
.feedback.correct { background: var(--green-soft); }
.feedback.wrong { background: var(--red-soft); }
.feedback .fb-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.feedback .fb-title.correct { color: #157a54; }
.feedback .fb-title.wrong { color: #b02a3a; }
.feedback .fb-meta { margin-top: 6px; font-size: 14px; font-weight: 700; color: var(--ink-soft); line-height: 1.5; }
.feedback .fb-spot { margin-top: 6px; font-weight: 800; font-size: 13px; color: var(--purple); }
.feedback .fb-alt { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--coral); margin-top: 8px; }
.feedback .next { margin-top: 14px; }

@keyframes pop { 0% { transform: scale(0.94); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* Altitude ladder (desktop sidebar) */
.ladder {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 18px 16px;
  text-align: center;
  position: sticky;
  top: 16px;
}
.ladder .summit-label { font-weight: 900; font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.08em; }
.ladder-track {
  position: relative;
  height: 250px;
  margin: 12px auto 6px;
  width: 46px;
  background: linear-gradient(180deg, rgba(238, 243, 248, 0.9), rgba(221, 230, 239, 0.9));
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(36, 38, 61, 0.08);
}
.ladder-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, #ffd166 0%, #ff9a6a 55%, #ff6b4a 100%);
  border-radius: 999px;
  transition: height 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.ladder-ticks {
  position: absolute;
  left: -34px;
  top: 0; bottom: 0;
  width: 30px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 900;
  color: var(--ink-faint);
  text-align: right;
}
.ladder-climber {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  transition: bottom 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
}
.ladder .alt-num { font-family: var(--font-display); font-weight: 700; font-size: 24px; color: var(--coral); }
.ladder .alt-zone { font-weight: 800; font-size: 13px; color: var(--purple); margin-top: 2px; }

/* Horizontal altitude meter (mobile) */
.ladder-h { display: none; align-items: center; gap: 10px; margin-top: 12px; }
.ladder-h .lh-track { position: relative; flex: 1; height: 16px; border-radius: 999px; background: linear-gradient(90deg, rgba(238,243,248,.9), rgba(221,230,239,.9)); overflow: visible; box-shadow: inset 0 2px 6px rgba(36,38,61,.08); }
.ladder-h .lh-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: linear-gradient(90deg, #ffd166, #ff9a6a 55%, #ff6b4a); transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
.ladder-h .lh-climber { position: absolute; top: 50%; transform: translate(-50%, -50%); font-size: 22px; transition: left 0.6s cubic-bezier(0.22, 1, 0.36, 1); filter: drop-shadow(0 2px 3px rgba(0,0,0,.25)); }
.ladder-h .lh-end { font-size: 10px; font-weight: 900; color: var(--ink-faint); }

/* ==========================================================================
   Results
   ========================================================================== */
.summit { text-align: center; padding: 28px 24px; }
.summit .big-alt { font-family: var(--font-display); font-weight: 700; font-size: clamp(44px, 9vw, 72px); color: var(--coral); line-height: 1; }
.summit .big-alt .unit { font-size: 0.4em; color: var(--ink-faint); }
.summit .zone-pill {
  display: inline-block;
  margin-top: 8px;
  background: var(--purple-soft);
  color: var(--purple);
  font-weight: 900;
  font-size: 14px;
  border-radius: 999px;
  padding: 7px 16px;
}
.summit .rank-line { margin-top: 12px; font-weight: 800; color: var(--ink-soft); font-size: 15px; }
.summit .share-row { margin-top: 18px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pr-banner { background: var(--gold-soft); color: #8a5b00; font-weight: 900; font-size: 14px; border-radius: 999px; padding: 8px 16px; display: inline-block; margin: 6px 0; animation: pop 0.3s ease; }
.streak-line { color: var(--coral); font-weight: 900; font-size: 14px; margin: 6px 0 0; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.bar-label { text-align: right; font-weight: 800; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { grid-column: 1 / -1; height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--purple), var(--coral)); }

.qresult { display: flex; flex-direction: column; gap: 10px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.qresult:last-child { border-bottom: none; }
.qresult .qr-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.qresult .qr-prompt { font-weight: 800; font-size: 15px; }
.qresult .qr-answer { display: inline-flex; gap: 8px; align-items: center; background: rgba(244, 246, 251, 0.8); border-radius: var(--radius-sm); padding: 8px 12px; font-weight: 800; font-size: 14px; }
.qresult .qr-answer.correct { background: var(--green-soft); color: #157a54; }
.qresult .qr-answer.wrong { background: var(--red-soft); color: #b02a3a; }
.qresult .qr-alt { font-weight: 900; color: var(--coral); font-size: 14px; margin-left: auto; }
.qresult .qr-note { color: var(--ink-faint); font-size: 12px; font-weight: 700; }

/* Duels */
.duel { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 12px 0; }
.duel-side { text-align: center; flex: 0 0 auto; min-width: 120px; }
.duel-side.you { border: 2px solid var(--green); border-radius: var(--radius); padding: 12px; background: var(--green-soft); }
.duel-side.rival { border: 2px solid var(--line); border-radius: var(--radius); padding: 12px; background: rgba(255,255,255,.6); }
.d-name { font-weight: 900; font-size: 14px; }
.d-alt { font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--coral); }
.d-vs { font-weight: 900; color: var(--ink-faint); }

/* ==========================================================================
   Tables, tabs, groups
   ========================================================================== */
table.leaderboard { width: 100%; border-collapse: collapse; font-size: 14px; }
table.leaderboard th { text-align: left; font-weight: 900; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); padding: 8px 10px; border-bottom: 2px solid var(--line); }
table.leaderboard td { padding: 10px; border-bottom: 1px solid var(--line); font-weight: 700; }
table.leaderboard tr.me td { background: var(--gold-soft); }
.rank-num { font-weight: 900; color: var(--ink-faint); width: 40px; }
.rank-1 { color: var(--gold); }
.rank-2 { color: #9aa3b2; }
.rank-3 { color: #d98a5b; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { border: 1px solid var(--line); background: rgba(255,255,255,.7); color: var(--ink-soft); font-weight: 800; font-size: 13px; border-radius: 999px; padding: 8px 14px; cursor: pointer; transition: all 0.15s; }
.tab:hover { border-color: var(--purple); color: var(--purple); }
.tab.active { background: linear-gradient(135deg, #9a7fd0, #6f4fa5); border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(111, 79, 165, 0.35); }

.group-join { display: flex; gap: 10px; flex-wrap: wrap; }
.group-join input { flex: 1 1 180px; font-family: inherit; font-size: 16px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; padding: 12px 16px; border-radius: 999px; border: 2px solid var(--line); outline: none; text-align: center; background: rgba(255,255,255,.8); }
.group-join input:focus { border-color: var(--purple); box-shadow: 0 0 0 4px var(--purple-soft); }

/* ==========================================================================
   Affirming stats, badges, levels, hall of fame
   ========================================================================== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.stat { background: rgba(255, 255, 255, 0.72); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 12px; text-align: center; box-shadow: var(--shadow-sm); }
.stat .v { font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--coral); line-height: 1.15; word-break: break-word; }
.stat .l { font-size: 11px; font-weight: 800; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 4px; }
.pep { text-align: center; font-weight: 800; color: var(--purple); font-size: 14px; margin: 4px 0 0; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.badge-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; opacity: 0.5; filter: grayscale(0.7); background: rgba(255,255,255,.5); }
.badge-item.on { opacity: 1; filter: none; border-color: var(--gold); background: var(--gold-soft); }
.b-emoji { font-size: 26px; }
.b-name { font-weight: 900; font-size: 14px; }
.b-desc { font-size: 12px; color: var(--ink-faint); font-weight: 700; }

.levelbar { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; }
.levelbar-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--gold), var(--coral)); border-radius: 999px; transition: width 0.6s ease; }

.hall-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.hall-item:last-child { border-bottom: none; }
.hall-item .h-emoji { font-size: 22px; }
.h-ans { font-weight: 900; font-size: 15px; }
.h-prom { font-size: 12px; color: var(--ink-faint); font-weight: 700; }

/* ==========================================================================
   My climbs (history)
   ========================================================================== */
.hlist { display: flex; flex-direction: column; gap: 10px; }
.hentry { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: rgba(255,255,255,.5); }
.hentry summary { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; list-style: none; flex-wrap: wrap; }
.hentry summary::-webkit-details-marker { display: none; }
.hentry summary:hover { background: rgba(255,255,255,.7); }
.h-title { font-weight: 900; font-size: 14px; flex: 1 1 auto; min-width: 120px; }
.h-date { color: var(--ink-faint); font-size: 12px; font-weight: 800; }
.h-zone { color: var(--purple); font-size: 12px; font-weight: 800; background: var(--purple-soft); border-radius: 999px; padding: 3px 9px; }
.h-total { font-family: var(--font-display); font-weight: 700; color: var(--coral); font-size: 15px; }
.h-correct { font-size: 12px; font-weight: 800; color: var(--ink-faint); }
.h-answers { padding: 2px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.h-answer { border-left: 3px solid var(--line); padding: 8px 10px; background: rgba(250, 251, 254, 0.8); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.h-answer.ok { border-left-color: var(--green); background: var(--green-soft); }
.h-answer.no { border-left-color: var(--red); background: var(--red-soft); }
.h-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.h-prompt { font-weight: 800; font-size: 13px; }
.h-alt { font-weight: 900; color: var(--coral); font-size: 13px; white-space: nowrap; }
.h-your { font-size: 13px; font-weight: 700; margin-top: 2px; }
.h-note { color: var(--ink-faint); font-weight: 700; font-size: 12px; }

/* ==========================================================================
   Confetti, toast, misc
   ========================================================================== */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 999; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; opacity: 0.9; border-radius: 2px; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { 0% { transform: translateY(0) rotate(0deg); opacity: 1; } 100% { transform: translateY(105vh) rotate(720deg); opacity: 0; } }

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s;
  pointer-events: none;
  z-index: 60;
  max-width: 90vw;
  text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.muted { color: var(--ink-faint); }
.small { font-size: 13px; }
.spacer { flex: 1; }

.loading { text-align: center; padding: 60px 20px; color: var(--ink-soft); font-weight: 800; }
.spinner { width: 34px; height: 34px; border: 4px solid var(--purple-soft); border-top-color: var(--purple); border-radius: 50%; margin: 0 auto 14px; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Mountain scene animation helpers (SVG)
   ========================================================================== */
.cloud { animation: drift 26s linear infinite; }
.cloud.c2 { animation-duration: 34s; animation-delay: -10s; }
.cloud.c3 { animation-duration: 44s; animation-delay: -20s; }
@keyframes drift { 0% { transform: translateX(-30px); } 50% { transform: translateX(30px); } 100% { transform: translateX(-30px); } }

.trail-path { stroke-dasharray: 8 8; animation: dashmove 2.6s linear infinite; }
@keyframes dashmove { to { stroke-dashoffset: -32; } }

.climber-bob { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* Seasons */
body[data-season="winter"] { --sky-1: #c7ddf2; --sky-2: #eef4fb; }
body[data-season="spring"] { --sky-1: #c9eecf; --sky-2: #eefbe9; }
body[data-season="summer"] { --sky-1: #a8d8f0; --sky-2: #e9f8ff; }
body[data-season="autumn"] { --sky-1: #f6d8a8; --sky-2: #fdf1dc; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 760px) {
  .topbar { padding: 10px 14px 4px; gap: 10px; }
  .brand { font-size: 22px; }
  .brand-mark { width: 28px; height: 28px; }
  .nav { display: none; }
  .tabbar { display: grid; }
  .player-chip { margin-left: auto; padding: 7px 12px; }
  .chip-title { display: none; }
  #app { padding: 6px 14px 96px; gap: 16px; }
  .card { padding: 20px; border-radius: 18px; }
  .quiz-grid { grid-template-columns: 1fr; }
  .ladder { position: static; }
  .ladder .summit-label, .ladder-track { display: none; }
  .ladder-h { display: flex; }
  .options { grid-template-columns: 1fr; }
  .prompt { font-size: 22px; }
  .answer-form .btn { flex: 1 1 auto; }
  .footer { padding-bottom: 96px; }
  .hero { padding: 22px 16px 20px; }
}

@media (min-width: 761px) {
  .tabbar { display: none; }
}

@media (max-width: 420px) {
  .btn { font-size: 14px; padding: 12px 18px; }
  .btn-lg { font-size: 16px; padding: 14px 22px; }
  table.leaderboard { font-size: 13px; }
  table.leaderboard th, table.leaderboard td { padding: 7px 6px; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
  html { scroll-behavior: auto; }
}
