:root {
  --bg: #0b0f17;
  --bg-soft: #121826;
  --card: #161d2e;
  --line: #243149;
  --text: #e8edf7;
  --muted: #8494b0;
  --primary: #5b8cff;
  --primary-ink: #06122e;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --gold: #fbbf24;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: radial-gradient(1200px 600px at 50% -10%, #182545 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans KR", sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
  padding: 22px 18px 40px;
  display: flex;
  flex-direction: column;
}

.screen { display: flex; flex-direction: column; gap: 18px; flex: 1; }
.hidden { display: none !important; }

/* 로비 */
.brand { text-align: center; margin-top: 20px; }
.brand-badge {
  font-size: 40px;
  width: 76px; height: 76px; line-height: 76px;
  margin: 0 auto 14px;
  border-radius: 22px;
  background: linear-gradient(160deg, #2a3a63, #16203a);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.06);
}
.brand h1 { font-size: 28px; letter-spacing: -0.5px; }
.tag { color: var(--muted); margin-top: 6px; font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 7px; }
.field span { font-size: 13px; color: var(--muted); font-weight: 600; }
input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 15px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color .15s;
}
input:focus { border-color: var(--primary); }
#codeInput { text-transform: uppercase; letter-spacing: 3px; font-weight: 700; }

.btn {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .06s, filter .15s;
}
.btn:active { transform: scale(.985); }
.btn-primary {
  background: linear-gradient(180deg, #6a97ff, var(--primary));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px rgba(91, 140, 255, .35);
}
.btn-primary:hover { filter: brightness(1.05); }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; cursor: pointer;
}
.room-item:hover { border-color: var(--primary); }
.room-item .rc { font-weight: 800; letter-spacing: 2px; }
.room-item .rm { font-size: 12px; color: var(--muted); }

.error { color: var(--red); font-size: 13px; text-align: center; min-height: 18px; }

/* 게임 헤더 */
.game-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.room-tag { font-size: 14px; color: var(--muted); }
.room-tag b { color: var(--text); letter-spacing: 2px; font-size: 16px; }
.round-tag {
  font-weight: 800; font-size: 15px;
  background: var(--bg-soft); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px;
}
.btn-mini {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 7px 12px; border-radius: 999px; font-size: 13px; cursor: pointer;
}

/* 반응 패드 */
.pad {
  border-radius: 20px;
  min-height: 260px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: background .08s, box-shadow .12s;
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.pad-inner { padding: 24px; }
.pad-main { font-size: 42px; font-weight: 900; letter-spacing: -1px; line-height: 1.1; }
.pad-sub { margin-top: 10px; font-size: 15px; opacity: .85; }

.pad-idle   { background: linear-gradient(160deg, #18202f, #121826); color: var(--muted); }
.pad-wait   { background: linear-gradient(160deg, #3a1220, #2a0d18); color: #ffd9df;
              box-shadow: inset 0 0 0 2px rgba(239,68,68,.35); }
.pad-go     { background: linear-gradient(160deg, #16a34a, #15803d); color: #eafff1;
              box-shadow: 0 0 0 3px rgba(34,197,94,.35), 0 12px 40px rgba(34,197,94,.35); }
.pad-tapped { background: linear-gradient(160deg, #1e2a44, #16203a); color: var(--text); }
.pad-false  { background: linear-gradient(160deg, #7c2d12, #431407); color: #ffd9c4;
              box-shadow: inset 0 0 0 2px rgba(245,158,11,.4); }
.pad-count  { background: linear-gradient(160deg, #1c2740, #131a2c); color: var(--text); }
.pad-result { background: linear-gradient(160deg, #1a2440, #131a2c); color: var(--text); }
.pad-win    { background: linear-gradient(160deg, #2a2410, #1c1806); color: var(--gold);
              box-shadow: 0 0 0 3px rgba(251,191,36,.3); }

.big-ms { font-variant-numeric: tabular-nums; }

.host-controls { display: flex; gap: 10px; }
.host-controls .btn { flex: 1; }
.hint { text-align: center; color: var(--muted); font-size: 13px; min-height: 18px; }

/* 순위표 */
.board {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.board-head, .prow {
  display: grid;
  grid-template-columns: 34px 1fr 68px 68px 44px;
  align-items: center;
  gap: 6px;
  padding: 11px 14px;
}
.board-head { color: var(--muted); font-size: 12px; font-weight: 700; border-bottom: 1px solid var(--line); }
.col-last, .col-best, .col-wins { text-align: right; }
.prow { border-bottom: 1px solid rgba(36,49,73,.5); }
.prow:last-child { border-bottom: none; }
.prow.me { background: rgba(91,140,255,.08); }
.prow .rk { font-weight: 800; color: var(--muted); }
.prow .rk.p1 { color: var(--gold); }
.prow .nm { font-weight: 700; display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .nm .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
.prow .nm .dot.off { background: #495569; }
.prow .nm .host { font-size: 10px; color: var(--primary); border: 1px solid var(--primary); border-radius: 5px; padding: 0 4px; }
.prow .ms { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.prow .ms.dim { color: var(--muted); font-weight: 500; }
.prow .ms.false { color: var(--amber); }
.prow .ms.miss { color: var(--red); }
.prow .wins { text-align: right; font-weight: 800; }
.prow .tapdot { font-size: 11px; color: var(--green); }

@media (max-width: 380px) {
  .pad-main { font-size: 34px; }
  .board-head, .prow { grid-template-columns: 28px 1fr 58px 58px 36px; padding: 10px; font-size: 14px; }
}
