:root {
  --ink: #14100d;
  --cream: #fff5d7;
  --red: #f23d2e;
  --yellow: #ffd84a;
  --blue: #2864dc;
  --green: #72df8d;
  --muted: rgba(20,16,13,.62);
  --shadow: 7px 7px 0 var(--ink);
}
* {
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
[hidden] { display: none !important; }
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  height: 100dvh;
  color: var(--ink);
  background: var(--red);
  font-family: "DM Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 16% 18%, rgba(255,216,74,.4) 0 3px, transparent 4px),
    radial-gradient(circle at 82% 74%, rgba(255,245,215,.24) 0 4px, transparent 5px),
    var(--red);
  background-size: 38px 38px, 57px 57px, auto;
}
.grain { position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: .045; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
#app { width: min(780px, 100%); height: 100dvh; overflow: hidden; margin: 0 auto; padding: 16px clamp(14px, 4vw, 28px) calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.masthead { min-height: 44px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-bottom: 18px; }
.back { justify-self: start; font: 500 .68rem "DM Mono", monospace; letter-spacing: .1em; }
.mini-mark { font: 400 clamp(1.1rem, 4vw, 1.55rem) "Archivo Black", sans-serif; letter-spacing: -.08em; transform: rotate(-2deg); }
.mini-mark i { color: var(--cream); font-style: normal; }
.sound-btn { justify-self: end; width: 38px; height: 38px; border: 2px solid var(--ink); border-radius: 50%; background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); font-weight: 900; cursor: pointer; }
.sound-btn.off { color: rgba(20,16,13,.38); background: var(--cream); box-shadow: none; }
main { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
footer { margin-top: 22px; display: flex; align-items: center; gap: 10px; font: 500 .55rem "DM Mono", monospace; letter-spacing: .09em; }
footer i { flex: 1; height: 2px; background: currentColor; }

.hero { margin: clamp(20px, 6vh, 58px) 0 24px; }
.kicker { display: inline-block; margin: 0 0 12px; padding: 5px 9px; border: 2px solid var(--ink); background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); font: 500 .65rem "DM Mono", monospace; letter-spacing: .08em; transform: rotate(-2deg); }
.hero h1 { margin: 0; color: var(--cream); font: 400 clamp(4rem, 18vw, 9rem)/.72 "Archivo Black", sans-serif; letter-spacing: -.095em; text-transform: uppercase; text-shadow: 5px 5px 0 var(--ink); -webkit-text-stroke: 2px var(--ink); }
.hero h1 span { display: block; color: var(--yellow); margin-left: .18em; transform: rotate(-2deg); }
.hero p { max-width: 44ch; margin: 25px 0 0; color: var(--cream); font-weight: 700; line-height: 1.45; }
.panel { position: relative; margin-bottom: 20px; padding: clamp(18px, 5vw, 30px); border: 2px solid var(--ink); background: var(--cream); box-shadow: var(--shadow); }
.panel::after { content: ""; position: absolute; left: 0; right: 0; bottom: -9px; height: 9px; background: linear-gradient(135deg, var(--cream) 6px, transparent 0) 0 0/12px 12px repeat-x; }
.panel-title { display: flex; justify-content: space-between; gap: 10px; margin: 0 0 22px; padding-bottom: 12px; border-bottom: 2px dashed rgba(20,16,13,.25); font: 500 .65rem "DM Mono", monospace; letter-spacing: .1em; text-transform: uppercase; }
.setting + .setting { margin-top: 27px; }
.setting-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.setting-head label { font-weight: 800; }
.setting-head output { font: 400 2rem "Archivo Black", sans-serif; color: var(--blue); }
input[type="range"] { width: 100%; height: 28px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 8px; border: 2px solid var(--ink); background: var(--yellow); }
input[type="range"]::-moz-range-track { height: 8px; border: 2px solid var(--ink); background: var(--yellow); }
input[type="range"]::-webkit-slider-thumb { width: 27px; height: 27px; margin-top: -11px; appearance: none; border: 2px solid var(--ink); border-radius: 50%; background: var(--blue); box-shadow: 2px 2px 0 var(--ink); }
input[type="range"]::-moz-range-thumb { width: 25px; height: 25px; border: 2px solid var(--ink); border-radius: 50%; background: var(--blue); box-shadow: 2px 2px 0 var(--ink); }
.range-labels { display: flex; justify-content: space-between; margin-top: 4px; color: var(--muted); font: 500 .58rem "DM Mono", monospace; }
.round-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 0 0 21px; }
.round-chip { padding: 9px 5px; border: 1.5px solid var(--ink); background: var(--cream); text-align: center; font: 500 .58rem "DM Mono", monospace; }
.round-chip:nth-child(2) { background: var(--yellow); }
.round-chip:nth-child(3) { background: var(--green); }
.btn { width: 100%; min-height: 58px; padding: 14px 18px; border: 2px solid var(--ink); background: var(--cream); box-shadow: 5px 5px 0 var(--ink); font-weight: 800; cursor: pointer; transition: transform .1s, box-shadow .1s; }
.btn:hover { transform: translate(-2px,-2px); box-shadow: 8px 8px 0 var(--ink); }
.btn:active { transform: translate(3px,3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--yellow); }
.btn.blue { color: #fff; background: var(--blue); }
.text-btn { align-self: center; margin-top: 18px; padding: 8px; border: 0; background: none; font: 500 .65rem "DM Mono", monospace; text-decoration: underline; cursor: pointer; }

.handoff { flex: 1; min-height: 0; display: grid; place-items: center; text-align: center; }
.handoff-card { width: min(510px, 100%); padding: clamp(28px, 7vw, 52px) clamp(20px, 6vw, 44px); border: 3px solid var(--ink); background: var(--cream); box-shadow: 10px 10px 0 var(--ink); transform: rotate(-1deg); }
.handoff .turn-label, .phase-card .turn-label { display: inline-block; padding: 5px 9px; border: 2px solid var(--ink); background: var(--yellow); font: 500 .63rem "DM Mono", monospace; letter-spacing: .1em; }
.handoff h2 { margin: 25px 0 12px; font: 400 clamp(2.8rem, 11vw, 5.6rem)/.88 "Archivo Black", sans-serif; letter-spacing: -.065em; text-transform: uppercase; }
.handoff p { margin: 0 auto 28px; max-width: 32ch; color: var(--muted); font-weight: 700; line-height: 1.45; }
.turn-score { display: flex; justify-content: center; gap: 24px; margin: 0 0 24px; }
.turn-score span { font: 500 .6rem "DM Mono", monospace; text-transform: uppercase; }
.turn-score b { display: block; color: var(--blue); font: 400 2rem "Archivo Black", sans-serif; }

.play { flex: 1; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 18px; }
.play-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.round-label, .remaining { font: 500 .62rem "DM Mono", monospace; letter-spacing: .08em; text-transform: uppercase; }
.remaining { justify-self: end; }
.timer { position: relative; width: 74px; height: 74px; display: grid; place-items: center; border: 3px solid var(--ink); border-radius: 50%; background: var(--yellow); box-shadow: 4px 4px 0 var(--ink); font: 400 1.65rem "Archivo Black", sans-serif; }
.timer.danger { color: var(--cream); background: var(--red); animation: pulse .55s infinite alternate; }
.word-card { position: relative; align-self: stretch; display: grid; place-items: center; min-height: 300px; overflow: hidden; padding: 35px 18px; border: 3px solid var(--ink); background: var(--cream); box-shadow: 9px 9px 0 var(--ink); text-align: center; }
.word-card::before, .word-card::after { content: ""; position: absolute; width: 90px; height: 90px; border: 18px solid var(--yellow); border-radius: 50%; opacity: .65; }
.word-card::before { left: -42px; top: -43px; }
.word-card::after { right: -43px; bottom: -45px; border-color: var(--blue); }
.word { position: relative; z-index: 1; max-width: 100%; font: 400 clamp(2.8rem, 12vw, 6.5rem)/.9 "Archivo Black", sans-serif; letter-spacing: -.06em; overflow-wrap: anywhere; }
.word-card.mime-mode { cursor: pointer; touch-action: none; }
.word-card.mime-mode .word { color: var(--muted); font: 500 clamp(.72rem, 3vw, .9rem)/1.5 "DM Mono", monospace; letter-spacing: .08em; text-transform: uppercase; }
.word-card.mime-mode.revealing { background: var(--yellow); }
.word-card.mime-mode.revealing .word { color: var(--ink); font: 400 clamp(2.8rem, 12vw, 6.5rem)/.9 "Archivo Black", sans-serif; letter-spacing: -.06em; text-transform: none; }
.actions { display: grid; grid-template-columns: .85fr 1.4fr; gap: 12px; }
.action { min-height: 84px; border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); font-weight: 800; cursor: pointer; transition: background .12s, color .12s, transform .12s, box-shadow .12s; }
.action.pass { background: var(--cream); }
.action.guessed { background: var(--green); font-size: 1.05rem; }
.action.guessed.validated { color: var(--cream); background: var(--blue); transform: translate(3px,3px); box-shadow: 1px 1px 0 var(--ink); cursor: wait; }
.action:disabled { opacity: 1; }
.action:active { transform: translate(3px,3px); box-shadow: 1px 1px 0 var(--ink); }

.last-word-check .handoff-card { transform: rotate(1deg); }
.last-word-check .check-kicker { margin: 24px auto 6px; color: var(--ink); font: 800 .76rem "DM Mono", monospace; letter-spacing: .04em; text-transform: uppercase; }
.last-word-check h2 { margin: 10px 0 28px; color: var(--blue); overflow-wrap: anywhere; text-transform: none; }
.check-actions { display: grid; grid-template-columns: 1fr 1.2fr; gap: 12px; }
.check-actions .btn { min-height: 70px; padding-inline: 10px; }
.check-no { background: var(--cream); }
.check-yes { background: var(--green); }

.phase { flex: 1; display: grid; place-items: center; }
.phase-card { width: min(560px, 100%); padding: clamp(25px, 6vw, 45px); border: 3px solid var(--ink); background: var(--cream); box-shadow: 10px 10px 0 var(--ink); }
.phase-card h1 { margin: 22px 0 8px; font: 400 clamp(3rem, 12vw, 6rem)/.82 "Archivo Black", sans-serif; letter-spacing: -.07em; text-transform: uppercase; }
.phase-card h1 em { display: block; color: var(--blue); font-style: normal; }
.phase-card .rule { margin: 24px 0; padding: 18px; border: 2px solid var(--ink); background: var(--yellow); font-weight: 800; line-height: 1.45; }
.phase-card p { line-height: 1.5; font-weight: 700; }
.final-stamp { display: inline-block; margin-bottom: 12px; color: var(--cream); background: var(--blue); padding: 6px 10px; font: 500 .65rem "DM Mono", monospace; transform: rotate(-2deg); }

@keyframes pulse { to { transform: scale(1.08) rotate(2deg); } }
@media (max-width: 560px) {
  #app { padding-top: 10px; }
  .masthead { margin-bottom: 10px; }
  footer { display: none; }
  .hero { margin-top: 16px; }
  .hero h1 { font-size: clamp(4.4rem, 24vw, 7rem); }
  .panel { padding: 18px; box-shadow: 5px 5px 0 var(--ink); }
  .handoff { min-height: 0; }
  .handoff-card { box-shadow: 7px 7px 0 var(--ink); }
  .play { min-height: 0; gap: 12px; }
  .play-top { padding-top: 2px; }
  .timer { width: 64px; height: 64px; font-size: 1.4rem; }
  .word-card { min-height: 280px; box-shadow: 6px 6px 0 var(--ink); }
  .actions { padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  .action { min-height: 78px; }
  .check-actions { grid-template-columns: 1fr; }
  .check-actions .btn { min-height: 58px; }
}
/* Keep every setup control, including the start button, inside the locked
   viewport. Browser chrome and landscape tablets commonly leave less than
   900px of usable height even when the screen itself is much taller. */
@media (max-height: 900px) {
  #app { padding-top: 7px; padding-bottom: max(7px, env(safe-area-inset-bottom)); }
  .masthead { min-height: 36px; margin-bottom: 4px; }
  .sound-btn { width: 34px; height: 34px; }
  footer { display: none; }
  .hero { margin: 2px 0 9px; }
  .kicker { margin-bottom: 7px; padding: 3px 7px; font-size: .55rem; }
  .hero h1 { font-size: clamp(3.2rem, 14vh, 5.2rem); text-shadow: 3px 3px 0 var(--ink); }
  .hero p { display: none; }
  .panel { margin-bottom: 10px; padding: 11px 15px; box-shadow: 4px 4px 0 var(--ink); }
  .panel::after { display: none; }
  .panel-title { margin-bottom: 8px; padding-bottom: 7px; }
  .setting + .setting { margin-top: 8px; }
  .setting-head { margin-bottom: 2px; }
  .setting-head output { font-size: 1.3rem; }
  input[type="range"] { height: 23px; }
  .round-strip { margin-bottom: 8px; }
  .round-chip { padding: 6px 3px; }
  .btn { min-height: 48px; padding: 10px 15px; }
  .handoff-card, .phase-card { padding: 20px 18px; box-shadow: 6px 6px 0 var(--ink); }
  .handoff h2 { margin: 15px 0 8px; font-size: clamp(2.2rem, 9vh, 4rem); }
  .handoff p { margin-bottom: 15px; }
  .turn-score { margin-bottom: 14px; }
  .phase-card h1 { margin: 13px 0 6px; font-size: clamp(2.5rem, 10vh, 4.6rem); }
  .phase-card .rule { margin: 12px 0; padding: 11px; }
  .play { gap: 8px; }
  .timer { width: 55px; height: 55px; font-size: 1.2rem; }
  .word-card { min-height: 0; padding: 18px 12px; }
  .action { min-height: 62px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
