/* Moon Mission. Colours are Book 4's theme colours (night indigo, flame orange, rocket red, deep teal, moon cream, balloon blue). */
:root {
  color-scheme: light;
  --indigo: #3B2E8C; --indigo-dark: #2C2270; --flame: #FFAE4F; --flame-dark: #E0862A; --red: #C2364A; --teal: #0F7B83;
  --green: #2B8A3E; --blue: #4AA3DF; --moon: #F2E3A0; --star: #ECEFF9; --star-deep: #DCE3F3;
  --ink: #1E2240; --muted: #5C6080; --white: #FFFFFF; --line: #D5DBEE;
  --font: "Century Gothic", "Avenir Next", "Avenir", "Nunito", "Segoe UI", system-ui, sans-serif;
  --radius: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--star); line-height: 1.4; }
button, select, output { font: inherit; color: inherit; }
img { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 1.2em; height: 1.2em; flex: none; }
:focus-visible { outline: 3px solid var(--flame-dark); outline-offset: 2px; }

/* ---- Top bar ---- */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 16px; background: var(--indigo); color: var(--white); }
.back { color: var(--white); text-decoration: none; font-weight: 700; padding: 6px 10px; border-radius: 999px; background: rgba(255, 255, 255, .16); }
.back:hover { background: rgba(255, 255, 255, .28); }
.game-title { margin: 0; font-size: 1.5rem; letter-spacing: .02em; }
.goal-pill { margin: 0 auto 0 0; background: var(--moon); color: var(--ink); font-weight: 800; border-radius: 999px; padding: 6px 14px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.tool { display: inline-flex; align-items: center; gap: 6px; border: 2px solid rgba(255, 255, 255, .55); background: transparent; color: var(--white); border-radius: 999px; padding: 6px 12px; min-height: 40px; cursor: pointer; font-weight: 700; }
.tool:hover { background: rgba(255, 255, 255, .16); }
#soundBtn .mute { display: none; }
#soundBtn[aria-pressed="false"] .mute { display: inline; }
#soundBtn[aria-pressed="false"] .waves { display: none; }
#voiceBtn .mute { display: none; }
#voiceBtn[aria-pressed="false"] .mute { display: inline; }
#voiceBtn[aria-pressed="false"] .lines { display: none; }

/* ---- Layout ---- */
.game { display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "stage controls" "sheet sheet"; gap: 16px; padding: 16px; max-width: 1400px; margin: 0 auto; }
.stage-wrap { grid-area: stage; }
.control-panel { grid-area: controls; }
.sheet-panel { grid-area: sheet; display: grid; grid-template-columns: 1.15fr 1fr; gap: 24px; }
.panel { background: var(--white); border-radius: var(--radius); padding: 16px; box-shadow: 0 2px 0 var(--line); }
.panel h2 { margin: 0 0 10px; font-size: 1.15rem; color: var(--indigo); }
.muted { display: block; font-size: .85rem; font-weight: 400; color: var(--muted); }

/* ---- Stage: the room behind, then Noor and Auntie, then the chairs, the string and the rocket in front ---- */
.stage { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #DCE6EF; box-shadow: 0 2px 0 var(--line); }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; }
#back { z-index: 0; }
.who { position: absolute; width: auto; z-index: 1; transition: opacity .3s; }
.who-noor { left: 1.5%; bottom: 7%; }
.who-noor.is-jump { bottom: 11%; }
.who-auntie { right: 1%; bottom: 3%; }
.who.bob { animation: bob .45s ease-out; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-4%); } }
#scene { z-index: 2; pointer-events: none; }
.say { position: absolute; z-index: 3; top: 3%; max-width: 29%; margin: 0; padding: .5em .75em; border-radius: 14px; background: var(--white); border: 3px solid var(--ink); font-weight: 700; font-size: clamp(.72rem, 1.5vw, 1rem); line-height: 1.25; box-shadow: 0 3px 0 rgba(30, 34, 64, .15); }
.say:empty { display: none; }
.say::after { content: ""; position: absolute; bottom: -12px; width: 18px; height: 18px; background: inherit; border: inherit; border-top: 0; border-left: 0; transform: rotate(45deg); }
.say-noor { left: 1.5%; }
.say-noor::after { left: 18%; }
.say-auntie { right: 13%; }
.say-auntie::after { right: 10%; }
.say.is-mc { color: var(--indigo); border-color: var(--indigo); font-weight: 800; text-transform: uppercase; letter-spacing: .02em; }
.count { position: absolute; z-index: 3; top: 22%; left: 50%; margin: 0; transform: translateX(-50%); display: grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%; background: rgba(255, 255, 255, .92); border: 6px solid var(--indigo); color: var(--indigo); font-weight: 900; font-size: clamp(2.2rem, 8vw, 5.4rem); line-height: 1; animation: count-in .7s ease-out; }
@keyframes count-in { from { transform: translateX(-50%) scale(1.7); opacity: 0; } 30% { opacity: 1; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
.stamp { position: absolute; z-index: 3; top: 30%; left: 50%; margin: 0; transform: translate(-50%, 0) rotate(-7deg); padding: .2em .6em; border: 5px solid currentColor; border-radius: 12px; background: rgba(255, 255, 255, .92); font-weight: 900; font-size: clamp(1.1rem, 3.8vw, 2.6rem); letter-spacing: .04em; white-space: nowrap; animation: stamp-in .35s cubic-bezier(.2, 1.6, .5, 1); }
.stamp.is-pass { color: var(--green); }
.stamp.is-fail { color: var(--red); }
.stamp.is-safe, .stamp.is-go { color: var(--indigo); }
@keyframes stamp-in { from { transform: translate(-50%, 0) rotate(-7deg) scale(1.9); opacity: 0; } to { transform: translate(-50%, 0) rotate(-7deg) scale(1); opacity: 1; } }
.caption { position: absolute; z-index: 3; left: 50%; bottom: 2.5%; transform: translateX(-50%); width: 58%; margin: 0; padding: .4em .8em; border-radius: 12px; background: rgba(255, 255, 255, .94); text-align: center; font-weight: 700; font-size: clamp(.68rem, 1.45vw, 1rem); line-height: 1.3; box-shadow: 0 2px 0 rgba(30, 34, 64, .12); }
.caption:empty { display: none; }

/* result card */
.result { margin-top: 12px; background: var(--white); border-radius: var(--radius); border: 4px solid var(--indigo); padding: 14px 18px; box-shadow: 0 6px 18px rgba(30, 34, 64, .14); text-align: center; animation: pop-card .35s ease-out; }
.result-kicker { margin: 0 0 2px; font-size: .8rem; font-weight: 800; letter-spacing: .14em; color: var(--indigo); text-transform: uppercase; }
.result h2 { margin: 0 0 4px; font-size: clamp(1.05rem, 2.4vw, 1.6rem); color: var(--indigo); }
.result h2:focus { outline: none; }
.result p { margin: 4px 0; }
.result .guess-note { font-weight: 700; }
.result .hint { font-weight: 700; color: var(--teal); }
.result .guess-note:empty, .result .hint:empty, .result p:empty { display: none; }
.result.is-pass { border-color: var(--green); }
.result.is-pass h2 { color: var(--green); }
.result.is-fail { border-color: var(--red); }
.result.is-fail h2 { color: var(--red); }
.result-btns { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
@keyframes pop-card { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.confetti { position: absolute; z-index: 3; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 16px; border-radius: 3px; animation: fall 2.2s ease-in forwards; }
@keyframes fall { to { transform: translateY(620px) rotate(540deg); opacity: .9; } }

/* ---- Controls ---- */
.mission { background: var(--star); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; }
.mission p { margin: 0; }
.mission-step { font-weight: 800; color: var(--indigo); }
.mission-text { margin: 4px 0 2px !important; }
.link-btn { border: 0; background: none; padding: 6px 0; color: var(--indigo); font-weight: 700; text-decoration: underline; cursor: pointer; text-align: left; }
.link-btn:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; }

.checks { display: grid; gap: 10px; }
.check { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 3px solid var(--line); border-radius: 14px; background: var(--white); cursor: pointer; text-align: left; min-height: 64px; }
.check:hover:not(:disabled) { border-color: var(--indigo); }
.check .tick { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 3px solid var(--indigo); background: var(--white); }
.check[aria-pressed="true"] { border-color: var(--green); background: #EEF8F0; }
.check[aria-pressed="true"] .tick { background: var(--green); border-color: var(--green); }
.check[aria-pressed="true"] .tick::after { content: ""; width: 9px; height: 17px; border: solid var(--white); border-width: 0 4px 4px 0; transform: translateY(-2px) rotate(45deg); }
.check .c-name { display: block; font-weight: 800; font-size: 1rem; line-height: 1.2; }
.check .c-sub { display: block; font-size: .82rem; color: var(--muted); line-height: 1.2; margin-top: 2px; }

.choose { border: 0; margin: 0 0 12px; padding: 0; min-width: 0; }
.choose legend { padding: 0; margin-bottom: 6px; font-weight: 800; }
.num { display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; margin-right: 4px; border-radius: 50%; background: var(--moon); font-size: .9em; }
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choices.pushes, .choices.payloads { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; border: 3px solid var(--line); border-radius: 14px; background: var(--white); cursor: pointer; text-align: center; transition: transform .1s, border-color .1s; min-height: 44px; }
.choice:hover:not(:disabled) { border-color: var(--indigo); transform: translateY(-2px); }
.choice[aria-pressed="true"] { border-color: var(--indigo); background: #FFF6DE; box-shadow: 0 0 0 2px var(--flame) inset; }
.choice:disabled { opacity: .5; cursor: default; }
.choice svg { width: 76px; height: 40px; display: block; }
.choice img { height: 40px; width: auto; }
.choice .c-name { font-weight: 800; font-size: .95rem; line-height: 1.15; }
.choice .c-sub { font-size: .78rem; color: var(--muted); line-height: 1.15; }
.tip { margin: 8px 0 0; font-size: .86rem; color: var(--muted); text-align: center; }

.guess-q { font-weight: 800; font-size: 1.1rem; margin: 0 0 10px; }
.guesses { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.guesses .choice svg { width: 92px; height: 48px; }

.count-btn, .letgo-btn { font-size: 1.3rem; min-height: 64px; }
.letgo-btn { font-size: 1.7rem; letter-spacing: .06em; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.your-guess { text-align: center; color: var(--muted); margin: 10px 0 0; font-weight: 700; }
.your-guess:empty { display: none; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 8px 18px; border-radius: 999px; border: 3px solid transparent; font-weight: 800; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { width: 100%; min-height: 56px; font-size: 1.15rem; }
.btn-green { background: var(--green); color: var(--white); }
.btn-green:hover:not(:disabled) { background: #22702F; }
.btn-orange { background: var(--flame); color: var(--ink); box-shadow: 0 4px 0 var(--flame-dark); }
.btn-orange:hover:not(:disabled) { background: #FFC07A; }
.btn-orange:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--flame-dark); }
.btn-indigo { background: var(--indigo); color: var(--white); }
.btn-indigo:hover:not(:disabled) { background: var(--indigo-dark); }
.btn-white { background: var(--white); color: var(--ink); border-color: var(--line); }
.btn-white:hover:not(:disabled) { border-color: var(--indigo); }

/* ---- Mission log, chart and launch status ---- */
.sheet { width: 100%; border-collapse: collapse; }
.sheet th { background: var(--indigo); color: var(--white); text-align: center; padding: 8px 6px; font-size: .9rem; }
.sheet th:first-child { text-align: left; padding-left: 10px; }
.sheet td { border: 2px solid var(--ink); padding: 6px; text-align: center; font-weight: 800; font-size: .95rem; height: 58px; }
.sheet td:first-child { text-align: left; }
.sheet tr.is-new td { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { background: #FFE6B8; } 100% { background: transparent; } }
.row-set { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 700; line-height: 1.2; }
.row-set b { display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--indigo); color: var(--white); font-size: .95rem; }
.row-set .with { display: block; font-size: .78rem; color: var(--teal); }
.cell-track { display: inline-flex; flex-direction: column; align-items: center; font-size: .8rem; line-height: 1.1; }
.cell-track svg { width: 86px; height: 30px; }
.cell-guess { display: inline-flex; flex-direction: column; align-items: center; font-size: .78rem; line-height: 1.1; }
.cell-guess svg { width: 60px; height: 22px; }
.dash { color: #B6BCD4; }
.mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: var(--white); font-size: 1rem; }
.mark.is-pass { background: var(--green); }
.mark.is-fail { background: var(--red); }
.empty { color: var(--muted); font-size: .92rem; margin: 10px 0 2px; }

.chart { display: grid; gap: 8px; padding: 4px 0; }
.track-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 8px; }
.track-name { font-weight: 800; font-size: .86rem; line-height: 1.15; }
.track-name b { color: var(--indigo); }
.track-name span { display: block; font-weight: 600; font-size: .76rem; color: var(--muted); }
.track-row svg { width: 100%; height: 62px; }
.chart-empty { color: var(--muted); font-size: .9rem; margin: 0; }
.chart-note { color: var(--muted); font-size: .78rem; margin: 2px 0 0; }
.summary { font-weight: 800; color: var(--indigo); font-size: 1.05rem; margin: 12px 0 4px; }
.summary:empty { display: none; }
.status { margin-top: 14px; border-radius: 14px; padding: 12px 14px; background: var(--star); border: 3px dashed var(--line); }
.status p { margin: 0 0 6px; }
.status-head { font-weight: 800; }
.status-word { display: inline-block; border-radius: 6px; padding: 1px 8px; color: var(--white); background: var(--red); letter-spacing: .06em; }
.status.is-ready { border-style: solid; border-color: var(--flame); background: #FFF6DE; }
.status.is-ready .status-word, .status.is-go .status-word { background: var(--green); }
.status.is-go { border-style: solid; border-color: var(--green); background: #EEF8F0; }
.status-text { font-size: .92rem; }

/* ---- Help ---- */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(660px, calc(100% - 32px)); max-height: calc(100% - 32px); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(30, 34, 64, .5); }
.help-body { padding: 20px 24px; }
.help-body h2 { margin-top: 0; color: var(--indigo); }
.help-body h3 { margin: 16px 0 4px; }
.help-body a { color: var(--indigo); }

/* ---- Smaller screens ---- */
@media (max-width: 980px) {
  .game { grid-template-columns: 1fr; grid-template-areas: "stage" "controls" "sheet"; }
  .sheet-panel { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .game { padding: 10px; gap: 10px; }
  .game-title { font-size: 1.2rem; }
  .bar { padding: 8px 10px; }
  .goal-pill { padding: 4px 10px; font-size: .85rem; }
  .tool { padding: 4px 10px; }
  .say { max-width: 34%; font-size: .62rem; padding: .35em .5em; border-width: 2px; }
  .say-auntie { max-width: 31%; }
  .say::after { width: 10px; height: 10px; bottom: -7px; }
  .caption { width: 64%; font-size: .62rem; padding: .3em .5em; }
  .count { border-width: 4px; }
  .choice svg { width: 60px; height: 32px; }
  .choice .c-name { font-size: .86rem; }
  .sheet td { font-size: .85rem; height: 52px; padding: 4px; }
  .row-set { font-size: .78rem; gap: 5px; }
  .cell-track svg { width: 64px; height: 24px; }
  .track-row { grid-template-columns: 92px 1fr; }
  .result { padding: 10px 12px; }
  .result p { font-size: .92rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
