/* =========================================================================
   SAF Sky Quest — design tokens
   Theme: aviation "boarding pass / flight path" — built for the AMIC x
   Airbus SAF booth game. One cohesive sky-and-runway look; no dark mode
   needed (kiosk/booth context, single fixed presentation).
   ========================================================================= */
:root {
  --deep-sky: #0B3D65;
  --sky-blue: #1C6DD0;
  --cloud-blue: #6EC6FF;
  --saf-green: #2FBF71;
  --sun-amber: #FFB020;
  --cloud-white: #F7FAFC;
  --ink: #0B1F33;
  --coral: #E8555A;
  --coral-tint: #FDEBEC;
  --green-tint: #E7F9F0;

  --font-display: 'Baloo 2', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, monospace;

  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow-card: 0 20px 45px -20px rgba(11, 61, 101, 0.45);
  --shadow-btn: 0 8px 0 0 rgba(11, 31, 51, 0.18);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  background: linear-gradient(180deg, #BFE3FF 0%, #DFF1FF 38%, #F3FAFF 75%, #FFFFFF 100%);
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; font-weight: 700; }
p { margin: 0; }
.mono { font-family: var(--font-mono); }

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

/* ---------------------------------------------------------------------
   Ambient sky background
   --------------------------------------------------------------------- */
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

/* Hidden <svg><symbol> defs block holding the reusable mascot artwork */
.svg-defs { position: absolute; width: 0; height: 0; }
.cloud {
  position: absolute;
  background: #fff;
  opacity: 0.6;
  border-radius: 100px;
  filter: blur(1px);
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 100px;
}
.cloud--a { width: 180px; height: 56px; top: 8%; left: -10%; animation: drift 62s linear infinite; }
.cloud--a::before { width: 90px; height: 90px; top: -40px; left: 20px; }
.cloud--a::after { width: 70px; height: 70px; top: -26px; left: 100px; }
.cloud--b { width: 130px; height: 42px; top: 22%; left: -15%; animation: drift 48s linear infinite; animation-delay: -10s; opacity: 0.45; }
.cloud--b::before { width: 60px; height: 60px; top: -26px; left: 16px; }
.cloud--b::after { width: 50px; height: 50px; top: -18px; left: 70px; }
.cloud--c { width: 220px; height: 64px; top: 68%; left: -20%; animation: drift 80s linear infinite; animation-delay: -30s; opacity: 0.5; }
.cloud--c::before { width: 100px; height: 100px; top: -46px; left: 30px; }
.cloud--c::after { width: 80px; height: 80px; top: -30px; left: 130px; }
.cloud--d { width: 100px; height: 34px; top: 45%; left: -10%; animation: drift 40s linear infinite; animation-delay: -22s; opacity: 0.4; }
.cloud--d::before { width: 46px; height: 46px; top: -20px; left: 12px; }
.cloud--d::after { width: 38px; height: 38px; top: -14px; left: 54px; }

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(140vw); }
}

/* ---------------------------------------------------------------------
   App shell / screens
   --------------------------------------------------------------------- */
#app { position: relative; z-index: 1; min-height: 100vh; }
.screen {
  display: none;
  min-height: 100vh;
  padding: clamp(16px, 3vw, 32px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ---------------------------------------------------------------------
   Mascot
   --------------------------------------------------------------------- */
.mascot svg { width: 100%; height: 100%; display: block; }
.mascot { filter: drop-shadow(0 12px 18px rgba(11,61,101,0.25)); }
.mascot--md { width: 96px; height: 84px; }
.mascot--lg { width: 128px; height: 112px; }
.mascot--xl { width: 168px; height: 147px; }
.idle-bob { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-10px) rotate(1.5deg); }
}

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
  border: none;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  padding: 14px 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(4px); }
.btn-icon { display: inline-block; }

.btn--primary { background: var(--sun-amber); color: #3A2400; box-shadow: var(--shadow-btn); }
.btn--primary:active { box-shadow: 0 4px 0 0 rgba(11,31,51,0.18); }
.btn--primary:hover { filter: brightness(1.04); }

.btn--secondary { background: var(--saf-green); color: #06301A; box-shadow: 0 8px 0 0 rgba(6,48,26,0.25); }
.btn--secondary:active { box-shadow: 0 4px 0 0 rgba(6,48,26,0.25); }

.btn--ghost { background: transparent; color: var(--deep-sky); border: 2px solid rgba(11,61,101,0.25); box-shadow: none; }
.btn--ghost:active { transform: translateY(2px); }

.btn--outline { background: #fff; color: var(--sky-blue); border: 2px solid var(--cloud-blue); box-shadow: none; }
.btn--outline:hover { background: #EFF8FF; }

.btn--text { background: none; color: var(--deep-sky); box-shadow: none; text-decoration: underline; padding: 8px; font-family: var(--font-body); font-weight: 700; opacity: 0.75; }

.btn--xl { font-size: 1.25rem; padding: 18px 36px; }
.btn--lg { font-size: 1.1rem; padding: 16px 30px; }
.btn--sm { font-size: 0.85rem; padding: 8px 16px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn[hidden] { display: none; }

/* ---------------------------------------------------------------------
   Generic cards
   --------------------------------------------------------------------- */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: clamp(24px, 4vw, 44px);
  width: 100%;
  max-width: 560px;
  text-align: center;
  position: relative;
}
.card--wide { max-width: 780px; text-align: left; }
.card--narrow { max-width: 460px; }
.card-title { font-size: clamp(1.4rem, 3vw, 1.9rem); color: var(--deep-sky); margin-bottom: 10px; }
.card--wide .card-title { text-align: center; }
.card-lede { color: #4A5D70; margin-bottom: 22px; line-height: 1.5; }
.card--wide .card-lede { text-align: center; }

/* ---------------------------------------------------------------------
   Title screen
   --------------------------------------------------------------------- */
.title-card { text-align: center; max-width: 520px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.eyebrow { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.8rem; color: var(--sky-blue); margin-top: 14px; }
.game-title {
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  color: var(--deep-sky);
  line-height: 1.05;
  margin: 6px 0 4px;
}
.subtitle { color: #48586B; max-width: 420px; margin: 6px 0 22px; line-height: 1.5; }
.title-card .btn--xl { margin-bottom: 10px; }

/* ---------------------------------------------------------------------
   Form fields
   --------------------------------------------------------------------- */
.field { display: block; text-align: left; margin-bottom: 16px; }
.field-label { display: block; font-weight: 800; font-size: 0.92rem; color: var(--deep-sky); margin-bottom: 6px; }
.req { color: var(--coral); }
.optional { color: #8497A8; font-weight: 600; font-size: 0.82rem; }
.field input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid #D6E6F5;
  font-size: 1.05rem;
  background: #F9FCFF;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.field input:focus { border-color: var(--sky-blue); background: #fff; }
.field-error { color: var(--coral); font-weight: 700; margin: -6px 0 14px; font-size: 0.9rem; }

/* ---------------------------------------------------------------------
   Story dialog screen
   --------------------------------------------------------------------- */
.story-wrap { width: 100%; max-width: 760px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.story-kicker { font-family: var(--font-display); font-weight: 700; color: var(--deep-sky); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.85rem; }
.dialog-row { display: flex; align-items: flex-end; gap: 18px; width: 100%; }
.dialog-box {
  background: #fff;
  border: 3px solid var(--deep-sky);
  border-radius: var(--radius-md);
  padding: 22px 26px;
  flex: 1;
  position: relative;
  box-shadow: var(--shadow-card);
}
.dialog-box::before {
  content: "";
  position: absolute;
  left: -18px;
  bottom: 26px;
  border: 12px solid transparent;
  border-right-color: var(--deep-sky);
}
.dialog-box::after {
  content: "";
  position: absolute;
  left: -13px;
  bottom: 28px;
  border: 9px solid transparent;
  border-right-color: #fff;
}
.dialog-text { font-size: clamp(1.05rem, 2.4vw, 1.3rem); line-height: 1.55; color: var(--ink); min-height: 3.6em; }
.dialog-controls { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; gap: 12px; }
.dialog-dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dialog-dots .dot { width: 8px; height: 8px; border-radius: 50%; background: #D6E6F5; transition: background 0.2s ease, transform 0.2s ease; }
.dialog-dots .dot.done { background: var(--saf-green); }
.dialog-dots .dot.current { background: var(--sun-amber); transform: scale(1.3); }

/* ---------------------------------------------------------------------
   Story summary / peek text
   --------------------------------------------------------------------- */
.summary-text { text-align: left; max-height: 48vh; overflow-y: auto; padding-right: 6px; margin-bottom: 24px; }
.summary-text p { line-height: 1.65; color: #2C3E50; margin-bottom: 14px; font-size: 1.02rem; }
.summary-text p:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------------
   Instructions
   --------------------------------------------------------------------- */
.instructions-list { list-style: none; margin: 0 0 26px; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.instructions-list li { display: flex; gap: 14px; align-items: flex-start; font-size: 1.02rem; line-height: 1.5; color: #2C3E50; }
.instr-num {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--deep-sky);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ---------------------------------------------------------------------
   Quiz shell
   --------------------------------------------------------------------- */
.quiz-shell { width: 100%; max-width: 1180px; display: flex; flex-direction: column; gap: 12px; }
.quiz-header { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.quiz-header-left { display: flex; align-items: center; gap: 10px; }
.quiz-header-right { display: flex; align-items: center; gap: 12px; }
.quiz-home-btn {
  flex: none; border: none; border-radius: 999px; cursor: pointer;
  font-family: var(--font-body); font-weight: 700; font-size: 1rem;
  padding: 6px 16px; color: var(--coral); background: var(--coral-tint);
  box-shadow: 0 4px 12px -6px rgba(11,61,101,0.35);
  transition: background 0.15s ease, transform 0.1s ease;
}
.quiz-home-btn:hover { background: #FBDCDD; }
.quiz-home-btn:active { transform: scale(0.96); }
.quiz-peek-btn {
  flex: none; border: none; border-radius: 999px; cursor: pointer;
  font-family: var(--font-body); font-weight: 700; font-size: 1rem;
  padding: 6px 16px; color: var(--sky-blue); background: #fff;
  box-shadow: 0 4px 12px -6px rgba(11,61,101,0.35);
  transition: background 0.15s ease, transform 0.1s ease;
}
.quiz-peek-btn:hover { background: #EEF4FA; }
.quiz-peek-btn:active { transform: scale(0.96); }
.quiz-stat {
  font-weight: 700; color: var(--deep-sky); background: #fff; border-radius: 999px;
  padding: 6px 16px; box-shadow: 0 4px 12px -6px rgba(11,61,101,0.35); font-size: 1rem;
}

/* flight-path progress tracker: the signature element */
.flightpath { position: relative; height: 40px; margin: 2px 8px 0; }
.flightpath-line {
  position: absolute; left: 0; right: 0; top: 20px; height: 3px;
  background-image: linear-gradient(90deg, var(--deep-sky) 60%, transparent 0%);
  background-size: 14px 3px; background-repeat: repeat-x;
  opacity: 0.35;
}
.flightpath-stops { position: absolute; inset: 0; display: flex; justify-content: space-between; align-items: center; }
.flightpath-stop {
  width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid #C7DEF2;
  display: flex; align-items: center; justify-content: center; transition: all 0.25s ease; position: relative; z-index: 1;
}
.flightpath-stop.done { border-color: var(--saf-green); background: var(--saf-green); }
.flightpath-stop.current { border-color: var(--sun-amber); transform: scale(1.35); box-shadow: 0 0 0 5px rgba(255,176,32,0.25); }
.flightpath-plane {
  position: absolute; top: -6px; transform: translateX(-50%) rotate(90deg);
  font-size: 1.3rem; transition: left 0.5s cubic-bezier(.4,1.4,.6,1); color: var(--deep-sky);
  filter: drop-shadow(0 3px 4px rgba(11,61,101,0.3));
}

/* boarding pass card */
.boarding-pass {
  position: relative;
  display: flex;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.bp-main { flex: 1; padding: clamp(18px, 2.2vw, 28px) clamp(26px, 3.5vw, 44px); min-width: 0; }
.bp-stub {
  flex: none; width: 190px;
  background: linear-gradient(180deg, var(--deep-sky) 0%, #082B49 100%); color: #fff;
  display: flex; flex-direction: column; align-items: stretch; justify-content: center;
  padding: 16px 16px; text-align: center; gap: 8px;
}
.bp-stub-label { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.13em; opacity: 0.65; text-transform: uppercase; }
.bp-stub-qnum { font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; line-height: 1.1; }

.bp-stub-brand { font-family: var(--font-display); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.04em; opacity: 0.9; }

.bp-stub-route { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.bp-stub-route-col { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.bp-stub-route-col--end { align-items: flex-end; }
.bp-stub-route-value { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; line-height: 1.1; }
.bp-stub-route-icon { color: var(--sun-amber); font-size: 0.9rem; flex: none; }

.bp-stub-divider { height: 1px; background: rgba(255,255,255,0.18); }

.bp-stub-grid { display: flex; justify-content: space-between; gap: 6px; }
.bp-stub-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.bp-stub-grid .bp-stub-cell:last-child { align-items: flex-end; }
.bp-stub-value { font-family: var(--font-display); font-weight: 700; font-size: 0.92rem; }

.bp-stub-gate { display: flex; flex-direction: column; align-items: center; gap: 4px; }

.bp-stub-barcode {
  height: 34px; width: 100%; border-radius: 3px;
  background-image: repeating-linear-gradient(
    90deg,
    #fff 0, #fff 2px,
    transparent 2px, transparent 4px,
    #fff 4px, #fff 5px,
    transparent 5px, transparent 8px,
    #fff 8px, #fff 11px,
    transparent 11px, transparent 12px,
    #fff 12px, #fff 13px,
    transparent 13px, transparent 16px,
    #fff 16px, #fff 19px,
    transparent 19px, transparent 20px,
    #fff 20px, #fff 21px,
    transparent 21px, transparent 24px
  );
  background-size: 24px 100%;
  background-repeat: repeat-x;
  opacity: 0.85;
}
.bp-stub-barcode-code {
  display: block; font-family: var(--font-mono); font-size: 0.62rem;
  letter-spacing: 0.12em; opacity: 0.55; text-align: center; margin-top: 4px;
}
.bp-perforation {
  position: absolute; right: 190px; top: 0; bottom: 0; width: 0;
  border-left: 3px dashed rgba(11,61,101,0.25);
}
.bp-notch { position: absolute; width: 28px; height: 28px; background: #DFF1FF; border-radius: 50%; right: 176px; z-index: 2; }
.bp-notch--left { top: -14px; }
.bp-notch--right { bottom: -14px; }

.bp-eyebrow { font-family: var(--font-display); font-weight: 700; color: var(--sky-blue); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.95rem; margin-bottom: 8px; }
.bp-prompt { font-size: clamp(1.25rem, 2.4vw, 1.6rem); line-height: 1.38; color: var(--ink); margin-bottom: 16px; white-space: pre-line; }

/* MCQ / true-false options */
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.options-grid.options-grid--2col-tf { grid-template-columns: 1fr 1fr; max-width: 480px; }
.option-btn {
  text-align: left;
  background: #F7FAFC;
  border: 2px solid #E1EEF8;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.35;
  display: flex; gap: 12px; align-items: flex-start;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.option-btn:hover:not(:disabled) { border-color: var(--cloud-blue); background: #EFF8FF; }
.option-btn:active:not(:disabled) { transform: scale(0.98); }
.option-key {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--deep-sky); color: #fff; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
}
.option-btn.is-selected { border-color: var(--sky-blue); background: #E7F1FD; }
.option-btn.is-correct { border-color: var(--saf-green); background: var(--green-tint); }
.option-btn.is-wrong { border-color: var(--coral); background: var(--coral-tint); }
.option-btn:disabled { cursor: default; }

/* ---------------------------------------------------------------------
   QR scan UI (single + sequence)
   --------------------------------------------------------------------- */
.qr-panel { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.qr-viewport {
  position: relative; width: 210px; height: 210px; flex: none;
  border-radius: var(--radius-md); overflow: hidden; background: #0B1F33;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.15);
}
.qr-viewport video { width: 100%; height: 100%; object-fit: cover; }
.qr-viewport .qr-corner {
  position: absolute; width: 26px; height: 26px; border: 3px solid var(--sun-amber);
}
.qr-corner--tl { top: 8px; left: 8px; border-right: none; border-bottom: none; }
.qr-corner--tr { top: 8px; right: 8px; border-left: none; border-bottom: none; }
.qr-corner--bl { bottom: 8px; left: 8px; border-right: none; border-top: none; }
.qr-corner--br { bottom: 8px; right: 8px; border-left: none; border-top: none; }
.qr-scanline {
  position: absolute; left: 8px; right: 8px; height: 2px; background: var(--sun-amber);
  box-shadow: 0 0 8px 2px rgba(255,176,32,0.7);
  animation: scan 2.2s ease-in-out infinite;
}
@keyframes scan { 0%,100% { top: 12%; } 50% { top: 85%; } }
.qr-status { font-family: var(--font-mono); font-size: 0.74rem; color: #fff; background: rgba(11,31,51,0.55); position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 9px; text-align: center; }

.qr-side { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 12px; }
.qr-tiles-ref { display: flex; flex-wrap: wrap; gap: 8px; }
.qr-tile-chip {
  background: #F7FAFC; border: 2px solid #E1EEF8; border-radius: 999px; padding: 7px 13px;
  font-weight: 700; font-size: 0.85rem; color: var(--deep-sky);
}

/* Direction hint above a ranking sequence (e.g. "Most abundant -> Least
   abundant") — a gradient line with a CSS-drawn arrowhead, spanning the
   same row as the slot boxes below it. Only rendered when the question
   has a rankHint (ordered-magnitude questions, not category matching). */
.qr-rank-hint {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 0.78rem;
  color: var(--deep-sky); text-transform: uppercase; letter-spacing: 0.03em;
}
.qr-rank-hint-arrow {
  flex: 1; height: 2px; min-width: 24px; margin: 0 2px;
  background: linear-gradient(90deg, var(--cloud-blue), var(--sky-blue));
  position: relative;
}
.qr-rank-hint-arrow::after {
  content: ""; position: absolute; right: -1px; top: 50%; transform: translateY(-50%);
  border-style: solid; border-width: 5px 0 5px 8px;
  border-color: transparent transparent transparent var(--sky-blue);
}

.qr-slots { display: flex; flex-wrap: wrap; gap: 10px; }
.qr-slot {
  border: 2px dashed #C7DEF2; border-radius: var(--radius-sm); padding: 10px 12px;
  width: 150px; flex: 0 0 150px;
  text-align: center; background: #F7FAFC;
}
.qr-slot .qr-slot-label { display: block; font-size: 0.74rem; font-weight: 700; color: #6B7F92; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.qr-slot .qr-slot-value { font-family: var(--font-display); font-weight: 700; color: var(--deep-sky); font-size: 1rem; min-height: 1.3em; }
.qr-slot.filled { border-style: solid; border-color: var(--sky-blue); background: #EFF8FF; }
.qr-slot.current { border-color: var(--sun-amber); box-shadow: 0 0 0 4px rgba(255,176,32,0.2); }

.bp-skip-row { margin-top: 10px; text-align: center; }

/* ---------------------------------------------------------------------
   Results screen
   --------------------------------------------------------------------- */
.results-card { max-width: 480px; }
.results-stats { display: flex; justify-content: center; gap: 20px; margin: 22px 0 10px; flex-wrap: wrap; }
.results-stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.results-stat-value { font-size: 1.6rem; font-weight: 700; color: var(--deep-sky); }
.results-stat-label { font-size: 0.78rem; color: #7A8CA0; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.results-sync { font-size: 0.88rem; color: #7A8CA0; margin: 6px 0 20px; font-weight: 700; }
.results-actions { display: flex; gap: 12px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   Leaderboard
   --------------------------------------------------------------------- */
.leaderboard-wrap { overflow-x: auto; margin-bottom: 22px; }
.leaderboard-table { width: 100%; border-collapse: collapse; min-width: 480px; }
.leaderboard-table th {
  text-align: left; font-family: var(--font-display); font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: #7A8CA0; padding: 8px 12px; border-bottom: 2px solid #E1EEF8;
}
.leaderboard-table td { padding: 12px; border-bottom: 1px solid #EEF4FA; font-weight: 700; color: var(--ink); }
.leaderboard-table tr:hover td { background: #F7FAFC; }
.leaderboard-empty { text-align: center; color: #8497A8; padding: 24px !important; }
.rank-badge { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; font-family: var(--font-mono); font-size: 0.85rem; background: #EEF4FA; color: var(--deep-sky); }
.rank-badge.gold { background: #FFE7A8; color: #7A4E00; }
.rank-badge.silver { background: #E6ECF1; color: #465264; }
.rank-badge.bronze { background: #F3D3B8; color: #7A3E10; }

/* ---------------------------------------------------------------------
   Story-peek modal
   --------------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11,31,51,0.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.peek-modal {
  background: #fff; border-radius: var(--radius-lg); padding: 26px 28px; max-width: 640px; width: 100%;
  box-shadow: var(--shadow-card); max-height: 80vh; display: flex; flex-direction: column;
}
.peek-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 14px; }
.peek-title { font-family: var(--font-display); font-weight: 700; color: var(--deep-sky); font-size: 1.2rem; }
.peek-header-right { display: flex; align-items: center; gap: 10px; flex: none; }
.peek-close {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: none;
  background: #EEF4FA; color: var(--deep-sky); font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.peek-close:hover { background: #E1EEF8; }
.peek-close:active { transform: scale(0.92); }
.peek-timer { position: relative; width: 60px; height: 60px; flex: none; }
.peek-ring-bg { fill: none; stroke: #EEF4FA; stroke-width: 5; }
.peek-ring-fg {
  fill: none; stroke: var(--coral); stroke-width: 5; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 0.2s linear;
}
.peek-ring-fg.is-urgent { animation: peekRingPulse 0.6s ease-in-out infinite; }
@keyframes peekRingPulse {
  0%, 100% { stroke-width: 5; }
  50% { stroke-width: 8; }
}
.peek-timer-number {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 1.15rem; color: var(--coral);
}
.peek-timer-number.is-urgent { animation: peekNumberPulse 0.6s ease-in-out infinite; }
@keyframes peekNumberPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.22); }
}
.peek-text { margin-bottom: 0; }

/* ---------------------------------------------------------------------
   Answer feedback modal (pops up after every question)
   --------------------------------------------------------------------- */
.answer-modal {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 32px 30px 28px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-card);
  border-top: 8px solid var(--saf-green);
  animation: popIn 0.28s cubic-bezier(.34,1.56,.64,1);
}
.answer-modal.is-wrong { border-top-color: var(--coral); }
.answer-modal.is-skipped { border-top-color: var(--sky-blue); }
@keyframes popIn {
  0% { transform: scale(0.85) translateY(12px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.answer-modal-icon {
  width: 72px; height: 72px; border-radius: 50%; margin: -68px auto 14px;
  background: var(--green-tint); font-size: 2.2rem;
  display: flex; align-items: center; justify-content: center;
  border: 6px solid #fff; box-shadow: var(--shadow-card);
}
.answer-modal.is-wrong .answer-modal-icon { background: var(--coral-tint); }
.answer-modal.is-skipped .answer-modal-icon { background: #E7F1FD; }
.answer-modal-title { font-size: 1.5rem; color: var(--deep-sky); margin-bottom: 10px; }
.answer-modal.is-wrong .answer-modal-title { color: #8C2328; }
.answer-modal.is-skipped .answer-modal-title { color: var(--sky-blue); }
.answer-modal-text { color: #3A4C5E; line-height: 1.55; margin-bottom: 22px; font-size: 1rem; }
.quit-modal-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   Toast
   --------------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px;
  font-weight: 700; box-shadow: 0 12px 30px -10px rgba(0,0,0,0.4); z-index: 100; font-size: 0.92rem;
  max-width: 90vw; text-align: center;
}
.toast[hidden] { display: none; }
.toast.is-error { background: var(--coral); }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 700px) {
  .boarding-pass { flex-direction: column; }
  .bp-stub { width: 100%; flex-direction: row; padding: 14px 22px; }
  .bp-perforation { display: none; }
  .bp-notch { display: none; }
  .dialog-row { flex-direction: column; align-items: center; }
  .dialog-box::before, .dialog-box::after { display: none; }
  .options-grid { grid-template-columns: 1fr; }
  .qr-panel { flex-direction: column; align-items: center; }
}
