:root {
  --bg: #0d0e14;
  --card: #191b24;
  --line: #2a2d3a;
  --field: #10121a;
  --text: #e8e9ee;
  --muted: #9aa0b0;
  --accent: #b23a48;
  --accent2: #2a2d3a;
  --good: #3ecf8e;
  --bad: #ff6b6b;
  --gold: #e9c46a;
  --night: #6c7bff;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
#app { max-width: 420px; margin: 0 auto; min-height: 100vh; padding: 16px; display: flex; flex-direction: column; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.muted { color: var(--muted); font-size: 14px; }
.h { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
input { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--field); color: var(--text); font-size: 16px; margin: 6px 0; }
button { width: 100%; padding: 13px; border-radius: 10px; border: 0; background: var(--accent); color: #fff; font-size: 16px; font-weight: 600; margin-top: 10px; cursor: pointer; }
button.sec { background: var(--accent2); color: var(--text); }
button:disabled { opacity: .4; cursor: not-allowed; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.opt { padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--field); color: var(--text); font-weight: 500; font-size: 15px; cursor: pointer; text-align: center; }
.opt.sel { border-color: var(--accent); background: rgba(178, 58, 72, .18); }
.opt:disabled { opacity: .35; cursor: not-allowed; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.av { width: 30px; height: 30px; border-radius: 50%; background: var(--accent2); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex: none; }
.right { margin-left: auto; text-align: right; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.brand { font-weight: 700; }
.err { color: var(--bad); font-size: 14px; min-height: 18px; margin-top: 8px; }
.code { font-size: 32px; font-weight: 800; letter-spacing: .1em; text-align: center; margin: 6px 0; }
.hero { text-align: center; padding: 18px 0 2px; }
.moon { font-size: 64px; line-height: 1; display: inline-block; filter: drop-shadow(0 0 22px rgba(108, 123, 255, .55)); }
.top .moon { font-size: 18px; filter: none; vertical-align: -2px; }
.dead { opacity: .45; text-decoration: line-through; }
.tiers { display: flex; gap: 8px; margin-top: 6px; }
.tier { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--field); color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer; }
.tier.sel { border-color: var(--night); background: rgba(108,123,255,.15); color: #aeb6ff; }
.qr-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 50; }
.qr-box { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px 20px; text-align: center; max-width: 320px; width: 90%; }
.qr-box img { display: block; margin: 12px auto; border-radius: 10px; background: #fff; padding: 8px; }
.qr-close { margin-top: 14px; background: var(--accent2); color: var(--text); font-size: 14px; padding: 10px; }
.edit-name-btn { width: auto; padding: 4px 9px; font-size: 13px; margin: 0 0 0 auto; margin-top: 0; background: transparent; color: var(--muted); border: 1px solid var(--line); }
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: rgba(60,60,80,.95); border: 1px solid var(--night); color: var(--text); padding: 10px 20px; border-radius: 20px; font-size: 14px; font-weight: 600; z-index: 200; pointer-events: none; transition: opacity .5s; white-space: nowrap; }
@keyframes spin { to { transform: rotate(360deg); } }
#spin { animation: spin 1s linear infinite; }

/* Role reveal */
.role-card { position: relative; background: var(--field); border: 1px solid var(--line); border-radius: 16px; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 14px 0; user-select: none; -webkit-user-select: none; cursor: pointer; overflow: hidden; }
.role-hidden { text-align: center; color: var(--muted); }
.role-hidden .peek { font-size: 44px; }
.role-shown { text-align: center; }
.role-shown .role-icon { font-size: 54px; }
.role-shown .role-name { font-size: 26px; font-weight: 800; margin-top: 6px; }
.role-shown .role-desc { color: var(--muted); font-size: 14px; margin: 8px 14px 0; }
.role-mafia .role-name { color: var(--bad); }
.role-detective .role-name { color: var(--night); }
.role-doctor .role-name { color: var(--good); }
.role-villager .role-name { color: var(--gold); }

/* Night */
.night-banner { text-align: center; padding: 20px 0 8px; }
.night-banner .nb-moon { font-size: 46px; display: inline-block; filter: drop-shadow(0 0 18px rgba(108, 123, 255, .6)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* Dawn / verdict */
.dawn { border-radius: 12px; padding: 14px; margin: 12px 0; text-align: center; font-size: 15px; }
.dawn.death { background: rgba(255,107,107,.1); border: 1px solid rgba(255,107,107,.4); }
.dawn.safe { background: rgba(62,207,142,.1); border: 1px solid rgba(62,207,142,.4); }
.timer { font-size: 40px; font-weight: 800; text-align: center; letter-spacing: .05em; margin: 8px 0; font-variant-numeric: tabular-nums; }
.role-tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; border-radius: 6px; padding: 2px 7px; margin-left: 6px; }
.rt-mafia { background: rgba(255,107,107,.15); color: var(--bad); }
.rt-detective { background: rgba(108,123,255,.15); color: #aeb6ff; }
.rt-doctor { background: rgba(62,207,142,.15); color: var(--good); }
.rt-villager { background: rgba(233,196,106,.15); color: var(--gold); }
.win-banner { text-align: center; font-size: 26px; font-weight: 800; margin: 14px 0 6px; }
.confetti { position: fixed; top: -16px; width: 9px; height: 14px; border-radius: 2px; z-index: 60; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(620deg); } }
