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

:root {
  --green: #6FFF00;
  --neon: #39FF14;
  --fire: #FF6B00;
  --gold: #FFD700;
  --bg: #080808;
  --card: #111111;
  --muted: #666666;
  --font-head: 'Bangers', cursive;
  --font-body: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #fff;
  font-family: var(--font-body);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

body { cursor: none; }
@media (max-width: 768px) { body { cursor: auto; } }

#game-canvas {
  display: block;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

/* ── Screens ── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(8,8,8,0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  overflow-y: auto;
  padding: 20px;
}

.hidden { display: none !important; }

.screen-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 420px;
  padding: 40px 24px;
}

.title-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  filter: drop-shadow(0 0 20px var(--green)) drop-shadow(0 0 40px rgba(111,255,0,0.3));
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%,100% { filter: drop-shadow(0 0 20px var(--green)) drop-shadow(0 0 40px rgba(111,255,0,0.3)); }
  50%      { filter: drop-shadow(0 0 40px var(--green)) drop-shadow(0 0 80px rgba(111,255,0,0.6)); }
}

.game-title {
  font-family: var(--font-head);
  font-size: clamp(3.5rem, 12vw, 5.5rem);
  letter-spacing: 4px;
  line-height: 1;
  text-align: center;
  color: #fff;
  text-shadow:
    0 0 20px rgba(111,255,0,0.6),
    0 0 40px rgba(111,255,0,0.2),
    3px 3px 0 rgba(0,0,0,0.8);
}

.tap-hint {
  font-family: var(--font-head);
  font-size: 1.1rem;
  letter-spacing: 5px;
  color: var(--green);
  animation: blink 1.2s ease-in-out infinite;
}

@keyframes blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* ── HUD ── */
#hud {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.hud-score {
  font-family: var(--font-head);
  font-size: clamp(2.5rem, 8vw, 4rem);
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 0 20px rgba(111,255,0,0.5), 2px 2px 0 rgba(0,0,0,0.8);
  line-height: 1;
}

.hud-rank {
  font-family: var(--font-head);
  font-size: 0.75rem;
  letter-spacing: 4px;
}

/* ── Game Over ── */
.go-rank {
  font-family: var(--font-head);
  font-size: clamp(2rem, 8vw, 3.5rem);
  letter-spacing: 4px;
  text-shadow: 0 0 30px currentColor;
}

.go-score {
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 5vw, 2rem);
  color: #fff;
  letter-spacing: 2px;
}

.username-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(111,255,0,0.4);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: var(--font-head);
  font-size: 1.1rem;
  letter-spacing: 3px;
  color: #fff;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.username-input::placeholder { color: #444; }
.username-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 20px rgba(111,255,0,0.2);
}

.go-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
}

.go-btn {
  flex: 1;
  font-family: var(--font-head);
  font-size: 1rem;
  letter-spacing: 2px;
  padding: 14px 12px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
}

.go-btn:active { transform: scale(0.97); }

.go-btn:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.go-btn-share {
  background: #000;
  color: #fff;
  border-color: #333;
}
.go-btn-share:hover { border-color: #fff; box-shadow: 0 0 20px rgba(255,255,255,0.1); }

.go-btn-submit {
  background: var(--green);
  color: #000;
  border-color: var(--green);
}
.go-btn-submit:hover { background: var(--neon); box-shadow: 0 0 20px var(--neon); }
.go-btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.go-btn-retry {
  width: 100%;
  background: transparent;
  color: var(--muted);
  border-color: #222;
  font-size: 0.9rem;
  letter-spacing: 3px;
}
.go-btn-retry:hover { color: #fff; border-color: #444; }

.submit-status {
  font-family: var(--font-head);
  font-size: 0.85rem;
  letter-spacing: 2px;
  min-height: 20px;
  color: var(--green);
}

/* ── Leaderboard ── */
.lb-wrap {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
}

.lb-header {
  font-family: var(--font-head);
  font-size: 0.75rem;
  letter-spacing: 4px;
  color: var(--muted);
  padding: 10px 16px 8px;
  border-bottom: 1px solid #1a1a1a;
}

.leaderboard {
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
}

.lb-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid #111;
  transition: background 0.15s;
}
.lb-row:last-child { border-bottom: none; }
.lb-row.lb-top { background: rgba(111,255,0,0.05); }

.lb-rank {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.lb-row.lb-top .lb-rank { color: var(--green); }

.lb-name {
  font-family: var(--font-head);
  font-size: 1rem;
  letter-spacing: 1px;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--green);
  white-space: nowrap;
}

.lb-empty {
  font-family: var(--font-head);
  font-size: 0.8rem;
  letter-spacing: 2px;
  color: var(--muted);
  padding: 20px;
  text-align: center;
}

.back-link {
  font-family: var(--font-head);
  font-size: 0.8rem;
  letter-spacing: 3px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
  margin-top: 4px;
}
.back-link:hover { color: #fff; }
