@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@400;600;700;800&family=Sarabun:wght@400;500;600&display=swap');

:root {
  --bg: #12142b;
  --bg-2: #1c2048;
  --panel: #1a1d3d;
  --panel-line: #34386b;
  --gold: #ffc145;
  --gold-dim: #7a5f1f;
  --coral: #ff5d5d;
  --mint: #4ecdc4;
  --ink: #f5f3ec;
  --ink-dim: #a8adc9;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at 50% 0%, var(--bg-2) 0%, var(--bg) 65%);
  color: var(--ink);
  font-family: 'Sarabun', sans-serif;
  min-height: 100vh;
}

::selection { background: var(--gold); color: #14172e; }

a { color: var(--gold); }

.stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.stage::before {
  content: '';
  position: absolute;
  top: -20%;
  left: 50%;
  width: 900px;
  height: 900px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255,193,69,0.14) 0%, rgba(255,193,69,0) 60%);
  pointer-events: none;
}

.eyebrow {
  font-family: 'Kanit', sans-serif;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 10px;
}

.name-card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 28px;
  padding: 48px 36px;
  min-width: min(90vw, 440px);
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
  position: relative;
  z-index: 1;
}

.name-number {
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  color: var(--gold);
  font-size: 20px;
  letter-spacing: .05em;
}

.name-display {
  font-family: 'Kanit', sans-serif;
  font-weight: 800;
  font-size: clamp(32px, 9vw, 56px);
  line-height: 1.15;
  margin: 10px 0 0;
  min-height: 1.3em;
}

.name-display.spinning {
  color: var(--ink-dim);
  animation: flicker .08s linear infinite;
}

.name-display.revealed {
  color: var(--gold);
  animation: pop .45s cubic-bezier(.2,1.3,.4,1);
}

@keyframes flicker { 50% { opacity: .55; } }
@keyframes pop { 0% { transform: scale(.85); opacity: 0; } 60% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }

.timer-ring-wrap {
  margin-top: 30px;
  display: flex;
  justify-content: center;
}

.timer-ring { position: relative; width: 140px; height: 140px; }
.timer-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.timer-ring circle {
  fill: none;
  stroke-width: 8;
}
.timer-ring .track { stroke: var(--panel-line); }
.timer-ring .progress {
  stroke: var(--gold);
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke .3s;
}
.timer-ring .progress.urgent { stroke: var(--coral); }
.timer-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Kanit', sans-serif;
  font-weight: 700;
  font-size: 34px;
}

.status-line {
  margin-top: 22px;
  font-size: 16px;
  color: var(--ink-dim);
}

.status-line.warn { color: var(--gold); }

.game-over {
  font-family: 'Kanit', sans-serif;
  font-weight: 800;
  font-size: clamp(40px, 12vw, 84px);
  color: var(--coral);
  text-shadow: 0 0 40px rgba(255,93,93,.5);
  animation: pop .5s cubic-bezier(.2,1.3,.4,1);
  letter-spacing: .04em;
}

.idle-msg {
  font-family: 'Kanit', sans-serif;
  font-weight: 700;
  font-size: clamp(24px, 6vw, 34px);
  color: var(--ink-dim);
}

.pulse-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--mint);
  margin-right: 8px;
  animation: pulse 1.4s ease-in-out infinite;
  vertical-align: middle;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* ===== Admin ===== */
.admin-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.admin-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-title {
  font-family: 'Kanit', sans-serif;
  font-weight: 800;
  font-size: 26px;
}

.badge {
  font-family: 'Kanit', sans-serif;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  color: var(--ink-dim);
}
.badge.status-picked { color: var(--gold); border-color: var(--gold-dim); }
.badge.status-waiting_next { color: var(--gold); border-color: var(--gold-dim); }
.badge.status-game_over { color: var(--coral); border-color: #6b2f2f; }
.badge.status-idle { color: var(--mint); border-color: #275a56; }

.card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}

.card h2 {
  font-family: 'Kanit', sans-serif;
  font-size: 16px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 16px;
}

.current-pick {
  text-align: center;
  padding: 18px 0 8px;
}
.current-pick .name-display { font-size: clamp(26px, 6vw, 38px); color: var(--gold); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

button, .btn {
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  font-size: 15px;
  border: none;
  border-radius: 12px;
  padding: 13px 22px;
  cursor: pointer;
  color: #14172e;
  background: var(--gold);
  transition: transform .12s ease, filter .12s ease;
}
button:hover { filter: brightness(1.08); }
button:active { transform: scale(.97); }
button:disabled { opacity: .4; cursor: not-allowed; }

button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--panel-line);
}

button.danger {
  background: var(--coral);
  color: #2c0f0f;
}

button.big {
  padding: 20px 28px;
  font-size: 20px;
  width: 100%;
  border-radius: 16px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 6px;
}

input[type=number], input[type=password], input[type=text], textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--panel-line);
  color: var(--ink);
  border-radius: 10px;
  padding: 11px 13px;
  font-family: 'Sarabun', sans-serif;
  font-size: 15px;
}

textarea { min-height: 180px; resize: vertical; font-family: 'JetBrains Mono', monospace; font-size: 13.5px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 16px;
  color: var(--ink-dim);
  font-size: 14px;
}
.checkbox-row input { width: 18px; height: 18px; }

.hint { font-size: 12.5px; color: var(--ink-dim); margin-top: 8px; line-height: 1.5; }

.login-box {
  max-width: 340px;
  margin: 90px auto;
  padding: 30px;
}

.qr-link {
  display: block;
  text-align: center;
  padding: 12px;
  border: 1px dashed var(--panel-line);
  border-radius: 12px;
  font-size: 13px;
  color: var(--ink-dim);
  word-break: break-all;
  margin-top: 10px;
}

.round-tag {
  font-family: 'Kanit', sans-serif;
  color: var(--ink-dim);
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  color: var(--ink);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  z-index: 50;
}
.toast.show { opacity: 1; }

@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
}
