: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; }
.header-link { display: inline-flex; align-items: center; text-decoration: none; }
.sound-library-button { min-width: 46px; justify-content: center; padding: 10px; font-size: 1.15rem; }
.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:disabled { cursor: not-allowed; opacity: .42; transform: none; }
button:hover { transform: translateY(-1px); }
button:disabled:hover { transform: none; }
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; }
.ambience-toggle { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .74rem; }
.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; }
.setup-editor-card { margin-top: 28px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(0,0,0,.14); }
.setup-editor-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.setup-editor-header h3 { margin: 0; font-family: Georgia, serif; font-size: 1.25rem; font-weight: 500; }
.setup-player-list { display: grid; gap: 7px; }
.setup-player-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(175px, .8fr) auto; align-items: center; gap: 9px; padding: 8px 9px; border-radius: 10px; background: rgba(255,255,255,.05); }
.setup-player-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.setup-player-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setup-player-row select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 9px; color: var(--ink); background: var(--panel-solid); font: inherit; }
.setup-player-row select:focus { border-color: var(--gold); outline: none; }
.available-players { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.available-player-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.setup-editor-card .role-summary { margin-top: 15px; }
.setup-editor-card .form-actions { margin-top: 22px; }
.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.previous-choice, .target-button:disabled { border-color: rgba(255,255,255,.08); color: var(--muted); background: rgba(0,0,0,.16); cursor: not-allowed; opacity: .48; }
.target-button.previous-choice:hover, .target-button:disabled:hover { border-color: rgba(255,255,255,.08); background: rgba(0,0,0,.16); }
.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.wolf-marked { border: 1px solid rgba(150,126,190,.58); background: rgba(89,67,123,.24); box-shadow: 0 0 18px rgba(89,67,123,.14); }
.roster-row.wolf-healed-row { border-color: rgba(143,210,164,.62); background: rgba(67,112,82,.22); }
.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; }
.wolf-mark { display: block; margin-top: 3px; color: #c4a9ed; font-size: .68rem; font-weight: 700; }
.wolf-mark.wolf-healed { color: var(--green); }
.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); }
.night-report { margin-top: 24px; padding: 15px 17px; border: 1px solid rgba(228,183,107,.24); border-radius: 14px; background: rgba(228,183,107,.07); }
.night-report-title { margin-bottom: 9px; color: var(--gold-soft); font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.night-summary { display: grid; gap: 6px; margin: 0; padding-left: 20px; color: #d7d6de; font-size: .9rem; line-height: 1.45; }
.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; }
.game-over-graphic { position: relative; display: grid; place-items: center; height: 170px; margin: -4px 0 22px; overflow: hidden; border-radius: 16px; background: linear-gradient(180deg, rgba(228,183,107,.22), rgba(36,26,29,.65)); }
.game-over-graphic span { position: absolute; }
.game-over-sun { top: 18px; color: #ffe6a5; font-size: 3.4rem; }
.game-over-village { bottom: 18px; font-size: 4.8rem; filter: saturate(.9); }
.game-over-moon { top: 18px; color: #b7c4e9; font-size: 3.5rem; }
.game-over-wolf { bottom: 17px; font-size: 5rem; filter: saturate(.55) contrast(1.1); }
.winner-card.werewolf-win { border-color: rgba(125,103,163,.55); background: rgba(47,37,68,.35); }
.winner-card.village-win { border-color: rgba(228,183,107,.5); }
.game-over-summary { display: grid; gap: 7px; margin: 18px 0 22px; padding-left: 20px; color: #d7d6de; line-height: 1.45; }
.vote-result-card { max-width: 680px; }
.vote-result-graphic { position: relative; display: grid; place-items: center; height: 168px; margin: -8px 0 18px; overflow: hidden; border: 1px solid rgba(137,150,185,.22); border-radius: 20px; background: linear-gradient(180deg, rgba(39,48,78,.72), rgba(14,18,31,.92)); }
.vote-result-moon { position: absolute; top: 16px; right: 22%; color: #b9c5e8; font-size: 2.4rem; }
.vote-result-village { position: absolute; bottom: 16px; color: #a9a9b7; font-size: 4.3rem; filter: grayscale(.45); }
.vote-result-rain { position: absolute; inset: 12px 12%; color: rgba(183,198,235,.38); font-size: 1.3rem; letter-spacing: 1.3rem; line-height: 1.8; transform: rotate(-10deg); }
footer { margin-top: 22px; color: rgba(255,255,255,.38); font-size: .75rem; text-align: center; }
.audio-library-shell { max-width: 1180px; }
.audio-library-panel { padding: clamp(22px, 4vw, 42px); }
.audio-library { display: grid; gap: 30px; margin-top: 30px; }
.audio-group { display: grid; gap: 13px; }
.audio-group-heading { padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.audio-group-heading .eyebrow { margin-bottom: 4px; }
.audio-group-heading .muted { margin-bottom: 0; }
.audio-item-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.audio-item-card { padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.045); }
.audio-item-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.audio-item-heading h3 { margin: 0; font-family: Georgia, serif; font-size: 1.1rem; font-weight: 500; }
.audio-track + .audio-track { margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.audio-track-heading { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; color: var(--gold-soft); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.audio-file-list { display: grid; gap: 7px; }
.audio-file-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; background: rgba(0,0,0,.15); }
.audio-file-row.unavailable { opacity: .55; }
.audio-file-main { min-width: 0; }
.audio-file-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .83rem; }
.audio-file-meta { display: block; margin-top: 3px; color: var(--muted); font-size: .7rem; }
.audio-file-actions { display: contents; }
.audio-demo-button { white-space: nowrap; }
.audio-sequence-actions { margin-top: 8px; }
.audio-source-link { color: var(--gold-soft); font-size: .72rem; text-decoration: none; }
.audio-source-link:hover { text-decoration: underline; }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 22px, 680px); padding-top: 18px; }
  .topbar { margin-bottom: 18px; }
  .topbar .ghost-button:not(.header-link) { display: none; }
  .volume-control { padding: 7px 8px; }
  .volume-control input { width: 58px; }
  .ambience-toggle { max-width: 130px; }
  .ambience-toggle,
  .sound-library-button { display: none; }
  .header-link { padding: 9px 10px; font-size: .76rem; }
  .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; }
  .setup-player-row { grid-template-columns: minmax(0, 1fr) minmax(130px, .85fr) auto; gap: 6px; padding: 8px 6px; }
  .setup-player-row .small-button { padding: 7px 6px; }
  .setup-editor-header { align-items: stretch; flex-direction: column; }
  .audio-item-grid { grid-template-columns: 1fr; }
  .audio-file-row { grid-template-columns: minmax(0, 1fr) auto; }
  .audio-source-link { grid-column: 1; grid-row: 2; }
  .audio-file-actions { grid-column: 2; grid-row: 1 / span 2; }
}

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