:root {
  --bg: #0b1020;
  --line: #1f2a44;
  --text: #e8eefc;
  --muted: #8b9ab8;
  --accent: #38e08a;
  --accent-2: #16b8f3;
  --danger: #ff5c6c;
  --gold: #ffd66b;
}

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

html, body { height: 100%; overscroll-behavior: none; }

body {
  background: radial-gradient(1200px 700px at 50% -10%, #1b2745 0%, var(--bg) 55%, #070a14 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 100dvh;
}

.app {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 12px var(--accent-2);
}

.stats { display: flex; gap: 8px; }

.stat {
  min-width: 74px;
  padding: 7px 11px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 1px;
  align-items: flex-end;
}

.stat-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.stat-value {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  transition: color 0.15s ease, transform 0.15s ease;
}

.stat-value.bump { color: var(--accent); transform: scale(1.14); }
.stat-value.best { color: var(--gold); }

.lives-stat { align-items: flex-start; }

.lives { display: flex; gap: 4px; height: 22px; align-items: center; }

.heart {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: var(--danger);
  box-shadow: 0 0 8px rgba(255, 92, 108, 0.55);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.heart.lost {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
  transform: scale(0.82);
}

/* ---------- Stage ---------- */
.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 20px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(22, 184, 243, 0.12), rgba(56, 224, 138, 0.05));
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  background: #0d1426;
  touch-action: none;
  user-select: none;
  cursor: crosshair;
}

/* ---------- Overlay ---------- */
.overlay {
  position: absolute;
  inset: 8px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  background: rgba(8, 12, 24, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.overlay.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 320px;
}

.overlay-title { font-size: 24px; font-weight: 800; letter-spacing: 0.02em; }
.overlay[data-state="over"] .overlay-title { color: var(--danger); }
.overlay[data-state="paused"] .overlay-title { color: var(--accent-2); }
.overlay[data-state="win"] .overlay-title { color: var(--accent); }

.overlay-desc { font-size: 13px; line-height: 1.8; color: var(--muted); }
.overlay-score { font-size: 14px; color: var(--muted); }

.overlay-score strong {
  color: var(--accent);
  font-size: 22px;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #06130c;
  padding: 12px 28px;
  border-radius: 999px;
  background: linear-gradient(180deg, #57f0a1, #27c978);
  box-shadow: 0 8px 22px rgba(39, 201, 120, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
}

.btn:active { transform: translateY(1px) scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; }

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
  font-size: 13px;
  padding: 9px 16px;
  font-weight: 600;
}

.btn-ghost:active { background: rgba(255, 255, 255, 0.12); }

/* ---------- Footer ---------- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.legend { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 4px; }

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 11px;
  text-align: center;
  color: var(--text);
}

.actions { display: flex; gap: 8px; }

@media (max-width: 390px) {
  .stat { min-width: 62px; padding: 6px 9px; }
  .stat-value { font-size: 16px; }
  .brand-text { display: none; }
  .heart { width: 11px; height: 11px; }
  .legend { font-size: 11px; }
}
