:root {
  color-scheme: dark;
  --ink: #fff4de;
  --green: #bee9c7;
  --paper: #101e19;
  --card: #1d2e26;
  --surface: #263b30;
  --input: #14251d;
  --muted: #becfc2;
  --rule: #496557;
  --red: #ff826c;
  --red-text: #ff8b73;
  --yellow: #f7c85c;
  --mint: #bee9a7;
  --dark-ink: #202820;
  --shadow: 0 16px 44px #040d0980;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 100%;
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  background-color: var(--paper);
  background-image: radial-gradient(ellipse at 24% 0%, #2c5b4050, transparent 63%),
    linear-gradient(#bde7a914 1px, transparent 1px), linear-gradient(90deg, #bde7a914 1px, transparent 1px);
  background-size: auto, 27px 27px, 27px 27px;
}

button, input, textarea { font: inherit; }
button { color: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button, input, a { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 4px;
}

:focus:not(:focus-visible) { outline: none; }

.shell { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }

.topbar {
  border-bottom: 1px solid #8dab9236;
  background: #13231c;
}

.topbar-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 850;
  letter-spacing: -.035em;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  border: 1.5px solid var(--yellow);
  border-radius: 8px;
  box-shadow: 0 3px 0 #8a672a;
  transform: rotate(-8deg);
  background: var(--yellow);
  color: var(--dark-ink);
  font-size: 1.56rem;
  font-weight: 800;
  line-height: 1;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 15px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  font-weight: 750;
  text-align: center;
  transition: background-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.button:hover:not(:disabled) { background-color: #395347; }

.help-button {
  min-height: 38px;
  font-size: .88rem;
  gap: 8px;
}

.sound-button { min-height: 38px; padding-inline: 11px; font-size: .88rem; gap: 6px; }
.sound-button[aria-pressed="true"] { color: var(--yellow); }
.sound-icon { position: relative; width: 19px; height: 18px; }
.sound-icon::before, .sound-icon::after { content: ""; position: absolute; }
.sound-icon::before {
  top: 2px;
  left: 0;
  width: 11px;
  height: 14px;
  background: currentColor;
  clip-path: polygon(0 29%, 42% 29%, 100% 0, 100% 100%, 42% 71%, 0 71%);
}
.sound-icon::after { inset: 2px 0 2px 10px; border-right: 2px solid currentColor; border-radius: 50%; }
.sound-button[aria-pressed="false"] .sound-icon::before { opacity: .55; }
.sound-button[aria-pressed="false"] .sound-icon::after {
  inset: 8px 0 auto 4px;
  height: 2px;
  border: 0;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(-48deg);
}

.question-icon {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1.4px solid currentColor;
  border-radius: 50%;
  font-size: .73rem;
  line-height: 1;
}

.intro { padding: 38px 0 27px; }
.intro-art { display: none; }
main:has(.in-progress) .intro { display: none; }

.eyebrow, .micro {
  margin: 0;
  color: var(--green);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-weight: 800;
  font-size: .87rem;
  letter-spacing: .115em;
}

.eyebrow { display: inline-flex; align-items: center; gap: 9px; }
.eyebrow span { color: var(--red-text); font-size: 1.22rem; line-height: 1; }

h1 {
  margin: 7px 0 10px;
  font-family: Impact, "Arial Black", system-ui, sans-serif;
  font-weight: 900;
  font-size: clamp(3.4rem, 8.6vw, 7.4rem);
  line-height: .99;
  letter-spacing: -.026em;
}

h1 em {
  display: inline-block;
  color: var(--red-text);
  font-style: normal;
  transform: skew(-7deg);
  transform-origin: bottom left;
  margin-left: .035em;
}

.tagline { margin: 0; color: var(--muted); font-size: clamp(1.05rem, 2.3vw, 1.3rem); font-weight: 650; }

.game-board {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  align-items: stretch;
}

.game-panel, .art-panel {
  margin: 0;
  border: 1px solid var(--rule);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.game-panel { background: linear-gradient(155deg, var(--surface), var(--card) 55%); padding: 24px 28px 25px; min-height: 440px; }

.game-board:not(.in-progress) .game-panel { display: flex; flex-direction: column; justify-content: center; }

.art-panel {
  position: relative;
  min-width: 0;
  align-self: stretch;
  min-height: 440px;
  overflow: hidden;
  background: #163524;
}

.art-panel img {
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 48%;
}

h2 { margin: 0; font-size: clamp(1.68rem, 3.5vw, 2.18rem); letter-spacing: -.055em; line-height: 1.1; font-weight: 850; overflow-wrap: anywhere; }

.subtitle { margin: 7px 0 20px; color: var(--muted); line-height: 1.45; }

fieldset { margin: 0 0 17px; border: 0; padding: 0; min-width: 0; }
legend { font-size: .92rem; font-weight: 800; padding: 0; }

.player-legend { width: 100%; float: left; margin-bottom: 8px; }
.field-row { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.count { font: 750 .82rem ui-monospace, monospace; color: var(--muted); }

.players {
  clear: left;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}

.player-input {
  display: flex;
  align-items: center;
  min-width: 0;
  background: var(--input);
  border: 1px solid var(--rule);
  border-radius: 8px;
}

.player-input:focus-within { border-color: var(--green); }

.player-input input {
  min-width: 0;
  width: 100%;
  border: 0;
  padding: 10px 8px;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
}

.player-input input:focus { outline: none; }
.player-input input::placeholder { color: #a6b9aa; opacity: 1; }

.remove-player, .icon-button { flex: none; padding: 0; line-height: 1; font-size: 1.35rem; }
.remove-player { border: 0; border-radius: 5px; background: transparent; width: 32px; height: 34px; margin-right: 3px; }
.remove-player:hover { background: #563c34; }
.icon-button { width: 42px; }

.add-player {
  background: transparent;
  border-style: dashed;
  border-color: #759481;
  color: var(--green);
  font-size: .9rem;
}
.add-player span { font-size: 1.15rem; line-height: 1; }

.difficulty-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.choice { position: relative; display: block; min-width: 0; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.choice span {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 7px 9px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--input);
  font-size: .89rem;
  font-weight: 750;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.choice span:hover { background: #395347; }
.choice input:checked + span { border-color: var(--yellow); background: #4b4627; color: #fff2bf; box-shadow: inset 0 0 0 1px var(--yellow); }
.choice input:focus-visible + span { outline: 3px solid var(--yellow); outline-offset: 3px; }
.difficulty-symbol { font: 800 1rem/1 ui-monospace, monospace; }

.primary {
  width: 100%;
  min-height: 50px;
  border: 1px solid #ffda83;
  box-shadow: 0 4px 0 #8a672a;
  background: var(--yellow);
  color: var(--dark-ink);
  font-size: 1rem;
  font-weight: 850;
}

.primary:hover:not(:disabled) { background: #ffda83; }
.primary:active:not(:disabled) { box-shadow: none; transform: translate(2px, 3px); }
.play-icon { font-size: .82rem; }

.game-steps {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px 28px;
  list-style: none;
  margin: 30px 0 0;
  padding: 0 0 30px;
  color: var(--green);
}

.game-steps li { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 750; }
.step-icon { display: grid; place-items: center; width: 24px; height: 24px; font: 850 1rem/1 ui-monospace, monospace; border: 1px solid var(--ink); border-radius: 5px; color: var(--dark-ink); }
.step-yellow { background: var(--yellow); }
.step-green { background: var(--mint); }
.step-red { background: #f7aa92; }

.game-board.in-progress { grid-template-columns: minmax(0, 690px); justify-content: center; margin-top: clamp(20px, 5vw, 56px); }
.in-progress .art-panel, .in-progress + .game-steps { display: none; }
.in-progress .game-panel { min-height: 0; margin-bottom: 42px; }
.stage-label { margin-bottom: 10px; }

.handoff {
  min-height: 290px;
  display: grid;
  align-content: center;
  text-align: center;
  justify-items: center;
}

.handoff .primary { max-width: 360px; }
.handoff-symbol { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 20px; border: 2px solid var(--yellow); border-radius: 14px; background: var(--yellow); color: var(--dark-ink); box-shadow: 0 4px 0 #8a672a; transform: rotate(-7deg); font-size: 1.9rem; font-weight: 900; }

.role-card {
  margin: 15px 0;
  border: 1px solid #618e69;
  border-radius: 12px;
  padding: 11px 13px;
  background: #304838;
}

.role-card.impostor { background: #472c2b; border-color: #ae675a; }
.role-card p { margin: 3px 0 0; line-height: 1.4; }

.equation {
  margin: 16px 0;
  padding: 16px;
  text-align: center;
  background-color: var(--paper);
  background-image: linear-gradient(#aed6aa19 1px, transparent 1px), linear-gradient(90deg, #aed6aa19 1px, transparent 1px);
  background-size: 18px 18px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  font: 800 clamp(1.45rem, 5.5vw, 2.5rem)/1.2 ui-monospace, monospace;
}

.answer-label { display: block; margin-bottom: 6px; font-weight: 750; }
.answer-input { width: 100%; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px; background: var(--input); color: var(--ink); }
.clue-input { display: block; min-height: 72px; resize: vertical; }
.error { min-height: 1.4em; margin: 5px 0 10px; color: var(--red-text); font-size: .88rem; }

.answer-list { list-style: none; margin: 15px 0 23px; padding: 0; }
.answer-list li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px 16px; padding: 11px 0; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; align-items: start; }
.answer-list li:first-child { border-top: 1px solid var(--rule); }
.answer-list .answer { font: 700 .93rem/1.55 ui-monospace, monospace; }
.player-clue { margin: 0 0 4px; line-height: 1.4; }
.answer-list small { color: var(--muted); font-size: .88rem; }
.answer-list .feedback { display: block; }
.answer-list .worked-solution { display: block; margin-top: 4px; line-height: 1.45; }
.impostor-label { display: block; color: var(--red-text); font-size: .86rem; font-weight: 750; }
.result-actions { display: flex; gap: 10px; }
.result-actions .primary { flex: 1; }
.result-actions .button { min-height: 50px; }

dialog { width: min(500px, calc(100% - 34px)); max-height: calc(100dvh - 40px); padding: 23px; border: 1px solid var(--rule); border-radius: 20px; background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: #090f0be0; }
.dialog-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.invite-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.invite-qr-image { display: block; width: min(240px, 100%); aspect-ratio: 1; margin: 14px auto; background: white; image-rendering: pixelated; }
.invite-qr-link { display: block; width: fit-content; margin-inline: auto; color: var(--yellow); }
.host-display { padding-block: clamp(20px, 4vw, 48px); }
.host-display h1 { margin: 0 0 18px; font-size: clamp(2rem, 6vw, 4.8rem); }
.host-display .game-panel { min-height: 0; }
.host-display .answer-list .answer { font-size: clamp(1rem, 2.6vw, 1.45rem); }
.display-code { color: var(--yellow); font: 850 clamp(2.25rem, 9vw, 6rem)/1.2 ui-monospace, monospace; letter-spacing: .13em; }
.match-scoreboard { margin-block: 14px; padding: 14px; border: 1px solid var(--rule); border-radius: 14px; background: var(--input); }
.match-scoreboard .live-roster { margin-block: 8px 0; }
.score-points { margin-left: auto; color: var(--yellow); font-weight: 800; white-space: nowrap; }
.rules-list { margin: 17px 0 22px; padding-left: 25px; line-height: 1.5; }
.rules-list li + li { margin-top: 10px; }

@media (max-width: 850px) {
  .shell { width: calc(100% - 40px); }
  .game-board { grid-template-columns: 1.2fr 1fr; gap: 15px; }
  .game-panel { padding: 20px; }
  .art-panel img { object-fit: cover; }
}

@media (max-width: 650px) {
  .shell { width: calc(100% - 34px); }
  .topbar-inner { min-height: 60px; }
  .brand { font-size: 1rem; }
  .brand-icon { width: 28px; height: 28px; font-size: 1.35rem; }
  .help-button { padding-inline: 10px; }
  .intro { padding: 29px 0 24px; }
  h1 { font-size: clamp(2.9rem, 11.15vw, 4.45rem); }
  .game-board { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .game-panel { min-height: 0; padding: 19px 16px 21px; }
  .art-panel { min-height: 0; aspect-ratio: 1.1; }
  .art-panel img { object-fit: contain; }
  .game-steps { margin-top: 24px; gap: 10px 15px; }
  .game-steps li { font-size: .82rem; }
}

@media (max-width: 360px) {
  .topbar-inner { gap: 8px; }
  .topbar-actions { gap: 6px; }
  .help-button { min-width: 40px; }
  .help-label { display: none; }
  h1 { font-size: 12vw; }
  .difficulty-options .choice span { padding-inline: 4px; gap: 4px; }
  .result-actions { flex-wrap: wrap; }
  .result-actions .primary { flex-basis: 100%; }
}

@media (max-width: 460px) {
  .sound-button { min-width: 40px; }
  .sound-label { display: none; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }

[hidden] { display: none !important; }
.mode-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 13px;
}
.mode-picker button {
  min-height: 40px;
  padding: 5px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: .9rem;
  font-weight: 800;
}
.mode-picker button[aria-pressed="true"] {
  background: #3a5143;
  border-color: #668673;
  color: var(--ink);
}
.mode-picker button[aria-pressed="false"]:hover { background: #2d4638; }
.in-progress #mode-picker { display: none; }

.live-form .answer-input + label { margin-top: 12px; }
.live-form .error:empty, .live-error:empty, .copy-status:empty { display: none; }
.live-form .primary { margin-top: 14px; }
.live-form .error:not(:empty) { margin-bottom: 0; }
.room-verification { margin-top: 12px; }
.room-verification p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.room-verification p:empty { display: none; }
.code-input { text-transform: uppercase; letter-spacing: .06em; }
.code-input::placeholder { text-transform: none; letter-spacing: 0; }

.plain-button {
  border-color: transparent;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: .2em;
  margin-top: 9px;
  font-size: .9rem;
}

.live-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 7px 15px;
  align-items: center;
  margin-bottom: 13px;
}
.room-connection {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 4px 8px;
  background: #30513f;
  border: 1px solid #62886e;
  border-radius: 5px;
  color: var(--green);
  font: 750 .82rem ui-monospace, monospace;
}

.invite-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 13px 15px;
  border-radius: 9px;
  background: var(--input);
  border: 1px solid var(--rule);
}
.invite-box .answer-label { margin-bottom: 2px; }
.invite-code { font: 850 clamp(1.2rem, 5vw, 1.65rem)/1.2 ui-monospace, monospace; letter-spacing: .14em; }
.copy-status { margin: 6px 0 0; color: var(--green); overflow-wrap: anywhere; }
.lobby-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 17px 0 8px; font-size: 1rem; }
.live-roster { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.live-roster li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 5px 7px; min-height: 42px; border: 1px solid var(--rule); border-radius: 6px; overflow-wrap: anywhere; }
.roster-note { font: 750 .78rem ui-monospace, monospace; color: var(--green); background: #325341; padding: 2px 4px; border-radius: 3px; }
.live-roster .remove-player { margin-right: 0; margin-left: auto; width: 31px; height: 31px; }

@media (max-width: 420px) {
  .mode-picker { margin-bottom: 15px; }
  .live-roster { grid-template-columns: minmax(0, 1fr); }
}

.field-hint { clear: left; margin: 0 0 9px; color: var(--muted); font-size: .86rem; }

.player-avatar {
  display: block;
  width: 33px;
  height: 33px;
  flex: none;
  border: 1px solid #fff4de62;
  border-radius: 10px;
  background: #385246 url("./avatars.webp") no-repeat;
  background-size: 300% 200%;
}
.avatar-1 { background-position: 50% 0; }
.avatar-2 { background-position: 100% 0; }
.avatar-3 { background-position: 0 100%; }
.avatar-4 { background-position: 50% 100%; }
.avatar-5 { background-position: 100% 100%; }
.avatar-6, .avatar-7, .avatar-8, .avatar-9, .avatar-10, .avatar-11 { background-image: url("./avatars-extra.webp"); }
.avatar-7 { background-position: 50% 0; }
.avatar-8 { background-position: 100% 0; }
.avatar-9 { background-position: 0 100%; }
.avatar-10 { background-position: 50% 100%; }
.avatar-11 { background-position: 100% 100%; }

.avatar-field { margin: 14px 0 0; }
.avatar-picker { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 9px 7px; margin-top: 7px; }
.avatar-option { display: block; position: relative; cursor: pointer; }
.avatar-option input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.avatar-option .player-avatar { width: 100%; height: auto; aspect-ratio: 1; border-radius: 11px; }
.avatar-option:hover .player-avatar { border-color: var(--ink); }
.avatar-option input:checked + .player-avatar { outline: 2px solid var(--yellow); outline-offset: 2px; }
.avatar-option input:focus-visible + .player-avatar { outline: 3px solid var(--ink); outline-offset: 3px; }
.avatar-cycle { display: grid; place-items: center; padding: 4px 0 4px 4px; border: 0; background: transparent; border-radius: 9px; }
.avatar-cycle .player-avatar { width: 34px; height: 34px; }
.avatar-cycle:hover .player-avatar { border-color: var(--yellow); }

.handoff-avatar { margin-bottom: 16px; transform: rotate(-6deg); }
.handoff-avatar .player-avatar { width: 87px; height: 87px; border-radius: 17px; box-shadow: 0 6px 0 #06130e; }
.stage-identity, .player-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.stage-identity .player-avatar { width: 50px; height: 50px; border-radius: 13px; }
.live-roster .player-avatar { width: 27px; height: 27px; border-radius: 7px; }

.discussion-clock {
  display: grid;
  grid-template-columns: 23px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 11px;
  padding: 13px 15px;
  background: var(--input);
  border: 1px solid var(--rule);
  border-radius: 15px;
  font-weight: 750;
}
.clock-icon { display: block; width: 20px; height: 20px; border: 2px solid var(--yellow); border-radius: 50%; position: relative; }
.clock-icon::after { content: ""; position: absolute; top: 3px; left: 7px; width: 5px; height: 6px; border-left: 2px solid var(--yellow); border-bottom: 2px solid var(--yellow); }
.clock-value { font: 850 clamp(1.65rem, 4.5vw, 2.25rem)/1 ui-monospace, monospace; font-variant-numeric: tabular-nums; color: var(--yellow); }
.discussion-clock progress { grid-column: 1 / -1; width: 100%; height: 7px; accent-color: var(--yellow); }
.discussion-clock progress::-webkit-progress-bar { background: #40594a; border-radius: 6px; }
.discussion-clock progress::-webkit-progress-value { background: var(--yellow); border-radius: 6px; }
.discussion-clock progress::-moz-progress-bar { background: var(--yellow); border-radius: 6px; }
.time-low .clock-value { color: var(--red); }
.time-low progress { accent-color: var(--red); }
.time-low progress::-webkit-progress-value { background: var(--red); }
.time-low progress::-moz-progress-bar { background: var(--red); }

@media (max-width: 650px) {
  .shell { width: calc(100% - 28px); }
  .intro { display: grid; grid-template-columns: minmax(0, 1fr) clamp(76px, 29vw, 150px); gap: 6px; align-items: center; padding: 21px 0 19px; }
  .intro-art { display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: 17px; border: 1px solid var(--rule); transform: rotate(4deg); box-shadow: 0 4px 14px #040d0980; }
  .intro h1 { font-size: clamp(2.25rem, 10.5vw, 4.2rem); margin: 5px 0 6px; }
  .intro h1 span { display: block; }
  .intro .eyebrow { font-size: .73rem; }
  .intro .tagline { font-size: .94rem; }
  .game-panel { border-radius: 20px; }
  .art-panel { display: none; }
}

@media (max-width: 340px) {
  .intro { grid-template-columns: minmax(0, 1fr) 76px; }
  .avatar-picker { gap: 5px; }
  .avatar-option .player-avatar { border-radius: 8px; }
  .player-identity { gap: 6px; }
  .player-identity .player-avatar { width: 26px; height: 26px; border-radius: 7px; }
}

.voting-heading { display: flex; gap: 7px 15px; flex-wrap: wrap; align-items: baseline; justify-content: space-between; }
.vote-progress { margin: 0; color: var(--green); font: 750 .86rem ui-monospace, monospace; }

.ballot-choices { margin-bottom: 0; }
.ballot-choices legend { color: var(--muted); }

.ballot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 9px;
}

.suspect-card {
  --suspect-accent: #f4c45f;
  position: relative;
  min-width: 0;
  display: grid;
  cursor: pointer;
  scroll-margin-bottom: 105px;
}

.suspect-card[data-avatar="1"] { --suspect-accent: #68bcec; }
.suspect-card[data-avatar="2"] { --suspect-accent: #b494dd; }
.suspect-card[data-avatar="3"] { --suspect-accent: #74d9c2; }
.suspect-card[data-avatar="4"] { --suspect-accent: #fc9676; }
.suspect-card[data-avatar="5"] { --suspect-accent: #ec9cb6; }
.suspect-card[data-avatar="6"] { --suspect-accent: #80d7e7; }
.suspect-card[data-avatar="7"] { --suspect-accent: #f9a763; }
.suspect-card[data-avatar="8"] { --suspect-accent: #d1a8dc; }
.suspect-card[data-avatar="9"] { --suspect-accent: #86e4a8; }
.suspect-card[data-avatar="10"] { --suspect-accent: #9daafa; }
.suspect-card[data-avatar="11"] { --suspect-accent: #f0c256; }

.suspect-card input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }

.suspect-card-face {
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  justify-items: center;
  align-content: center;
  gap: 10px;
  min-height: 143px;
  padding: 14px 12px 12px;
  text-align: center;
  overflow-wrap: anywhere;
  background: radial-gradient(ellipse at 50% 20%, color-mix(in srgb, var(--suspect-accent) 33%, var(--input)), transparent 82%), var(--input);
  border: 1px solid color-mix(in srgb, var(--suspect-accent) 48%, var(--rule));
  border-radius: 16px;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.suspect-card-face strong { max-width: 100%; line-height: 1.2; }
.suspect-card-face .player-avatar { width: clamp(60px, 11vw, 83px); height: auto; aspect-ratio: 1; border-radius: 13px; box-shadow: 0 5px 0 #08191080; }
.suspect-card:hover input:not(:disabled) + .suspect-card-face { transform: translateY(-2px); border-color: var(--suspect-accent); }
.suspect-card input:checked + .suspect-card-face { border-color: var(--yellow); box-shadow: inset 0 0 0 2px var(--yellow); }
.suspect-card input:disabled:not(:checked) + .suspect-card-face { opacity: .65; cursor: default; }
.suspect-card input:focus-visible + .suspect-card-face { outline: 2px solid var(--ink); outline-offset: 3px; }

.selection-mark {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  visibility: hidden;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--dark-ink);
  font-weight: 900;
}

.suspect-card input:checked + .suspect-card-face .selection-mark { visibility: visible; }
.ballot-actions { position: sticky; bottom: 0; z-index: 1; padding: 13px 0 8px; background: #1d2e26f7; }
.ballot-actions .primary:disabled { opacity: 1; color: #d0d9c8; background: #344b3e; border-color: #607969; box-shadow: none; }

.ballot-waiting { padding: 22px 12px; text-align: center; }
.vote-check { display: grid; place-items: center; width: 49px; height: 49px; margin: 0 auto 12px; border-radius: 16px; background: var(--mint); color: var(--dark-ink); font-size: 1.65rem; font-weight: 900; }

.round-review { margin-top: 12px; padding: 0 14px; border: 1px solid var(--rule); border-radius: 12px; background: var(--input); }
.round-review summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; list-style: none; cursor: pointer; font-weight: 750; }
.round-review summary::-webkit-details-marker { display: none; }
.round-review summary::after { content: ""; width: 8px; height: 8px; margin-right: 2px; border: solid var(--green); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.round-review[open] summary::after { transform: rotate(225deg); }
.round-review .answer-list { margin: 0 0 5px; }

.result-spotlight {
  --result-accent: var(--red);
  padding: clamp(22px, 5.5vw, 38px) 15px 18px;
  text-align: center;
  border: 1px solid color-mix(in srgb, var(--result-accent) 65%, var(--rule));
  border-radius: 20px;
  background: radial-gradient(ellipse at 50% 35%, color-mix(in srgb, var(--result-accent) 27%, var(--paper)), transparent 76%),
    repeating-linear-gradient(135deg, #fff4de06 0 1px, transparent 1px 13px), var(--paper);
}

.result-spotlight.caught { --result-accent: var(--mint); }
.result-spotlight h2 { font-size: clamp(1.85rem, 6vw, 2.8rem); }
.result-spotlight > p { margin: 14px 0 0; color: var(--muted); overflow-wrap: anywhere; }

.revealed-players { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.revealed-player {
  display: grid;
  justify-items: center;
  gap: 10px;
  flex: 0 1 145px;
  min-width: 0;
  margin: 0;
  padding: 14px 10px 13px;
  background: var(--input);
  border: 1px solid var(--rule);
  border-radius: 17px;
}

.revealed-player:only-child { flex-basis: 185px; }
.revealed-player .player-avatar { width: 102px; height: 102px; max-width: 100%; border-radius: 15px; box-shadow: 0 5px 0 #081910; }
.revealed-player figcaption { display: grid; justify-items: center; gap: 4px; min-width: 0; font-size: 1.12rem; overflow-wrap: anywhere; }
.revealed-player figcaption span { padding: 3px 8px; border-radius: 6px; background: var(--result-accent); color: var(--dark-ink); font-size: .82rem; font-weight: 850; }
.result-spotlight + .result-actions { margin-top: 13px; }
.result-actions > .subtitle { margin: 0; }

@media (prefers-reduced-motion: no-preference) {
  .handoff .player-avatar, .stage-identity, .equation, .discussion-clock {
    animation: stage-in 250ms ease-out both;
  }
  .ballot-grid > .suspect-card { animation: stage-in 270ms ease-out both; }
  .ballot-grid > .suspect-card:nth-child(2) { animation-delay: 30ms; }
  .ballot-grid > .suspect-card:nth-child(3) { animation-delay: 60ms; }
  .ballot-grid > .suspect-card:nth-child(n+4) { animation-delay: 90ms; }
  .suspect-card input:checked + .suspect-card-face .selection-mark, .vote-check {
    animation: card-pop 280ms ease-out both;
  }
  .time-running-low .clock-icon { animation: countdown-pulse 1s ease-out infinite; }
  .result-spotlight { animation: stage-in 320ms ease-out both; }
  .revealed-player { animation: card-pop 460ms 100ms ease-out both; }
  .revealed-player:nth-child(n+2) { animation-delay: 170ms; }
  .revealed-player:nth-child(n+3) { animation-delay: 240ms; }

  @keyframes stage-in {
    from { opacity: .5; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
  @keyframes card-pop {
    0% { opacity: .5; transform: scale(.88); }
    60% { opacity: 1; transform: scale(1.04); }
    100% { transform: scale(1); }
  }
  @keyframes countdown-pulse {
    0%, 100% { transform: scale(1); }
    28% { transform: scale(1.19); }
  }
}

@media (max-width: 650px) {
  .ballot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .suspect-card-face { min-height: 121px; padding: 10px 8px; gap: 8px; }
}

.settings-panel { margin: 0 0 18px; }
.settings-panel h3 { margin: 0 0 9px; font-size: 1.13rem; letter-spacing: -.025em; }
.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px 13px;
  min-height: 66px;
  margin-bottom: 7px;
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-radius: 11px;
  background: var(--input);
}
.setting-row p, .setting-toggle > span > span {
  display: block;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.35;
}
.setting-stepper { display: grid; grid-template-columns: 38px 48px 38px; align-items: center; text-align: center; }
.setting-stepper .button { min-height: 38px; padding: 0; font: 850 1.25rem/1 ui-monospace, monospace; }
.setting-stepper output { font: 850 .95rem ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.setting-toggle { cursor: pointer; }
.setting-toggle input {
  appearance: none;
  position: relative;
  width: 48px;
  height: 28px;
  margin: 0;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--surface);
  cursor: pointer;
}
.setting-toggle input::after {
  content: "";
  position: absolute;
  inset: 3px auto auto 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 140ms ease;
}
.setting-toggle input:checked { border-color: var(--yellow); background: var(--yellow); }
.setting-toggle input:checked::after { transform: translateX(20px); background: var(--dark-ink); }
.settings-difficulty { margin: 12px 0 0; }
.private-hint { padding-top: 7px; color: #ffcfac; }
.private-hint strong { margin-right: 5px; }
.ballot-count { margin: 0 0 8px; text-align: center; }

@media (max-width: 360px) {
  .setting-row { gap: 7px; padding: 8px; }
  .setting-stepper { grid-template-columns: 33px 42px 33px; }
  .revealed-player { flex-basis: 125px; }
}

.discussion-content {
  display: grid;
  gap: 12px;
  margin: 15px 0 18px;
}

.discussion-clues, .discussion-chat {
  min-width: 0;
  padding: 12px 13px;
  background: var(--input);
  border: 1px solid var(--rule);
  border-radius: 14px;
}

.discussion-content h3, .room-tools h3 {
  margin: 0 0 7px;
  font-size: 1.02rem;
}

.discussion-clues .answer-list {
  max-height: 220px;
  margin: 0;
  overflow-y: auto;
}

.discussion-clues .answer-list li {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 7px;
}

.discussion-clues .player-avatar, .chat-feed .player-avatar {
  width: 25px;
  height: 25px;
  border-radius: 6px;
}

.chat-feed {
  max-height: 205px;
  overflow-y: auto;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  overscroll-behavior: contain;
}

.chat-feed li {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  overflow-wrap: anywhere;
}

.chat-feed li div { min-width: 0; }
.chat-feed li p { margin: 2px 0 0; line-height: 1.35; white-space: pre-wrap; }
.chat-feed .chat-empty { color: var(--muted); }
.chat-compose { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.chat-compose .button { background: var(--yellow); color: var(--dark-ink); }

.room-options { margin-top: 14px; }
.room-tools { display: grid; gap: 14px; padding: 0 0 12px; }
.room-tools p, .host-recovery p { margin: 0 0 7px; color: var(--muted); line-height: 1.4; }
.room-tools code {
  display: block;
  padding: 8px;
  margin-bottom: 8px;
  border: 1px dashed var(--rule);
  border-radius: 8px;
  color: var(--yellow);
  overflow-wrap: anywhere;
  user-select: all;
}
.room-tools select {
  appearance: none;
  padding-right: 29px;
  background-image: linear-gradient(45deg, transparent 48%, var(--muted) 49% 69%, transparent 70%),
    linear-gradient(135deg, transparent 30%, var(--muted) 31% 51%, transparent 52%);
  background-position: calc(100% - 17px) 51%, calc(100% - 11px) 51%;
  background-repeat: no-repeat;
  background-size: 6px 6px;
}
.management-actions { display: flex; flex-wrap: wrap; gap: 7px; margin: 7px 0; }
.host-recovery { margin-top: 12px; padding: 11px; border: 1px solid var(--yellow); border-radius: 11px; }

@media (min-width: 660px) {
  .discussion-content { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
