:root {
  color-scheme: dark;
  --bg: #0b1020;
  --card: rgba(21, 29, 49, 0.9);
  --card-2: rgba(30, 40, 66, 0.85);
  --text: #f4f7ff;
  --muted: #9da9c3;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #8fa8ff;
  --danger: #ff6b73;
  --ok: #7fe0a1;
  --shadow: 0 18px 50px rgba(0,0,0,.26);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); }
body { overflow-x: hidden; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.sky {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  transition: background 800ms ease;
}
.sky-lobby { background: radial-gradient(circle at 50% -10%, #293456, #0b1020 55%); }
.sky-day { background: linear-gradient(#73b6ff 0%, #d9efff 46%, #f5dba8 100%); }
.sky-night { background: radial-gradient(circle at 50% -10%, #24375f, #080d18 58%, #04060c 100%); }
.sun, .moon { position: absolute; left: 50%; top: 9vh; font-size: 74px; transform: translate(-50%, -140px) scale(.7); opacity: 0; transition: all 800ms cubic-bezier(.2,.8,.2,1); filter: drop-shadow(0 8px 28px rgba(0,0,0,.25)); }
.sky-day .sun { transform: translate(-50%, 0) scale(1); opacity: .95; }
.sky-night .moon { transform: translate(-50%, 0) scale(1); opacity: .95; }
.stars { position: absolute; inset: 16vh 0 auto; text-align: center; letter-spacing: 28px; opacity: 0; transition: opacity .8s; color: #d8e4ff; font-size: 22px; }
.sky-night .stars { opacity: .65; }

.app-shell { width: min(100%, 980px); margin: 0 auto; padding: calc(18px + env(safe-area-inset-top)) 16px calc(36px + env(safe-area-inset-bottom)); }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(24px, 6vw, 34px); margin-bottom: 0; }
h2 { font-size: 27px; margin-bottom: 10px; }
h3 { font-size: 20px; margin-bottom: 6px; }
.eyebrow { color: #afbbe0; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 750; margin-bottom: 5px; }
.muted { color: var(--muted); line-height: 1.6; }
.hidden { display: none !important; }
.full { width: 100%; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.login-card { max-width: 540px; margin: 8vh auto 0; padding: 28px; }
.hero-icon { font-size: 54px; margin-bottom: 12px; }
.stack { display: grid; gap: 14px; }
label span { display: block; font-size: 13px; color: #bbc5dc; margin-bottom: 7px; font-weight: 650; }
input { width: 100%; border: 1px solid var(--line); background: #0e1629; color: var(--text); padding: 15px 16px; border-radius: 15px; outline: none; }
input:focus { border-color: rgba(143,168,255,.65); box-shadow: 0 0 0 3px rgba(143,168,255,.12); }

.btn { border: 0; border-radius: 15px; padding: 14px 17px; font-weight: 780; cursor: pointer; color: white; transition: transform .15s ease, opacity .15s ease; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #7f9cff, #665ce9); }
.btn-night { background: linear-gradient(135deg, #2d417b, #1c2857); }
.btn-day { background: linear-gradient(135deg, #f1a744, #dd7e32); }
.btn-danger { background: linear-gradient(135deg, #d95163, #a83242); }
.btn-ghost { background: rgba(255,255,255,.07); border: 1px solid var(--line); margin-top: 16px; }
.status-text { min-height: 24px; color: #ffafb5; margin-top: 10px; font-size: 14px; }
.rule-summary { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.rule-summary span { padding: 6px 9px; border-radius: 999px; background: rgba(255,255,255,.06); color: #b9c4dd; font-size: 12px; }

.phase-badge, .count-pill, .seat-pill { border: 1px solid var(--line); background: rgba(10,16,31,.66); border-radius: 999px; padding: 8px 11px; white-space: nowrap; font-size: 13px; font-weight: 700; }

.role-hero { padding: 26px; text-align: center; position: relative; overflow: hidden; }
.seat-pill { position: absolute; right: 18px; top: 18px; }
.role-emoji { font-size: 68px; margin: 4px 0 10px; }
.phase-card { margin-top: 14px; padding: 18px; display: flex; gap: 16px; align-items: center; }
.phase-visual { font-size: 42px; width: 58px; text-align: center; }
#roleCards { margin-top: 14px; }
.info-card { padding: 20px; }
.info-card p, .info-card li { color: #c8d1e5; line-height: 1.7; }
.info-card ul { margin: 8px 0 0; padding-left: 19px; }
.dead-page .role-hero, .dead-page .phase-card, .dead-page .info-card { filter: grayscale(1); opacity: .55; }

.judge-grid { display: grid; gap: 14px; }
.judge-console, .judge-grid > .card { padding: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.host-prompt { margin-top: 16px; padding: 16px; border-radius: 18px; background: rgba(255,255,255,.055); border: 1px solid var(--line); }
.prompt-title { font-size: 13px; color: #b7c3de; font-weight: 750; margin-bottom: 9px; }
.prompt-body { color: #f2f5ff; line-height: 1.75; white-space: pre-line; }
.phase-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.tiny-note { color: #8d9ab7; font-size: 12px; line-height: 1.55; margin-top: 11px; }
.player-list { display: grid; gap: 10px; margin-top: 14px; }
.player-row { display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; align-items: center; padding: 12px; border-radius: 16px; background: rgba(255,255,255,.045); border: 1px solid var(--line); }
.player-row.dead { opacity: .55; filter: grayscale(1); }
.seat-box { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: rgba(143,168,255,.12); font-weight: 850; }
.player-main strong, .player-main small { display: block; }
.player-main small { color: var(--muted); margin-top: 3px; }
.player-actions { display: grid; grid-template-columns: 1fr; gap: 7px; min-width: 112px; }
.alive-btn, .reveal-btn { padding: 9px 10px; border-radius: 12px; border: 0; font-weight: 750; color: white; cursor: pointer; }
.alive-btn { background: #9a3342; }
.player-row.dead .alive-btn { background: #27754a; }
.reveal-btn { background: rgba(255,255,255,.10); color: #d8dfef; border: 1px solid var(--line); }
.reveal-btn.is-revealed { background: rgba(255,190,73,.16); color: #ffe1a2; border-color: rgba(255,190,73,.35); }
.role-hidden { color: #9aa6be; font-style: italic; }
.empty-state { padding: 24px 10px; text-align: center; color: var(--muted); }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-color: rgba(255,107,115,.2); }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(6px); }
.modal-card { position: relative; width: min(100%, 430px); background: #141c30; border: 1px solid var(--line); border-radius: 25px; padding: 24px; box-shadow: 0 28px 90px rgba(0,0,0,.5); text-align: center; }
.modal-icon { font-size: 50px; margin-bottom: 8px; }
.modal-body { color: #c7d0e3; line-height: 1.7; margin: 10px 0 18px; }
.victim-line { padding: 10px; border-radius: 12px; margin: 7px 0; background: rgba(255,255,255,.055); }

@media (min-width: 760px) {
  .judge-grid { grid-template-columns: 1.05fr .95fr; }
  .danger-zone { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .topbar { align-items: center; }
  .player-row { grid-template-columns: 42px 1fr; }
  .player-actions { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; min-width: 0; }
  .topbar h1 { font-size: 22px; }
  .topbar .eyebrow { display: none; }
  .login-card { margin-top: 4vh; padding: 22px; }
  .danger-zone { align-items: stretch; flex-direction: column; }
  .alive-btn { width: 100%; }
  .reveal-btn { width: 100%; }
}
