/* ============================================
   VINYL SNAKE - Retro Arcade Record Store
   ============================================ */

:root {
  --bg: #0a0a0a;
  --board: #1a1a2e;
  --snake: #e8a838;
  --accent: #ff6b35;
  --text: #e0d4b8;
  --text-dim: #7a7060;
  --neon-glow: #ff6b35;
  --red: #e63946;
  --gold: #ffd700;
  --blue: #4cc9f0;
  --green: #06d6a0;
  --splatter1: #e63946;
  --splatter2: #4cc9f0;
  --splatter3: #06d6a0;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Press Start 2P', monospace;
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

/* Background vinyl groove pattern */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: 
    repeating-radial-gradient(
      circle at 50% 50%,
      transparent 0px,
      transparent 3px,
      rgba(255,255,255,0.008) 3px,
      rgba(255,255,255,0.008) 4px
    );
  pointer-events: none;
  z-index: 0;
}

/* Noise texture overlay */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

#game-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

/* CRT Scanline Overlay */
#crt-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1000;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.12) 2px,
    rgba(0,0,0,0.12) 4px
  );
  mix-blend-mode: multiply;
}

#crt-overlay::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0,0,0,0.4) 100%
  );
}

/* Screen Container */
#screen-container {
  position: relative;
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  animation: fadeIn 0.4s ease;
}
.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glow Text Effect */
.glow-text {
  text-shadow:
    0 0 4px var(--neon-glow),
    0 0 12px rgba(255,107,53,0.5),
    0 0 24px rgba(255,107,53,0.2);
}

/* ========================
   TITLE SCREEN
   ======================== */

.title-vinyl-container {
  margin-bottom: 20px;
}

.title-vinyl {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #111;
  position: relative;
  animation: spin 4s linear infinite;
  box-shadow: 0 0 20px rgba(232,168,56,0.2);
}

.vinyl-groove {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.06);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
.v1 { width: 90%; height: 90%; }
.v2 { width: 72%; height: 72%; }
.v3 { width: 56%; height: 56%; }
.v4 { width: 40%; height: 40%; }

.vinyl-label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.vinyl-label span {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--bg);
  animation: spin 4s linear infinite reverse;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.game-title {
  font-size: clamp(24px, 6vw, 42px);
  color: var(--accent);
  letter-spacing: 4px;
  text-align: center;
  margin-bottom: 8px;
}

.subtitle {
  font-size: clamp(8px, 2vw, 11px);
  color: var(--text-dim);
  margin-bottom: 28px;
  letter-spacing: 2px;
}

/* Play Button */
.play-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 32px;
  background: var(--snake);
  border: 3px solid var(--accent);
  color: var(--bg);
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 24px;
  position: relative;
  outline: none;
}
.play-btn:hover, .play-btn:focus {
  background: var(--accent);
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(255,107,53,0.5);
}
.play-btn:active {
  transform: scale(0.97);
}

/* Controls Info */
.controls-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
  text-align: center;
}
.control-row {
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 1px;
}
.key {
  color: var(--snake);
  padding: 2px 6px;
  border: 1px solid var(--snake);
  font-size: 7px;
}

/* Record Legend */
.record-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 7px;
  color: var(--text-dim);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.black-vinyl { background: #333; border: 1px solid #555; }
.red-vinyl { background: var(--red); }
.gold-vinyl { background: var(--gold); }
.splatter-vinyl {
  background: conic-gradient(var(--splatter1) 0deg, var(--splatter2) 120deg, var(--splatter3) 240deg, var(--splatter1) 360deg);
}

/* ========================
   HUD
   ======================== */

#hud {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  width: 100%;
  max-width: 600px;
}
.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.hud-label {
  font-size: 7px;
  color: var(--text-dim);
  letter-spacing: 1px;
}
.hud-value {
  font-size: 14px;
  color: var(--snake);
}
.combo-display {
  transition: opacity 0.3s;
}
.combo-display .hud-value {
  color: var(--accent);
}

/* Canvas Wrapper */
#canvas-wrapper {
  position: relative;
  border: 3px solid #2a2a3e;
  box-shadow:
    0 0 10px rgba(232,168,56,0.1),
    inset 0 0 30px rgba(0,0,0,0.5);
  background: var(--board);
  line-height: 0;
}

#game-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Collection Popup */
.collection-popup {
  position: absolute;
  pointer-events: none;
  font-size: 9px;
  color: var(--snake);
  text-shadow: 0 0 6px var(--neon-glow);
  opacity: 0;
  transform: translateY(0);
  transition: all 0.5s ease;
  white-space: nowrap;
  z-index: 10;
  font-family: 'Press Start 2P', monospace;
}
.collection-popup.show {
  opacity: 1;
  animation: popFloat 1s ease forwards;
}
@keyframes popFloat {
  0% { opacity: 1; transform: translateY(0) scale(1.2); }
  30% { opacity: 1; transform: translateY(-10px) scale(1); }
  100% { opacity: 0; transform: translateY(-30px) scale(0.8); }
}

/* ========================
   GAME OVER SCREEN
   ======================== */

.gameover-title {
  font-size: clamp(20px, 5vw, 32px);
  color: var(--red);
  margin-bottom: 12px;
  text-shadow:
    0 0 4px var(--red),
    0 0 12px rgba(230,57,70,0.5);
}

.new-hs {
  font-size: clamp(10px, 2.5vw, 14px);
  color: var(--gold);
  margin-bottom: 16px;
  animation: hsFlash 0.6s ease infinite alternate;
  text-shadow: 0 0 10px rgba(255,215,0,0.6);
}
.new-hs.hidden { display: none; }

@keyframes hsFlash {
  from { opacity: 0.6; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1.03); }
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
  width: 100%;
  max-width: 400px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}
.stat-label {
  font-size: 7px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-align: center;
}
.stat-value {
  font-size: 16px;
  color: var(--snake);
}

/* Screen Shake */
@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-4px, 2px); }
  20% { transform: translate(4px, -2px); }
  30% { transform: translate(-3px, -3px); }
  40% { transform: translate(3px, 3px); }
  50% { transform: translate(-2px, 1px); }
  60% { transform: translate(2px, -1px); }
  70% { transform: translate(-1px, 2px); }
  80% { transform: translate(1px, -1px); }
  90% { transform: translate(0, 1px); }
}
.screen-shake {
  animation: screenShake 0.4s ease;
}

/* Flash on game over */
@keyframes screenFlash {
  0% { opacity: 0.8; }
  50% { opacity: 0; }
  100% { opacity: 0; }
}
.screen-flash {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #fff;
  pointer-events: none;
  z-index: 999;
  animation: screenFlash 0.3s ease forwards;
}

/* Mobile hint */
.mobile-hint {
  display: none;
}
@media (pointer: coarse) {
  .mobile-hint {
    display: block;
  }
}

/* Responsive canvas sizing */
@media (max-width: 480px) {
  #screen-container {
    padding: 8px;
  }
  #hud {
    gap: 8px;
  }
  .hud-value {
    font-size: 11px;
  }
  .game-title {
    letter-spacing: 2px;
  }
  .stats-grid {
    gap: 8px;
  }
  .stat-item {
    padding: 8px 4px;
  }
  .stat-value {
    font-size: 13px;
  }
  .record-legend {
    font-size: 6px;
  }
}
