:root {
  --bg: #0b1120;
  --bg-soft: #0f172a;
  --card: #1e293b;
  --card-2: #273449;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #a78bfa;
  --good: #34d399;
  --bad: #fb7185;
  --warn: #fbbf24;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background:
    radial-gradient(1200px 600px at 20% -10%, #1e293b 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 0%, #172554 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
    "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* Top bar */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: rgba(11, 17, 32, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
#topTitle { margin: 0; font-size: 18px; text-align: center; font-weight: 700; }
.icon-btn {
  height: 44px; width: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--text); font-size: 20px; cursor: pointer;
}
.icon-btn[hidden] { visibility: hidden; display: inline-block; }
.icon-btn:active { transform: scale(0.94); }

#screen {
  max-width: 720px; margin: 0 auto;
  padding: 18px 16px calc(28px + env(safe-area-inset-bottom));
}

/* Hub grid */
.hero {
  text-align: center; padding: 10px 6px 22px;
}
.hero .emoji { font-size: 46px; }
.hero h2 { margin: 6px 0 4px; font-size: 24px; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; }

.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.game-card {
  background: linear-gradient(160deg, var(--card), var(--card-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 16px; text-align: left; cursor: pointer;
  box-shadow: var(--shadow); min-height: 128px;
  display: flex; flex-direction: column; justify-content: space-between;
  color: var(--text); transition: transform 0.08s ease;
}
.game-card:active { transform: translateY(2px) scale(0.99); }
.game-card .ico { font-size: 32px; }
.game-card .name { font-weight: 700; font-size: 16px; margin-top: 10px; }
.game-card .desc { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* Generic UI */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  margin-bottom: 14px;
}
h3.section { margin: 4px 0 12px; font-size: 15px; color: var(--muted); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 18px; border-radius: 14px; border: none;
  background: var(--accent); color: #06283d; font-size: 17px; font-weight: 700;
  cursor: pointer; margin-top: 6px;
}
.btn:active { transform: scale(0.98); }
.btn.secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.good { background: var(--good); color: #052e23; }
.btn.bad { background: var(--bad); color: #3b0713; }
.btn.warn { background: var(--warn); color: #3a2a03; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin-top: 0; }

.stepper {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 10px 0;
}
.stepper .val { font-size: 30px; font-weight: 800; min-width: 60px; text-align: center; }
.round-btn {
  width: 54px; height: 54px; border-radius: 50%; font-size: 26px; font-weight: 700;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text); cursor: pointer;
}
.round-btn:active { transform: scale(0.92); }

label.field { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 13px; }
input[type=text], select, textarea {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  font-size: 16px; font-family: inherit;
}
textarea { min-height: 120px; resize: vertical; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text); font-size: 14px; cursor: pointer;
}
.chip.on { background: var(--accent); color: #06283d; border-color: var(--accent); font-weight: 700; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.good { background: rgba(52,211,153,.18); color: var(--good); }
.pill.bad { background: rgba(251,113,133,.18); color: var(--bad); }
.pill.mute { background: var(--card-2); color: var(--muted); }

.big-note { text-align: center; padding: 26px 10px; }
.big-note .huge { font-size: 44px; font-weight: 800; margin: 8px 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.spacer { height: 10px; }

ul.clean { list-style: none; margin: 0; padding: 0; }
ul.clean li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
ul.clean li:last-child { border-bottom: none; }

.player-tag { display: inline-flex; align-items: center; gap: 6px; }
.dead { text-decoration: line-through; color: var(--muted); }

/* Reveal card (pass-the-phone) */
.reveal {
  border-radius: var(--radius); padding: 34px 20px; text-align: center;
  border: 1px solid var(--line); user-select: none;
  background: linear-gradient(160deg, #1b2740, #10192e);
  min-height: 260px; display: flex; flex-direction: column; justify-content: center; gap: 10px;
}
.reveal .word { font-size: 40px; font-weight: 800; }
.reveal .role { font-size: 34px; font-weight: 800; }
.reveal .who { font-size: 20px; color: var(--muted); }
.reveal.liar .word { color: var(--bad); }

.hold-hint { color: var(--muted); font-size: 13px; margin-top: 6px; }

.big-question {
  font-size: clamp(24px, 7vw, 40px); font-weight: 800; text-align: center;
  padding: 22px 6px; line-height: 1.3;
}
.vs-wrap { display: flex; align-items: stretch; gap: 12px; margin: 14px 0; }
.vs-side {
  flex: 1; border-radius: var(--radius); border: 1px solid var(--line);
  padding: 22px 12px; text-align: center; font-size: 20px; font-weight: 800; cursor: pointer;
  background: linear-gradient(160deg, var(--card), var(--card-2));
}
.vs-side.a { border-color: #38bdf8; }
.vs-side.b { border-color: #a78bfa; }
.vs-mid { align-self: center; font-weight: 800; color: var(--muted); }

.spinner-wrap { text-align: center; padding: 10px 0; }
.spin-name {
  font-size: clamp(30px, 10vw, 60px); font-weight: 800; padding: 30px 10px;
  min-height: 120px; display: flex; align-items: center; justify-content: center;
}

.count-badge { font-variant-numeric: tabular-nums; }
.progress { color: var(--muted); font-size: 13px; text-align: center; margin-bottom: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 12px; z-index: 50; box-shadow: var(--shadow);
}

@media (min-width: 560px) {
  .grid { grid-template-columns: 1fr 1fr 1fr; }
}
