:root {
  color-scheme: light;
  font-family: "DM Sans", ui-rounded, system-ui, sans-serif;
  background: #f7f3eb;
  color: #282136;
  --ink: #282136;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main {
  width: min(100%, 700px);
  min-height: 100svh;
  margin: auto;
  padding: max(14px, env(safe-area-inset-top)) 16px max(10px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
header, .heading, .header-actions, .turn-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
header { flex: none; }
h1 { margin: 0; font-size: clamp(2rem, 8vw, 3rem); font-weight: 900; letter-spacing: -.075em; line-height: 1.1; }
h1 span { margin-left: 7px; color: #c63c54; }
header p { margin: 4px 0 0; font-size: .72rem; color: #625769; }
h2 { margin: 0; font-size: 1.7rem; letter-spacing: -.045em; line-height: 1.1; }
p { line-height: 1.35; }
button, input { font: inherit; color: var(--ink); }
button {
  min-width: 0; min-height: 44px; border: 0; border-radius: 12px; padding: 9px 12px;
  font-size: .9rem; font-weight: 750; cursor: pointer; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
button:not(:disabled):active { transform: translateY(1px); }
.action { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--ink); color: #fffaf3; }
.record::before, .playback::before { content: ""; width: 24px; height: 24px; background: currentColor; flex: none; }
.record::before { border-radius: 50%; }
#record-phrase::before { width: 30px; height: 30px; }
.record[aria-pressed="true"]::before { border-radius: 2px; }
.flip::before { content: "↶"; font-size: 2.1rem; line-height: 1; flex: none; }
.flip[aria-pressed="true"]::before { content: ""; width: 26px; height: 26px; border-radius: 2px; background: currentColor; }
.playback { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--ink); color: #fffaf3; }
.playback::before { clip-path: polygon(12% 0, 100% 50%, 12% 100%); }
.playback[aria-pressed="true"]::before { clip-path: inset(0 round 2px); }
.reset { border: 2px solid var(--ink); background: #f8ce76; box-shadow: 2px 2px 0 var(--ink); padding-inline: 9px; font-size: .78rem; }
.icon-button { min-width: 44px; padding: 0; font-size: 1.5rem; background: #eadfe7; border: 1px solid #c6b8c8; }
#game { display: flex; flex-direction: column; flex: 1; gap: 10px; min-width: 0; }
.turn-heading { font-size: .88rem; }
#current-player { overflow-wrap: anywhere; }
#round-count { flex: none; color: #625769; font-size: .78rem; }
#score-strip { display: flex; gap: 6px; list-style: none; padding: 0 0 3px; margin: 0; overflow-x: auto; }
#score-strip li { display: flex; gap: 8px; align-items: center; flex: none; background: #ede5ed; border: 1px solid transparent; padding: 5px 10px; border-radius: 20px; font-size: .8rem; }
#score-strip li[aria-current="true"] { border-color: var(--ink); background: #f8ce76; }
.score-name { max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-picker { border: 1px solid #d4cbd4; border-radius: 18px; padding: 8px; background: #fffaf3; text-align: center; }
.prompt-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.prompt-options button { border: 1px solid #c6b8c8; background: #f7f3eb; padding-inline: 3px; font-size: .76rem; }
.prompt-options button[aria-pressed="true"] { background: #f8ce76; border-color: var(--ink); }
#game-prompt { margin: 10px 5px 5px; font-size: clamp(1.15rem, 5vw, 1.65rem); line-height: 1.2; font-weight: 850; overflow-wrap: anywhere; }
#new-prompt { background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.step-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.step-tabs button { background: #ede5ed; }
.step-tabs button[aria-current="step"] { background: var(--ink); color: #fffaf3; }
.phases { flex: 1; display: grid; min-height: 0; }
.phases section {
  display: none; flex-direction: column; justify-content: space-between; gap: 16px;
  min-width: 0; padding: 16px; border: 2px solid transparent; border-radius: 22px; background: var(--panel);
}
.phases section[data-visible="true"] { display: flex; border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
#phrase { --panel: #ffadb5; }
#imitation { --panel: #f8ce76; }
#reveal { --panel: #b8e3bc; }
.copy p { margin: 6px 0 0; font-size: .85rem; }
.controls { display: grid; gap: 6px; }
#imitation .controls { gap: 22px; }
#imitation .controls button { min-height: 52px; }
#record-phrase, #play-reveal { min-height: 68px; font-size: 1.15rem; }
#play-reveal { font-size: 1.35rem; }
.award-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.award-controls button { min-height: 54px; font-size: 1rem; background: #fffaf3; border: 1px solid var(--ink); }
.award-controls span { font-size: 1.3em; margin-right: 4px; }
.next-player { text-align: center; margin: 0; font-size: .75rem; overflow-wrap: anywhere; }
#timer { font-size: .9rem; font-weight: 800; font-variant-numeric: tabular-nums; }
#timer:empty, #status:empty { display: none; }
#status { margin: 0; padding: 10px; border-radius: 10px; background: #ffdde0; font-size: .87rem; }
.setup, .results { background: #fffaf3; border: 1px solid #d4cbd4; border-radius: 22px; padding: 22px; display: flex; flex-direction: column; gap: 20px; margin-block: auto; }
.setup p, .results p { margin: 8px 0 0; color: #625769; }
#player-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
#player-name { width: 100%; min-width: 0; border: 1px solid #c6b8c8; border-radius: 12px; padding: 8px 10px; font-size: 1rem; }
.setup-players, #final-scores { list-style: none; padding: 0; margin: 0; }
.setup-players:empty { display: none; }
.setup-players li, #final-scores li { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid #e9e0e7; padding: 5px 0; }
.setup-players span, #final-scores span { overflow-wrap: anywhere; }
.setup-players button { background: #f2e9ee; min-width: 44px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { margin-bottom: 10px; font-weight: 750; }
.turn-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.turn-options label { position: relative; }
.turn-options input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.turn-options span { display: block; text-align: center; padding: 12px; border-radius: 12px; border: 1px solid #c6b8c8; cursor: pointer; }
.turn-options input:checked + span { background: #f8ce76; border: 2px solid var(--ink); padding: 11px; }
.turn-options input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 3px; }
.results { text-align: center; background: #b8e3bc; }
.winner-icon { font-size: 3rem; }
#winner-title { overflow-wrap: anywhere; }
#final-scores li { border-color: #91b99a; padding-block: 12px; }
dialog { max-width: min(90vw, 420px); border: 2px solid var(--ink); border-radius: 22px; background: #fffaf3; color: var(--ink); padding: 24px; }
dialog::backdrop { background: #28213688; }
.dialog-actions { display: flex; gap: 8px; }
.dialog-actions button { flex: 1; }
footer { text-align: center; color: #685d70; font-size: .7rem; margin-top: auto; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-height: 740px) and (max-width: 899px) {
  main { gap: 8px; padding-top: 10px; padding-bottom: 8px; }
  #game { gap: 7px; }
  .phases section { padding: 12px; gap: 10px; }
  h2 { font-size: 1.5rem; }
  .copy p { font-size: .8rem; }
}
@media (min-width: 900px) {
  main { width: min(100%, 1400px); padding: 24px 32px; gap: 20px; }
  #game { gap: 16px; }
  .step-tabs { display: none; }
  .phases { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
  .phases section { display: flex; min-height: 320px; padding: 24px; border-radius: 30px; }
  h2 { font-size: 2.4rem; }
  .copy p { font-size: 1rem; }
  #game-prompt { font-size: 1.8rem; }
  .prompt-picker { padding-inline: 24px; }
  .prompt-options { max-width: 600px; margin: auto; }
  .setup, .results { width: 550px; max-width: 100%; align-self: center; }
}
