:root {
  --dark: #171311;
  --panel: #2c2320;
  --ink: #fff1da;
  --muted: #cfbaa8;
  --quiet: #bfa895;
  --dim: #ad9684;
  --gold: #edbd75;
  --gold-light: #f7d194;
  --frame: #634b3e;
  --studio-surface: var(--panel);
  --studio-edge: #927662;
  --studio-accent: var(--gold);
  --studio-muted: var(--muted);
  --studio-ink: var(--ink);
  --espresso-raised: #382c25;
  --espresso-inset: #201916;
  --espresso-hover: #49372e;
  background: var(--dark);
}

body, body[data-scene] {
  background: radial-gradient(ellipse at 50% 0%, #3b2b23, #231915 48%, var(--dark) 83%);
}

body[data-scene='night']:has(.pantry-board) {
  background:
    linear-gradient(180deg, #241913d9, #2418145c 29%, #2317137d 55%, var(--dark) 92%),
    url('/assets/night-pantry.webp') center top / max(100%, 78rem) auto no-repeat var(--dark);
}

body[data-scene='night']:has(.scene-night[data-night-stage='dawn']) {
  background: radial-gradient(ellipse at 70% 9%, #49382e, #2c201a 49%, var(--dark) 84%);
}

.scene-title::before {
  background:
    linear-gradient(90deg, #170f0dfb 4%, #211713ed 24%, #251912ae 42%, #2b170020 67%, #25171106 85%),
    linear-gradient(0deg, #160f0c9b, transparent 48%),
    url('/assets/title-landscape.jpg') center 49% / cover no-repeat var(--dark);
}

.wordmark { color: var(--ink); }
.pantry-seal { background: radial-gradient(circle at 30% 20%, #594032, var(--espresso-inset) 76%); }
.settings-gear::after { background: var(--espresso-inset); }

.button.primary {
  border-color: #f0c483;
  background: linear-gradient(#f3cd94, #e3ae64);
  color: #261811;
  box-shadow: 0 2px 0 #9f673e, 0 7px 18px #150e0a65;
}

.button:is(.secondary, .utility-button, .rules-toggle),
.invite-actions > .button.secondary,
.scene-night[data-night-stage='dawn'] .button[data-focus='show-clues'] {
  border-color: var(--studio-edge);
  background: var(--espresso-raised);
  color: var(--ink);
}

.button:disabled, .button[aria-disabled='true'], .scene-lobby .lobby-start:disabled {
  border-color: #745d50;
  background: #3b302a;
  color: #d3beac;
  box-shadow: none;
}

input.input, select, textarea {
  border-color: var(--studio-edge);
  background-color: var(--espresso-inset);
  color: var(--ink);
}
.input::placeholder, textarea::placeholder { color: #ad9684; }

.game-toolbar { background: #241c19; }
.game-tool { border-color: transparent; }
.seat-open, .lobby-seat .seat-open {
  border-color: #ad8b7259;
  background: #211915;
  color: var(--quiet);
}
.lobby-seat > .seat-edit > span, .player-avatar, .avatar-thumb { background: var(--espresso-raised); }
.lobby-seat > .button.seat-edit { border-color: transparent; background: transparent; box-shadow: none; }
.lobby-table .seat-count { background: var(--espresso-inset); border-color: var(--studio-edge); }

.chat-panel { border-color: var(--frame); background: var(--espresso-inset); }
.chat-line { background: var(--espresso-raised); }
.chat-line.is-you { background: #57402d; }
.vote-seat .vote-option:has(input:checked) { background: #edc58b; }
.vote-seat .vote-mark { background: #32241e; }
.vote-seat .vote-option:has(input:checked) .vote-mark { background: #87502f; }
.choice-receipt { background: linear-gradient(105deg, #513d2b, #362923); }
.scene-night .recruitment .button.recruit-choice { background: #51372d; }

:is(.phase-dock, .host-advance-dock) {
  background: linear-gradient(transparent, #171311f5 34%, var(--dark));
}
.host-next-hint { background: var(--dark); }
.scene-roll .host-next-hint { background: transparent; }

.scene-night[data-mode='online'] .scene-main > .stage-progress:has(.phase-time),
.scene-night[data-mode='online']:has(.recruitment) .scene-main > .stage-progress { background: var(--espresso-inset); }
.pantry-board .seat-name,
.pantry-board .pantry-status {
  border-color: #b7957470;
  background: #211915f0;
}
.pantry-board .pantry-seat[data-awake='true'] .seat-name { background: #4b3528; }

.secret-card.is-concealed {
  border-color: #937353;
  background:
    repeating-linear-gradient(126deg, #c79d640b 0 1px, transparent 1px 7px),
    linear-gradient(130deg, #4a3428, #2d201b 76%);
}
.secret-card.is-concealed .private-toggle.primary {
  border-color: #f0c483;
  background: linear-gradient(#f3cd94, #e3ae64);
}
.cup-inspection {
  border-color: #9a7756;
  background: var(--panel);
  box-shadow: 0 5px 0 #211713, 0 18px 29px #120b08a6;
}
.cup-stage {
  background:
    radial-gradient(ellipse at 46% 45%, #99704432, transparent 73%),
    linear-gradient(0deg, #251b16, #4d392e 84%, #564033);
}
.cup-actions, .cup-inspection .secret-watch { background: var(--espresso-inset); }
.cup-shadow, .die-contact { background: #140c09ed; }

.connection-band[data-status='connected'] {
  border-color: #ae8f6f;
  color: var(--ink);
  background: var(--espresso-raised);
}
.scene-seat-ended {
  background: radial-gradient(ellipse at 10% 0%, #49362c, var(--panel) 76%);
  box-shadow: 0 4px 0 var(--espresso-inset);
}

.result-banner {
  --outcome: #5a3b2a;
  border-color: #b8966b;
  background:
    repeating-linear-gradient(115deg, #65462909 0 1px, transparent 1px 6px),
    linear-gradient(140deg, #f4e5cc, #dcc29e);
  color: #3c291f;
  box-shadow: 0 13px 28px #140c09aa;
}
.result-banner:not([data-winner='thief']) .muted { color: #4e372c; }

:is(.rules-dialog, .private-dialog, .avatar-dialog, .invite-dialog, .cue-settings-dialog, .room-action-dialog) {
  border-color: var(--studio-edge);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 65px #100906d1;
}
:is(.rules-dialog, .private-dialog, .avatar-dialog, .invite-dialog, .room-action-dialog)::backdrop { background: #120d0bd9; }
:is(.rules-header, .private-dialog-top, .invite-dialog-header, .cue-settings-fixed, .feedback-actions, .avatar-dialog-actions) {
  background: var(--panel);
}
.cue-settings-dialog .private-dialog-top { background: transparent; }
.cue-settings-group, .room-action-buttons { border-color: var(--frame); }
.room-action-buttons .button.danger {
  border-color: #ad7667;
  background: #5b352e;
  color: #ffe5db;
}
.room-action-buttons .button.danger:disabled { opacity: .65; }
.cue-setting-rail, .cue-language[aria-pressed='true'], .avatar-option { background: var(--espresso-inset); }
.cue-setting-rail, .avatar-option { border-color: var(--studio-edge); }
.cue-setting-rail::after { background: var(--muted); }
.cue-setting-check:checked + .cue-setting-rail { background: #c38e51; }
.avatar-option[aria-pressed='true'] { background: #513a2a; }
.conversation-clues.button { background: #443027; color: var(--ink); }

.scene-entry {
  width: min(100%, 560px);
  gap: 9px;
  padding-block: clamp(9px, 2.5vh, 24px) 8px;
}
.scene-entry .scene-header { margin-block: 0 5px; }
.scene-entry .stage-title { font-size: clamp(2.14rem, 7.6vw, 3.85rem); }
.scene-entry .button.entry-back {
  padding-inline: 0 6px;
  color: var(--gold-light);
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.entry-form {
  gap: 11px;
  padding: clamp(10px, 3.7vw, 24px);
  border: 1px solid var(--frame);
  border-block-start-color: var(--studio-edge);
  border-radius: 11px;
  background: var(--panel);
  box-shadow: 0 13px 27px #120c0990;
  min-inline-size: 0;
}
.entry-form .field { gap: 4px; }
.entry-form .field-label, .entry-form .field label { font-size: .91rem; }
.entry-form .input { min-height: 45px; }
.entry-form .mode-options { gap: 7px; }
.entry-form .mode-options legend { margin-bottom: 6px; font-size: .9rem; }
.entry-form .mode-choice {
  min-height: 53px;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 8px;
  align-content: center;
  padding: 7px 9px;
  border-color: #806758;
  border-radius: 7px;
  background: var(--espresso-inset);
}
.entry-form .mode-choice input { grid-row: auto; }
.entry-form .mode-choice:has(input:checked) {
  border-color: var(--gold);
  background: #443226;
  box-shadow: inset 2px 0 var(--gold);
}
.entry-form .mode-copy { gap: 2px; }
.entry-form .mode-description { color: var(--muted); font-size: .81rem; line-height: 1.23; }
.entry-form .avatar-trigger { min-height: 44px; border-color: #806758; background: var(--espresso-raised); }
.entry-form .avatar-trigger .player-avatar { width: 31px; height: 31px; }
.entry-form .entry-actions > .button { min-height: 47px; }
.roll-timer-setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 3px 8px;
  padding-block: 2px 7px;
  border-block-end: 1px solid var(--frame);
}
.roll-timer-control {
  display: grid;
  grid-template-columns: 4.3rem auto;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.roll-timer-control .input { padding-inline: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.roll-timer-unit { color: var(--muted); font-size: .78rem; }
.roll-timer-setting .field-help { grid-column: 1 / -1; color: var(--muted); font-size: .78rem; }

@media (min-width: 510px) {
  .entry-form .mode-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .entry-form .mode-choice { min-height: 68px; align-items: center; }
}

@media (max-width: 420px) and (max-height: 650px) {
  .scene-entry {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 10px;
    padding-block-start: 8px;
  }
  .scene-entry .scene-header { grid-area: 1 / 1; align-self: center; margin: 0; }
  .scene-entry .stage-title { font-size: 1.8rem; }
  .scene-entry .button.entry-back { grid-area: 1 / 2; gap: 5px; font-size: .76rem; }
  .scene-entry .scene-main { grid-column: 1 / -1; }
  .scene-entry .entry-form { gap: 8px; padding: 10px; }
}

@media (max-width: 680px) {
  body[data-scene='night']:has(.pantry-board) {
    background:
      linear-gradient(180deg, #261a14cc, #23181460 31%, #201713ed 66%, var(--dark)),
      url('/assets/night-pantry-mobile.webp') center top / auto min(57svh, 390px) no-repeat var(--dark);
  }
}

@media (max-width: 690px) {
  .scene-title::before {
    background:
      linear-gradient(180deg, #1b120ebb, #291a1282 24%, transparent 44%, transparent 70%, #1b130ed7 92%, var(--dark)),
      url('/assets/title-portrait.jpg') center 39% / cover no-repeat var(--dark);
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .scene-title::before {
    background:
      linear-gradient(90deg, #1c130ff4 5%, #24170ec7 33%, #24170e24 65%, transparent 84%),
      url('/assets/title-landscape.jpg') center / cover no-repeat var(--dark);
  }
}

@media (hover: hover) {
  .button:is(.secondary, .utility-button, .rules-toggle):hover:not(:disabled),
  .entry-form .mode-choice:hover:not(:has(input:checked)),
  .avatar-option:hover:not([aria-pressed='true']),
  .cue-help-link:hover, .cue-language:hover { background: var(--espresso-hover); }
  .lobby-seat > .button.seat-edit:hover:not(:disabled) { background: transparent; }
  .room-action-buttons .button.danger:hover:not(:disabled) { background: #754438; }
  .button.entry-back:hover:not(:disabled) { background: transparent; color: var(--ink); border-color: transparent; }
}
