/* Aviationary styles. Sky colours are set from game.js as you climb. */
:root {
  --sky-top: #8fd3ff;
  --sky-bottom: #dcf2ff;
  --on-sky: #12324a;          /* text drawn directly on the sky */
  --on-sky-soft: #2f5874;
  --ink: #12324a;             /* text on white cards */
  --card: #ffffff;
  --accent: #ff7a3d;
  --accent-dark: #e85f22;
  --muted: #5f7a8f;
  --display: "Fredoka", "Nunito", "Segoe UI", system-ui, sans-serif;
  --body: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--sky-bottom); }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--on-sky);
  font-family: var(--body);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ---------- Sky ---------- */
#sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: linear-gradient(to bottom, var(--sky-top), var(--sky-bottom));
}
#stars { position: absolute; inset: 0; opacity: 0; transition: opacity 1.5s; }
.star {
  position: absolute;
  width: 2px; height: 2px;
  border-radius: 50%;
  background: #fff;
  animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle { 50% { opacity: .25; } }

#clouds { position: absolute; inset: 0; }
.cloud {
  position: absolute;
  left: 0;
  opacity: .9;
  animation: drift linear infinite;
}
@keyframes drift {
  from { transform: translateX(110vw); }
  to   { transform: translateX(-60vw); }
}
/* Clouds rush downward as the plane climbs past them */
#clouds.whoosh { animation: whoosh .9s ease-out; }
@keyframes whoosh {
  0%   { transform: translateY(0); }
  45%  { transform: translateY(70px); opacity: .4; }
  46%  { transform: translateY(-50px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

#ground {
  position: absolute;
  left: 0; bottom: 0;
  width: 100%;
  height: 140px;
  transition: transform 1.2s ease-in-out, opacity .4s;
}
body.airborne #ground { transform: translateY(160px); }
/* Scrolling down the results fades the ground and parked plane away */
body.scrolled #ground, body.scrolled #runway-plane { opacity: 0; }

/* ---------- Layout ---------- */
#app {
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.screen { flex: 1; display: flex; flex-direction: column; }
.hidden { display: none !important; }

.big-btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 32px;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 5px 0 var(--accent-dark), 0 8px 18px #0003;
  cursor: pointer;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--accent-dark), 0 4px 10px #0003; }

/* ---------- Plane ---------- */
.plane { display: block; overflow: visible; }
.plane .prop, .alt-marker .prop { animation: spin .12s linear infinite; transform-origin: 121px 33px; }
@keyframes spin { 50% { transform: scaleY(.15); } }

/* ---------- Start ---------- */
#start { justify-content: center; align-items: center; text-align: center; gap: 14px; position: relative; padding-bottom: 120px; }
.logo { display: flex; flex-direction: column; align-items: center; }
.logo-trail { width: 260px; height: 62px; margin-bottom: -10px; overflow: visible; }
.logo h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.6rem, 13vw, 3.4rem);
  color: #fff;
  letter-spacing: .5px;
  text-shadow: 0 3px 0 #2d7fc1, 0 6px 14px #0b3a6640;
}
.tagline { margin: 0; color: var(--on-sky-soft); font-weight: 700; line-height: 1.4; }
.puzzle-no { margin: 0; font-weight: 800; }
.streak { margin: 4px 0 0; padding: 4px 14px; border-radius: 999px; background: #ffffffb3; color: #c2410c; font-weight: 800; }
#runway-plane {
  position: fixed;
  z-index: -1;
  bottom: 22px;
  left: 50%;
  width: 96px;
  margin-left: -48px;
  transition: transform 1.1s cubic-bezier(.5, 0, .7, .4), opacity .4s;
}
#runway-plane.takeoff { transform: translate(60vw, -70vh) rotate(-28deg) scale(.6); opacity: 0; }
body.airborne #runway-plane { opacity: 0; }
#runway-plane.landing { animation: landing 1.3s ease-out; }
@keyframes landing {
  0%   { transform: translate(-70vw, -60vh) rotate(22deg) scale(.6); opacity: 0; }
  20%  { opacity: 1; }
  75%  { transform: translate(-6vw, -3vh) rotate(6deg) scale(1); }
  100% { transform: none; }
}

/* ---------- Game ---------- */
/* Top bar: "Word 5 of 7" | altitude pill (truly centred) | seconds pill + sound button */
.hud { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; font-weight: 800; color: var(--on-sky); }
.hud-left { white-space: nowrap; font-size: .95rem; }
.hud-pill {
  background: #ffffffb3; border-radius: 999px; padding: 4px 11px;
  color: var(--ink);       /* pills are always light, so keep dark text even in the night sky */
  white-space: nowrap; font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 4px #0b3a661a;
}
.hud-right { justify-self: end; display: flex; align-items: center; gap: 6px; }
#seconds { display: inline-block; min-width: 2ch; text-align: right; }
/* "−2s" that appears just below the timer bar, under the seconds, and drifts down */
.time-penalty {
  position: absolute; right: 36px;   /* under the seconds pill, left of the sound button */
  top: calc(100% + 24px);  /* below the 10px timer bar and its 10px gap */
  z-index: 3;
  font-family: var(--display); font-weight: 700; font-size: 1.1rem;
  color: #fff; background: #e8433a; border-radius: 999px; padding: 0 8px;
  pointer-events: none;
  animation: penalty-up 1.1s ease-out forwards;
}
@keyframes penalty-up {
  0%   { opacity: 0; transform: translateY(-4px) scale(.7); }
  20%  { opacity: 1; transform: translateY(0) scale(1.1); }
  100% { opacity: 0; transform: translateY(16px) scale(1); }
}
.plane-wrap.wobble { animation: wobble .5s ease-in-out; }
@keyframes wobble {
  25% { transform: rotate(-5deg) translateY(2px); }
  50% { transform: rotate(4deg); }
  75% { transform: rotate(-2deg); }
}
#seconds { font-variant-numeric: tabular-nums; }
.timer { height: 10px; margin-top: 10px; background: #ffffff70; border-radius: 6px; overflow: hidden; }
#timer-bar { height: 100%; width: 100%; background: var(--accent); border-radius: 6px; }
#timer-bar.low { background: #e8433a; }
/* Last 5 seconds (game.js setTension): pulsing red bar, red popping seconds, plane shake */
.timer.low { animation: timer-pulse .5s ease-in-out infinite alternate; }
@keyframes timer-pulse { from { box-shadow: 0 0 0 0 #e8433a00; } to { box-shadow: 0 0 0 4px #e8433a55; } }
#seconds.low { color: #e8433a; }
#seconds.tick-pop { animation: tick-pop .3s ease-out; }
@keyframes tick-pop { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }
#plane-move.shake { animation: plane-shake .35s linear infinite; }
@keyframes plane-shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(-1.5px, 1px) rotate(-1.5deg); }
  50% { transform: translate(1px, -1px) rotate(1deg); }
  75% { transform: translate(1.5px, 1px) rotate(-1deg); }
}

/* The plane + clue + answer block sits in the middle of the space above the keyboard */
.stage { position: relative; flex: 1; display: flex; align-items: center; margin-top: 12px; }
#game.revealing .stage { flex: 0 0 auto; margin-top: auto; }
#game.revealing .reveal { margin-bottom: auto; }
/* container-type lets the text below size itself to this column's width (cqi units) */
/* Same space on both sides keeps the column centred while the meter floats at the edge */
.stage-main { flex: 1; min-width: 0; display: flex; flex-direction: column; container-type: inline-size; padding-inline: 46px; }

.plane-wrap { position: relative; height: 84px; display: flex; justify-content: center; align-items: center; }
#plane { width: 110px; animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
/* ---------- Answer animations (animations.js) ---------- */
/* The plane sits in #plane-move so animations can move it without fighting the bob */
#plane-move { position: relative; z-index: 1; width: 110px; pointer-events: none; }
#plane-move #plane { display: block; }
/* Layers centred on the plane's resting spot. fx-back sits behind the clue and answer box
   (negative z-index) so text always stays readable; fx-front passes in front of the plane. */
.fx-layer { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
#fx-back { z-index: -1; }
#fx-front { z-index: 2; }
#fx-sparks { position: fixed; inset: 0; z-index: 3; overflow: hidden; pointer-events: none; }
.fx { position: absolute; pointer-events: none; }
.fx svg { display: block; width: 100%; height: 100%; overflow: visible; }
/* Crescent: darkens the sky only (it lives inside #sky, behind everything else) */
#sky-dim { position: absolute; inset: 0; background: #0d2366; opacity: 0; pointer-events: none; }
#plane.sputter { animation: sputter 1s ease-in-out; }
@keyframes sputter {
  0%, 100% { transform: rotate(0); }
  15% { transform: translate(-3px, 4px) rotate(8deg); }
  30% { transform: translate(3px, -2px) rotate(-7deg); }
  45% { transform: translate(-2px, 5px) rotate(6deg); }
  60% { transform: translate(2px, 0) rotate(-4deg); }
  80% { transform: translate(0, 2px) rotate(2deg); }
}
.puff {
  position: absolute;
  left: 50%; top: 50%;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #8a96a3;
  opacity: 0;
  animation: puff 1s ease-out forwards;
}
@keyframes puff {
  0%   { opacity: .8; transform: translate(-60px, 0) scale(.4); }
  100% { opacity: 0;  transform: translate(-110px, -18px) scale(1.6); }
}

.clue {
  margin: 6px 0 12px;
  text-align: center;
  font-family: var(--display);
  /* Shrinks for long words (--len = number of letters, set in game.js) so it always fits on one line */
  font-size: min(clamp(2.3rem, 12vw, 3.4rem), calc(100cqi / (var(--len, 6) * 0.8)));
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--on-sky);
  white-space: nowrap;
}
.clue.pop { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

.answer {
  min-height: 58px;
  padding: 12px;
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  text-align: center;
  font-family: var(--display);
  font-size: min(1.7rem, calc((100cqi - 28px) / (var(--len, 10) * 0.8)));
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  box-shadow: 0 6px 18px #0b3a6626;
  white-space: nowrap;
  overflow: hidden;
}
.caret { display: inline-block; width: 2px; height: 1em; background: var(--ink); vertical-align: middle; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
/* Guesses already tried for this word, crossed out */
.tried { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin-top: 8px; }
.tried:empty { display: none; }
.tried span {
  padding: 2px 9px; border-radius: 999px;
  background: #ffffffb3; color: #6f8496;
  font-size: .8rem; font-weight: 700;
  text-decoration: line-through; text-decoration-thickness: 2px;
}
.hint { text-align: center; color: var(--on-sky-soft); font-weight: 700; min-height: 1.4em; margin: 10px 0 0; }
.hint.suggest { color: #fff; background: #3f7fd6; border-radius: 999px; padding: 4px 12px; align-self: center; }
.answer.corrected { animation: corrected .5s ease-out; box-shadow: 0 0 0 3px #3f7fd6, 0 6px 18px #0b3a6626; }
@keyframes corrected { 30% { transform: scale(1.04); } }
.hint.wrong { color: #fff; background: #e8433a; border-radius: 999px; padding: 4px 12px; align-self: center; }
.answer.shake { animation: shake .4s ease-in-out; box-shadow: 0 0 0 3px #e8433a, 0 6px 18px #0b3a6626; }
@keyframes shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

/* ---------- Altitude meter ---------- */
/* Floats at the screen edge instead of taking width from the game column */
.altimeter {
  position: absolute; top: 0; bottom: 0;
  right: -10px;            /* pushed out into the page margin */
  width: 32px;
  display: flex; flex-direction: column;
  align-items: flex-end;   /* bar hugs the right edge, labels sit to its left */
  padding: 10px 0;
}
.alt-track {
  position: relative;
  flex: 1;
  min-height: 180px;
  width: 10px;
  margin-right: 4px;
  border-radius: 8px;
  background: #ffffff55;
  box-shadow: inset 0 0 0 1.5px #ffffff90;
}
.alt-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0%;
  border-radius: 8px;
  background: linear-gradient(to top, #ffb43d, #ff7a3d);
  transition: height 1.2s ease-in-out;
}
.alt-tick { position: absolute; left: -5px; right: -5px; bottom: calc(var(--at) * 100%); height: 2px; background: #ffffffaa; }
.alt-tick span { position: absolute; right: 100%; top: -7px; margin-right: 3px; font-size: .5rem; font-weight: 800; color: var(--on-sky-soft); }
.alt-marker {
  position: absolute;
  left: 50%;
  bottom: 0%;
  width: 34px;
  transform: translate(-50%, 50%) rotate(-90deg);
  transition: bottom 1.2s ease-in-out;
  overflow: visible;
  filter: drop-shadow(0 2px 2px #0003);
}

/* ---------- Reveal ---------- */
/* ---------- Level icons (drawn <symbol>s, see index.html) ---------- */
.lv-icon { display: inline-block; width: 1.25em; height: 1.25em; vertical-align: -0.28em; flex: none; overflow: visible; }
/* An icon on a white circle with a ring in the level's colour */
.lv-badge {
  display: inline-grid; place-items: center; flex: none;
  width: 2em; height: 2em; border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 3px var(--level-color);
}
.lv-badge .lv-icon { width: 1.35em; height: 1.35em; vertical-align: 0; }

.reveal { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 14px; }
.ladder { display: flex; gap: 6px; justify-content: center; margin-bottom: 6px; }
.rung {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: #ffffff8c;
  filter: grayscale(1);
  opacity: .55;
  transition: transform .3s, opacity .3s, filter .3s;
}
.rung .lv-icon { width: 26px; height: 26px; vertical-align: 0; }
.rung.lit { filter: none; opacity: 1; background: #fff; transform: scale(1.3); box-shadow: inset 0 0 0 3px var(--rung-color), 0 0 16px var(--rung-color); animation: land .6s ease-out; }
@keyframes land { 0% { transform: scale(.3); } 60% { transform: scale(1.5); } 100% { transform: scale(1.3); } }
.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 20px 6px 6px;
  border-radius: 999px;
  color: #fff;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 600;
  box-shadow: 0 4px 12px #0003;
  animation: pop .4s ease-out;
}
.badge .lv-badge { font-size: 1.1rem; }
.reveal-text { font-weight: 700; color: var(--on-sky); }
.reveal-text b { font-family: var(--display); letter-spacing: 1px; }

/* ---------- Phone keyboard ---------- */
/* Touch screens use the phone's own keyboard: a hidden text box takes the typing
   (16px so iPhones don't zoom in), and the game fits the space above the keyboard. */
#native-input { position: fixed; top: 0; left: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; font-size: 16px; pointer-events: none; }
body:not(.native-kb) #native-input { display: none; }
body.native-kb .keyboard { display: none !important; }
body.native-kb:has(#game:not(.hidden)) #app { min-height: var(--vvh, 100dvh); height: var(--vvh, 100dvh); }

/* ---------- On-screen keyboard ---------- */
.keyboard { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 14px; }
.kb-row { display: flex; gap: 5px; justify-content: center; }
.key {
  flex: 1;
  max-width: 44px;
  height: 52px;
  border: 0;
  border-radius: 8px;
  background: #ffffffe6;
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.05rem;
  font-weight: 800;
  box-shadow: 0 2px 0 #0b3a6633;
  cursor: pointer;
  touch-action: manipulation;
}
.key.wide { flex: 1.6; max-width: 70px; font-size: .8rem; }
.key:active { background: #dbeefc; transform: translateY(1px); }
.key.enter { background: var(--accent); color: #fff; box-shadow: 0 2px 0 var(--accent-dark); }
.key.enter:active { background: var(--accent-dark); }
.key.pop-key { animation: key-pop .18s ease-out; }
/* Lit up for a moment when the same key is pressed on a real keyboard */
.key.lit { background: #3f7fd6; color: #fff; transform: translateY(2px) scale(.94); box-shadow: none; }
.key.enter.lit { background: var(--accent-dark); }
@keyframes key-pop { 50% { transform: scale(1.12) translateY(-2px); } }

/* ---------- Results ---------- */
#results { text-align: center; color: var(--on-sky); padding-bottom: 130px; } /* room for the runway */
.results-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
#results h2 { margin: 10px 0 2px; font-family: var(--display); font-size: 1.9rem; }
.final-altitude { font-family: var(--display); font-size: 2.6rem; font-weight: 700; margin: 0; line-height: 1.1; }
.final-score { margin: 4px 0 0; font-weight: 700; opacity: .85; }
/* Where you rank: today's players as a curve, with a YOU marker */
.dist-card { margin-top: 14px; padding: 12px 12px 10px; }
#dist-chart { display: block; width: 100%; height: auto; overflow: visible; }
.dist-area { fill: url(#dist-fill); animation: dist-fade .8s ease-out backwards; }
.dist-line { fill: none; stroke: #2f7fd6; stroke-width: 2.5; stroke-linejoin: round;
  stroke-dasharray: 1; animation: dist-draw 1.1s ease-out backwards; }
.dist-axis { stroke: #c9dbea; stroke-width: 1.5; }
.dist-tick { stroke: #c9dbea; stroke-width: 1.5; }
.dist-num { font-family: var(--body); font-size: 9.5px; font-weight: 800; fill: var(--muted); text-anchor: middle; }
.dist-you line { stroke: var(--accent); stroke-width: 2.5; }
.dist-you circle { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.dist-you text { font-family: var(--display); font-size: 11px; font-weight: 700; fill: var(--accent-dark); text-anchor: middle; letter-spacing: 1px; }
.dist-you { animation: dist-fade .5s ease-out .8s backwards; }
@keyframes dist-draw { from { stroke-dashoffset: 1; } }
@keyframes dist-fade { from { opacity: 0; } }
.beat { margin: 6px 0 0; color: var(--ink); font-weight: 800; }
.beat b { color: var(--accent-dark); }

.share-row { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 18px 0 6px; }
.share-preview { display: flex; justify-content: center; gap: 6px; font-size: 1.6rem; }
.share-preview .lv-icon { width: 1.3em; height: 1.3em; }

.section-title { margin: 22px 0 8px; font-family: var(--display); font-size: 1.15rem; text-align: left; }

/* Flight log chart + answers */
.section-title small { font-family: var(--body); font-size: .75rem; font-weight: 700; opacity: .75; margin-left: 6px; }
.card { background: var(--card); color: var(--ink); border-radius: 16px; box-shadow: 0 6px 18px #0b3a6626; }
.chart-card { padding: 8px 6px 2px; }
#chart { display: block; width: 100%; height: auto; overflow: visible; }
#chart .grid { stroke: #d6e4ef; stroke-width: 1; stroke-dasharray: 3 4; }
#chart .ground-line { stroke: #6cc04a; stroke-width: 4; stroke-linecap: round; }
#chart .col { cursor: pointer; outline: none; }
/* Column highlight in the level's colour (--c is set per column in game.js) */
#chart .col-bg { fill: var(--c); fill-opacity: 0; transition: fill-opacity .2s; }
#chart .col:hover .col-bg, #chart .col:focus-visible .col-bg { fill-opacity: .08; }
#chart .col.selected .col-bg { fill-opacity: .16; }
#chart .trail {
  stroke-width: 3; stroke-dasharray: 2 5; stroke-linecap: round; opacity: .7;
  transition: stroke-width .2s, opacity .2s;
  transform-box: fill-box; transform-origin: bottom;
  animation: trail-grow .6s ease-out backwards;
  animation-delay: calc(var(--i) * .08s);
}
#chart .col:hover .trail, #chart .col:focus-visible .trail, #chart .col.selected .trail { stroke-width: 4; opacity: 1; }
#chart .dot { fill: #fff; stroke-width: 3; }
/* The badge (circle + icon) grows with a springy bounce */
#chart .badge {
  transform-box: fill-box; transform-origin: center;
  transition: transform .35s cubic-bezier(.34, 1.8, .64, 1), filter .2s;
}
#chart .col:hover .badge, #chart .col:focus-visible .badge { transform: translateY(-2px) scale(1.15); }
#chart .col.selected .badge { transform: translateY(-3px) scale(1.25); filter: drop-shadow(0 3px 3px rgba(11, 58, 102, .28)); }
#chart .col:active .badge { transform: scale(1.05); }
#chart .pop {
  transform-box: fill-box; transform-origin: center;
  animation: badge-pop .45s cubic-bezier(.34, 1.8, .64, 1) backwards;
  animation-delay: calc(var(--i) * .08s);
}
@keyframes trail-grow { from { transform: scaleY(0); } }
@keyframes badge-pop { from { transform: scale(0); } }
#chart .col-num { font-family: var(--display); font-size: 13px; font-weight: 600; text-anchor: middle; fill: var(--muted); transition: fill .2s; }
#chart .col.selected .col-num { fill: var(--c); font-weight: 700; }

.answers-card { margin-top: 10px; padding: 12px; text-align: left; }
.ans-head { display: flex; align-items: center; gap: 8px; }
.ans-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; container-type: inline-size; }
.ans-title small { color: var(--muted); font-weight: 800; font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; }
.ans-title b { font-family: var(--display); font-size: min(1.6rem, calc(100cqi / (var(--len, 8) * 0.8))); letter-spacing: 1.5px; white-space: nowrap; }
.ans-arrow {
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: #eef5fb; color: var(--ink);
  font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.ans-arrow:active { background: #dbeefc; }
.ans-you { text-align: center; margin: 4px 0 12px; font-weight: 700; color: var(--muted); }
.ans-you b { color: var(--ink); }
.ans-group { border-left: 5px solid var(--level-color); padding: 2px 0 2px 10px; margin-bottom: 12px; }
.ans-group-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.ans-group-head span { display: inline-flex; align-items: center; gap: 4px; font-family: var(--display); font-weight: 600; color: var(--level-color); }
.ans-group-head small { color: var(--muted); font-weight: 800; font-size: .72rem; }
.ans-group.collapsed { display: none; }
.show-all {
  display: block; width: 100%;
  margin-top: 4px; padding: 10px;
  border: 2px dashed #c9dbea; border-radius: 12px;
  background: none; color: var(--ink);
  font-family: var(--body); font-size: .95rem; font-weight: 800;
  cursor: pointer;
}
.show-all:hover { background: #f4f9fd; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 3px 9px; border-radius: 999px; background: #f1f7fc; font-weight: 700; font-size: .88rem; }
.chip.mine { background: var(--level-color); color: #fff; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--level-color); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats div { background: var(--card); color: var(--ink); border-radius: 14px; padding: 10px 4px; display: flex; flex-direction: column; box-shadow: 0 4px 12px #0b3a661f; }
.stats b { font-family: var(--display); font-size: 1.6rem; }
.stats span { font-size: .72rem; font-weight: 800; color: var(--muted); }

.countdown { margin-top: 22px; display: flex; flex-direction: column; font-weight: 800; }
.countdown b { font-family: var(--display); font-size: 2rem; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.countdown a { color: inherit; }

/* ---------- Help button + popup ---------- */
.help-btn {
  width: 36px; height: 36px;
  border: 0; border-radius: 50%;
  background: #ffffffd9; color: var(--ink);
  font-family: var(--display); font-size: 1.2rem; font-weight: 700;
  box-shadow: 0 2px 8px #0b3a6633;
  cursor: pointer;
}
/* Speaker + help buttons in the start screen's top-right corner */
.corner-btns { position: absolute; top: 0; right: 0; display: flex; gap: 8px; }
.sound-btn { font-family: var(--body); font-size: 1rem; }
.help-btn.small { width: 30px; height: 30px; font-size: .85rem; }


.modal {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  padding: 16px;
  background: #06183acc;
  animation: fade .2s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  position: relative;
  width: 100%; max-width: 420px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 22px 18px 18px;
  border-radius: 20px;
  background: var(--card); color: var(--ink);
  box-shadow: 0 20px 50px #0006;
  text-align: center;
  animation: pop .3s ease-out;
}
.modal-card h2 { margin: 0 0 8px; font-family: var(--display); font-size: 1.7rem; }
.modal-card h3 { margin: 16px 0 8px; font-family: var(--display); }
.modal-close { position: absolute; top: 10px; right: 10px; border: 0; background: none; font-size: 1.2rem; color: var(--muted); cursor: pointer; padding: 6px; }
.how { text-align: left; margin: 0; padding-left: 22px; line-height: 1.45; font-weight: 600; }
.how li { margin-bottom: 6px; }
.levels { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.levels li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 12px; background: #f1f7fc; border-left: 5px solid var(--level-color); }
.lv-emoji { display: flex; font-size: 1.05rem; }
.lv-text { flex: 1; display: flex; flex-direction: column; }
.lv-text small { color: var(--muted); font-weight: 700; line-height: 1.25; }
.lv-points { font-family: var(--display); font-weight: 700; color: var(--level-color); white-space: nowrap; }
.help-foot { color: var(--muted); font-weight: 700; margin: 14px 0; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 20;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: #12324a; color: #fff;
  font-weight: 800;
  box-shadow: 0 6px 18px #0005;
  white-space: nowrap;
}
.toast.show { animation: toast-in .25s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

@media (prefers-reduced-motion: reduce) {
  /* No pulsing or shaking in the last 5 seconds (the red colour and ticks stay) */
  .timer.low, #plane-move.shake { animation: none !important; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
