/* ══════════════════════════════════════════════════════════
   AI 마피아 — 심야 라운지 테마
   ══════════════════════════════════════════════════════════ */

:root {
  --bg: #070a12;
  --bg-2: #0b101c;
  --panel: #121a2b;
  --panel-2: #182238;
  --panel-3: #0e1626;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #edf1f9;
  --muted: #93a0b8;
  --muted-2: #6c7a93;
  --gold: #f6c453;
  --gold-2: #e9a93c;
  --red: #ef5b64;
  --green: #3ecf8e;
  --blue: #5b8cff;
  --purple: #a78bfa;
  --radius: 20px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Noto Sans KR", "Malgun Gothic", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--gold); }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
::selection { background: rgba(246, 196, 83, 0.28); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* 배경 안개 */
.bg-fog {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(900px 600px at 12% -5%, rgba(64, 88, 160, 0.2), transparent 60%),
    radial-gradient(800px 500px at 95% 8%, rgba(246, 196, 83, 0.07), transparent 60%),
    radial-gradient(1000px 700px at 50% 110%, rgba(80, 40, 90, 0.18), transparent 65%),
    linear-gradient(180deg, #070a12 0%, #080c16 50%, #060810 100%);
}
.bg-fog i {
  position: absolute;
  width: 46vw;
  height: 46vw;
  min-width: 340px;
  min-height: 340px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: fog 26s ease-in-out infinite alternate;
}
.bg-fog i:nth-child(1) { background: #21356b; top: 8%; left: -12%; }
.bg-fog i:nth-child(2) { background: #5c3b2c; top: 42%; right: -18%; animation-delay: -8s; opacity: 0.22; }
.bg-fog i:nth-child(3) { background: #3b2a5c; bottom: -20%; left: 22%; animation-delay: -15s; opacity: 0.28; }
@keyframes fog {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(4%, -5%, 0) scale(1.12); }
}

#app { position: relative; z-index: 1; }

/* ───────────── 공통 ───────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 13px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s;
  white-space: nowrap;
}
.btn:hover { background: #223050; border-color: var(--line-strong); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(160deg, #ffd678, var(--gold-2));
  color: #1c1303;
  border-color: rgba(255, 220, 140, 0.5);
  box-shadow: 0 10px 28px rgba(246, 196, 83, 0.22);
}
.btn.primary:hover { filter: brightness(1.05); background: linear-gradient(160deg, #ffdf95, #f0b44a); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.btn.danger { background: rgba(239, 91, 100, 0.14); border-color: rgba(239, 91, 100, 0.35); color: #ffb3b8; }
.btn.danger:hover { background: rgba(239, 91, 100, 0.22); }
.btn.sm { padding: 7px 12px; border-radius: 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn.xl { padding: 16px 22px; font-size: 16px; border-radius: 16px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.chip.gold { background: rgba(246, 196, 83, 0.12); border-color: rgba(246, 196, 83, 0.3); color: var(--gold); }
.chip.red { background: rgba(239, 91, 100, 0.12); border-color: rgba(239, 91, 100, 0.3); color: #ff9aa1; }
.chip.blue { background: rgba(91, 140, 255, 0.13); border-color: rgba(91, 140, 255, 0.3); color: #a9c0ff; }
.chip.green { background: rgba(62, 207, 142, 0.12); border-color: rgba(62, 207, 142, 0.3); color: #7ce7b7; }
.chip.purple { background: rgba(167, 139, 250, 0.13); border-color: rgba(167, 139, 250, 0.3); color: #c9b6ff; }

.muted { color: var(--muted); }
.tiny { font-size: 11.5px; }

.boot {
  min-height: 70dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
}
.boot-moon { font-size: 44px; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 0.45; transform: scale(0.94); } 50% { opacity: 1; transform: scale(1.04); } }

.noscript { padding: 60px 24px; text-align: center; }

/* ───────────── 상단 바 ───────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(7, 10, 18, 0.74);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: linear-gradient(150deg, #24345a, #0d1322);
  border: 1px solid rgba(246, 196, 83, 0.22);
  box-shadow: inset 0 0 24px rgba(246, 196, 83, 0.1);
}
.brand-name { font-weight: 900; font-size: 16px; letter-spacing: -0.03em; line-height: 1.1; }
.brand-name small { display: block; font-size: 9px; font-weight: 700; letter-spacing: 0.18em; color: var(--muted-2); margin-top: 2px; }
.topbar .spacer { flex: 1; }
.phase-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 700;
}
.phase-pill.night { background: rgba(91, 140, 255, 0.1); border-color: rgba(91, 140, 255, 0.3); color: #b9cbff; }
.phase-pill.day { background: rgba(246, 196, 83, 0.1); border-color: rgba(246, 196, 83, 0.28); color: var(--gold); }
.topbar .icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
}
.topbar .icon-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.conn-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(62, 207, 142, 0.8); }
.conn-dot.sim { background: var(--gold); box-shadow: 0 0 8px rgba(246, 196, 83, 0.8); }

/* ───────────── 로비 ───────────── */

.lobby {
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 24px 96px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 44px;
  align-items: start;
}
.lobby-hero { padding-top: 24px; position: sticky; top: 96px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--gold);
  text-transform: uppercase;
}
.eyebrow::before { content: ""; width: 18px; height: 1px; background: var(--gold); opacity: 0.7; }
.lobby-hero h1 {
  margin: 18px 0 16px;
  font-size: clamp(44px, 6.4vw, 76px);
  line-height: 0.98;
  letter-spacing: -0.055em;
  font-weight: 900;
  background: linear-gradient(180deg, #ffffff 10%, #b9c6e0 60%, #7d8cab 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lobby-hero h1 .moon {
  display: inline-block;
  font-size: 0.72em;
  -webkit-text-fill-color: initial;
  filter: drop-shadow(0 6px 24px rgba(246, 196, 83, 0.3));
  animation: hover 5s ease-in-out infinite;
}
@keyframes hover { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-7px) rotate(3deg); } }
.lede { font-size: 15.5px; line-height: 1.75; color: #aab6cc; max-width: 470px; }
.lede b { color: #e8edf8; font-weight: 700; }

.hero-chat { margin-top: 34px; display: flex; flex-direction: column; gap: 10px; max-width: 440px; }
.hero-chat .hc {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  opacity: 0;
  animation: rise 0.7s ease forwards;
}
.hero-chat .hc:nth-child(1) { animation-delay: 0.15s; }
.hero-chat .hc:nth-child(2) { animation-delay: 0.55s; margin-left: 34px; }
.hero-chat .hc:nth-child(3) { animation-delay: 0.95s; }
.hero-chat .hc:nth-child(4) { animation-delay: 1.35s; margin-left: 20px; }
.hc-av { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: #182238; border: 1px solid var(--line); font-size: 17px; flex: none; }
.hc-bubble { background: #141d2f; border: 1px solid var(--line); padding: 9px 13px; border-radius: 4px 14px 14px 14px; font-size: 13.5px; color: #cdd7e9; line-height: 1.5; }
.hc-bubble b { color: var(--gold); font-weight: 700; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.hero-stats { margin-top: 30px; display: flex; flex-wrap: wrap; gap: 18px; }
.hero-stat { display: flex; flex-direction: column; gap: 2px; }
.hero-stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
.hero-stat span { font-size: 11px; color: var(--muted-2); letter-spacing: 0.04em; }

/* 설정 패널 */
.panel {
  background: linear-gradient(180deg, rgba(24, 34, 56, 0.92), rgba(13, 19, 32, 0.96));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.setup { padding: 24px; }
.setup-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.setup-head h2 { font-size: 19px; letter-spacing: -0.03em; }
.setup-head p { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field { margin-top: 24px; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.label-row label { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.label-row .hint { font-size: 11px; color: var(--muted-2); }

.seg { display: flex; gap: 5px; padding: 4px; background: #0a101c; border: 1px solid var(--line); border-radius: 13px; }
.seg button { flex: 1; padding: 9px 6px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--muted); transition: 0.16s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: linear-gradient(160deg, #ffd678, var(--gold-2)); color: #1c1303; box-shadow: 0 4px 14px rgba(246, 196, 83, 0.2); }

.range-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--gold); height: 4px; }
.range-row output { min-width: 70px; text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.role-list { display: flex; flex-direction: column; gap: 6px; }
.role-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.022);
  border: 1px solid transparent;
}
.role-row.active { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.06); }
.role-row.auto { background: transparent; }
.r-emoji { font-size: 17px; width: 24px; text-align: center; flex: none; }
.r-main { min-width: 0; flex: 1; }
.r-main b { font-size: 13px; font-weight: 700; display: block; line-height: 1.3; }
.r-main small { font-size: 10.5px; color: var(--muted-2); display: block; }
.stepper { display: flex; align-items: center; gap: 2px; flex: none; }
.stepper button {
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: #1a2438;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
  line-height: 1;
  display: grid;
  place-items: center;
}
.stepper button:hover:not(:disabled) { background: #243252; color: var(--text); }
.stepper button:disabled { opacity: 0.3; cursor: not-allowed; }
.stepper .num { min-width: 24px; text-align: center; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stepper .num.zero { color: var(--muted-2); }
.role-row .lock { font-size: 10px; color: var(--muted-2); padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; }

.myroles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.myrole {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px;
  border-radius: 11px;
  background: #0b1220;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  transition: 0.15s;
}
.myrole span:first-child { font-size: 16px; }
.myrole:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); }
.myrole.on { background: rgba(246, 196, 83, 0.1); border-color: rgba(246, 196, 83, 0.5); color: var(--gold); }
.myrole:disabled { opacity: 0.28; cursor: not-allowed; }

.cast-head { display: flex; align-items: center; justify-content: space-between; }
.cast { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cast-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.04);
  min-width: 0;
}
.cast-card .cc-av { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: #182238; font-size: 14px; flex: none; }
.cast-card .cc-main { min-width: 0; }
.cast-card b { display: block; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cast-card small { display: block; font-size: 9.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.setup-summary { margin-top: 20px; padding: 12px 14px; border-radius: 13px; background: rgba(246, 196, 83, 0.05); border: 1px solid rgba(246, 196, 83, 0.16); font-size: 12px; color: #d8c79e; line-height: 1.6; }
.setup-summary.err { background: rgba(239, 91, 100, 0.07); border-color: rgba(239, 91, 100, 0.3); color: #ffb3b8; }
.setup .start { margin-top: 14px; }
.resume {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(91, 140, 255, 0.08);
  border: 1px solid rgba(91, 140, 255, 0.25);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
}
.resume .grow { flex: 1; min-width: 0; }
.resume b { display: block; font-size: 13px; }

/* ───────────── 게임 화면 ───────────── */

.game > * { min-width: 0; }
.game {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 20px 0;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 330px;
  gap: 16px;
  height: calc(100dvh - 63px);
  align-items: stretch;
}

.roster { min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.roster-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px; }
.roster-head h2 { font-size: 11px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; }
.roster-head span { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.roster-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; padding: 2px; min-height: 0; }
.roster-list::-webkit-scrollbar { width: 4px; }
.roster-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 4px; }

.pl {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid transparent;
  width: 100%;
  text-align: left;
  color: inherit;
  transition: 0.16s;
}
.pl:hover { background: rgba(255, 255, 255, 0.05); }
.pl.me { border-color: rgba(246, 196, 83, 0.34); background: rgba(246, 196, 83, 0.06); }
.pl.dead { opacity: 0.45; }
.pl.speaking { border-color: rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.07); }
.pl-av { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; background: #1a2540; flex: none; position: relative; }
.pl-av .x { position: absolute; right: -3px; bottom: -3px; font-size: 11px; background: #0b101c; border-radius: 50%; padding: 1px; }
.pl-main { min-width: 0; flex: 1; }
.pl-main b { display: block; font-size: 12.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-main small { display: block; font-size: 9.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.pl-meta .chip { font-size: 8.5px; padding: 2px 6px; }
.pl-votes { font-size: 10px; font-weight: 800; color: var(--gold); background: rgba(246, 196, 83, 0.12); border-radius: 999px; padding: 1px 6px; }

.table {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.82), rgba(10, 15, 26, 0.92));
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.table-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}
.table-head .th-title { font-size: 13px; font-weight: 800; }
.table-head .th-sub { font-size: 11px; color: var(--muted-2); }
.table-head .spacer { flex: 1; }
.ai-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--muted-2); padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; }
.ai-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.ai-badge.sim .dot { background: var(--gold); }

.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 22px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.chat::-webkit-scrollbar { width: 6px; }
.chat::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 6px; }

.msg { display: flex; gap: 9px; max-width: min(620px, 92%); animation: msgIn 0.26s ease both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg .av { width: 35px; height: 35px; border-radius: 11px; background: #1a2540; display: grid; place-items: center; font-size: 17px; flex: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05); }
.msg .body { min-width: 0; }
.msg .who { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 11px; color: var(--muted-2); }
.msg .who b { color: #d6e0f2; font-size: 12px; font-weight: 700; }
.msg .who .ptag { font-size: 9.5px; color: var(--muted-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 999px; }
.bubble {
  background: #172034;
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 9px 13px;
  border-radius: 4px 14px 14px 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e4eaf5;
}
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.me .who { justify-content: flex-end; }
.msg.me .bubble {
  background: linear-gradient(160deg, #ffd678, #eaa93c);
  border-color: rgba(255, 230, 170, 0.4);
  color: #1d1404;
  border-radius: 14px 4px 14px 14px;
  font-weight: 600;
}
.msg.me .av { background: #3a2f15; }

.typing .bubble { display: inline-flex; gap: 4px; align-items: center; min-height: 38px; padding: 12px 14px; }
.typing .bubble i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: dot 1.1s infinite; }
.typing .bubble i:nth-child(2) { animation-delay: 0.15s; }
.typing .bubble i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.sys {
  align-self: center;
  max-width: 92%;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  padding: 7px 14px;
  border-radius: 999px;
  white-space: pre-wrap;
}
.sys.day { border-radius: 13px; background: rgba(91, 140, 255, 0.08); border-color: rgba(91, 140, 255, 0.22); color: #c2d1ff; font-size: 12.5px; }
.sys.death { border-radius: 13px; background: rgba(239, 91, 100, 0.08); border-color: rgba(239, 91, 100, 0.28); color: #ffb0b6; font-size: 12.5px; }
.sys.good { border-radius: 13px; background: rgba(62, 207, 142, 0.08); border-color: rgba(62, 207, 142, 0.25); color: #9fe9c8; }
.sys.gold { border-radius: 13px; background: rgba(246, 196, 83, 0.07); border-color: rgba(246, 196, 83, 0.22); color: #f0d79a; }
.sys b { color: inherit; }

.vote-card {
  align-self: center;
  width: min(560px, 100%);
  background: #101827;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  animation: msgIn 0.3s ease both;
}
.vote-card h4 { font-size: 12px; letter-spacing: 0.06em; color: var(--gold); margin-bottom: 10px; text-transform: uppercase; }
.vote-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 4px 0; }
.vote-row .from { color: var(--muted); min-width: 76px; }
.vote-row .arrow { color: var(--muted-2); }
.vote-row .to { font-weight: 700; }
.vote-row .why { margin-left: auto; color: var(--muted-2); font-size: 11px; text-align: right; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tally { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 7px; }
.tally-row { display: grid; grid-template-columns: 78px 1fr 28px; align-items: center; gap: 8px; font-size: 11.5px; }
.tally-row .bar { height: 7px; border-radius: 4px; background: #1a2438; overflow: hidden; }
.tally-row .bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #f6c453, #e07a3f); transition: width 0.6s cubic-bezier(0.2, 0.9, 0.2, 1); }
.tally-row .n { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--gold); }
.tally-row.me .bar i { background: linear-gradient(90deg, #6f9bff, #a78bfa); }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(9, 13, 23, 0.94);
}
.composer input {
  flex: 1;
  min-width: 0;
  background: #0b1220;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 15px;
  font-size: 14px;
  outline: 0;
}
.composer input:focus { border-color: rgba(246, 196, 83, 0.5); box-shadow: 0 0 0 3px rgba(246, 196, 83, 0.08); }
.composer input:disabled { opacity: 0.55; }
.composer .send {
  width: 47px;
  height: 47px;
  border-radius: 14px;
  background: linear-gradient(160deg, #ffd678, #e9a93c);
  color: #1c1303;
  font-size: 18px;
  display: grid;
  place-items: center;
  flex: none;
  transition: 0.15s;
}
.composer .send:disabled { opacity: 0.35; }
.composer .send:not(:disabled):hover { filter: brightness(1.06); }
.composer-hint { padding: 0 16px 10px; font-size: 11px; color: var(--muted-2); background: rgba(9, 13, 23, 0.94); }

/* 사이드 액션 패널 */
.side { min-height: 0; min-width: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; }
.side::-webkit-scrollbar { width: 4px; }
.side::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }
.side-card { background: linear-gradient(180deg, rgba(24, 34, 56, 0.94), rgba(13, 19, 32, 0.97)); border: 1px solid var(--line); border-radius: 20px; padding: 18px; }
.phase-kicker { font-size: 10px; font-weight: 800; letter-spacing: 0.16em; color: var(--muted-2); text-transform: uppercase; }
.side-card h3 { font-size: 18px; letter-spacing: -0.03em; margin-top: 6px; line-height: 1.3; }
.side-card p.desc { font-size: 12.5px; line-height: 1.65; color: var(--muted); margin-top: 7px; }
.steps { display: flex; gap: 4px; margin: 14px 0 2px; }
.steps span { flex: 1; height: 3px; border-radius: 2px; background: #1a2438; transition: 0.3s; }
.steps span.on { background: var(--gold); box-shadow: 0 0 8px rgba(246, 196, 83, 0.4); }
.steps span.done { background: #4a5b80; }
.targets { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 13px 0; }
.target {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px;
  border-radius: 11px;
  background: #0d1524;
  border: 1px solid var(--line);
  color: inherit;
  font-size: 11.5px;
  text-align: left;
  transition: 0.14s;
  min-width: 0;
}
.target:hover:not(:disabled) { border-color: var(--line-strong); background: #131e32; }
.target.on { border-color: rgba(246, 196, 83, 0.7); background: rgba(246, 196, 83, 0.1); box-shadow: 0 0 0 1px rgba(246, 196, 83, 0.2); }
.target:disabled { opacity: 0.3; cursor: not-allowed; }
.target .t-av { font-size: 15px; }
.target .t-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.side-actions { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.side-note { margin-top: 12px; font-size: 11px; color: var(--muted-2); line-height: 1.6; }
.side-card.highlight { border-color: rgba(246, 196, 83, 0.3); box-shadow: 0 0 40px rgba(246, 196, 83, 0.06); }
.side-card.dark { background: #0b1220; }
.mini-role { display: flex; align-items: center; gap: 9px; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.mini-role .mr-emoji { font-size: 22px; }
.mini-role b { font-size: 13px; display: block; }
.mini-role small { font-size: 10.5px; color: var(--muted-2); display: block; line-height: 1.4; }

.side-log { display: flex; flex-direction: column; gap: 6px; }
.side-log div { font-size: 11.5px; color: var(--muted); display: flex; gap: 7px; }
.side-log b { color: #c8d3e7; font-weight: 700; }

/* 모바일 빠른 액션 */
.fab { display: none; }
@media (max-width: 960px) {
  .fab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    right: 14px;
    bottom: calc(84px + env(safe-area-inset-bottom));
    z-index: 35;
    padding: 11px 16px;
    border-radius: 999px;
    background: linear-gradient(160deg, #ffd678, #e9a93c);
    color: #1c1303;
    font-size: 13px;
    font-weight: 800;
    border: 1px solid rgba(255, 230, 170, 0.55);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), 0 0 24px rgba(246, 196, 83, 0.2);
  }
  .fab[hidden] { display: none; }
}

/* ───────────── 결과 화면 ───────────── */

.over { max-width: 980px; margin: 0 auto; padding: 32px 22px 90px; }
.result {
  text-align: center;
  padding: 38px 22px 34px;
  border-radius: 26px;
  position: relative;
  overflow: hidden;
}
.result::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 240px at 50% 0%, rgba(246, 196, 83, 0.16), transparent 70%);
  pointer-events: none;
}
.result.win { background: linear-gradient(180deg, rgba(21, 46, 40, 0.9), rgba(10, 18, 18, 0.96)); border: 1px solid rgba(62, 207, 142, 0.28); }
.result.lose { background: linear-gradient(180deg, rgba(48, 22, 30, 0.9), rgba(18, 10, 14, 0.96)); border: 1px solid rgba(239, 91, 100, 0.3); }
.result .r-emoji { font-size: 48px; line-height: 1; }
.result h1 { font-size: clamp(30px, 6vw, 46px); letter-spacing: -0.04em; margin: 12px 0 8px; }
.result.win h1 { color: #8ff0c6; }
.result.lose h1 { color: #ff9fa6; }
.result p { color: #b9c7dd; font-size: 13.5px; line-height: 1.7; max-width: 520px; margin: 0 auto; }
.result .tags { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

.tabs { display: flex; gap: 5px; overflow-x: auto; margin: 24px 0 14px; padding-bottom: 2px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 8px 14px; border-radius: 999px; background: #111a2b; border: 1px solid var(--line); color: var(--muted); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.tab.on { background: linear-gradient(160deg, #ffd678, #e9a93c); color: #1c1303; border-color: transparent; }
.tabbody { background: rgba(16, 24, 39, 0.85); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.reveal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rv-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.rv-card.dead { opacity: 0.62; }
.rv-av { width: 36px; height: 36px; border-radius: 11px; background: #1a2540; display: grid; place-items: center; font-size: 18px; flex: none; }
.rv-main { min-width: 0; flex: 1; }
.rv-main b { display: block; font-size: 12.5px; }
.rv-main small { display: block; font-size: 10px; color: var(--muted-2); }
.rv-role { font-size: 10.5px; font-weight: 800; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.rv-role.mafia { background: rgba(239, 91, 100, 0.14); color: #ff9aa1; border: 1px solid rgba(239, 91, 100, 0.3); }
.rv-role.citizen { background: rgba(91, 140, 255, 0.12); color: #a9c0ff; border: 1px solid rgba(91, 140, 255, 0.26); }
.night-card { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.night-card:last-child { border-bottom: 0; }
.night-card h4 { font-size: 12px; color: var(--gold); margin-bottom: 6px; }
.night-line { font-size: 12px; color: #c4d0e4; line-height: 1.75; }
.night-line em { color: var(--muted-2); font-style: normal; }
.inner-list { display: flex; flex-direction: column; gap: 10px; }
.inner-item { display: flex; gap: 9px; align-items: flex-start; }
.inner-item .av { width: 30px; height: 30px; border-radius: 9px; background: #1a2540; display: grid; place-items: center; font-size: 15px; flex: none; }
.inner-item .txt { font-size: 12.5px; color: #ccd7ea; line-height: 1.6; }
.inner-item .txt b { color: var(--gold); font-size: 11px; display: block; margin-bottom: 2px; }
.timeline { display: flex; flex-direction: column; gap: 5px; }
.timeline div { font-size: 12px; color: var(--muted); display: flex; gap: 8px; }
.timeline .d { color: var(--gold); font-weight: 800; min-width: 42px; font-variant-numeric: tabular-nums; }
.over-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: center; flex-wrap: wrap; }
.over-stats { display: flex; justify-content: center; gap: 26px; margin-top: 20px; }
.over-stats div { text-align: center; }
.over-stats b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.over-stats span { font-size: 10.5px; color: var(--muted-2); letter-spacing: 0.05em; }

/* ───────────── 모달 ───────────── */

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  background: rgba(3, 6, 12, 0.74);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(560px, calc(100vw - 40px));
  max-width: 560px;
  min-width: 0;
  max-height: 90dvh;
  overflow-y: auto;
  background: linear-gradient(180deg, #182238 0%, #0e1424 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 26px;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.72);
  animation: pop 0.28s cubic-bezier(0.2, 0.9, 0.2, 1);
  position: relative;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
.modal h2 { font-size: 22px; letter-spacing: -0.03em; }
.modal .sub { font-size: 12.5px; color: var(--muted); line-height: 1.65; margin-top: 6px; }
.modal .foot { display: flex; gap: 8px; margin-top: 20px; }
.modal .foot .grow { flex: 1; }
.modal-x { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 9px; color: var(--muted); font-size: 16px; display: grid; place-items: center; }
.modal-x:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }

.role-reveal { text-align: center; padding: 6px 0; }
.role-reveal .rr-emoji { font-size: 64px; line-height: 1; filter: drop-shadow(0 10px 30px rgba(246, 196, 83, 0.25)); animation: pop 0.5s ease both; }
.role-reveal h2 { margin-top: 12px; font-size: 28px; }
.role-reveal .rr-team { margin-top: 6px; }
.role-reveal .rr-desc { margin-top: 14px; font-size: 13px; color: #b7c4da; line-height: 1.7; text-align: left; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); border-radius: 13px; padding: 12px 14px; }
.role-reveal .rr-tips { margin-top: 10px; text-align: left; display: flex; flex-direction: column; gap: 5px; }
.role-reveal .rr-tips li { font-size: 12px; color: var(--muted); padding-left: 14px; position: relative; }
.role-reveal .rr-tips li::before { content: "·"; position: absolute; left: 3px; color: var(--gold); }

.night-modal { background: linear-gradient(180deg, #101a33 0%, #0a0f1e 100%); overflow: hidden; }
.night-modal::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(400px 200px at 80% -10%, rgba(91, 140, 255, 0.22), transparent 70%),
    radial-gradient(300px 160px at 10% 10%, rgba(167, 139, 250, 0.12), transparent 70%);
  pointer-events: none;
}
.night-modal > * { position: relative; }
.night-modal .moonline { font-size: 34px; }
.night-modal h2 { margin-top: 8px; }
.target-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin: 16px 0; }
.target-grid .target { padding: 10px; font-size: 12.5px; }
.target-note { font-size: 11.5px; color: var(--muted-2); line-height: 1.6; }
.suggestion {
  margin: 12px 0;
  padding: 11px 13px;
  border-radius: 12px;
  background: rgba(239, 91, 100, 0.08);
  border: 1px solid rgba(239, 91, 100, 0.24);
  font-size: 12.5px;
  color: #ffc4c8;
  line-height: 1.55;
}
.suggestion b { color: #ff9aa1; }
.invest-result {
  margin: 16px 0;
  padding: 20px;
  border-radius: 16px;
  text-align: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  animation: pop 0.4s ease both;
}
.invest-result.mafia { background: rgba(239, 91, 100, 0.1); border-color: rgba(239, 91, 100, 0.4); }
.invest-result.clean { background: rgba(62, 207, 142, 0.08); border-color: rgba(62, 207, 142, 0.35); }
.invest-result .ir-emoji { font-size: 34px; }
.invest-result b { display: block; font-size: 17px; margin-top: 6px; }
.invest-result small { font-size: 12px; color: var(--muted); }

.rules-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 14px; }
.rule-role { display: flex; gap: 9px; padding: 9px; border-radius: 11px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.rule-role .e { font-size: 18px; }
.rule-role b { display: block; font-size: 12px; }
.rule-role small { display: block; font-size: 10px; color: var(--muted-2); line-height: 1.45; }
.rule-list { margin-top: 14px; display: flex; flex-direction: column; gap: 7px; }
.rule-list li { font-size: 12px; color: var(--muted); line-height: 1.6; padding-left: 16px; position: relative; }
.rule-list li::before { content: "→"; position: absolute; left: 0; color: var(--gold); font-size: 10px; top: 3px; }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-of-type { border-bottom: 0; }
.setting-row b { font-size: 13px; display: block; }
.setting-row small { font-size: 11px; color: var(--muted-2); display: block; margin-top: 2px; line-height: 1.5; }
.key-input { width: 100%; background: #0b1220; border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; font-size: 13px; outline: 0; margin-top: 10px; }
.key-input:focus { border-color: rgba(246, 196, 83, 0.5); }
.status-line { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); margin-top: 10px; }
.status-line .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.status-line .dot.off { background: var(--muted-2); }

/* 토스트 */
#toast-root { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #1b2740; border: 1px solid var(--line-strong); padding: 10px 16px; border-radius: 999px; font-size: 12.5px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); animation: toastIn 0.25s ease both; max-width: 90vw; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ───────────── 반응형 ───────────── */

@media (max-width: 1180px) {
  .game { grid-template-columns: 220px minmax(0, 1fr) 300px; gap: 12px; }
}

@media (max-width: 1080px) {
  .lobby { grid-template-columns: 1fr; gap: 24px; padding-top: 20px; }
  .lobby-hero { position: static; padding-top: 0; }
  .lobby-hero h1 { font-size: clamp(38px, 9vw, 58px); }
  .hero-chat { display: none; }
  .hero-stats { margin-top: 20px; }
}

@media (max-width: 960px) {
  .game {
    grid-template-columns: 1fr;
    height: auto;
    padding: 10px 12px 0;
    gap: 10px;
  }
  .roster { order: 0; }
  .roster-head { display: none; }
  .roster-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 6px;
    padding: 2px 2px 6px;
    scrollbar-width: none;
  }
  .roster-list::-webkit-scrollbar { display: none; }
  .pl { width: auto; flex: none; padding: 6px 8px; }
  .pl-main small { display: none; }
  .pl-meta { flex-direction: row; align-items: center; }
  .pl-main b { font-size: 11.5px; max-width: 74px; }
  .side { order: 1; overflow: visible; gap: 8px; }
  .side-card.dark { display: none; }
  .side-card { padding: 15px 16px; }
  .side-card h3 { font-size: 17px; }
  .side-card p.desc { font-size: 12px; margin-top: 5px; }
  .side-card .steps { margin: 10px 0 0; }
  .table { order: 2; min-height: 62vh; scroll-margin-top: 66px; }
  .chat { overflow: visible; max-height: none; padding: 16px 14px 8px; gap: 12px; }
  .game { min-height: 100dvh; }
  .composer { position: sticky; bottom: 0; z-index: 20; backdrop-filter: blur(12px); }
  .composer-hint { position: sticky; bottom: 0; z-index: 19; }
  .side-card { padding: 14px 15px; }
  .side-card h3 { font-size: 16.5px; }
  .targets { margin: 10px 0; }
  .steps { margin: 10px 0 0; }
  .side-note { display: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand-name small { display: none; }
  .brand-mark { width: 34px; height: 34px; font-size: 18px; }
  .brand-name { font-size: 14.5px; }
  .phase-pill { padding: 6px 10px; font-size: 11.5px; }
  .phase-pill .label { display: none; }
  .topbar .icon-btn { width: 34px; height: 34px; font-size: 15px; }
  .topbar .icon-btn.rules { display: none; }
  .topbar { gap: 5px; }
  .lobby { padding: 22px 14px 80px; }
  .lede { font-size: 14px; }
  .setup { padding: 18px; border-radius: 20px; }
  .myroles { grid-template-columns: repeat(4, 1fr); }
  .cast { grid-template-columns: 1fr 1fr; }
  .chat { padding: 14px 12px 6px; }
  .msg { max-width: 96%; }
  .bubble { font-size: 13.5px; }
  .modal { width: 100vw; max-width: 100vw; border-radius: 22px 22px 0 0; max-height: 94dvh; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
  .modal-back { padding: 0; align-items: end; }
  .modal .foot .btn { flex: 1; }
  .rules-roles { grid-template-columns: 1fr; }
  .reveal-grid { grid-template-columns: 1fr; }
  .result h1 { font-size: 30px; }
  .over { padding: 22px 12px 80px; }
  .result { padding: 30px 16px 26px; }
  .tabs { margin-top: 18px; }
  .side-card { border-radius: 17px; }
  .targets { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 380px) {
  .myroles { grid-template-columns: repeat(3, 1fr); }
  .targets { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
