:root {
  --page-bg: #050507;
  --page-fg: #f5f5f7;
  --page-accent: #38bdf8;
  --page-danger: #ff3b30;
  --page-gold: #ffd60a;
  --panel-bg: rgba(14, 14, 18, 0.86);
  --panel-border: rgba(255, 255, 255, 0.14);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--page-bg);
  color: var(--page-fg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.bg-canvas, .fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.bg-canvas { z-index: 0; }
.fx-canvas { z-index: 4; }

.stage { position: fixed; inset: 0; z-index: 3; overflow: hidden; }

.ring-body {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
  transform-origin: center center;
  cursor: grab;
}
.ring-body.is-dragging { cursor: grabbing; }
.ring-body.is-popped { opacity: 0; pointer-events: none; }
.ring-canvas { display: block; pointer-events: none; }
.ring-hit-target { position: absolute; border-radius: 50%; cursor: inherit; }

.capsule-body {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--page-fg) 26%, transparent);
  background: color-mix(in srgb, var(--page-bg) 78%, var(--page-fg) 10%);
  color: var(--page-fg);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  cursor: grab;
  will-change: transform;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
}
.capsule-body:active { cursor: grabbing; }

.arcade-hud {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.arcade-hud[hidden], .hud-combo[hidden], .arcade-modal[hidden],
.leaderboard-form[hidden], .tweaks-panel[hidden] { display: none; }

.hud-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--page-fg) 20%, transparent);
  background: color-mix(in srgb, var(--page-bg) 72%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 700;
}
.hud-divider { opacity: 0.35; font-weight: 400; }
.hud-timer.is-urgent { color: var(--page-danger); animation: pulse-urgent 420ms ease-in-out infinite alternate; }
@keyframes pulse-urgent { from { opacity: 1; } to { opacity: 0.45; } }

.hud-combo {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--page-accent);
  color: #050507;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 120ms cubic-bezier(0.22, 1, 0.36, 1);
}
.hud-combo.is-pop { transform: scale(1.16); }

.burst-layer { position: fixed; inset: 0; z-index: 9; pointer-events: none; }
.score-float {
  position: fixed;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
  color: var(--page-accent);
  transform: translate(-50%, -50%);
  animation: float-up 680ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  white-space: nowrap;
}
.score-float.is-gold { color: var(--page-gold); font-size: 20px; }
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -55%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(0.95); }
}

.arcade-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 5, 7, 0.56);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.arcade-panel {
  width: min(360px, 100%);
  padding: 24px 22px 18px;
  border-radius: 22px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: #f5f5f7;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.arcade-badge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.78;
}
.arcade-score-line {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.arcade-final-score { font-size: 56px; line-height: 1; font-weight: 800; letter-spacing: -0.04em; }
.arcade-final-unit { font-family: var(--font-mono); font-size: 16px; opacity: 0.65; }
.arcade-rank-line { margin: 8px 0 18px; display: flex; flex-direction: column; gap: 3px; }
.arcade-rank { font-family: var(--font-mono); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; color: var(--page-accent); }
.arcade-stats { font-family: var(--font-mono); font-size: 12px; opacity: 0.62; }

.leaderboard-box {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}
.leaderboard-head {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.55;
  margin-bottom: 8px;
}
.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.leaderboard-list li {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 6px;
}
.leaderboard-list li.is-me { background: rgba(56, 189, 248, 0.16); color: #fff; }
.lb-rank { opacity: 0.5; }
.lb-name { font-weight: 700; letter-spacing: 0.08em; }
.lb-score { font-variant-numeric: tabular-nums; }

.leaderboard-form { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.leaderboard-form label { display: block; font-family: var(--font-mono); font-size: 11px; opacity: 0.7; margin-bottom: 6px; }
.initials-row { display: flex; gap: 8px; align-items: center; }
.initials-group { display: flex; gap: 6px; }
.initials-group input {
  width: 34px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
}
.initials-group input:focus { outline: none; border-color: var(--page-accent); }

.btn-sign, .btn-primary, .btn-ghost, .btn-done {
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  transition: transform 120ms ease, opacity 120ms ease;
}
.btn-sign:active, .btn-primary:active, .btn-ghost:active { transform: scale(0.97); }
.btn-sign { flex: 1; height: 36px; border-radius: 8px; background: #fff; color: #050507; font-weight: 700; font-size: 13px; }
.arcade-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.btn-primary { height: 40px; border-radius: 12px; background: #f5f5f7; color: #050507; font-weight: 700; font-size: 14px; }
.btn-ghost { height: 40px; border-radius: 12px; background: rgba(255, 255, 255, 0.09); color: #f5f5f7; font-weight: 600; font-size: 13px; }
.btn-done { margin-top: 10px; background: transparent; color: rgba(255, 255, 255, 0.55); font-size: 13px; padding: 6px 14px; }
.btn-done:hover { color: #fff; }

.arcade-credit {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.52);
  display: flex;
  justify-content: center;
  gap: 6px;
}
.arcade-credit a { color: rgba(255, 255, 255, 0.82); text-decoration: none; }
.arcade-credit a:hover { color: var(--page-accent); }

.tweaks-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  width: 260px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: #f5f5f7;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tweaks-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.85; }
.tweaks-close { background: none; border: none; color: inherit; font-size: 18px; cursor: pointer; line-height: 1; }
.tweak-field { display: flex; flex-direction: column; gap: 4px; }
.tweak-field span { display: flex; justify-content: space-between; opacity: 0.78; }
.tweak-field input[type="range"] { accent-color: var(--page-accent); width: 100%; cursor: pointer; }
.tweak-field input[type="text"] {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
}
.tweaks-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tweaks-actions button {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}
