@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  --neon-cyan: #00f5ff;
  --neon-pink: #ff00ff;
  --neon-yellow: #ffff00;
  --neon-green: #00ff00;
  --neon-orange: #ff6600;
  --bg: #0a0a0f;
  --card-bg: #111122;
  --border: #222244;
}

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

body {
  background: var(--bg);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── HEADER ─── */
header {
  text-align: center;
  padding: 40px 20px 30px;
  position: relative;
  border-bottom: 2px solid var(--neon-cyan);
  box-shadow: 0 0 30px rgba(0, 245, 255, 0.3);
  background: linear-gradient(180deg, #0d0d1a 0%, var(--bg) 100%);
}

.logo {
  font-size: clamp(24px, 5vw, 48px);
  letter-spacing: 4px;
  margin-bottom: 12px;
}

.pixel-text { color: #fff; text-shadow: 0 0 10px #fff; }
.pixel-text.accent {
  color: var(--neon-cyan);
  text-shadow: 0 0 20px var(--neon-cyan), 0 0 40px var(--neon-cyan);
}

.tagline {
  font-size: 10px;
  color: #888;
  letter-spacing: 2px;
  margin-top: 8px;
}

/* ─── DIFFICULTY BAR ─── */
.difficulty-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.diff-label {
  font-size: 9px;
  color: #666;
  letter-spacing: 2px;
}

.diff-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  letter-spacing: 1px;
  padding: 7px 14px;
  background: transparent;
  border: 2px solid #333;
  color: #555;
  cursor: pointer;
  transition: all 0.15s;
}
.diff-btn:hover { border-color: #888; color: #ccc; }
.diff-btn.active[data-level="1"] { border-color: #00ff00; color: #00ff00; background: rgba(0,255,0,0.1); box-shadow: 0 0 10px rgba(0,255,0,0.3); }
.diff-btn.active[data-level="2"] { border-color: #ffff00; color: #ffff00; background: rgba(255,255,0,0.1); box-shadow: 0 0 10px rgba(255,255,0,0.3); }
.diff-btn.active[data-level="3"] { border-color: #ff4444; color: #ff4444; background: rgba(255,68,68,0.1); box-shadow: 0 0 10px rgba(255,68,68,0.3); }

.scanline {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.05) 2px,
    rgba(0,0,0,0.05) 4px
  );
  pointer-events: none;
}

/* ─── GRID ─── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  padding: 40px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ─── CARD ─── */
.game-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.game-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--card-glow, var(--neon-cyan));
  box-shadow: 0 0 20px var(--card-glow, var(--neon-cyan)),
              0 8px 32px rgba(0,0,0,0.6);
}

.game-card[data-color="#00f5ff"]:hover { --card-glow: #00f5ff; }
.game-card[data-color="#ffff00"]:hover { --card-glow: #ffff00; }
.game-card[data-color="#00ff00"]:hover  { --card-glow: #00ff00; }
.game-card[data-color="#ff6600"]:hover  { --card-glow: #ff6600; }
.game-card[data-color="#ff00ff"]:hover  { --card-glow: #ff00ff; }
.game-card[data-color="#ffffff"]:hover  { --card-glow: #ffffff; }

/* ─── PREVIEW AREAS ─── */
.game-preview {
  height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  border-bottom: 2px solid var(--border);
  position: relative;
  overflow: hidden;
}

/* Tetris preview */
.tetris-preview { gap: 3px; }
.block-row { display: flex; gap: 3px; }
.b {
  width: 22px; height: 22px;
  background: var(--neon-cyan);
  box-shadow: inset -3px -3px 0 rgba(0,0,0,0.4);
}
.b.b2 { background: #ff6b6b; }
.b.b3 { background: #a855f7; }
.b.b4 { background: var(--neon-green); }
.b.b5 { background: var(--neon-yellow); }
.b.b6 { background: var(--neon-orange); }

/* Pac-Man preview */
.pacman-preview { gap: 8px; }
.pac-ghost-row { display: flex; gap: 6px; }
.ghost {
  width: 22px; height: 22px;
  border-radius: 11px 11px 0 0;
  position: relative;
}
.ghost::after {
  content: '';
  position: absolute;
  bottom: -5px; left: 0; right: 0; height: 6px;
  background: inherit;
  clip-path: polygon(0 0, 33% 100%, 66% 0, 100% 100%, 100% 0);
}
.ghost-red    { background: #ff0000; }
.ghost-pink   { background: #ffb8ff; }
.ghost-cyan   { background: #00ffff; }
.ghost-orange { background: #ffb852; }

.pacman-char {
  width: 36px; height: 36px;
  background: var(--neon-yellow);
  border-radius: 50%;
  clip-path: polygon(50% 50%, 100% 15%, 100% 85%);
  box-shadow: 0 0 12px var(--neon-yellow);
  animation: chomp 0.4s infinite alternate;
}

@keyframes chomp {
  from { clip-path: polygon(50% 50%, 100% 20%, 100% 80%); }
  to   { clip-path: polygon(50% 50%, 100% 48%, 100% 52%); }
}

.dots-row { display: flex; align-items: center; gap: 8px; }
.dot {
  width: 6px; height: 6px;
  background: #fff;
  border-radius: 50%;
}
.dot.big-dot {
  width: 12px; height: 12px;
  animation: pulse 0.8s infinite alternate;
}
@keyframes pulse {
  from { opacity: 1; }
  to   { opacity: 0.2; }
}

/* Snake preview */
.snake-preview { padding: 10px; }
#snakePreview { image-rendering: pixelated; }

/* Breakout preview */
.breakout-preview {
  gap: 4px;
  position: relative;
}
.bricks { display: flex; flex-direction: column; gap: 3px; }
.brick-row { display: flex; gap: 3px; }
.brick {
  width: 26px; height: 10px;
  border-radius: 1px;
}
.brick.r { background: #ff4444; }
.brick.o { background: #ff8844; }
.brick.y { background: #ffff44; }

.bo-ball {
  width: 10px; height: 10px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 8px #fff;
  animation: bounceBall 1.2s ease-in-out infinite alternate;
}
@keyframes bounceBall {
  from { bottom: 30px; left: 30%; }
  to   { bottom: 80px; left: 70%; }
}

.paddle {
  width: 60px; height: 8px;
  background: var(--neon-cyan);
  border-radius: 2px;
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 8px var(--neon-cyan);
}

/* Space Invaders preview */
.si-preview { flex-direction: column; gap: 4px; }
.invaders-row { display: flex; gap: 6px; font-size: 18px; }
.inv { animation: flicker 1s infinite; }
.inv:nth-child(2) { animation-delay: 0.2s; }
.inv:nth-child(3) { animation-delay: 0.4s; }
.inv:nth-child(4) { animation-delay: 0.6s; }
@keyframes flicker {
  0%, 90%, 100% { opacity: 1; }
  95% { opacity: 0.3; }
}
.laser-beam {
  width: 3px; height: 20px;
  background: var(--neon-green);
  margin: 0 auto;
  box-shadow: 0 0 6px var(--neon-green);
  animation: shootLaser 1.5s infinite;
}
@keyframes shootLaser {
  from { transform: translateY(0); opacity: 1; }
  to   { transform: translateY(-50px); opacity: 0; }
}
.si-ship { font-size: 22px; margin-top: 4px; }

/* Pong preview */
.pong-preview { background: #000; }
.pong-field {
  width: 160px; height: 100px;
  border: 2px solid #333;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pong-field::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  border-left: 2px dashed #333;
}
.pong-paddle {
  width: 6px; height: 36px;
  background: #fff;
  position: absolute;
}
.pong-paddle.left  { left: 8px; animation: pongPaddle 1.2s infinite alternate; }
.pong-paddle.right { right: 8px; animation: pongPaddle 1.2s infinite alternate-reverse; }
@keyframes pongPaddle {
  from { top: 10px; }
  to   { top: 54px; }
}
.pong-ball {
  width: 8px; height: 8px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  animation: pongBall 1.5s linear infinite alternate;
  box-shadow: 0 0 6px #fff;
}
@keyframes pongBall {
  from { left: 20%; top: 20%; }
  to   { left: 75%; top: 70%; }
}

/* ─── GAME INFO ─── */
.game-info {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.game-info h2 {
  font-size: 14px;
  letter-spacing: 2px;
  color: #fff;
}

.game-info p {
  font-size: 8px;
  color: #888;
  line-height: 1.6;
}

.stars {
  font-size: 10px;
  color: var(--neon-yellow);
  letter-spacing: 2px;
}

.play-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 16px;
  background: transparent;
  border: 2px solid currentColor;
  font-size: 10px;
  font-family: inherit;
  letter-spacing: 2px;
  color: var(--neon-cyan);
  align-self: flex-start;
  transition: background 0.15s, color 0.15s;
}

.game-card:hover .play-btn {
  background: var(--neon-cyan);
  color: #000;
}

/* ─── FOOTER ─── */
footer {
  text-align: center;
  padding: 24px;
  font-size: 8px;
  color: #444;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

/* ─── GAME PAGE SHARED ─── */
.game-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  gap: 16px;
}

.game-page h1 {
  font-size: clamp(14px, 3vw, 28px);
  letter-spacing: 4px;
  text-align: center;
}

.back-link {
  color: var(--neon-cyan);
  text-decoration: none;
  font-size: 10px;
  letter-spacing: 2px;
  align-self: flex-start;
  padding: 6px 0;
}
.back-link:hover { text-decoration: underline; }

.score-bar {
  display: flex;
  gap: 32px;
  font-size: 10px;
  letter-spacing: 2px;
  color: #aaa;
}
.score-bar span b { color: var(--neon-yellow); }

canvas {
  display: block;
  image-rendering: pixelated;
  border: 2px solid var(--border);
  box-shadow: 0 0 20px rgba(0, 245, 255, 0.2);
}

.controls-hint {
  font-size: 8px;
  color: #555;
  letter-spacing: 1px;
  text-align: center;
  line-height: 2;
}

.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  padding: 10px 20px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  background: transparent;
  border: 2px solid var(--neon-cyan);
  color: var(--neon-cyan);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn:hover { background: var(--neon-cyan); color: #000; }
.btn.danger { border-color: #ff4444; color: #ff4444; }
.btn.danger:hover { background: #ff4444; color: #000; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  font-family: 'Press Start 2P', monospace;
}
.overlay h2 { font-size: 20px; color: var(--neon-cyan); letter-spacing: 4px; }
.overlay p  { font-size: 10px; color: #aaa; }
