:root {
  --bg: #0b1020;
  --card: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.15);
  --text: #eaf1ff;
  --muted: #a9b7d9;
  --primary: #7c5cff;
  --primary-2: #22d1ee;
  --danger: #ff4267;
  --ok: #2ee59d;
  --warning: #ffcc00;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: 'Montserrat', system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 800px at 10% 10%, rgba(124, 92, 255, 0.25), transparent 40%),
              radial-gradient(1000px 700px at 90% 20%, rgba(34, 209, 238, 0.25), transparent 45%),
              radial-gradient(900px 900px at 50% 120%, rgba(255, 66, 103, 0.25), transparent 50%),
              var(--bg);
  background-attachment: fixed;
}

.banner {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 88px;
  background: linear-gradient(90deg, rgba(124, 92, 255, 0.18), rgba(34, 209, 238, 0.18));
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.title-wrap {
  text-align: center;
}

.title {
  margin: 0;
  letter-spacing: 1px;
  font-family: 'Space Grotesk', monospace;
  font-weight: 800;
  font-size: 36px;
  background: linear-gradient(90deg, #fff, #c9d3ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.15);
}

.subtitle {
  margin-top: -2px;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 4px;
  text-transform: uppercase;
}

.game-shell {
  max-width: 1100px;
  margin: 28px auto;
  padding: 0 16px 48px;
}

.top-bar {
  display: grid;
  grid-template-columns: 160px 1fr 160px;
  align-items: center;
  gap: 16px;
}

.timer {
  position: relative;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.timer-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0deg, rgba(255,255,255,0.12) 0deg);
  box-shadow: 0 0 0 6px rgba(255,255,255,0.05) inset, 0 10px 30px rgba(0,0,0,0.35);
}

.timer-text {
  position: relative;
  z-index: 1;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 36px;
  font-weight: 800;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
}

.timer-text.low {
  color: var(--danger);
}

.timer-text.flash {
  animation: flash 0.7s steps(2, jump-none) infinite;
}

@keyframes flash {
  0%, 49% { filter: drop-shadow(0 0 0 rgba(255,255,255,0)); }
  50%, 100% { filter: drop-shadow(0 0 10px rgba(255, 66, 103, 0.75)); }
}

.scoreboard, .level-info {
  justify-self: center;
  text-align: center;
}

.score-label, .level-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.score-value, .level-value {
  margin-top: 6px;
  font-size: 36px;
  font-weight: 800;
}

.play-area {
  margin-top: 24px;
  display: grid;
  gap: 16px;
}

.gm-box {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px 22px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25), 0 0 0 8px rgba(255,255,255,0.025) inset;
}

.gm-role {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.gm-text {
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.4;
}

.controls {
  display: grid;
  gap: 12px;
}

#guessForm {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.guess-input {
  width: 100%;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 18px;
  outline: none;
  transition: box-shadow 160ms ease, border-color 160ms ease;
}

.guess-input:focus {
  border-color: rgba(124, 92, 255, 0.8);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.2);
}

.control-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 160ms ease, background 160ms ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }

.btn.primary { background: linear-gradient(180deg, rgba(124,92,255,0.85), rgba(124,92,255,0.65)); border-color: rgba(124,92,255,0.7); }
.btn.danger { background: linear-gradient(180deg, rgba(255,66,103,0.85), rgba(255,66,103,0.65)); border-color: rgba(255,66,103,0.7); }
.btn.ghost { background: rgba(255,255,255,0.06); }
.btn.xl { padding: 16px 22px; font-size: 18px; border-radius: 16px; }

.leaderboard-card {
  margin-top: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px 16px 8px;
}

.leaderboard-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.leaderboard-title { font-weight: 800; letter-spacing: 0.5px; }

.mini-btn {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  cursor: pointer;
}

.leaderboard-list {
  list-style: none;
  margin: 10px 0 0 0;
  padding: 0;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px dashed rgba(255,255,255,0.12);
  color: var(--text);
}

.leaderboard-list li:last-child { border-bottom: none; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, 0.75);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
  z-index: 100;
}

.overlay[hidden] { display: none !important; }

.modal {
  width: min(720px, 92vw);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.06));
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 40px 80px rgba(0,0,0,0.35);
  padding: 18px 18px 16px;
}

.modal-title {
  font-size: 28px;
  font-weight: 800;
}

.final-score {
  margin-top: 6px;
  font-size: 52px;
  font-weight: 800;
}

.modal-body { margin-top: 8px; color: var(--muted); }

.modal-actions { margin-top: 14px; display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions.end { justify-content: center; }

.field { display: grid; gap: 6px; margin-top: 12px; }
.field-label { font-size: 14px; color: var(--text); }
.text-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  outline: none;
}

input[type="range"] { width: 100%; }
.level-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

.rules { margin: 12px 0 0 0; padding-left: 18px; }
.rules li { margin: 6px 0; }

#confetti-canvas {
  position: fixed;
  pointer-events: none;
  inset: 0;
}

@media (max-width: 720px) {
  .top-bar { grid-template-columns: 1fr 1fr; gap: 14px; }
  .scoreboard { justify-self: end; }
  .level-info { justify-self: start; }
  .timer { grid-column: 1 / -1; justify-self: center; }
}


