/* Fizz Lab. Colours are Book 3's theme colours (berry, sunny yellow, cobalt, mint, balloon orange). */
:root {
  color-scheme: light;
  --berry: #A8285F; --berry-dark: #84204B; --sun: #FFD447; --sun-dark: #E8B820; --cobalt: #1F5FA8; --violet: #5B3C99;
  --green: #2B8A3E; --orange: #F28C38; --orange-dark: #CF6B1A; --mint: #EAF6EE; --mint-deep: #CFEBDD; --vinegar: #A8DCF0;
  --ink: #26203A; --muted: #5F5870; --white: #FFFFFF; --line: #CFE5D7;
  --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(--mint); 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(--violet); outline-offset: 2px; }

/* ---- Top bar ---- */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 16px; background: var(--berry); 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(--sun); 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(--berry); }
.muted { display: block; font-size: .85rem; font-weight: 400; color: var(--muted); }

/* ---- Stage: the room, then the people, then the counter in front of them ---- */
.stage { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: var(--mint-deep); 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-veer { left: 4%; bottom: 7%; }
.who-mom { right: 3%; bottom: -6%; }
.who-papa { left: 21%; bottom: -8%; }
.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: 30%; 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(38, 32, 58, .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-veer { left: 2%; }
.say-veer::after { left: 18%; }
.say-mom { right: 2%; }
.say-mom::after { right: 22%; }
.say-papa { left: 31%; }
.say-papa::after { left: 16%; }
.say.is-safe { color: var(--berry); border-color: var(--berry); font-weight: 800; text-transform: uppercase; letter-spacing: .02em; }
.stamp { position: absolute; z-index: 3; top: 34%; 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.2rem, 4.2vw, 2.8rem); letter-spacing: .04em; white-space: nowrap; animation: stamp-in .35s cubic-bezier(.2, 1.6, .5, 1); }
.stamp.is-new { color: var(--green); }
.stamp.is-nothing { color: var(--cobalt); }
.stamp.is-party { color: var(--berry); }
@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: 60%; 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(38, 32, 58, .12); }
.caption:empty { display: none; }

/* result card */
.result { margin-top: 12px; background: var(--white); border-radius: var(--radius); border: 4px solid var(--berry); padding: 14px 18px; box-shadow: 0 6px 18px rgba(38, 32, 58, .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(--berry); text-transform: uppercase; }
.result h2 { margin: 0 0 4px; font-size: clamp(1.05rem, 2.4vw, 1.6rem); color: var(--berry); }
.result h2:focus { outline: none; }
.result p { margin: 4px 0; }
.result .guess-note { font-weight: 700; }
.result .hint { font-weight: 700; color: var(--violet); }
.result .guess-note:empty, .result .hint:empty, .result p:empty { display: none; }
.result.is-new { border-color: var(--green); }
.result.is-new h2 { color: var(--green); }
.result.is-nothing { border-color: var(--cobalt); }
.result.is-nothing h2 { color: var(--cobalt); }
.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(--mint); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; }
.mission p { margin: 0; }
.mission-step { font-weight: 800; color: var(--berry); }
.mission-text { margin: 4px 0 2px !important; }
.link-btn { border: 0; background: none; padding: 6px 0; color: var(--berry-dark); 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; }
.goggle-ico { width: 2.2em; height: 1.1em; }

.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(--sun); font-size: .9em; }
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choices.spoons { 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(--berry); transform: translateY(-2px); }
.choice[aria-pressed="true"] { border-color: var(--berry); background: #FFF6D6; box-shadow: 0 0 0 2px var(--sun) inset; }
.choice:disabled { opacity: .5; cursor: default; }
.choice svg { width: 52px; height: 48px; display: block; }
.choice .c-name { font-weight: 800; font-size: .98rem; line-height: 1.15; }
.choice .c-sub { font-size: .78rem; color: var(--muted); line-height: 1.15; }
.choice .c-done { margin-top: 2px; font-size: .7rem; font-weight: 800; border-radius: 999px; padding: 1px 7px; color: var(--white); }
.c-done.is-gas { background: var(--green); }
.c-done.is-none { background: var(--cobalt); }
.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: 64px; height: 84px; }

.mix-btn { font-size: 1.3rem; min-height: 64px; }
.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(--orange); color: var(--ink); box-shadow: 0 4px 0 var(--orange-dark); }
.btn-orange:hover:not(:disabled) { background: #F6A15A; }
.btn-orange:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--orange-dark); }
.btn-berry { background: var(--berry); color: var(--white); }
.btn-berry:hover:not(:disabled) { background: var(--berry-dark); }
.btn-white { background: var(--white); color: var(--ink); border-color: var(--line); }
.btn-white:hover:not(:disabled) { border-color: var(--berry); }

/* ---- Test sheet, secret cups and strips ---- */
.sheet { width: 100%; border-collapse: collapse; }
.sheet th { background: var(--berry); 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: #FFE98A; } 100% { background: transparent; } }
.row-mix { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 700; line-height: 1.2; }
.row-mix b { color: var(--berry); font-size: 1rem; }
.row-mix svg { width: 30px; height: 30px; flex: none; }
.row-mix .it-was { display: block; font-size: .78rem; color: var(--green); }
.cell-ball { display: inline-flex; flex-direction: column; align-items: center; font-size: .78rem; line-height: 1.1; }
.cell-ball svg { width: 26px; height: 34px; }
.dash { color: #B9C7BE; }
.mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: var(--white); font-size: 1rem; }
.mark.is-yes { background: var(--green); }
.mark.is-no { background: var(--cobalt); }
.empty { color: var(--muted); font-size: .92rem; margin: 10px 0 2px; }

.cups-box { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.secret { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border: 2px dashed var(--line); border-radius: 14px; text-align: center; }
.secret svg { width: 56px; height: 54px; }
.secret .s-name { font-weight: 800; font-size: 1rem; }
.secret .s-name.is-hidden { color: var(--muted); letter-spacing: .2em; }
.secret .s-status { font-size: .78rem; font-weight: 700; color: var(--muted); }
.secret .s-status.is-gas { color: var(--green); }
.secret.is-open { border-style: solid; border-color: var(--sun); background: #FFFBEA; }
.reveal-hint { font-size: .88rem; color: var(--muted); margin: 8px 0 4px; }
.reveal-hint:empty { display: none; }
.btn-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 6px 0 18px; }

.chart { display: grid; gap: 10px; padding: 4px 0; }
.strip-row { display: grid; grid-template-columns: 128px 1fr; align-items: center; gap: 8px; }
.strip-name { font-weight: 800; font-size: .86rem; line-height: 1.15; }
.strip-name b { color: var(--berry); }
.strip-name span { display: block; font-weight: 600; font-size: .76rem; color: var(--muted); }
.strip-track { position: relative; height: 30px; }
.strip { position: absolute; left: 0; top: 4px; bottom: 4px; border-radius: 3px; background: var(--orange); background-image: repeating-linear-gradient(90deg, transparent 0 22px, rgba(255, 255, 255, .45) 22px 24px); transition: width .5s ease-out; box-shadow: 0 2px 0 var(--orange-dark); }
.strip-label { position: absolute; top: 50%; transform: translateY(-50%); font-weight: 900; font-size: .9rem; padding-left: 6px; white-space: nowrap; }
.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(--berry); font-size: 1.05rem; margin: 12px 0 4px; }
.summary:empty { display: none; }

/* ---- 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(38, 32, 58, .5); }
.help-body { padding: 20px 24px; }
.help-body h2 { margin-top: 0; color: var(--berry); }
.help-body h3 { margin: 16px 0 4px; }
.help-body a { color: var(--berry-dark); }

/* ---- 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-papa { left: 28%; }
  .say::after { width: 10px; height: 10px; bottom: -7px; }
  .caption { width: 66%; font-size: .62rem; padding: .3em .5em; }
  .choice svg { width: 44px; height: 40px; }
  .choice .c-name { font-size: .88rem; }
  .sheet td { font-size: .85rem; height: 52px; padding: 4px; }
  .row-mix { font-size: .78rem; gap: 5px; }
  .row-mix svg { width: 24px; height: 24px; }
  .strip-row { grid-template-columns: 100px 1fr; }
  .result { padding: 10px 12px; }
  .result p { font-size: .92rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
