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

html, body {
  height: 100%;
  overflow: hidden;
  background: #0a0a1a;
  color: #ffffff;
  font-family: 'Inter', system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #0a0a1a;
}

/* HUD */
#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: linear-gradient(180deg, #0d0d24 0%, #0a0a1a 100%);
  border-bottom: 1px solid rgba(0, 204, 255, 0.15);
  z-index: 10;
  flex-shrink: 0;
}

.hud-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.4);
  display: block;
  margin-bottom: 2px;
}

#attempt-count, #pb-value {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

#pb-value {
  color: #00ccff;
}

/* Canvas */
#play-canvas {
  flex: 1;
  display: block;
  width: 100%;
  cursor: pointer;
  touch-action: none;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  background: rgba(5, 5, 20, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.overlay.active {
  display: flex;
}

.overlay-card {
  background: linear-gradient(135deg, #12122a 0%, #1a1a3e 100%);
  border: 1px solid rgba(0, 204, 255, 0.2);
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 0 40px rgba(0, 204, 255, 0.08), 0 8px 32px rgba(0, 0, 0, 0.6);
}

.game-title {
  font-family: Impact, 'Arial Black', system-ui;
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #ffffff;
  text-shadow: 0 0 20px rgba(0, 204, 255, 0.4), 0 0 60px rgba(0, 204, 255, 0.15);
  margin-bottom: 4px;
}

.game-title .accent {
  color: #00ccff;
  text-shadow: 0 0 30px rgba(0, 204, 255, 0.6);
}

.subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  margin-bottom: 16px;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
}

/* Neon Button */
.neon-btn {
  display: inline-block;
  padding: 14px 48px;
  font-family: Impact, 'Arial Black', system-ui;
  font-size: 22px;
  letter-spacing: 2px;
  color: #0a0a1a;
  background: #00ccff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 0 20px rgba(0, 204, 255, 0.4), 0 0 60px rgba(0, 204, 255, 0.15);
  text-transform: uppercase;
  touch-action: manipulation;
}

.neon-btn:hover {
  background: #33ddff;
  box-shadow: 0 0 30px rgba(0, 204, 255, 0.6), 0 0 80px rgba(0, 204, 255, 0.25);
  transform: scale(1.02);
}

.neon-btn:active {
  transform: scale(0.97);
  box-shadow: 0 0 10px rgba(0, 204, 255, 0.3);
}

.hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 20px;
  letter-spacing: 0.5px;
}

.hint kbd {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  font-size: 10px;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
}

/* Results */
.results-card {
  max-width: 460px;
  padding: 32px 40px;
}

.results-title {
  font-family: Impact, 'Arial Black', system-ui;
  font-size: 32px;
  letter-spacing: 3px;
  color: #00ccff;
  text-shadow: 0 0 20px rgba(0, 204, 255, 0.4);
  margin-bottom: 20px;
}

#attempts-list {
  margin-bottom: 16px;
}

.attempt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  margin-bottom: 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  animation: fadeInRow 0.3s ease forwards;
  opacity: 0;
}

.attempt-row .attempt-num {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.3);
  min-width: 28px;
}

.attempt-row .attempt-time {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

.attempt-row .attempt-ms {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
  margin-left: 2px;
}

.attempt-row.best-attempt .attempt-time {
  color: #00ff88;
  text-shadow: 0 0 12px rgba(0, 255, 136, 0.4);
}

.attempt-row.false-start .attempt-time {
  color: #ff3355;
}

.attempt-row.false-start .attempt-num {
  color: #ff3355;
}

.attempt-row .attempt-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.4);
}

.attempt-row.best-attempt .attempt-badge {
  color: #00ff88;
  background: rgba(0, 255, 136, 0.12);
}

.results-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
}

.summary-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
}

.summary-row .stat-label {
  margin-bottom: 4px;
  font-size: 10px;
}

.summary-row .stat-value {
  font-size: 22px;
}

#rank-display {
  font-family: Impact, 'Arial Black', system-ui;
  font-size: 26px;
  letter-spacing: 2px;
}

.rank-badge.godlike { color: #ffd700; text-shadow: 0 0 20px rgba(255, 215, 0, 0.5); }
.rank-badge.pro { color: #00ccff; text-shadow: 0 0 20px rgba(0, 204, 255, 0.5); }
.rank-badge.fast { color: #00ff88; text-shadow: 0 0 20px rgba(0, 255, 136, 0.4); }
.rank-badge.good { color: #88ff44; text-shadow: 0 0 16px rgba(136, 255, 68, 0.3); }
.rank-badge.average { color: #ffcc00; text-shadow: 0 0 16px rgba(255, 204, 0, 0.3); }
.rank-badge.slow { color: #ff6655; }

#pb-row {
  grid-column: 1 / -1;
}

#results-pb {
  color: #00ccff;
}

/* Audio unlock */
#audio-unlock {
  z-index: 30;
}

/* Animations */
@keyframes fadeInRow {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 480px) {
  .overlay-card {
    padding: 28px 20px;
  }
  .game-title {
    font-size: 30px;
  }
  .results-title {
    font-size: 24px;
  }
  .results-card {
    padding: 24px 16px;
  }
  .results-summary {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .summary-row .stat-value {
    font-size: 18px;
  }
  #hud {
    padding: 8px 14px;
  }
  #attempt-count, #pb-value {
    font-size: 15px;
  }
}
