:root {
  color-scheme: dark;
  --ink: #f6f3ea;
  --muted: #a5a8b7;
  --panel: rgba(22, 25, 38, .86);
  --panel-solid: #181b29;
  --line: rgba(255, 255, 255, .1);
  --gold: #e4b76b;
  --gold-soft: #f2d49b;
  --red: #ef7477;
  --blue: #8ab8e8;
  --green: #8fd2a4;
  --shadow: 0 24px 80px rgba(0, 0, 0, .3);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: #10131d; transition: background 700ms ease; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; opacity: .85; background: radial-gradient(circle at 15% 10%, rgba(104, 126, 181, .2), transparent 35%), radial-gradient(circle at 90% 20%, rgba(222, 154, 86, .12), transparent 30%); pointer-events: none; }
body.scene-night { background: #0b1221; }
body.scene-dawn { background: #3c2731; }
body.scene-day { background: #263544; }
body.scene-vote { background: #302934; }
body.scene-win { background: #282a1d; }
.app-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, serif; font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 500; letter-spacing: -.04em; }
h1 span { color: var(--gold); font-size: .7em; }
h2 { margin-bottom: 0; font-family: Georgia, serif; font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 500; }
.eyebrow { margin-bottom: 6px; color: var(--gold); font-size: .7rem; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
.top-actions, .form-actions { display: flex; align-items: center; gap: 10px; }
.volume-control { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 12px; color: var(--gold-soft); background: rgba(255,255,255,.06); }
.volume-control span { font-size: .9rem; transform: rotate(-28deg); }
.volume-control input { width: 76px; height: 4px; padding: 0; accent-color: var(--gold); cursor: pointer; }
button { border: 0; color: var(--ink); font: inherit; cursor: pointer; transition: transform 160ms ease, background 160ms ease, border-color 160ms ease; }
button:hover { transform: translateY(-1px); }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.primary-button, .secondary-button, .ghost-button, .icon-button { border-radius: 12px; padding: 12px 17px; font-weight: 700; }
.primary-button { color: #241b11; background: var(--gold); box-shadow: 0 8px 26px rgba(228, 183, 107, .2); }
.primary-button:hover { background: var(--gold-soft); }
.secondary-button, .ghost-button { border: 1px solid var(--line); background: rgba(255,255,255,.06); }
.secondary-button:hover, .ghost-button:hover, .icon-button:hover { background: rgba(255,255,255,.12); }
.icon-button { min-width: 46px; padding: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.06); font-size: 1.15rem; }
.panel { border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.setup-panel { max-width: 720px; margin: 7vh auto 0; padding: clamp(24px, 5vw, 48px); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.section-heading.compact { align-items: center; margin-bottom: 14px; }
.lede { max-width: 620px; color: #d3d4da; font-size: 1.05rem; line-height: 1.65; }
.fine-print, .muted-label, .muted { color: var(--muted); font-size: .84rem; }
.saved-games { margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); }
.saved-game-list { display: grid; gap: 8px; }
.saved-game { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.04); }
.saved-game.current { border-color: rgba(228,183,107,.55); background: rgba(228,183,107,.08); }
.saved-game-info { min-width: 0; }
.saved-game-info strong, .saved-game-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-game-info small { margin-top: 3px; color: var(--muted); font-size: .75rem; }
.saved-game-actions { display: flex; flex-shrink: 0; gap: 7px; }
.small-button { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: rgba(255,255,255,.06); font-size: .76rem; font-weight: 700; }
.small-button.delete { color: #f0a5a5; }
.limit-pill, .count-pill, .phase-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 7px 11px; color: #282015; background: var(--gold); font-size: .75rem; font-weight: 800; white-space: nowrap; }
.count-input-label { display: block; margin: 30px 0 9px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.count-input-wrap { display: flex; align-items: center; gap: 12px; max-width: 260px; margin-bottom: 26px; }
.count-input-wrap input { font-size: 1.4rem; text-align: center; }
.count-input-wrap span { color: var(--muted); white-space: nowrap; }
input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 13px 14px; color: var(--ink); background: rgba(0,0,0,.2); font: inherit; }
input:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px rgba(228,183,107,.12); }
.form-actions { justify-content: space-between; flex-wrap: wrap; }
.status-strip { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 16px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 15px; background: rgba(0,0,0,.2); }
.status-message { color: #d8d9df; font-size: .92rem; text-align: right; }
.muted-label { margin-left: 10px; }
.game-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .85fr); gap: 16px; align-items: start; }
.scene-panel { min-height: 510px; padding: clamp(24px, 4vw, 44px); }
.roster-panel { padding: 22px; }
.scene-kicker { margin-bottom: 12px; color: var(--gold); font-size: .8rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.scene-title { max-width: 680px; margin-bottom: 14px; font-family: Georgia, serif; font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 400; letter-spacing: -.04em; line-height: 1.03; }
.scene-copy { max-width: 650px; color: #d2d3db; font-size: 1.05rem; line-height: 1.65; }
.role-card { display: inline-flex; align-items: center; gap: 13px; margin: 22px 0; padding: 14px 16px; border: 1px solid rgba(228,183,107,.35); border-radius: 14px; background: rgba(228,183,107,.09); }
.role-icon { font-size: 1.7rem; }
.role-card strong { display: block; font-family: Georgia, serif; font-size: 1.2rem; font-weight: 500; }
.role-matrix { margin: 26px 0 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: rgba(0,0,0,.14); }
.role-matrix-head, .role-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(170px, .7fr); align-items: center; gap: 16px; }
.role-matrix-head { padding: 10px 13px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.role-row { padding: 9px 13px; border-bottom: 1px solid rgba(255,255,255,.06); }
.role-row:last-child { border-bottom: 0; }
.role-row > span { display: flex; align-items: center; gap: 10px; min-width: 0; }
.role-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-row select { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; color: var(--ink); background: var(--panel-solid); font: inherit; }
.role-row select:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px rgba(228,183,107,.12); }
.role-summary { margin: 10px 0 0; color: var(--muted); font-size: .82rem; }
.role-warning { margin: 10px 0 0; color: #f0a5a5; font-size: .82rem; }
.target-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 24px 0; }
.target-button { min-height: 74px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: rgba(255,255,255,.05); text-align: left; }
.target-button:hover, .target-button.selected { border-color: var(--gold); background: rgba(228,183,107,.14); }
.target-button strong { display: block; margin-bottom: 4px; font-size: .95rem; }
.target-button small { color: var(--muted); font-size: .72rem; }
.scene-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }
.roster { display: grid; gap: 7px; }
.roster-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 11px; border-radius: 11px; background: rgba(255,255,255,.045); }
.roster-row.dead { opacity: .46; }
.roster-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 50%; color: #25202a; background: var(--gold); font-size: .74rem; font-weight: 800; }
.dead .avatar { background: #656776; }
.roster-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-tag { color: var(--muted); font-size: .7rem; text-align: right; }
.role-tag.werewolf { color: var(--red); }
.role-tag.seer { color: var(--blue); }
.role-tag.doctor { color: var(--green); }
.event-log { display: grid; gap: 7px; margin-top: 12px; }
.event { padding: 8px 10px; border-left: 2px solid var(--line); color: var(--muted); font-size: .82rem; }
.event.death { border-color: var(--red); color: #f2b1b1; }
.event.save { border-color: var(--green); color: #b4e3bf; }
.event.win { border-color: var(--gold); color: var(--gold-soft); }
.history-panel { margin-top: 16px; padding: 16px 20px; }
summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.vote-table { display: grid; gap: 8px; margin: 24px 0; }
.vote-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.05); }
.vote-row select { max-width: 220px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; color: var(--ink); background: var(--panel-solid); }
.winner-card { padding: 26px; border: 1px solid rgba(228,183,107,.4); border-radius: 18px; background: rgba(228,183,107,.1); }
.winner-card .scene-title { margin-bottom: 0; }
footer { margin-top: 22px; color: rgba(255,255,255,.38); font-size: .75rem; text-align: center; }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 22px, 680px); padding-top: 18px; }
  .topbar { margin-bottom: 18px; }
  .topbar .ghost-button { display: none; }
  .volume-control { padding: 7px 8px; }
  .volume-control input { width: 58px; }
  .game-grid { grid-template-columns: 1fr; }
  .scene-panel { min-height: 0; }
  .status-strip { align-items: flex-start; flex-direction: column; gap: 8px; }
  .status-message { text-align: left; }
  .section-heading { flex-direction: column; }
  .section-heading.compact { flex-direction: row; }
  .role-matrix-head, .role-row { grid-template-columns: minmax(0, 1fr) minmax(135px, .8fr); gap: 10px; }
  .role-row { padding: 9px 10px; }
}

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