:root {
  --bg1: #171a36;
  --bg2: #2b1d52;
  --text: #f4f1ff;
  --muted: #a9a3cf;
  --card: #241f45;
  --accent: #ffb547;
  --accent2: #4da3ff;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg1) 70%);
  background-color: var(--bg1);
}

body { display: flex; flex-direction: column; }

.hud {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 4px;
  min-height: 96px;
}

.hud-side { display: flex; gap: 8px; align-items: center; }
.hud-side.right { justify-content: flex-end; }

.best {
  display: flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 18px; color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
  padding: 6px 12px; border-radius: 999px;
}
.crown { font-size: 16px; }

.score-wrap { text-align: center; min-width: 120px; }
.score {
  font-size: 48px; font-weight: 800; line-height: 1;
  letter-spacing: -1px;
  text-shadow: 0 4px 18px rgba(155, 123, 255, 0.55);
  transition: transform 0.15s;
}
.score.bump { transform: scale(1.12); }
.combo {
  height: 20px; margin-top: 4px;
  font-size: 15px; font-weight: 700; color: var(--accent);
  opacity: 0; transition: opacity 0.2s;
}
.combo.show { opacity: 1; }

.icon-btn {
  width: 40px; height: 40px;
  border: 0; border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text); font-size: 20px;
  cursor: pointer;
}
.icon-btn:active { transform: scale(0.94); }

#game { flex: 1; width: 100%; min-height: 0; display: block; }

.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(10, 8, 30, 0.72);
  backdrop-filter: blur(4px);
  transition: opacity 0.25s;
  z-index: 10;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.card {
  width: 100%; max-width: 360px;
  background: var(--card);
  border-radius: 24px;
  padding: 24px 20px 20px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  transform: translateY(0);
  transition: transform 0.25s;
}
.overlay.hidden .card { transform: translateY(20px); }

.ov-title { font-size: 26px; font-weight: 800; margin-bottom: 12px; }
.big-score { font-size: 56px; font-weight: 800; margin: 4px 0; }
.sub { color: var(--muted); font-size: 15px; }
.record-badge {
  display: inline-block; margin: 8px 0 4px;
  padding: 4px 12px; border-radius: 999px;
  background: var(--accent); color: #2a1a00; font-weight: 800; font-size: 14px;
}

.top-list { list-style: none; padding: 0; margin: 16px 0 4px; text-align: left; max-height: 45vh; overflow-y: auto; }
.top-list li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 12px; border-radius: 12px; font-size: 15px;
}
.top-list li:nth-child(odd) { background: rgba(255, 255, 255, 0.04); }
.top-list li.me { background: rgba(77, 163, 255, 0.22); }
.top-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-list .pts { font-weight: 700; }

.ov-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.btn {
  border: 0; border-radius: 14px;
  padding: 14px 16px;
  font-size: 17px; font-weight: 700;
  color: #1b1035; background: linear-gradient(180deg, #ffd27a, var(--accent));
  cursor: pointer;
}
.btn.secondary { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.btn:active { transform: scale(0.98); }
