:root {
  color-scheme: dark;
  --ink: #f7eed5;
  --muted: #bac6b4;
  --quiet: #bac6b4;
  --dim: #9aab9d;
  --gold: #ffd268;
  --gold-light: #ffdc82;
  --dark: #10231d;
  --panel: #1b3128;
  --frame: #496155;
  --danger: #ffad9d;
  --serif: Georgia, 'Times New Roman', serif;
  --ease-out: cubic-bezier(.21, .7, .25, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-inline: max(var(--safe-left), var(--safe-right));
  --gutter: clamp(16px, 4vw, 44px);
  --dock-height: 61px;
  --dock-space: calc(var(--dock-height) + var(--safe-bottom) + 38px);
  --topbar-height: 64px;
  font: 1rem/1.48 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: #101f1b;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  min-width: 280px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  background: radial-gradient(ellipse at 52% 8%, #233b30 0, #152820 45%, #101f1b 85%);
}
button, input, textarea, select { font: inherit; }
button, label[for], summary { cursor: pointer; }
button { touch-action: manipulation; }
button:disabled { cursor: default; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
[data-screen-title]:focus { outline: none; }
:is(.sr-only, .game-announcement) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: min(1190px, 100%);
  min-height: calc(var(--topbar-height) + var(--safe-top));
  margin-inline: auto;
  padding: var(--safe-top) max(var(--gutter), var(--safe-right)) 0 max(var(--gutter), var(--safe-left));
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #f5e1aa;
  font: 700 1.25rem/1 var(--serif);
  letter-spacing: -.052em;
  white-space: nowrap;
}
.cheese-mark {
  display: inline-block;
  flex: 0 0 auto;
  width: 26px;
  height: 22px;
  background:
    radial-gradient(ellipse at 55% 51%, #b57420 0 8%, transparent 9%),
    radial-gradient(ellipse at 72% 68%, #bc7723 0 8%, transparent 9%),
    radial-gradient(ellipse at 36% 70%, #a96524 0 8%, transparent 9%),
    linear-gradient(160deg, #ffe094 0 68%, #e4a749 69%);
  clip-path: polygon(55% 2%, 97% 63%, 100% 81%, 87% 97%, 15% 97%, 0 82%, 0 67%);
}
.game-shell {
  width: min(1050px, 100%);
  margin-inline: auto;
  padding: 0 max(var(--gutter), var(--safe-right)) max(34px, calc(var(--safe-bottom) + 18px)) max(var(--gutter), var(--safe-left));
}
#app { min-width: 0; }
body:has(.scene-title) .topbar { position: absolute; inset: 0 0 auto; }
body:has(.scene-title) .wordmark > :not(.pantry-seal) { display: none; }
body:has(.scene-title) .game-shell { width: 100%; padding: 0; }
body:has(.scene-title) .notice { position: absolute; z-index: 6; inset: calc(var(--topbar-height) + 8px) var(--gutter) auto; max-width: 28rem; }

.scene { display: grid; align-content: start; justify-items: stretch; gap: clamp(15px, 3vw, 25px); width: min(100%, 680px); margin-inline: auto; min-width: 0; }
.scene:is(.is-entering,[data-entering='true']) { animation: scene-arrive 300ms var(--ease-out) both; }
@keyframes scene-arrive { from { opacity: .64; } to { opacity: 1; } }
.scene-header, .panel-header { display: grid; align-content: start; gap: 5px; min-width: 0; }
.scene-header h2, .stage-title, .rules-header h2, .private-dialog-top h2 {
  color: var(--ink);
  font: 700 clamp(2.05rem, 6vw, 4rem)/.98 var(--serif);
  letter-spacing: -.065em;
}
.scene-header h2 { width: fit-content; max-width: 100%; }
.scene-main { display: grid; align-content: start; gap: 16px; min-width: 0; }
.scene-actions, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; }
.eyebrow { color: var(--gold-light); font-size: .83rem; font-weight: 750; letter-spacing: .055em; }
.muted, .stage-note, .night-note { color: var(--muted); }
.night-note, .stage-note { min-width: 0; }
.scene-main h3 { font: 700 1.25rem/1.1 var(--serif); }
.stack { display: grid; gap: 15px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 46px;
  min-width: 0;
  max-width: 100%;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  font-size: .98rem;
  font-weight: 740;
  text-align: center;
  line-height: 1.2;
  overflow-wrap: anywhere;
  transition: transform 130ms var(--ease-out), background-color 130ms ease, filter 130ms ease, border-color 130ms ease;
}
.button.primary {
  border-color: #f6cb6c;
  color: #23180b;
  background: linear-gradient(#ffe491, #f7bf55 84%);
  box-shadow: 0 3px 0 #9a642b, 0 5px 14px #080e0a86;
}
.button.secondary, .button.utility-button {
  border-color: #789184;
  color: var(--ink);
  background: #293f36;
}
.button.ghost { color: #e5cc92; }
.button.rules-toggle { min-height: 44px; padding-inline: 11px; color: #efd8a3; font-size: .87rem; border-color: #9e907260; background: #15241dc9; }
.button:not(:disabled):active { transform: translateY(2px); }
.button:disabled { border-color: #617367; background: #3d5347; color: #d7e1d2; box-shadow: none; }
.button[aria-busy='true'] { cursor: progress; }
@media (hover: hover) {
  .button.primary:hover:not(:disabled) { filter: brightness(1.1); }
  .button:is(.secondary,.utility-button,.rules-toggle):hover:not(:disabled) { background: #3b5548; border-color: #a4b9a8; }
  .button.ghost:hover:not(:disabled) { background: #f4e2a31a; color: var(--gold-light); }
}

.scene.scene-title {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: start;
  align-content: center;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  padding: calc(var(--topbar-height) + var(--safe-top) + 16px)
    max(var(--gutter), var(--safe-right), calc((100vw - 1150px) / 2))
    max(34px, calc(var(--safe-bottom) + 22px))
    max(var(--gutter), var(--safe-left), calc((100vw - 1150px) / 2));
  overflow: hidden;
}
.scene-title::before {
  position: absolute;
  z-index: -2;
  inset: 0;
  content: '';
  background:
    linear-gradient(90deg, #0c1815fd 4%, #0e1915ee 23%, #101b17c7 40%, #101b171a 68%, #111a1812 84%),
    linear-gradient(0deg, #0b1914a6, transparent 48%),
    url('/assets/title-landscape.jpg') center 49% / cover no-repeat,
    #14261d;
}
.scene-title::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: '';
  pointer-events: none;
  background: radial-gradient(ellipse at 16% 61%, #d39d2b20, transparent 36%);
}
.title-content, .scene-title-copy { width: min(100%, 600px); }
.title-logo, .title-heading {
  color: #fff1c4;
  font: 900 clamp(4.8rem, 12.2vw, 8.9rem)/.79 var(--serif);
  letter-spacing: -.094em;
  text-shadow: 0 .045em #3f3015, 0 .087em #140f0a, 0 .13em .13em #0a100dd4;
}
:is(.title-logo, .title-heading) em { display: block; color: #ffcc60; font-style: normal; }
.title-tagline {
  max-width: 26rem;
  margin-top: clamp(16px, 3.6vw, 30px);
  color: #f8e9bf;
  font-size: clamp(.99rem, 2.1vw, 1.22rem);
  font-weight: 550;
  text-shadow: 0 2px 6px #0d170f;
}
.title-actions { width: min(100%, 410px); margin-top: clamp(17px, 3.2vw, 30px); gap: 12px; }
.title-actions .button { flex: 1 1 135px; min-height: 53px; font-size: 1.05rem; }

.scene-entry, .scene-host, .scene-join, .scene-reconnect {
  width: min(100%, 460px);
  padding-block: clamp(10px, 3.5vh, 30px) 4px;
}
.scene-entry { gap: 15px; }
.scene-entry .scene-header { margin-bottom: 1px; }
.button.entry-back {
  justify-self: start;
  min-height: 44px;
  padding-inline: 12px 14px;
  gap: 9px;
  color: #f6e3b4;
  border-color: #817354;
  background: #233a2f;
  box-shadow: 0 2px 0 #0b1813;
}
.back-arrow { flex: 0 0 auto; font-size: 1.25rem; line-height: 1; }
.entry-form { display: grid; align-content: start; gap: 14px; }
.entry-actions > .button { width: 100%; min-height: 49px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field-label, .field label, .mode-options legend { color: var(--ink); font-size: .96rem; font-weight: 710; }
.input, select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 10px 13px;
  border: 1px solid #718477;
  border-radius: 8px;
  color: var(--ink);
  background: #101f19;
  font-size: 1rem;
}
.entry-form .input { min-height: 48px; }
.input::placeholder, textarea::placeholder { color: #9bab9d; }
#join-code { font: 700 1.2rem/1.2 Consolas, ui-monospace, monospace; letter-spacing: .13em; }
.mode-options { display: grid; gap: 7px; min-width: 0; padding: 0; margin: 0; border: 0; }
.mode-options legend { margin-bottom: 5px; padding: 0; }
.mode-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2px 11px;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid #526b5c;
  border-radius: 10px;
  color: var(--ink);
  background: #182b24;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.mode-choice:has(input:checked) {
  border-color: #e3b952;
  background: #3a4028;
  box-shadow: inset 3px 0 #f8d578;
}
.mode-choice:has(input:focus-visible) { outline: 2px solid var(--gold-light); outline-offset: 2px; }
.mode-choice input { grid-row: span 2; width: 16px; height: 16px; margin: 0; accent-color: var(--gold); }
.mode-title, .mode-choice strong { color: var(--ink); font-weight: 750; }
.mode-description, .mode-choice .muted { color: var(--muted); font-size: .87rem; line-height: 1.27; }
.mode-copy { display: grid; gap: 2px; min-width: 0; }
.entry-form .avatar-trigger {
  justify-content: start;
  gap: 10px;
  width: 100%;
  min-height: 51px;
  padding: 5px 11px;
  background: #223a2f;
  border-color: #6f8a76;
  text-align: start;
}
.avatar-trigger .player-avatar { flex: 0 0 auto; width: 36px; height: 36px; }
.avatar-trigger-copy { display: grid; gap: 1px; min-width: 0; }
.avatar-trigger-copy > span { color: var(--muted); font-size: .78rem; }
.avatar-trigger > :last-child { min-width: 0; }
.avatar-trigger .avatar-trigger-arrow { margin-inline-start: auto; flex: 0 0 14px; color: var(--gold-light); font-size: 1.55rem; line-height: .8; }

.scene-lobby {
  gap: clamp(13px, 2.25vw, 20px);
  width: min(100%, 660px);
  padding-block: clamp(8px, 2.4vh, 25px) 4px;
}
.scene-lobby .scene-header { gap: 4px; }
.scene-lobby .scene-header > .muted { line-height: 1.35; }
.scene-lobby .scene-header h2 { font-size: clamp(2.35rem, 7vw, 3.65rem); }
.room-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 9px 13px;
  padding: 12px 0;
  border-block: 1px solid var(--frame);
}
.scene-lobby .lobby-invite {
  position: relative;
  padding: 12px clamp(12px, 3vw, 19px) 14px;
  border: 1px solid #9f8147;
  border-radius: 13px;
  background:
    radial-gradient(ellipse at 0% 0%, #dabb6c2b, transparent 66%),
    linear-gradient(146deg, #413923, #2c3021 75%);
  box-shadow: inset 0 0 0 2px #2a281d, 0 3px 0 #101a13, 0 10px 20px #07110d52;
}
.room-code-group { display: grid; gap: 3px; min-width: 0; }
.room-code-group .eyebrow { color: #e6d3a5; font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; }
.room-code {
  color: #ffdc83;
  font: 800 clamp(1.83rem, 7.5vw, 2.76rem)/1 Consolas, ui-monospace, monospace;
  letter-spacing: .133em;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 2px #211b10;
  user-select: all;
}
.mode-tag { color: var(--muted); font-size: .87rem; font-weight: 700; }
.scene-lobby .room-strip .mode-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 27px;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid #84714a;
  border-radius: 999px;
  color: #f2dfa9;
  background: #27271c;
  font-size: .76rem;
  text-align: center;
  line-height: 1.1;
}
.invite-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-inline-start: auto;
}
.invite-actions > .button { min-height: 44px; padding-inline: 11px; font-size: .89rem; }
.invite-actions > .button.secondary { border-color: #a9a087; background: #283a30; }
.invite-actions > .button.primary { color: #23180b; }
.invite-manual, .room-strip > .invite-input { flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; }
.invite-manual { display: grid; gap: 4px; }
.invite-input { font: .9rem/1.35 Consolas, ui-monospace, monospace; }

.roster-panel { display: grid; gap: 8px; min-width: 0; }
.roster-panel .stage-title { font-size: 1.52rem; letter-spacing: -.045em; }
.roster-panel .eyebrow { color: var(--muted); }
.roster-header { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; }
.seat-count { color: #e8d9a7; font-size: .84rem; font-weight: 690; white-space: nowrap; }
.roster-list, .result-list { display: grid; gap: 0; padding: 0; margin: 0; list-style: none; min-width: 0; }
.roster-player, .result-row {
  display: grid;
  align-items: center;
  min-width: 0;
  min-height: 49px;
  gap: 9px;
  border-block-end: 1px solid var(--frame);
}
.roster-player { grid-template-columns: auto minmax(0, 1fr) auto; padding: 5px 3px; }
.roster-player.is-you .player-avatar { border-color: #e5b75e; }
.player-avatar {
  position: relative;
  display: block;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border: 1px solid #819687;
  border-radius: 50%;
  background: #2f473a;
}
.player-avatar > .player-avatar-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 34%;
}
.player-name { min-width: 0; overflow-wrap: anywhere; font-weight: 680; }
.player-tag { color: var(--muted); font-size: .84rem; white-space: nowrap; }
.roster-player > .button { min-height: 43px; padding-inline: 8px; }
.roster-panel.lobby-table {
  gap: 8px;
  padding: 12px clamp(7px, 2.7vw, 18px) 11px;
  border: 5px solid #785335;
  border-radius: 21px;
  background:
    radial-gradient(ellipse at 50% 4%, #3b5949a8, transparent 69%),
    repeating-linear-gradient(38deg, #e5ffe609 0 1px, #1b2e2000 1px 4px),
    repeating-linear-gradient(142deg, #00000014 0 1px, transparent 1px 4px),
    #203b2e;
  box-shadow: inset 0 0 0 1px #ac8b53, inset 0 0 32px #0d211996, 0 0 0 1px #3a2920, 0 4px 0 #3c2b20, 0 11px 20px #08151073;
}
.lobby-table .roster-header { padding-inline: clamp(2px, 1.5vw, 8px); }
.lobby-table .seat-count {
  padding: 3px 7px;
  border: 1px solid #87916c;
  border-radius: 999px;
  background: #12291f;
  line-height: 1.15;
}
.lobby-table .roster-list {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
  gap: 8px 4px;
}
.lobby-table .lobby-seat {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-content: start;
  gap: 2px;
  min-width: 0;
  min-height: 82px;
  padding: 4px 1px;
  border: 0;
  text-align: center;
  line-height: 1.18;
}
.lobby-seat .player-avatar {
  width: clamp(37px, 11.7vw, 62px);
  height: clamp(37px, 11.7vw, 62px);
  margin-bottom: 2px;
  border: 2px solid #b1ad89;
  box-shadow: 0 2px 6px #080f0cad;
}
.lobby-seat.is-you .player-avatar { border-color: #ffda7d; box-shadow: 0 0 0 2px #483e24, 0 2px 6px #080f0cad; }
.lobby-seat .seat-open {
  border: 1px dashed #aab9918a;
  color: #bbc59d;
  background: radial-gradient(circle, #0b1e166b 23%, #1b33286e 24% 52%, #30483b44 53%);
  box-shadow: none;
}
.seat-open > :is(img, svg) { width: 54%; height: 54%; }
.lobby-seat .seat-copy { display: grid; justify-items: center; gap: 2px; min-width: 0; max-width: 100%; }
.lobby-seat .player-name {
  max-width: 100%;
  font-size: clamp(.76rem, 3.6vw, .96rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lobby-seat .player-tag, .lobby-seat.is-empty { color: #c5d0b7; font-size: .71rem; }
.lobby-seat.is-empty .seat-copy { font-size: .73rem; }
.lobby-seat.is-you .player-tag { color: #ffe197; }
.lobby-seat > :is(.seat-remove, .seat-edit) {
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: max(0px, calc(50% - clamp(31px, 8vw, 45px)));
  display: grid;
  justify-items: end;
  align-items: start;
  width: 44px;
  min-height: 44px;
  padding: 1px;
  border-color: transparent;
  color: #ffe4bd;
  background: transparent;
  font: 750 .89rem/1 system-ui, sans-serif;
}
.lobby-seat > :is(.seat-remove, .seat-edit) > span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid #bc9f73;
  border-radius: 50%;
  background: #2a382d;
  box-shadow: 0 1px 4px #0a140e8c;
}
.lobby-seat > .seat-remove > span { border-color: #bd8e7d; color: #ffded4; background: #493228; }
.lobby-seat > :is(.seat-remove, .seat-edit):hover:not(:disabled) { background: transparent; border-color: transparent; }
.lobby-seat > :is(.seat-remove, .seat-edit):hover:not(:disabled) > span { filter: brightness(1.22); }
.lobby-actions { display: grid; gap: 8px; }
.lobby-readiness { color: var(--muted); font-size: .9rem; line-height: 1.35; }
.lobby-buttons {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}
.lobby-buttons > .button { width: 100%; min-height: 49px; border-radius: 10px; padding-inline: 8px; }
.lobby-buttons > .button:only-child { grid-column: 1 / -1; }
.button.lobby-start:disabled {
  border-color: #9e905d;
  color: #e4d8a8;
  background: #3e4230;
  box-shadow: 0 2px 0 #141d14;
}
.button.lobby-close {
  color: #ffd3c9;
  border-color: #c68c7d;
  background: #3d2b26;
  box-shadow: 0 2px 0 #221914;
}
.button.lobby-close:disabled { color: #d7bfb7; border-color: #8f746b; background: #352822; }
@media (hover: hover) {
  .button.entry-back:hover:not(:disabled) { background: #345043; border-color: #b3a17a; }
  .mode-choice:hover:not(:has(input:checked)) { border-color: #9ba88b; background: #253d31; }
  .button.lobby-close:hover:not(:disabled) { color: #ffebe6; border-color: #e3ac9e; background: #543a31; }
}

.round-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 3px 0 1px;
  margin: 0;
  list-style: none;
}
.round-step {
  position: relative;
  min-width: 0;
  padding: 7px 0 0;
  border-block-start: 2px solid #53695a;
  color: var(--muted);
  font-size: .81rem;
  font-weight: 650;
  line-height: 1.12;
  text-align: center;
  overflow-wrap: anywhere;
}
.round-step[data-state='done'] { border-color: #8ba390; color: #d5dec8; }
.round-step:is([data-state='current'],[aria-current='step']) { border-color: var(--gold); color: var(--gold-light); font-weight: 800; }
.scene-utility { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 9px; min-width: 0; }
.scene-utility .button { min-height: 44px; padding-inline: 12px; font-size: .93rem; }
.stage-progress { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.phase-time {
  display: inline-grid;
  place-items: center;
  padding: 2px 8px;
  border: 1px solid #ad8a47;
  border-radius: 7px;
  color: var(--gold-light);
  background: #3a2f1b;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.phase-time[data-urgency='soon'] { border-color: #db9a7a; color: #ffe1cd; background: #56312a; }

.scene-roll { width: min(100%, 520px); }
.scene-roll .scene-main { gap: 14px; }
.secret-card {
  --role-edge: #a6b79c;
  --role-fill: #e0e8d4;
  --role-ink: #233529;
  --role-accent: #2a563d;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(118px, .75fr) minmax(0, 1.25fr);
  width: 100%;
  min-width: 0;
  min-height: 190px;
  border: 1px solid var(--role-edge);
  border-radius: 13px;
  background: linear-gradient(145deg, var(--role-fill), #fff2d8);
  color: var(--role-ink);
  box-shadow: 0 3px 0 #070c0887, 0 14px 24px #080e0a6b;
  overflow: hidden;
}
.secret-card[data-role='thief'] { --role-edge: #c18c80; --role-fill: #eecdbf; --role-ink: #4a2426; --role-accent: #7a3440; }
.secret-card[data-role='accomplice'] { --role-edge: #9dbbb5; --role-fill: #d5e7db; --role-ink: #193b3b; --role-accent: #2d6362; }
.secret-card .eyebrow, .secret-watch, .secret-ally { color: var(--role-accent); }
.secret-card .muted { color: var(--role-ink); }
.role-art { display: block; grid-row: 1; grid-column: 1; contain: size; width: 100%; height: 100%; min-height: 0; object-fit: cover; object-position: 50% 37%; background: #33281b; }
.role-copy { display: grid; grid-row: 1; grid-column: 2; align-content: center; justify-items: start; gap: 7px; min-width: 0; padding: 13px 17px; }
.role-copy .secret-role { color: var(--role-accent); font: 800 clamp(1.62rem, 6vw, 2.6rem)/.97 var(--serif); letter-spacing: -.059em; overflow-wrap: anywhere; }
.secret-die { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; min-height: 39px; margin-top: 3px; }
.secret-watch, .secret-ally { font-weight: 720; overflow-wrap: anywhere; }
.secret-card .button.private-toggle { padding: 6px 8px; color: var(--role-ink); border-color: #81775d; background: #f9eedb; box-shadow: none; font-size: .88rem; }
.secret-card.is-concealed {
  display: block;
  min-height: 105px;
  background: repeating-linear-gradient(115deg, #ffd2680c 0 2px, transparent 2px 13px), #263d31;
  border-color: #756046;
}
.secret-card.is-concealed .role-copy { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; min-height: inherit; padding: 15px 20px; }
.secret-card.is-concealed .eyebrow { color: #ffe3a4; }
.secret-card.is-revealing { animation: deal-card 520ms var(--ease-out) var(--reveal-delay, 0ms) both; transform-origin: 51% 73%; }
.secret-card.is-revealing .role-art { animation: illuminate-card 680ms ease-out var(--reveal-delay, 0ms) both; }
@keyframes deal-card { from { opacity: .24; transform: perspective(680px) rotateY(-23deg) translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes illuminate-card { from { filter: brightness(.58) saturate(.7); } to { filter: none; } }

.die { display: inline-grid; flex: 0 0 auto; grid-template: repeat(3,1fr) / repeat(3,1fr); place-items: center; width: 42px; height: 42px; padding: 6px; border: 1px solid #a77e48; border-radius: 9px; background: linear-gradient(142deg,#fffbe6,#e5bd83); box-shadow: 0 3px 0 #9e6336; }
.die .pip { visibility: hidden; width: 5px; height: 5px; border-radius: 50%; background: #39261b; }
.die[data-face='1'] .pip:nth-child(5),
.die[data-face='2'] .pip:is(:nth-child(3), :nth-child(7)),
.die[data-face='3'] .pip:is(:nth-child(3), :nth-child(5), :nth-child(7)),
.die[data-face='4'] .pip:is(:nth-child(1), :nth-child(3), :nth-child(7), :nth-child(9)),
.die[data-face='5'] .pip:is(:nth-child(1), :nth-child(3), :nth-child(5), :nth-child(7), :nth-child(9)),
.die[data-face='6'] .pip:is(:nth-child(1), :nth-child(3), :nth-child(4), :nth-child(6), :nth-child(7), :nth-child(9)) { visibility: visible; }

.scene-night { width: min(100%, 920px); grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
.scene-night .scene-header h2 { font-size: clamp(2rem, 5.9vw, 3.65rem); }
.scene-night[data-wake='true'] .stage-title { color: var(--gold-light); }
.scene-night .night-note { font-size: .94rem; }
.scene-night .scene-main { display: contents; }
.scene-night > :is(.round-steps, .host-advance-dock),
.scene-night .scene-main > :not(.scene-utility) { grid-column: 1 / -1; }
.scene-night .scene-utility { grid-column: 2; align-self: start; justify-content: end; }
.clue-list, .witness-list { display: grid; gap: 0; padding: 0; margin: 0; list-style: none; }
.clue-item {
  position: relative;
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 13px 0 14px 22px;
  border-block-end: 1px solid var(--frame);
  overflow-wrap: anywhere;
}
.clue-item::before { position: absolute; top: 20px; left: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); content: ''; }
.clue-item > strong { font: 700 clamp(1.23rem, 4.3vw, 1.58rem)/1.02 var(--serif); }
.witness-list { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); }
.witness-name { max-width: 100%; overflow-wrap: anywhere; }

.discussion-tabs { display: flex; gap: 20px; border-block-end: 1px solid var(--frame); }
.button.discussion-tab { justify-content: flex-start; min-width: 68px; padding-inline: 4px; border-radius: 0; border: 0; border-block-end: 3px solid transparent; color: var(--muted); background: none; }
.button.discussion-tab:is([aria-pressed='true'],[aria-selected='true']) { border-block-end-color: var(--gold); color: var(--gold-light); }
.chat-panel { display: grid; gap: 10px; min-width: 0; }
.chat-panel > h3 { font-size: 1.28rem; }
.chat-log {
  display: grid;
  gap: 8px;
  min-height: 80px;
  max-height: 290px;
  max-height: clamp(110px, 35dvh, 290px);
  margin: 0;
  padding: 4px 1px 8px;
  overflow: auto;
  overscroll-behavior: contain;
  list-style: none;
}
.chat-line { justify-self: start; max-width: min(93%, 530px); min-width: 0; padding: 7px 10px; border-radius: 11px 11px 11px 2px; color: var(--ink); background: #344c40; overflow-wrap: anywhere; }
.chat-line.is-you { justify-self: end; border-radius: 11px 11px 2px 11px; color: #fff0cf; background: #565030; }
.chat-author { display: block; color: #f9d477; font-size: .84rem; font-weight: 770; }
.chat-empty { padding-block: 10px; }
.chat-form { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 8px; padding-block-start: 8px; border-block-start: 1px solid var(--frame); }
.chat-form > .button { min-height: 50px; }
.voice-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 7px 11px; padding-block: 7px; border-block-end: 1px solid var(--frame); }
.voice-bar[data-status='on'] { border-color: #92ad75; }
.voice-status { flex: 1 1 147px; min-width: 0; color: var(--muted); font-size: .89rem; }
.voice-bar .button { min-height: 44px; padding-inline: 12px; font-size: .91rem; }

.result-details summary { min-height: 44px; padding: 9px 0; color: var(--gold-light); font-weight: 730; }
.result-details > :not(summary) { margin-top: 8px; }

.scene-reveal { width: min(100%, 730px); }
.result-banner {
  --outcome: #ace0ae;
  --outcome-dark: #284e37;
  display: grid;
  grid-template-columns: minmax(122px, .82fr) minmax(0, 1.18fr);
  align-items: stretch;
  min-height: 218px;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid #809475;
  border-radius: 15px;
  background: radial-gradient(ellipse at 98% 15%, var(--outcome-dark), #182d25 70%);
  box-shadow: 0 13px 28px #07160eb0;
}
.result-banner[data-winner='thief'] { --outcome: #ffd49b; --outcome-dark: #68423b; border-color: #a97760; }
.result-banner .scene-header, .result-banner .panel-header, .result-banner .result-copy {
  align-self: center;
  gap: 8px;
  padding: 15px 16px;
}
.result-banner .result-copy .scene-header, .result-banner .result-copy .panel-header { padding: 0; }
.result-banner h2 { color: var(--outcome); font-size: clamp(1.95rem, 6.5vw, 3.7rem); }
.result-banner .muted { overflow-wrap: anywhere; }
.result-hero, .result-hero img { display: block; width: 100%; height: 100%; max-height: 295px; object-fit: cover; object-position: center 39%; margin: 0; }
.result-banner > img.result-hero { contain: size; }
.result-hero img { height: 100%; }
.result-details { border-block-start: 1px solid var(--frame); }
.result-row { grid-template-columns: auto minmax(0,1fr) auto; padding: 5px 2px; }
.result-avatar { display: block; width: 44px; height: 44px; object-fit: cover; object-position: 50% 36%; border: 1px solid #b9a06a; border-radius: 8px; }
.player-result { display: grid; gap: 2px; min-width: 0; }
.player-result .muted { font-size: .87rem; }
.result-votes { color: #ffdd93; font-weight: 690; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scene-reveal:is(.is-entering,[data-entering='true']) .result-banner { animation: verdict-turn 550ms var(--ease-out) both; }
@keyframes verdict-turn { from { opacity: .35; transform: rotate(-1deg) scale(.98); } to { opacity: 1; transform: none; } }

.phase-dock, .host-advance-dock {
  position: fixed;
  z-index: 4;
  inset: auto 0 0;
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 13px max(var(--gutter), var(--safe-right)) calc(10px + var(--safe-bottom)) max(var(--gutter), var(--safe-left));
  background: linear-gradient(transparent, #10231df5 34%, #10231d);
  pointer-events: none;
}
:is(.phase-dock,.host-advance-dock) > * { max-width: 520px; pointer-events: auto; }
:is(.phase-dock,.host-advance-dock) > .button { width: min(100%, 520px); min-height: var(--dock-height); }
.phase-dock > :is(.actions,.scene-actions) { display: flex; width: min(100%, 520px); }
.phase-dock > :is(.actions,.scene-actions) > .button { flex: 1 1 136px; min-height: var(--dock-height); }
.host-advance-dock .host-advance { font-size: 1.15rem; }
.host-next-hint { width: min(100%, 520px); padding: 4px 6px; color: #e9d7ad; background: #10231d; text-align: center; font-size: .85rem; }
body:has(.phase-dock, .scene-night .host-advance-dock):not(:has(.recruitment)) .game-shell { padding-bottom: var(--dock-space); }
:root:has(.phase-dock, .scene-night .host-advance-dock):not(:has(.recruitment)) { scroll-padding-block-end: var(--dock-space); }
:is(.scene-roll, .scene-night:has(.recruitment)) .host-advance-dock { position: static; padding: 8px 0 0; background: transparent; }
.scene-roll .host-next-hint { padding-inline: 0; background: transparent; text-align: start; }

.notice, .connection-band {
  width: min(100%, 680px);
  margin: 0 auto 12px;
  padding: 8px 11px;
  border-inline-start: 3px solid #e2b25b;
  color: #ffebc9;
  background: #483821;
  overflow-wrap: anywhere;
}
.notice:empty { display: none; }
.notice[data-kind='error'], .connection-band[data-status='offline'] { border-color: #ef9d8a; color: #ffe0d9; background: #52302c; }
.connection-band { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 7px 12px; }
.connection-copy { flex: 1 1 156px; }
.connection-band .button { min-height: 44px; }

.rules-dialog, .private-dialog, .avatar-dialog {
  width: min(560px, calc(100% - 2 * max(14px, var(--safe-inline, 0px))));
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #8e9b81;
  border-radius: 15px;
  color: var(--ink);
  background: #1c3229;
  box-shadow: 0 24px 65px #070e09d1;
}
.rules-dialog::backdrop, .private-dialog::backdrop, .avatar-dialog::backdrop { background: #070f0cbb; }
.rules-header, .private-dialog-top {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 11px;
  padding: 11px 15px;
  border-block-end: 1px solid var(--frame);
  background: #202f27;
}
.rules-header h2, .private-dialog-top h2 { font-size: clamp(1.51rem, 5.6vw, 2.26rem); }
.rules-steps { display: grid; gap: 13px; margin: 0; padding: 14px 16px 21px 38px; color: #d8dfcb; }
.rules-steps strong { color: var(--gold-light); }
.private-dialog-inner { display: grid; gap: 13px; }
.private-dialog-inner > :not(.private-dialog-top) { margin-inline: 13px; }
.private-dialog-inner > :last-child { margin-bottom: 15px; }
.private-dialog .secret-card { width: auto; }
body:has(:is(.rules-dialog,.private-dialog,.avatar-dialog)[open]) { overflow: hidden; }

.avatar-dialog {
  width: min(530px, calc(100% - 2 * max(12px, var(--safe-inline, 0px))));
  border-color: #9b8555;
  background: radial-gradient(ellipse at 20% 0%, #374639, #1b3027 65%);
}
.avatar-dialog[open] { animation: avatar-arrive 190ms var(--ease-out) both; }
@keyframes avatar-arrive {
  from { opacity: .55; transform: translateY(9px) scale(.982); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.avatar-dialog-inner { display: grid; gap: 13px; padding: clamp(12px, 3.8vw, 21px); }
.avatar-dialog-header { display: grid; gap: 5px; }
.avatar-dialog-header h2 {
  color: var(--ink);
  font: 700 clamp(1.6rem, 5.9vw, 2.27rem)/1.04 var(--serif);
  letter-spacing: -.045em;
}
.avatar-dialog-header p { color: var(--muted); font-size: .88rem; line-height: 1.35; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.avatar-option {
  position: relative;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 64px;
  padding: 3px 3px 5px;
  border: 1px solid #67806c;
  border-radius: 9px;
  color: #f2e6c5;
  background: #1a2d24;
  font-size: clamp(.66rem, 2.45vw, .8rem);
  font-weight: 710;
  line-height: 1.12;
  text-align: center;
  overflow-wrap: anywhere;
  transition: border-color 130ms ease, background-color 130ms ease, transform 130ms var(--ease-out);
}
.avatar-option:active { transform: scale(.966); }
.avatar-option[aria-pressed='true'] {
  border-color: #f8ce70;
  color: #ffe6a5;
  background: #4a4428;
  box-shadow: 0 0 0 1px #f8ce70;
}
.avatar-option[aria-pressed='true']::after {
  position: absolute;
  inset: 5px 5px auto auto;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  color: #251b0c;
  background: #ffdb7d;
  content: '✓';
  font-size: .69rem;
}
.avatar-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  background: #243c32;
  object-fit: cover;
  object-position: center 34%;
}
.avatar-dialog-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 8px; }
.avatar-dialog-actions > .button { min-height: 45px; padding-inline: 8px; }
@media (hover: hover) {
  .avatar-option:hover:not([aria-pressed='true']) { border-color: #bbc5a5; background: #304738; }
}

@media (min-width: 740px) {
  .result-list { grid-template-columns: repeat(2, minmax(0,1fr)); column-gap: 17px; }
}
@media (max-width: 690px) {
  :root { --topbar-height: 56px; --dock-height: 54px; }
  .scene.scene-title {
    align-content: stretch;
    justify-items: center;
    text-align: center;
    padding-block: calc(var(--topbar-height) + var(--safe-top) + 14px)
      max(28px, calc(var(--safe-bottom) + 18px), 4vh);
  }
  .scene-title::before {
    background:
      linear-gradient(180deg, #0c1a147d, #0c1a1445 24%, transparent 43%, transparent 71%, #0c1915bf 91%, #0c1915),
      url('/assets/title-portrait.jpg') center 39% / cover no-repeat,
      #17281e;
  }
  .title-content, .scene-title-copy {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    justify-items: center;
    width: min(100%, 430px);
  }
  .title-logo, .title-heading { max-width: 100%; font-size: clamp(2.65rem, 13vw, 5.6rem); line-height: .93; letter-spacing: -.087em; }
  :is(.title-logo, .title-heading) em { display: inline; }
  .title-tagline { margin-top: 11px; }
  .title-actions { align-self: end; gap: 8px; margin-top: 12px; justify-content: center; }
  .title-actions .button { flex: 1 1 120px; }
  :is(.scene-vote, .scene-discussion[data-mode='table']) {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8px;
  }
  :is(.scene-vote, .scene-discussion[data-mode='table']) .scene-main { display: contents; }
  :is(.scene-vote, .scene-discussion[data-mode='table']) > .round-steps,
  :is(.scene-vote, .scene-discussion[data-mode='table']) .scene-main > :not(.scene-utility) {
    grid-column: 1 / -1;
  }
  :is(.scene-vote, .scene-discussion[data-mode='table']) .scene-utility {
    grid-column: 2;
    align-self: start;
    justify-content: end;
  }
}
@media (max-width: 470px) {
  .scene { gap: 14px; }
  :is(.scene-night, .scene-vote, .scene-discussion[data-mode='table']) { column-gap: 8px; row-gap: 12px; }
  .scene-title .title-actions { width: 100%; }
  .scene-entry .entry-form { gap: 12px; }
  .scene-lobby .scene-main { gap: 13px; }
  .scene-lobby .lobby-invite { padding-block: 9px 10px; }
  .scene-lobby .lobby-invite:not(:has(.invite-actions > :nth-child(2))) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
  }
  .lobby-invite:not(:has(.invite-actions > :nth-child(2))) .room-code-group { grid-row: span 2; }
  .lobby-invite:not(:has(.invite-actions > :nth-child(2))) .mode-tag { justify-self: end; }
  .lobby-invite .invite-manual { grid-column: 1 / -1; }
  .invite-actions { flex: 1 1 100%; }
  .invite-actions > .button { flex: 1 1 0; }
  .roster-panel.lobby-table { padding-block: 9px 8px; }
  .scene-utility .button { padding-inline: 10px; }
  .secret-card { min-height: 171px; grid-template-columns: minmax(92px, .82fr) minmax(0, 1.18fr); }
  .role-copy { padding: 10px 11px; gap: 5px; }
  .role-copy .muted { line-height: 1.36; }
  .secret-die { flex-wrap: nowrap; gap: 7px; }
  .witness-list:has(> :nth-child(4)) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
    line-height: 1.25;
  }
  .scene-roll .roll-actions > .button,
  .scene-discussion[data-mode='table'] .phase-actions > .button,
  .scene-reveal .scene-actions > .button { width: 100%; }
  .result-banner { grid-template-columns: minmax(94px,.75fr) minmax(0,1.25fr); min-height: 165px; }
  .result-banner .scene-header, .result-banner .panel-header, .result-banner .result-copy { padding: 10px; }
  .result-banner .result-copy .scene-header, .result-banner .result-copy .panel-header { padding: 0; }
  .result-banner h2 { font-size: clamp(1.58rem, 7.2vw, 2.35rem); }
  .private-dialog { margin: auto auto max(10px, var(--safe-bottom)); max-height: min(88dvh, calc(100dvh - var(--safe-top) - var(--safe-bottom) - 16px)); }
}
@media (max-width: 350px) {
  .scene-entry, .scene-lobby { padding-block-start: 8px; }
  .scene-entry { gap: 11px; }
  .scene-entry .entry-form { gap: 10px; }
  .scene-lobby .scene-header h2 { font-size: 2.18rem; }
  .lobby-seat .player-name { font-size: .75rem; }
  .lobby-seat .player-tag, .lobby-seat.is-empty .seat-copy { font-size: .67rem; }
  .roster-panel.lobby-table { border-width: 4px; }
  .lobby-table .lobby-seat { min-height: 72px; }
  .avatar-dialog-inner { gap: 11px; }
  .avatar-grid { gap: 5px; }
  .title-logo, .title-heading { font-size: clamp(2.38rem, 12.9vw, 2.8rem); }
  .title-actions .button { padding-inline: 10px; min-height: 49px; }
  .round-steps { column-gap: 4px; }
  .round-step { font-size: .78rem; }
}
@media (max-height: 465px) and (orientation: landscape) {
  :root { --dock-height: 49px; --topbar-height: 49px; }
  .scene.scene-title {
    align-content: center;
    justify-items: start;
    padding-block: calc(var(--topbar-height) + var(--safe-top) + 10px) max(16px, calc(var(--safe-bottom) + 10px));
    text-align: left;
  }
  .scene-title::before {
    background:
      linear-gradient(90deg, #111b16f5 5%, #111b16c7 33%, #111b1624 65%, transparent 84%),
      url('/assets/title-landscape.jpg') center / cover no-repeat,
      #14261d;
  }
  .title-content, .scene-title-copy { display: block; width: min(59%, 440px); }
  .title-logo, .title-heading { font-size: clamp(3rem, 10vw, 5.7rem); }
  :is(.title-logo, .title-heading) em { display: block; }
  .title-actions { justify-content: start; }
  .title-actions .button { flex-basis: 105px; min-height: 48px; }
  .scene-entry { padding-block-start: 8px; }
  .result-banner { min-height: 145px; }
  .result-banner h2 { font-size: clamp(1.8rem, 6vw, 2.85rem); }
  .avatar-dialog-actions { position: sticky; bottom: 0; padding-block: 6px; background: #21362c; }
}
@media (min-width: 580px) and (max-height: 465px) and (orientation: landscape) {
  .scene-night:has(.pantry-board) {
    grid-template-columns: minmax(0, .34fr) minmax(0, .66fr);
    grid-template-areas:
      "steps steps"
      "heading board"
      "progress board"
      "utility board"
      "recruit recruit"
      "host host";
    gap: 8px 14px;
  }
  .scene-night:has(.pantry-board) > .round-steps { grid-area: steps; }
  .scene-night:has(.pantry-board) > .scene-header { grid-area: heading; }
  .scene-night:has(.pantry-board) .scene-header h2 { font-size: clamp(1.8rem, 4.2vw, 2.75rem); }
  .scene-night:has(.pantry-board) .scene-main > .stage-progress { grid-area: progress; }
  .scene-night:has(.pantry-board) .scene-utility { grid-area: utility; justify-content: start; }
  .scene-night .scene-main > .pantry-board { grid-area: board; align-self: start; }
  .scene-night:has(.pantry-board) .scene-main > .recruitment { grid-area: recruit; }
  .scene-night:has(.pantry-board) > .host-advance-dock { grid-area: host; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
