@import url("https://fonts.googleapis.com/css2?family=Abril+Fatface&family=DM+Sans:opsz,wght@9..40,400;9..40,600;9..40,800&family=JetBrains+Mono:wght@500&display=swap");

:root {
  --bg: #0f0c0c;
  --bg-2: #1a1514;
  --panel: #241c1a;
  --line: #3b2e2a;
  --text: #f3e9d8;
  --muted: #a8988a;
  --hot: #c8102e;
  --hot-dark: #7d0a1d;
  --sun: #d9a441;
  --mint: #7cc59a;
  --sky: #8fb8e8;
  --danger: #ff5a4f;
  --radius: 16px;
  --display: "Abril Fatface", Georgia, serif;
  --body: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1100px 600px at 50% -20%, #3a1416 0%, transparent 65%),
    radial-gradient(800px 500px at 100% 120%, #2a1a10 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 1.2s;
}
body.is-night {
  --bg: #07080f;
  --bg-2: #0f111c;
  --panel: #151827;
  --line: #262a40;
  background:
    radial-gradient(900px 500px at 80% -10%, #1b2246 0%, transparent 60%),
    var(--bg);
}

h1, h2, h3, .display { font-family: var(--display); font-weight: 400; letter-spacing: 0.01em; margin: 0; }
a { color: var(--sun); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ---------- logo ---------- */
.logo {
  font-family: var(--display);
  font-size: clamp(56px, 12vw, 120px);
  line-height: 0.9;
  display: inline-block;
}
.logo .word {
  display: inline-block;
  letter-spacing: 0.08em;
  color: var(--text);
  border-bottom: 0.08em solid var(--hot);
  padding-bottom: 0.04em;
}
.logo.small { font-size: 28px; }

/* ---------- controls ---------- */
button, .btn {
  font: 800 18px/1 var(--body);
  border: 0;
  border-radius: 12px;
  padding: 16px 22px;
  background: var(--sun);
  color: #1d1300;
  cursor: pointer;
  box-shadow: 0 5px 0 #8a6420;
  transition: transform 0.06s, box-shadow 0.06s, opacity 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: manipulation;
}
button:active, .btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #8a6420; }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
button.hot, .btn.hot { background: var(--hot); color: white; box-shadow: 0 5px 0 var(--hot-dark); }
button.hot:active, .btn.hot:active { box-shadow: 0 1px 0 var(--hot-dark); }
button.ghost { background: var(--panel); color: var(--text); box-shadow: 0 5px 0 #000a; border: 1px solid var(--line); }
button.small { padding: 10px 14px; font-size: 15px; border-radius: 10px; }
button.block { width: 100%; }

input, select {
  font: 600 18px var(--body);
  color: var(--text);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px;
  width: 100%;
  outline: none;
}
input:focus, select:focus { border-color: var(--sun); }
input.code-input {
  font-family: var(--display);
  font-size: 34px;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
}
label { display: block; font-weight: 600; color: var(--muted); font-size: 14px; margin: 0 0 6px; }

.panel {
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow, .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lineup { font-weight: 800; color: var(--sun); letter-spacing: 0.02em; }

/* ---------- toasts ---------- */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { background: var(--danger); color: white; font-weight: 700; padding: 12px 16px; border-radius: 12px; box-shadow: 0 8px 24px #0008; transition: opacity 0.4s, transform 0.4s; }
.toast.info { background: var(--sky); color: #00253a; }
.toast.out { opacity: 0; transform: translateY(8px); }

.status-pill { position: fixed; top: 10px; right: 10px; font-size: 13px; font-weight: 700; padding: 6px 10px; border-radius: 99px; background: var(--danger); color: white; z-index: 40; }

/* ---------- landing ---------- */
.landing { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.landing-inner { width: min(560px, 100%); text-align: center; }
.landing .tag { font-size: 20px; color: var(--muted); margin: 22px 0 34px; font-style: italic; }
.landing .choices { display: grid; gap: 16px; text-align: left; }
.landing .choice h2 { font-size: 26px; margin-bottom: 6px; }
.landing .choice p { margin: 0 0 14px; color: var(--muted); }
.landing .rules { text-align: left; margin-top: 16px; }
.landing .rules summary { font-weight: 800; cursor: pointer; }
.landing .rules p { color: var(--muted); margin: 10px 0 0; }
.landing .rules b { color: var(--text); }

/* ---------- player (phone) ---------- */
.phone { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; }
.phone header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.phone .who { font-weight: 800; background: var(--panel); border: 1px solid var(--line); padding: 6px 12px; border-radius: 99px; font-size: 15px; }
.phase-bar { display: flex; align-items: center; gap: 10px; }
.phase-bar .label { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.timer-badge { font-family: var(--mono); font-weight: 500; background: var(--bg-2); border: 2px solid var(--line); border-radius: 10px; padding: 4px 10px; font-size: 16px; }
.timer-badge:empty { display: none; }
.timer-badge.low { border-color: var(--hot); color: var(--hot); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

.center-msg { text-align: center; padding: 28px 10px; }
.center-msg .big { font-family: var(--display); font-size: 36px; line-height: 1.1; margin-bottom: 10px; }
.center-msg .emoji { font-size: 60px; margin-bottom: 8px; }
.center-msg p { margin: 6px 0; }
.center-note { text-align: center; color: var(--muted); margin: 6px 0; }
.ask { font-size: 32px; text-align: center; margin-top: 14px; }

.role-card {
  display: block;
  width: 100%;
  text-align: center;
  padding: 26px 20px;
  border-radius: 20px;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: 0 6px 0 #000a;
}
.role-card:active { transform: translateY(3px); box-shadow: 0 3px 0 #000a; }
.role-card.down { background: repeating-linear-gradient(45deg, var(--panel) 0 12px, var(--bg-2) 12px 24px); }
.role-card .back { font-size: 64px; line-height: 1; color: var(--hot); }
.role-card .hint { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 10px; }
.role-card .icon { font-size: 60px; line-height: 1; }
.role-card .name { font-family: var(--display); font-size: 44px; margin: 6px 0; }
.role-card.mafia { border-color: var(--hot); background: color-mix(in srgb, var(--hot) 22%, var(--panel)); }
.role-card.mafia .name { color: #ff6b7d; }
.role-card.town { border-color: var(--mint); }
.role-card.town .name { color: var(--mint); }
.role-card .blurb { margin: 8px 0 0; font-size: 16px; }
.role-card .mates { font-weight: 800; color: var(--sun); margin: 12px 0 0; }
.role-card .notes { margin-top: 14px; text-align: left; background: var(--bg-2); border-radius: 12px; padding: 10px 14px; font-weight: 600; }
.role-card .notes .lbl { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.role-card .notes .bad { color: #ff6b7d; }
.role-card .notes .good { color: var(--mint); }

.targets { display: grid; gap: 10px; }
.target {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: var(--panel);
  color: var(--text);
  border: 2px solid var(--line);
  box-shadow: 0 4px 0 #000a;
  font-size: 20px;
  padding: 16px 18px;
}
.target.chosen { border-color: var(--sun); background: color-mix(in srgb, var(--sun) 20%, var(--panel)); }
.target.skip { justify-content: center; color: var(--muted); }
.target.skip.chosen { color: var(--text); }
.target .tag { font-size: 13px; font-weight: 800; background: var(--hot); color: white; padding: 4px 8px; border-radius: 6px; }
.target .tag.muted { background: none; color: var(--muted); }

.verdict-card { text-align: center; border-radius: 20px; padding: 34px 20px; border: 2px solid; margin-top: 10px; }
.verdict-card .who { font-family: var(--display); font-size: 44px; line-height: 1.05; }
.verdict-card .is { font-weight: 800; font-size: 24px; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.verdict-card.mafia { border-color: var(--hot); background: color-mix(in srgb, var(--hot) 25%, var(--panel)); color: #ffb3bd; }
.verdict-card.town { border-color: var(--mint); background: color-mix(in srgb, var(--mint) 15%, var(--panel)); color: var(--mint); }

.reveal-list { display: grid; gap: 8px; }
.reveal-list .row { background: var(--bg-2); border-radius: 10px; padding: 10px 12px; font-weight: 700; flex-wrap: wrap; }
.reveal-list .row.dead > .grow { text-decoration: line-through; color: var(--muted); }
.role-tag { font-weight: 800; }
.role-tag.mafia { color: #ff6b7d; }
.role-tag.town { color: var(--mint); }

/* ---------- host (TV) ---------- */
.tv { min-height: 100vh; padding: 3vh 4vw; display: flex; flex-direction: column; }
.tv header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3vh; gap: 20px; }
.tv .room-chip { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--line); padding: 8px 18px; border-radius: 99px; font-weight: 700; color: var(--muted); }
.tv .room-chip b { font-family: var(--display); color: var(--sun); font-size: 26px; letter-spacing: 0.15em; font-weight: 400; }
.tv main { flex: 1; display: flex; flex-direction: column; }

.lobby { display: grid; grid-template-columns: 1.1fr 1fr; gap: 4vw; align-items: start; }
.join-card { text-align: center; }
.join-card .how { font-size: 22px; color: var(--muted); }
.join-card .url { font-size: 30px; font-weight: 800; color: var(--text); margin: 6px 0 16px; word-break: break-all; }
.join-card .code { font-family: var(--display); font-size: clamp(80px, 13vw, 180px); line-height: 1; color: var(--text); letter-spacing: 0.12em; text-shadow: 5px 5px 0 var(--hot); }
.join-card .qr { background: white; padding: 12px; border-radius: 14px; display: inline-block; margin-top: 18px; }
.join-card .qr img { display: block; width: 170px; height: 170px; image-rendering: pixelated; }

.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.roster .p { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; font-weight: 800; font-size: 20px; position: relative; display: flex; justify-content: space-between; align-items: center; gap: 8px; animation: pop 0.35s cubic-bezier(.2,1.6,.4,1); }
.roster .p.off { opacity: 0.4; }
.roster .p .vip { font-size: 11px; background: var(--sun); color: #1d1300; padding: 3px 6px; border-radius: 6px; letter-spacing: 0.06em; }
.roster .p .x { background: none; box-shadow: none; color: var(--muted); padding: 2px 6px; font-size: 18px; }
.roster .p.done { border-color: var(--mint); }
.roster .p.done::after { content: "✓"; color: var(--mint); font-size: 22px; }
.roster .empty { color: var(--muted); grid-column: 1 / -1; font-size: 20px; padding: 20px 0; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }

.roster.suspects { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.suspect { animation: none !important; }
.suspect .nm { font-size: 22px; }
.suspect .sub { font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.suspect.dead { opacity: 0.55; }
.suspect.dead .nm { text-decoration: line-through; }
.suspect.mafia { border-color: var(--hot); }
.suspect.mafia .sub { color: #ff6b7d; }
.suspect .tomb { font-size: 26px; color: var(--muted); }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.big-prompt { text-align: center; margin: auto 0; padding: 2vh 0; }
.big-prompt .moon { font-size: clamp(60px, 8vw, 120px); line-height: 1; }
.big-prompt .label { font-size: 24px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; margin-top: 1vh; }
.big-prompt .text { font-family: var(--display); font-size: clamp(44px, 6.5vw, 110px); line-height: 1.04; margin: 2vh auto; max-width: 20ch; }
.big-prompt .sub { font-size: 24px; margin: 0 auto 2vh; max-width: 40ch; }
.big-prompt .victim { color: #ff6b7d; }
.big-prompt .lineup { font-size: 22px; }
.reveal { font-size: clamp(24px, 2.6vw, 38px); font-weight: 800; margin: 0 0 2vh; }
.reveal.mafia { color: #ff6b7d; }
.reveal.town { color: var(--mint); }
.big-timer { font-family: var(--mono); font-size: clamp(40px, 6vw, 80px); color: var(--text); }
.big-timer.low { color: var(--hot); animation: pulse 1s infinite; }

.voted-strip { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 3vh; }
.voted-strip span { background: var(--panel); border: 1px solid var(--line); padding: 10px 16px; border-radius: 99px; font-weight: 800; font-size: 20px; }
.voted-strip span.done { border-color: var(--mint); color: var(--mint); }

.results-layout { display: grid; grid-template-columns: 1.3fr 1fr; gap: 4vw; align-items: center; flex: 1; }
.tally { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; }
.tally b { font-size: 22px; }
.tally .n { font-family: var(--mono); font-size: 22px; color: var(--sun); }
.tally .track { height: 10px; background: var(--bg-2); border-radius: 99px; margin: 8px 0; overflow: hidden; }
.tally .fill { height: 100%; background: var(--sun); border-radius: 99px; transition: width 0.6s; }
.tally.out { border-color: var(--hot); }
.tally.out .fill { background: var(--hot); }
.tally.skip .fill { background: var(--muted); }
.tally .voters { color: var(--muted); font-size: 15px; }

.final { text-align: center; margin: auto; width: min(1000px, 100%); }
.final .crown { font-size: 90px; }
.final .winner { font-family: var(--display); font-size: clamp(56px, 8vw, 130px); line-height: 1; }
.final .winner.town { color: var(--mint); text-shadow: 5px 5px 0 #1d4a30; }
.final .winner.mafia { color: #ff6b7d; text-shadow: 5px 5px 0 var(--hot-dark); }
.final .roster { text-align: left; margin-top: 3vh; }
.tv-actions { display: flex; gap: 14px; justify-content: center; margin-top: 3vh; flex-wrap: wrap; }

@media (max-width: 900px) {
  .lobby, .results-layout { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .ask { font-size: 26px; }
  .role-card .name { font-size: 36px; }
}
