:root {
  color-scheme: light;
  font-family: "Avenir Next", Avenir, system-ui, sans-serif;
  color: #142c2a;
  background: #f5f1e6;
  font-synthesis: none;
  --ink: #142c2a;
  --muted: #53615b;
  --line: #dedace;
  --orange: #ffbc80;
  --teal: #8cf5d0;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main { max-width: 1320px; margin: 0 auto; padding: clamp(24px, 4vh, 48px) clamp(16px, 5vw, 70px) 32px; }
p, h1, h2 { margin: 0; }
button { font: inherit; font-weight: 700; cursor: pointer; }
button:focus-visible { outline: 3px solid #20725e; outline-offset: 4px; }
button:disabled { cursor: default; opacity: .63; }

.masthead { display: flex; justify-content: space-between; align-items: end; gap: 22px; margin-bottom: 23px; }
.subtitle { display: flex; align-items: center; gap: 9px; color: #415b50; font-size: .8rem; font-weight: 800; letter-spacing: .095em; text-transform: uppercase; }
.flag-mark { width: 19px; height: 13px; display: inline-block; background: linear-gradient(135deg, #de7b4b 50%, #254c42 50%); }
h1 { font-size: clamp(2.7rem, 6.1vw, 5.4rem); line-height: 1.04; letter-spacing: -.075em; font-weight: 800; margin-top: .12em; }
.modes { display: flex; flex-wrap: wrap; max-width: 100%; padding: 4px; gap: 4px; border-radius: 11px; background: #e7e5d8; white-space: nowrap; }
.modes button { border: 0; padding: 9px 13px; border-radius: 8px; color: var(--ink); background: transparent; font-size: .88rem; }
.modes button[aria-pressed=true] { background: #183d34; color: #fffdf4; }
.modes button[aria-pressed=false]:hover { background: #f6f4e9; }

.game { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(290px, 1fr); align-items: start; gap: clamp(13px, 2.2vw, 29px); }
.studio, .board { min-width: 0; }
.stage { position: relative; isolation: isolate; overflow: hidden; aspect-ratio: 16 / 10; border-radius: 17px; background: #122c2b; color: #fffdf4; }
.stage:not(.live) {
  background-image: linear-gradient(#c4ead412 1px, transparent 1px), linear-gradient(90deg, #c4ead412 1px, transparent 1px);
  background-position: center;
  background-size: 38px 38px;
}
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage video { object-fit: contain; transform: scaleX(-1); visibility: hidden; }
.stage.live video { visibility: visible; }
.stage-status, .legend { position: absolute; top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px; background: #102522e8; border: 1px solid #ccede22b; border-radius: 7px; font-size: .75rem; font-weight: 700; }
.stage-status { left: 14px; }
.stage-status span:first-child, .legend span::before { width: 8px; height: 8px; border-radius: 50%; background: #a8aea8; display: inline-block; content: ""; }
.stage.live .stage-status span:first-child, #player-key::before { background: var(--teal); }
.legend { right: 14px; gap: 12px; }
.legend:not(:has(span:not([hidden]))) { display: none; }
.legend span::before { margin-right: 6px; }
#guide-key::before { background: var(--orange); }
.start { position: absolute; bottom: clamp(11px, 4%, 30px); inset-inline: 0; display: grid; justify-items: center; gap: 8px; text-align: center; }
.start p { font-size: .75rem; color: #e3eee7; padding: 0 4px; }
.primary { background: var(--orange); color: #182522; border: 0; border-radius: 9px; padding: 10px 16px; }
.primary span { margin-left: 7px; }
.primary:hover { background: #ffd2aa; }
.studio-footer { display: flex; align-items: start; justify-content: space-between; gap: 13px; padding: 13px 2px 0; min-height: 58px; }
.instructions { flex: 1; color: #42544a; font-weight: 600; font-size: .9rem; }
.progress-track { max-width: 240px; height: 5px; margin-top: 7px; border-radius: 12px; background: #deeadf; overflow: hidden; }
#progress { height: 100%; width: 0; background: #247858; }

.board { display: grid; gap: 14px; }
.word-panel, .readout { padding: clamp(15px, 2.25vw, 27px); border: 1px solid var(--line); border-radius: 17px; background: #fffdf5; }
h2 { font-size: clamp(1.2rem, 2.25vw, 1.55rem); line-height: 1.15; letter-spacing: -.04em; }
.word-panel p, .readout p { color: var(--muted); font-size: .9rem; line-height: 1.4; }
.tiles { display: flex; flex-wrap: wrap; gap: 6px; min-height: 52px; margin: 19px 0 12px; }
.tile { display: grid; place-items: center; width: clamp(34px, 3.45vw, 47px); height: 51px; border: 1px solid #ddd9ca; border-radius: 8px; background: #f5f2e7; color: #53615b; font-size: 1.55rem; font-weight: 800; }
.tile.current, .practice-letter { border: 2px solid #ba703f; color: #754629; background: #fff3e5; }
.tile.revealed { border-color: #b5d6c6; background: #dcefe4; color: #193e32; }
.practice-letter { display: grid; place-items: center; width: 84px; min-height: 84px; border-radius: 10px; font-size: 3rem; font-weight: 800; line-height: 1; }
.transcript { display: block; overflow-wrap: anywhere; white-space: pre-wrap; font-weight: 800; font-size: 1.65rem; line-height: 1.45; letter-spacing: .08em; }
.transcript:empty::before { content: "…"; color: #657269; }
.sentence-text { letter-spacing: .025em; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.punctuation { display: flex; gap: 4px; }
.punctuation button { min-width: 30px; font-size: 1rem; line-height: 1; }
.quiet { border: 1px solid #d7d9cc; border-radius: 7px; background: #fdfbf1; color: var(--ink); padding: 6px 10px; font-size: .82rem; white-space: nowrap; }
.quiet:hover { background: #e8eee3; }
.quiet span { display: inline-block; margin-left: 4px; }
.word-panel .hint { margin-top: 13px; color: #69482c; }
.readout { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.readout p { margin-top: 5px; }
#detected { display: grid; place-items: center; flex: 0 0 65px; height: 65px; border-radius: 11px; background: #e7eee4; color: #204a3b; font-size: 2.55rem; font-weight: 800; line-height: 1; }
#detected[data-reading=true] { background: #d0f2df; }
#detected[data-space=true] { font-size: 1rem; }

@media (max-width: 830px) {
  .masthead { align-items: flex-start; flex-direction: column; gap: 14px; margin-bottom: 13px; }
  .game { grid-template-columns: minmax(0, 1fr); }
  .board { grid-template-columns: 1fr 1fr; align-items: start; }
}
@media (max-width: 530px) {
  main { padding-top: 21px; }
  .modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .modes button { padding-inline: 9px; white-space: normal; }
  .board { grid-template-columns: 1fr; gap: 9px; }
  .board:not(:has(.practice-letter)) .readout { grid-row: 1; }
  .stage { aspect-ratio: 4 / 3; }
  .stage-status, .legend { top: 9px; }
  .stage-status { left: 9px; }
  .legend { right: 9px; gap: 7px; }
}
