:root {
  color-scheme: dark;
  --ink: #08090d;
  --panel: rgba(17, 18, 24, .88);
  --paper: #eee8dc;
  --muted: #a8a399;
  --line: rgba(238, 232, 220, .14);
  --red: #cc3a31;
  --gold: #c7a65a;
  --green: #63bd82;
  --radius: 3px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--ink);
  color: var(--paper);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ink); }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 80% -10%, rgba(204, 58, 49, .16), transparent 36rem),
    radial-gradient(circle at -10% 70%, rgba(199, 166, 90, .07), transparent 30rem),
    linear-gradient(180deg, #0b0c11, #07080b 70%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.015) 1px, transparent 1px);
  background-size: 100% 4px;
  opacity: .55;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 20;
  opacity: .025;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, .button {
  min-height: 48px;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  background: var(--red);
  color: white;
  font-weight: 800;
  letter-spacing: .04em;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
button:hover, .button:hover { transform: translateY(-1px); background: #e2473d; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
button.secondary { background: transparent; border-color: var(--line); color: var(--paper); }
button.secondary:hover { border-color: var(--paper); background: rgba(255,255,255,.04); }
button.ghost { min-height: 36px; padding: .45rem .7rem; background: transparent; border-color: var(--line); color: var(--muted); font-size: .78rem; }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.masthead {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; text-transform: uppercase; font: 800 1rem/1 Georgia, serif; letter-spacing: .12em; }
.brand small { display: block; color: var(--muted); font: 600 .54rem/1.4 Inter, sans-serif; letter-spacing: .3em; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--red); border-radius: 50%; color: var(--red); font: 700 .66rem/1 Inter, sans-serif; }
.signal { color: var(--muted); text-transform: uppercase; font-size: .66rem; letter-spacing: .16em; }
.signal i { display: inline-block; width: 7px; height: 7px; margin-right: .45rem; border-radius: 50%; background: var(--red); box-shadow: 0 0 14px var(--red); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

main { position: relative; z-index: 1; width: min(1120px, calc(100% - 2rem)); min-height: calc(100vh - 170px); margin: 0 auto; padding: clamp(2rem, 7vw, 6rem) 0; }
footer { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 1rem; width: min(1120px, calc(100% - 2rem)); margin: 0 auto; padding: 1.5rem 0 2rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; }

.eyebrow { margin: 0 0 .8rem; color: var(--red); text-transform: uppercase; letter-spacing: .22em; font-size: .68rem; font-weight: 900; }
h1, h2, h3 { margin-top: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
h1 { max-width: 780px; margin-bottom: 1rem; font-size: clamp(2.6rem, 8vw, 6rem); line-height: .92; letter-spacing: -.045em; }
h2 { font-size: clamp(1.7rem, 4vw, 2.7rem); line-height: 1.02; }
h3 { font-size: 1.25rem; }
.lede { max-width: 680px; margin: 0 0 2rem; color: var(--muted); font: 400 clamp(1rem, 2.2vw, 1.25rem)/1.65 Georgia, serif; }
.hero { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .75fr); gap: clamp(2rem, 7vw, 7rem); align-items: end; }
.clock { position: relative; display: grid; aspect-ratio: 1; place-items: center; max-width: 330px; border: 1px solid var(--line); border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.05), transparent 65%); }
.clock::before { content: ""; position: absolute; inset: 11%; border: 1px dashed rgba(199,166,90,.35); border-radius: 50%; }
.clock strong { font: 400 clamp(3rem, 8vw, 5.2rem)/1 Georgia, serif; letter-spacing: -.06em; }
.clock span { position: absolute; bottom: 22%; color: var(--red); text-transform: uppercase; letter-spacing: .2em; font-size: .6rem; }

.panel { padding: clamp(1.2rem, 3vw, 2rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 22px 80px rgba(0,0,0,.25); backdrop-filter: blur(14px); }
.panel + .panel { margin-top: 1rem; }
.panel.redline { border-top: 2px solid var(--red); }
.panel.goldline { border-top: 2px solid var(--gold); }
.panel.secret { border-color: rgba(204,58,49,.5); background: linear-gradient(130deg, rgba(204,58,49,.12), var(--panel)); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.divider { height: 1px; margin: 1.5rem 0; background: var(--line); }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: .76rem; line-height: 1.5; }
.tag { display: inline-flex; align-items: center; min-height: 26px; padding: .25rem .55rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); text-transform: uppercase; font-size: .62rem; font-weight: 800; letter-spacing: .12em; }
.tag.good { border-color: rgba(99,189,130,.4); color: var(--green); }
.narrow { max-width: 620px; margin: auto; }
.compact-title { font-size: clamp(2.4rem, 8vw, 4.5rem); }
.centered { margin-inline: auto; }

label { display: grid; gap: .45rem; color: var(--muted); font-size: .78rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; background: rgba(0,0,0,.28); color: var(--paper); }
textarea { min-height: 150px; resize: vertical; line-height: 1.5; }
.player-count { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.player-count input { position: absolute; opacity: 0; pointer-events: none; }
.player-count label { display: grid; min-height: 70px; place-items: center; border: 1px solid var(--line); color: var(--paper); cursor: pointer; font: 400 1.7rem/1 Georgia, serif; }
.player-count input:checked + label { border-color: var(--red); background: rgba(204,58,49,.12); }

.steps { counter-reset: steps; display: grid; gap: 1px; margin: 2rem 0; background: var(--line); border: 1px solid var(--line); }
.step { counter-increment: steps; display: grid; grid-template-columns: 42px 1fr; gap: 1rem; padding: 1rem; background: #0c0d12; }
.step::before { content: counter(steps, decimal-leading-zero); color: var(--red); font: 700 .72rem/1 Inter, sans-serif; }
.step strong { display: block; margin-bottom: .35rem; }

.invitations { display: grid; gap: .65rem; }
.invite { display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: center; padding: .7rem; border: 1px solid var(--line); background: rgba(0,0,0,.18); }
.invite code { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: .68rem; }
.slot { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--red); border-radius: 50%; font-size: .7rem; font-weight: 900; }

.host-grid { display: grid; grid-template-columns: minmax(280px, .78fr) minmax(0, 1.22fr); gap: 1rem; align-items: stretch; }
.join-panel { display: grid; grid-template-columns: 1fr minmax(150px, 210px); gap: 1.2rem; align-items: center; }
.join-panel .actions, .join-panel .fine { grid-column: 1 / -1; }
.qr-wrap { aspect-ratio: 1; padding: .7rem; background: #fff; border: 5px solid #fff; border-radius: 8px; }
.qr-wrap svg { display: block; width: 100%; height: 100%; }
.control-panel { display: flex; flex-direction: column; }
.big-counter { display: flex; align-items: baseline; gap: .8rem; margin: .3rem 0 1.2rem; }
.big-counter strong { color: var(--paper); font: 400 clamp(2.8rem, 7vw, 5rem)/.9 Georgia, serif; letter-spacing: -.055em; }
.big-counter span { max-width: 120px; color: var(--muted); text-transform: uppercase; font-size: .62rem; font-weight: 800; letter-spacing: .13em; }
.seat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.seat-card { display: grid; grid-template-columns: 10px 1fr auto; gap: .5rem; align-items: center; min-height: 58px; padding: .65rem; border: 1px solid var(--line); background: rgba(0,0,0,.18); }
.seat-card small { grid-column: 2 / -1; color: var(--muted); font-size: .66rem; }
.seat-card .release-seat { grid-column: 2 / -1; justify-self: start; }
.seat-dot { width: 9px; height: 9px; border-radius: 50%; background: #454752; box-shadow: 0 0 0 4px rgba(255,255,255,.02); }
.seat-card.claimed { border-color: rgba(199,166,90,.34); }
.seat-card.claimed .seat-dot { background: var(--gold); }
.seat-card.online { border-color: rgba(99,189,130,.36); background: rgba(99,189,130,.035); }
.seat-card.online .seat-dot { background: var(--green); box-shadow: 0 0 13px rgba(99,189,130,.7); }
.seat-card.voted small { color: var(--green); }
.host-progress { margin-top: 1rem; }
.act-timeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 1.4rem 0; background: var(--line); }
.timeline-act { display: grid; grid-template-columns: auto 1fr; gap: .55rem; min-height: 74px; padding: .7rem; background: #0c0d12; opacity: .45; }
.timeline-act > span { color: var(--red); font: 400 1.25rem/1 Georgia, serif; }
.timeline-act strong, .timeline-act small { display: block; }
.timeline-act small { margin-top: .25rem; color: var(--muted); font-size: .62rem; }
.timeline-act.done { opacity: .72; }
.timeline-act.current { opacity: 1; background: rgba(204,58,49,.1); box-shadow: inset 0 -2px var(--red); }
.vote-track { overflow: hidden; height: 7px; margin: 1rem 0 1.4rem; background: rgba(255,255,255,.08); border-radius: 99px; }
.vote-track i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold)); transition: width .35s ease; }
.solution-slot { margin-top: 1rem; }
.sealed-role { max-width: 680px; margin: auto; padding-block: clamp(3rem, 10vw, 7rem); text-align: center; }
.player-progress, .vote-section, .player-revealed { margin-top: 3rem; }

.role-title { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.role-title h1 { font-size: clamp(2.5rem, 9vw, 5.5rem); }
.role-title .monogram { display: grid; flex: 0 0 66px; height: 66px; place-items: center; border: 1px solid var(--red); border-radius: 50%; color: var(--red); font: 400 1.4rem/1 Georgia, serif; }
.location { padding-left: 1rem; border-left: 2px solid var(--gold); font-family: Georgia, serif; line-height: 1.6; }
.objectives { margin: 0; padding-left: 1.15rem; line-height: 1.65; }
.objectives li + li { margin-top: .35rem; }

.act { overflow: hidden; border: 1px solid var(--line); background: rgba(10,11,15,.75); }
.act-head { display: grid; grid-template-columns: 42px 1fr auto; gap: .8rem; align-items: center; padding: 1rem; }
.act-number { color: var(--red); font: 400 1.6rem/1 Georgia, serif; }
.act h3 { margin: 0; }
.act-body { padding: 0 1rem 1rem 4.2rem; }
.code { display: inline-block; margin: .35rem 0; color: var(--gold); font: 500 1.35rem/1.2 ui-monospace, monospace; letter-spacing: .16em; }
.evidence { position: relative; overflow: hidden; }
.evidence::before { content: attr(data-id); position: absolute; right: -4px; top: -16px; color: rgba(238,232,220,.035); font: 400 6rem/1 Georgia, serif; }
.evidence ul { position: relative; margin: 1rem 0; padding-left: 1.2rem; color: var(--muted); line-height: 1.55; }
.evidence-summary { position: relative; padding-top: 1rem; border-top: 1px solid var(--line); font-family: Georgia, serif; }

.choices { display: grid; gap: .6rem; }
.choice { position: relative; display: flex; gap: .75rem; align-items: start; min-height: 48px; padding: .8rem; border: 1px solid var(--line); color: var(--paper); cursor: pointer; }
.choice input { width: 18px; min-height: 18px; margin-top: 2px; accent-color: var(--red); }
.receipt { word-break: break-all; padding: 1rem; border: 1px dashed var(--gold); background: rgba(199,166,90,.06); color: var(--gold); font: 700 .9rem/1.7 ui-monospace, monospace; letter-spacing: .08em; }
.verdict { padding: clamp(1.4rem, 5vw, 3rem); border: 1px solid var(--red); background: radial-gradient(circle at 50% 0, rgba(204,58,49,.2), transparent 60%), #0b0c10; text-align: center; }
.verdict h2 { font-size: clamp(2.1rem, 7vw, 4.5rem); }
.verdict .chain { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; margin-top: 2rem; background: var(--line); text-align: left; }
.verdict .chain article { padding: 1rem; background: #101116; }

.error { padding: .8rem; border-left: 2px solid var(--red); background: rgba(204,58,49,.08); color: #f1b1ac; }
.loading { display: grid; min-height: 50vh; place-items: center; color: var(--muted); text-transform: uppercase; letter-spacing: .18em; font-size: .7rem; }
.loading::after { content: ""; width: 30px; height: 30px; border: 1px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast { position: fixed; z-index: 50; right: 1rem; bottom: 1rem; max-width: min(360px, calc(100% - 2rem)); padding: .8rem 1rem; border: 1px solid var(--line); background: #15171e; color: var(--paper); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s ease; }
#toast.show { opacity: 1; transform: none; }

@media (max-width: 760px) {
  .hero, .grid, .grid.three, .host-grid { grid-template-columns: 1fr; }
  .clock { max-width: 250px; }
  footer { flex-direction: column; }
  .act-body { padding-left: 1rem; }
  .verdict .chain { grid-template-columns: 1fr; }
  .invite { grid-template-columns: auto 1fr; }
  .invite button { grid-column: 1 / -1; }
  .join-panel { grid-template-columns: 1fr; text-align: center; }
  .join-panel .qr-wrap { width: min(240px, 82vw); margin-inline: auto; }
  .join-panel .actions, .join-panel .fine { grid-column: auto; justify-content: center; }
  .act-timeline { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 380px) {
  main, .masthead, footer { width: min(100% - 1rem, 1120px); }
  .seat-grid { grid-template-columns: 1fr; }
  .role-title .monogram { flex-basis: 50px; height: 50px; }
}

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