:root {
  color-scheme: dark;
  --bg: #0b0e1c;
  --bg2: #111530;
  --panel: #171c38;
  --panel2: #1f2548;
  --line: #2c3462;
  --text: #eceeff;
  --muted: #9aa3cf;
  --accent: #8b7bff;
  --accent-strong: #6f5cff;
  --focus: #5ad1ff;
  --ok: #3ddc97;
  --warn: #ffb547;
  --bad: #ff5d73;
  --citizen: #4fc3f7;
  --liar: #ff5d73;
  --spy: #c77dff;
  --radius: 14px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .4);
  --font: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(1200px 600px at 10% -10%, #1d1950 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 0%, #0f2a45 0%, transparent 55%), var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  word-break: keep-all;
  overflow-wrap: anywhere;
}
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; margin-top: 1.2em; color: var(--muted); }
p { margin: .4em 0; }
kbd {
  font: 600 .75rem/1 var(--font); padding: .2em .45em; border-radius: 5px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--muted);
}
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; }
.skip-link:focus { left: 8px; background: var(--panel2); color: var(--text); padding: 8px 12px; border-radius: 8px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; font-weight: 400; }
.center { text-align: center; }
.ok-text { color: var(--ok); font-weight: 700; }
.bad-text { color: var(--bad); font-weight: 700; }
.spy-text { color: var(--spy); font-weight: 700; }
.hint { margin: .3em 0 0; font-size: .8rem; color: var(--muted); }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.row > input { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.noscript { padding: 24px; text-align: center; }

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
#app:focus { outline: none; }

/* ---------- 상단 ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  background: rgba(11, 14, 28, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -.02em; }
.logo { font-size: 1.3rem; }
.appbar-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.me-nick { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.conn-banner {
  position: sticky; top: 0; z-index: 30; text-align: center; padding: 8px;
  background: var(--warn); color: #241600; font-weight: 700;
  animation: pulse 1.4s ease-in-out infinite;
}
main { max-width: 1320px; margin: 0 auto; padding: 16px max(12px, env(safe-area-inset-left)) 40px; }
.site-footer { text-align: center; padding: 0 16px 28px; font-size: .8rem; color: var(--muted); }
.site-footer a { color: inherit; }

/* ---------- 버튼·입력 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  font: 600 .95rem/1.2 var(--font); cursor: pointer;
  transition: background .15s, transform .05s, border-color .15s;
}
.btn:hover:not(:disabled) { background: #29305c; border-color: #3c4580; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); border-color: transparent; color: #fff; }
.btn.primary:hover:not(:disabled) { background: linear-gradient(135deg, #9b8dff, #7b6aff); }
.btn.danger { background: #4a1d2a; border-color: #7a2c40; color: #ffd5dc; }
.btn.danger:hover:not(:disabled) { background: #5c2333; }
.btn.ghost { background: transparent; }
.btn.danger-ghost { background: transparent; border-color: #6a2a3a; color: #ff9aaa; }
.btn.big { min-height: 50px; padding: 12px 22px; font-size: 1.05rem; }
.btn.tiny { min-height: 30px; padding: 4px 10px; font-size: .8rem; border-radius: 8px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  font: 700 1rem/1 var(--font); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: #29305c; }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn.off { opacity: .45; text-decoration: line-through; }
input:not([type=range]):not([type=hidden]) {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: 1rem var(--font);
}
input:not([type=range]):focus-visible { border-color: var(--focus); outline-offset: 0; }
input:disabled { opacity: .5; cursor: not-allowed; }
input[type=range] { flex: 1; accent-color: var(--accent); min-height: 32px; }
label { font-weight: 600; font-size: .9rem; }
.form-error { color: var(--bad); font-size: .85rem; min-height: 1.2em; margin: 0; }
output { color: var(--accent); font-weight: 800; margin-left: 6px; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .74rem; font-weight: 700;
  background: #262d55; color: var(--muted); white-space: nowrap;
}
.badge.ok { background: rgba(61, 220, 151, .15); color: var(--ok); }
.badge.warn { background: rgba(255, 181, 71, .15); color: var(--warn); }
.badge.host { background: rgba(255, 210, 90, .15); color: #ffd25a; }
.badge.off { background: rgba(255, 93, 115, .15); color: var(--bad); }
.badge.live { background: var(--accent); color: #fff; animation: pulse 1.2s ease-in-out infinite; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 4px 0; padding: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--line); font-size: .85rem;
}
.chip-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .85rem; padding: 0 2px; }
.chip-x:hover { color: var(--bad); }
.chip-btn {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg2);
  color: var(--muted); font: 600 .85rem var(--font); cursor: pointer;
}
.chip-btn[aria-pressed=true] { background: rgba(139, 123, 255, .2); border-color: var(--accent); color: var(--text); }
.chip-btn:disabled { cursor: not-allowed; }
.count { font-size: .72rem; opacity: .7; font-weight: 500; }
.callout { padding: 10px 14px; border-radius: 10px; background: rgba(139, 123, 255, .14); border: 1px solid rgba(139, 123, 255, .4); margin: 8px 0; font-weight: 700; }
.callout.warn { background: rgba(255, 181, 71, .12); border-color: rgba(255, 181, 71, .45); color: var(--warn); }

/* ---------- 공통 패널 ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel), #141936);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-width: 0;
}
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin-bottom: 2px; }
.center-card {
  max-width: 420px; margin: 8vh auto 0; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px 24px; box-shadow: var(--shadow);
}
.center-card form { text-align: left; margin-top: 18px; }
.hero-logo { font-size: 3.4rem; animation: float 3s ease-in-out infinite; }
.spinner {
  width: 40px; height: 40px; margin: 8px auto; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite;
}
.avatar {
  --h: 250;
  display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: hsl(var(--h) 55% 38%); color: #fff; font-weight: 800;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2);
}
.avatar.empty { background: transparent; border: 2px dashed var(--line); box-shadow: none; }

/* ---------- 로비 ---------- */
.room-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.room-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line);
}
.room-card.playing { opacity: .75; }
.room-info { min-width: 0; }
.room-name { font-weight: 700; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-meta { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .85rem; margin-top: 4px; }
.empty-state { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 48px 16px; border: 2px dashed var(--line); border-radius: var(--radius); }

/* ---------- 대기방 ---------- */
.waiting-layout { display: grid; gap: 14px; }
.waiting-main { display: grid; gap: 14px; align-content: start; min-width: 0; }
.seats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.seat {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px; border-radius: 12px;
  background: var(--bg2); border: 1px solid var(--line); min-height: 64px;
}
.seat.me { border-color: var(--accent); }
.seat.ready { box-shadow: inset 0 0 0 1px rgba(61, 220, 151, .5); }
.seat.off { opacity: .55; }
.seat.empty { justify-content: flex-start; border-style: dashed; background: transparent; }
.seat-info { min-width: 0; flex: 1; }
.seat-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.seat-actions { display: flex; gap: 6px; width: 100%; }
.seat-actions .btn { flex: 1; }
.crown { margin-right: 3px; }
.start-bar { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.start-bar .btn { min-width: 200px; }
.settings .field { margin-bottom: 14px; }
.field-label { font-weight: 700; font-size: .88rem; margin-bottom: 6px; display: block; }
.value { font-weight: 700; color: var(--text); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); }
.seg-btn {
  min-height: 34px; padding: 4px 12px; border-radius: 9px; border: 0; background: transparent;
  color: var(--muted); font: 600 .88rem var(--font); cursor: pointer;
}
.seg-btn[aria-pressed=true] { background: var(--accent); color: #fff; }
.seg-btn:hover:not([aria-pressed=true]) { color: var(--text); }
.stepper { display: flex; align-items: center; gap: 10px; }
.step-val { min-width: 48px; text-align: center; font-weight: 800; font-size: 1.1rem; }

/* ---------- 채팅 ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; }
.log {
  list-style: none; margin: 0 0 10px; padding: 8px; flex: 1;
  height: 300px; overflow-y: auto; background: var(--bg2); border-radius: 10px; border: 1px solid var(--line);
  overscroll-behavior: contain;
}
.log-line { padding: 4px 6px; border-radius: 6px; font-size: .9rem; }
.log-line + .log-line { margin-top: 2px; }
.log-line .who { color: #b9b0ff; margin-right: 2px; }
.log-line.mine .who { color: var(--focus); }
.log-line.system { color: var(--muted); font-size: .82rem; text-align: center; font-style: italic; }
.log-line.description { background: rgba(79, 195, 247, .1); border-left: 3px solid var(--citizen); }
.log-line.defense { background: rgba(255, 181, 71, .1); border-left: 3px solid var(--warn); }
.tag { display: inline-block; font-size: .7rem; font-weight: 800; padding: 0 6px; border-radius: 4px; margin-right: 6px; vertical-align: 1px; }
.description .tag { background: var(--citizen); color: #062233; }
.defense .tag { background: var(--warn); color: #2a1a00; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; }
.chat-reason { margin: 6px 0 0; font-size: .8rem; color: var(--ok); min-height: 1.2em; }
.chat-reason.blocked { color: var(--warn); }

/* ---------- 투표 배너 ---------- */
.poll-banner {
  display: grid; gap: 8px; grid-template-columns: 1fr; align-items: center;
  padding: 12px 16px; margin-bottom: 14px; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 181, 71, .16), rgba(139, 123, 255, .14));
  border: 1px solid rgba(255, 181, 71, .5); animation: slidein .3s ease-out;
}
.poll-info { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.poll-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.poll-count { font-size: .9rem; }
.menu-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.menu-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--bg2); flex-wrap: wrap; }

/* ---------- 타이머 ---------- */
.timer { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.timer-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--bg2); overflow: hidden; border: 1px solid var(--line); }
.timer-bar span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--ok), var(--focus)); transition: width .1s linear; }
.timer-text { font-variant-numeric: tabular-nums; font-weight: 800; min-width: 3.2em; text-align: right; }
.timer.urgent .timer-bar span { background: var(--bad); }
.timer.urgent .timer-text { color: var(--bad); animation: pulse .5s ease-in-out infinite alternate; }

/* ---------- 게임 ---------- */
.topbar {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 10px 14px; margin-bottom: 14px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
}
.tb-left { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.round { font-weight: 800; color: var(--muted); }
.phase-name { font-weight: 800; font-size: 1.15rem; }
.tb-timer { grid-column: 1 / -1; grid-row: 2; }
.tb-right { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.target { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.game-layout { display: grid; gap: 14px; }
.g-main, .g-side { display: grid; gap: 14px; align-content: start; min-width: 0; }
.action { min-height: 200px; }
.action h2 { font-size: 1.25rem; }

.role-chip {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "label word kbd" "label topic kbd";
  gap: 0 12px; align-items: center; width: 100%; text-align: left; cursor: pointer;
  padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: inherit; --rc: var(--muted);
  border-left: 5px solid var(--rc);
}
.role-chip .role-label { grid-area: label; font-weight: 900; font-size: 1.2rem; color: var(--rc); }
.rc-word { grid-area: word; font-weight: 800; font-size: 1.1rem; }
.rc-topic { grid-area: topic; font-size: .8rem; color: var(--muted); }
.role-chip kbd { grid-area: kbd; }
.role-citizen { --rc: var(--citizen); }
.role-liar { --rc: var(--liar); }
.role-spy { --rc: var(--spy); }

.role-card {
  --rc: var(--muted);
  text-align: center; padding: 22px 18px; border-radius: 18px;
  background: radial-gradient(400px 200px at 50% 0%, color-mix(in srgb, var(--rc) 28%, transparent), transparent 70%), var(--bg2);
  border: 2px solid var(--rc);
}
.role-card .role-kicker { color: var(--muted); font-size: .9rem; }
.role-card .role-label { font-size: 2rem; font-weight: 900; color: var(--rc); letter-spacing: -.02em; }
.role-card .role-topic { margin-top: 6px; color: var(--muted); }
.role-card .role-word { font-size: 2rem; font-weight: 900; margin: 8px 0; }
.role-card .role-desc { color: var(--muted); font-size: .9rem; }
.role-card.big .role-label { font-size: 2.8rem; }
.role-card.big .role-word { font-size: 2.6rem; }
.reveal .role-card { animation: flip .8s cubic-bezier(.2, .8, .2, 1.2); }

.waiting-big { text-align: center; padding: 24px 8px; }
.speaker, .accused { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.accused .avatar, .speaker .avatar { width: 52px; height: 52px; font-size: 1.3rem; }
.accused-name { font-size: 1.4rem; font-weight: 900; }
.cur-desc { padding: 10px 14px; margin: 10px 0 14px; border-radius: 10px; background: var(--bg2); border-left: 3px solid var(--citizen); }
.cur-desc p { margin: 2px 0 0; font-size: 1.05rem; font-weight: 600; }
.vote-grid { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.vote-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; text-align: center;
  border-radius: 12px; background: var(--bg2); border: 1px solid var(--line);
}
.vote-card.dim { opacity: .45; }
.vote-card.picked { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(139, 123, 255, .35); }
.vc-name { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-status { font-size: .78rem; }
.voted { color: var(--ok); font-weight: 700; }
.tally { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.tally-line { font-size: 1rem; }
.answer-line { font-size: 1.05rem; }
.answer { color: #ffd25a; font-weight: 900; }

.order { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.order > li { padding: 8px 10px; border-radius: 10px; background: var(--bg2); border: 1px solid transparent; }
.order > li.speaking { border-color: var(--accent); background: rgba(139, 123, 255, .14); }
.order > li.off { opacity: .55; }
.o-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.o-num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--panel2); font-size: .75rem; font-weight: 800; }
.o-name { font-weight: 700; }
.o-descs { list-style: none; margin: 6px 0 0; padding: 0 0 0 30px; display: grid; gap: 3px; font-size: .88rem; }
.lap-tag { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-right: 6px; border-radius: 4px; background: var(--citizen); color: #062233; font-size: .7rem; font-weight: 800; }

.scores { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.scores li { display: grid; grid-template-columns: 24px 1fr auto; grid-template-areas: "rank name score" "rank bar bar"; gap: 2px 8px; align-items: center; padding: 6px 8px; border-radius: 10px; background: var(--bg2); }
.scores li.me { box-shadow: inset 0 0 0 1px var(--accent); }
.scores li.off { opacity: .55; }
.scores .rank { grid-area: rank; font-weight: 900; color: var(--muted); text-align: center; }
.s-name { grid-area: name; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-score { grid-area: score; }
.s-bar { grid-area: bar; height: 4px; border-radius: 999px; background: var(--panel2); overflow: hidden; }
.s-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--focus)); }

.summary { font-size: 1.15rem; font-weight: 800; padding: 12px 14px; border-radius: 12px; background: rgba(139, 123, 255, .14); }
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 12px 0; }
.result-grid > div { padding: 10px 12px; border-radius: 10px; background: var(--bg2); }
.result-grid dt { font-size: .78rem; color: var(--muted); }
.result-grid dd { margin: 2px 0 0; font-weight: 700; }
.deltas { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.deltas li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 6px 10px; border-radius: 8px; background: var(--bg2); }
.delta { min-width: 2.5em; text-align: right; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }

.celebrate { position: relative; overflow: hidden; text-align: center; padding: 20px 10px; border-radius: 16px; background: radial-gradient(400px 200px at 50% 0%, rgba(255, 210, 90, .25), transparent 70%); }
.celebrate .trophy { font-size: 4rem; animation: float 2.4s ease-in-out infinite; }
.celebrate h2 { font-size: 1.8rem; }
.celebrate.me h2 { color: #ffd25a; }
.winners { font-size: 1.1rem; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall 2.8s linear infinite; }
.confetti i:nth-child(4n+1) { background: var(--accent); }
.confetti i:nth-child(4n+2) { background: #ffd25a; }
.confetti i:nth-child(4n+3) { background: var(--ok); }
.confetti i:nth-child(4n) { background: var(--focus); }
.confetti i:nth-child(1) { left: 4%; animation-delay: 0s; }
.confetti i:nth-child(2) { left: 11%; animation-delay: .9s; }
.confetti i:nth-child(3) { left: 18%; animation-delay: .3s; }
.confetti i:nth-child(4) { left: 26%; animation-delay: 1.6s; }
.confetti i:nth-child(5) { left: 33%; animation-delay: .6s; }
.confetti i:nth-child(6) { left: 41%; animation-delay: 2.1s; }
.confetti i:nth-child(7) { left: 48%; animation-delay: 1.1s; }
.confetti i:nth-child(8) { left: 56%; animation-delay: .2s; }
.confetti i:nth-child(9) { left: 63%; animation-delay: 1.9s; }
.confetti i:nth-child(10) { left: 70%; animation-delay: .8s; }
.confetti i:nth-child(11) { left: 77%; animation-delay: 1.4s; }
.confetti i:nth-child(12) { left: 84%; animation-delay: .4s; }
.confetti i:nth-child(13) { left: 90%; animation-delay: 2.4s; }
.confetti i:nth-child(14) { left: 96%; animation-delay: 1.2s; }
.ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ranking li { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--bg2); }
.ranking li.win { background: rgba(255, 210, 90, .14); box-shadow: inset 0 0 0 1px rgba(255, 210, 90, .5); }
.ranking .rank { font-weight: 900; font-size: 1.1rem; text-align: center; }
.last-result { margin-top: 14px; }
.last-result summary { cursor: pointer; font-weight: 700; padding: 6px 0; }

/* ---------- 표 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { color: var(--muted); font-weight: 700; }
tbody th { font-weight: 700; white-space: nowrap; }
.flow { padding-left: 1.2em; display: grid; gap: 6px; }

/* ---------- 모달·토스트 ---------- */
#modal-root { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 12px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 6, 15, .7); backdrop-filter: blur(3px); animation: fade .2s; }
.modal {
  position: relative; width: min(560px, 100%); max-height: calc(100dvh - 24px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  animation: pop .2s ease-out;
}
.modal-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 16px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 1; }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 16px; }
.toasts { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(420px, calc(100% - 24px)); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 12px; background: #262d55; border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 600; animation: slideup .25s ease-out; transition: opacity .4s, transform .4s; }
.toast.error { background: #46192a; border-color: #8a2d45; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- 반응형 ---------- */
@media (min-width: 720px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .tb-timer { grid-column: auto; grid-row: auto; }
  .poll-banner { grid-template-columns: 1fr minmax(140px, 220px) auto auto; }
}
@media (min-width: 900px) {
  .waiting-layout { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
  .waiting-layout .chat { grid-column: 1 / -1; }
  .game-layout { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .game-layout .chat { grid-column: 1 / -1; }
}
@media (min-width: 1200px) {
  .waiting-layout { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); }
  .waiting-layout .chat { grid-column: auto; }
  .game-layout { grid-template-columns: minmax(240px, .8fr) minmax(0, 1.6fr) minmax(280px, 1fr); }
  .game-layout .g-side { grid-column: 1; grid-row: 1; }
  .game-layout .g-main { grid-column: 2; grid-row: 1; }
  .game-layout .chat { grid-column: 3; grid-row: 1; }
  .chat .log { height: auto; min-height: 300px; max-height: calc(100dvh - 260px); }
}
@media (max-width: 420px) {
  main { padding-left: 10px; padding-right: 10px; }
  .panel { padding: 12px; }
  .brand span:last-child { font-size: .95rem; }
  .target { display: none; }
  .role-card.big .role-label { font-size: 2.2rem; }
  .role-card.big .role-word { font-size: 2rem; }
  .start-bar .btn { min-width: 0; width: 100%; }
}

/* ---------- 움직임 ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes float { 50% { transform: translateY(-6px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } }
@keyframes slideup { from { opacity: 0; transform: translateY(8px); } }
@keyframes flip { from { opacity: 0; transform: perspective(800px) rotateY(90deg) scale(.9); } }
@keyframes fall { to { transform: translateY(260px) rotate(540deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
