:root {
  --ink: #f6f1e7;
  --muted: #99939a;
  --night: #09090d;
  --panel: #121117;
  --panel-2: #1a171f;
  --line: rgba(255, 255, 255, .1);
  --red: #e4433f;
  --red-dark: #7e171d;
  --gold: #e9bf72;
  --green: #5ac68c;
  --blue: #7198ff;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 8%, rgba(139, 28, 36, .28), transparent 33%),
    radial-gradient(circle at 92% 68%, rgba(70, 49, 95, .18), transparent 30%),
    var(--night);
  color: var(--ink);
  font-family: Manrope, Arial, sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.noise { position: fixed; inset: 0; z-index: -1; opacity: .2; pointer-events: none; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E"); }

.topbar {
  position: relative;
  z-index: 5;
  min-height: 76px;
  padding: 14px clamp(18px, 4vw, 58px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: -.03em; }
.brand b { color: var(--red); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #17141b; color: var(--gold); font-size: 24px; box-shadow: 0 0 24px rgba(228, 67, 63, .25); }
.text-button { border: 1px solid var(--line); border-radius: 999px; padding: 10px 17px; background: rgba(255,255,255,.04); cursor: pointer; font-weight: 700; }

.app-shell { width: min(1180px, calc(100% - 36px)); margin: 0 auto; padding: clamp(44px, 7vw, 92px) 0 80px; }
.screen { display: none; }
.screen.active { display: block; animation: enter .5s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

#setup-screen { grid-template-columns: minmax(260px, .78fr) minmax(520px, 1.22fr); gap: clamp(38px, 7vw, 100px); align-items: start; }
#setup-screen.active { display: grid; }
.setup-hero { position: sticky; top: 120px; padding-top: 24px; }
.eyebrow, .setup-heading span, .dialog-head span, .stage-kicker, .balance-title > span { color: var(--gold); text-transform: uppercase; letter-spacing: .15em; font-size: 10px; font-weight: 800; }
.setup-hero h1 { margin: 24px 0; font: 700 clamp(48px, 6.8vw, 88px)/.92 Unbounded, sans-serif; letter-spacing: -.075em; }
.setup-hero h1 em { color: var(--red); font-style: normal; }
.setup-hero p { max-width: 450px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.7; }

.setup-card, .stage-card, .winner-card {
  border: 1px solid var(--line);
  border-radius: 34px;
  background: linear-gradient(145deg, rgba(27,24,32,.98), rgba(15,14,19,.98));
  box-shadow: 0 38px 90px rgba(0, 0, 0, .36);
}
.setup-card { padding: clamp(22px, 4vw, 42px); }
.setup-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.setup-heading h2 { margin: 10px 0 0; font: 600 clamp(25px, 3vw, 36px)/1.15 Unbounded, sans-serif; letter-spacing: -.05em; }
.counter { min-width: 164px; padding: 7px; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: #0c0b10; }
.counter button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: #26212b; cursor: pointer; font-size: 24px; }
.counter button:disabled { opacity: .3; cursor: default; }
.counter strong { text-align: center; font: 700 24px Unbounded, sans-serif; }

.balance-panel { margin: 30px 0; padding: 19px; border: 1px solid rgba(233,191,114,.22); border-radius: 22px; background: rgba(233,191,114,.045); }
.balance-title { display: flex; justify-content: space-between; gap: 20px; align-items: center; }
.balance-title small { color: var(--muted); font-size: 11px; }
.role-chips { margin-top: 13px; display: flex; flex-wrap: wrap; gap: 8px; }
.role-chip { padding: 8px 11px; border-radius: 999px; background: rgba(255,255,255,.07); color: #d6d0d5; font-size: 11px; font-weight: 700; }
.role-chip.black { background: rgba(228,67,63,.16); color: #ff8f8b; }
.role-chip.joker { background: rgba(233,191,114,.14); color: var(--gold); }

.names-heading { margin: 30px 0 14px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.names-heading h3 { margin: 0; font-size: 16px; }
.names-heading span { color: var(--muted); font-size: 10px; }
.player-inputs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.name-field { position: relative; }
.name-field span { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #6e6971; font-size: 11px; font-weight: 800; }
.name-field input { width: 100%; height: 50px; padding: 0 14px 0 43px; border: 1px solid var(--line); border-radius: 14px; background: #0e0d12; color: var(--ink); font-size: 14px; }
.name-field input::placeholder { color: #625d65; }

.primary-button, .secondary-button, .danger-button {
  min-height: 58px;
  border: 0;
  border-radius: 17px;
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .2s, filter .2s;
}
.primary-button:hover, .secondary-button:hover, .danger-button:hover { transform: translateY(-2px); filter: brightness(1.08); }
.primary-button { width: 100%; margin-top: 22px; display: flex; justify-content: space-between; align-items: center; background: var(--red); color: #fff; }
.secondary-button { background: #29252e; color: #fff; }
.danger-button { background: var(--red-dark); color: #fff; }
.wide { width: 100%; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.button-row .primary-button { margin-top: 0; }

#stage-screen { width: min(780px, 100%); margin: 0 auto; }
.stage-card { overflow: hidden; }
.stage-top { min-height: 190px; padding: clamp(28px, 5vw, 48px); position: relative; display: flex; flex-direction: column; justify-content: flex-end; background: radial-gradient(circle at 82% 0%, rgba(228,67,63,.35), transparent 42%), #161219; }
.stage-top:after { content: "♠"; position: absolute; right: 6%; top: -30px; color: rgba(255,255,255,.055); font-size: 210px; line-height: 1; }
.stage-top h1 { position: relative; z-index: 1; margin: 10px 0 0; font: 600 clamp(30px, 6vw, 54px)/1 Unbounded, sans-serif; letter-spacing: -.06em; }
.stage-body { padding: clamp(24px, 5vw, 48px); }
.stage-body > p { color: var(--muted); line-height: 1.7; }
.pass-icon { width: 78px; height: 78px; margin-bottom: 23px; display: grid; place-items: center; border-radius: 50%; background: rgba(228,67,63,.12); color: var(--red); font-size: 38px; box-shadow: 0 0 0 13px rgba(228,67,63,.04); }
.privacy-note { margin: 20px 0 0; padding: 13px 15px; border-radius: 13px; background: rgba(233,191,114,.07); color: #c1b19a; font-size: 12px; line-height: 1.5; }

.role-reveal { min-height: 680px; display: flex; flex-direction: column; }
.role-visual { min-height: 300px; padding: 38px; display: grid; place-items: center; position: relative; overflow: hidden; text-align: center; background: radial-gradient(circle, rgba(228,67,63,.25), transparent 58%), #100d12; }
.role-visual.red-team { background: radial-gradient(circle, rgba(205,47,50,.35), transparent 58%), #100d12; }
.role-visual.black-team { background: radial-gradient(circle, rgba(0,0,0,.1), #050506 68%); }
.role-visual.joker-team { background: radial-gradient(circle, rgba(233,191,114,.26), transparent 58%), #100d12; }
.role-symbol { display: grid; place-items: center; width: 170px; height: 170px; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; font: 700 70px Unbounded, sans-serif; color: var(--gold); box-shadow: 0 0 0 22px rgba(255,255,255,.025); }
.role-copy { flex: 1; padding: clamp(25px, 5vw, 45px); display: flex; flex-direction: column; }
.role-copy h1 { margin: 8px 0 14px; font: 600 clamp(30px, 7vw, 48px)/1.05 Unbounded, sans-serif; letter-spacing: -.055em; }
.role-copy p { margin: 0; color: var(--muted); line-height: 1.65; }
.role-copy .primary-button { margin-top: auto; }
.team-list { margin-top: 18px; padding: 16px; border-radius: 15px; background: rgba(228,67,63,.09); color: #ffaaa7; font-size: 13px; line-height: 1.5; }

.phase-progress { display: flex; gap: 6px; margin-top: 18px; }
.phase-progress i { height: 4px; flex: 1; border-radius: 9px; background: rgba(255,255,255,.1); }
.phase-progress i.done { background: var(--red); }
.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 22px; }
.choice-button { min-height: 72px; padding: 13px 15px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 16px; background: #0e0d12; cursor: pointer; text-align: left; }
.choice-button:hover { border-color: rgba(233,191,114,.5); background: #19151c; }
.choice-button:disabled { opacity: .28; cursor: not-allowed; }
.choice-avatar { width: 39px; height: 39px; flex: none; display: grid; place-items: center; border-radius: 50%; background: #29242d; color: var(--gold); font-weight: 800; }
.choice-button b { display: block; font-size: 13px; }
.choice-button small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }

.check-result { margin: 25px 0 8px; padding: 26px; border-radius: 21px; text-align: center; }
.check-result.red { background: rgba(90,198,140,.1); border: 1px solid rgba(90,198,140,.3); color: #91e4b5; }
.check-result.black { background: rgba(228,67,63,.11); border: 1px solid rgba(228,67,63,.35); color: #ff918e; }
.check-result strong { display: block; margin-top: 8px; font: 600 28px Unbounded, sans-serif; }

.day-banner { padding: 35px; border-radius: 24px; background: linear-gradient(135deg, #e9bf72, #c98542); color: #171119; }
.day-banner h2 { margin: 0 0 10px; font: 600 clamp(25px, 5vw, 38px) Unbounded, sans-serif; letter-spacing: -.05em; }
.day-banner p { margin: 0; line-height: 1.6; }
.player-status-list { display: grid; gap: 8px; margin-top: 22px; }
.status-row { min-height: 58px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 14px; background: #0e0d12; }
.status-row span { font-size: 11px; color: var(--muted); }
.status-row .awake { color: var(--green); }
.status-row .asleep { color: var(--blue); }
.status-row .out { color: #ff7e7a; }

.event-log { margin-top: 22px; padding: 0; list-style: none; }
.event-log li { padding: 11px 0; border-bottom: 1px solid var(--line); color: #bbb5bd; font-size: 12px; line-height: 1.5; }
.event-log li:first-child { color: var(--ink); }

.winner-card { width: min(760px, 100%); margin: 6vh auto 0; padding: clamp(30px, 7vw, 70px); text-align: center; overflow: hidden; position: relative; }
.winner-card:before { content: ""; position: absolute; width: 340px; height: 340px; left: 50%; top: -220px; transform: translateX(-50%); border-radius: 50%; background: var(--red); filter: blur(80px); opacity: .35; }
.winner-symbol { position: relative; width: 120px; height: 120px; margin: 0 auto 28px; display: grid; place-items: center; border-radius: 50%; background: #09090d; border: 1px solid var(--line); color: var(--gold); font: 700 48px Unbounded, sans-serif; }
.winner-card h1 { position: relative; margin: 0; font: 600 clamp(34px, 7vw, 62px)/1 Unbounded, sans-serif; letter-spacing: -.07em; }
.winner-card p { position: relative; margin: 20px auto 0; max-width: 520px; color: var(--muted); line-height: 1.7; }
.reveal-table { margin: 28px 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; text-align: left; }
.reveal-table div { padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(0,0,0,.22); }
.reveal-table b { display: block; font-size: 13px; }
.reveal-table span { color: var(--muted); font-size: 10px; }

dialog { width: min(840px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 1px solid var(--line); border-radius: 28px; background: #131117; color: var(--ink); box-shadow: 0 40px 100px rgba(0,0,0,.7); }
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(8px); }
.dialog-head { padding: 27px 30px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 7px 0 0; font: 600 27px Unbounded, sans-serif; letter-spacing: -.05em; }
.dialog-head button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: #242028; cursor: pointer; font-size: 25px; }
.rules-grid { padding: 25px 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rules-grid article { padding: 16px; display: flex; gap: 13px; border-radius: 16px; background: rgba(255,255,255,.04); }
.role-dot { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 50%; font-size: 13px; }
.role-dot.black { background: var(--red-dark); }.role-dot.red { background: #244a38; }.role-dot.joker { background: #594321; color: var(--gold); }
.rules-grid h3 { margin: 0 0 5px; font-size: 13px; }.rules-grid p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.rules-note { margin: 0 30px 30px; padding: 16px 18px; border-radius: 15px; background: rgba(233,191,114,.08); color: #c4b69f; font-size: 12px; line-height: 1.6; }

@media (max-width: 820px) {
  #setup-screen.active { display: block; }
  .setup-hero { position: static; padding: 0 3px 42px; }
  .setup-hero h1 { font-size: clamp(48px, 13vw, 76px); }
  .setup-card { border-radius: 26px; }
}

@media (max-width: 560px) {
  .topbar { min-height: 66px; }
  .brand { font-size: 13px; }.brand-mark { width: 37px; height: 37px; font-size: 20px; }
  .app-shell { width: min(100% - 24px, 1180px); padding-top: 35px; }
  .setup-heading { display: block; }
  .counter { margin-top: 20px; width: 100%; }
  .names-heading { display: block; }.names-heading span { display: block; margin-top: 7px; }
  .player-inputs, .choice-grid, .button-row, .reveal-table, .rules-grid { grid-template-columns: 1fr; }
  .stage-card { border-radius: 25px; }
  .stage-top { min-height: 160px; }
  .role-reveal { min-height: calc(100vh - 115px); }
  .role-visual { min-height: 260px; }
  .role-symbol { width: 138px; height: 138px; font-size: 56px; }
  .rules-grid { padding: 18px; }.dialog-head { padding: 22px 18px; }.rules-note { margin: 0 18px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
