/* ============================================
   RETRO ARCADE - Shared Styles
   90s aesthetic with CRT vibes
   ============================================ */

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

:root {
  --bg-dark: #0a0a1a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --neon-pink: #ff2d95;
  --neon-cyan: #00e5ff;
  --neon-yellow: #ffe156;
  --neon-green: #39ff14;
  --neon-orange: #ff6f3c;
  --neon-purple: #bf5af2;
  --text-primary: #e0e0e0;
  --text-dim: #888;
  --border-glow: rgba(0, 229, 255, 0.2);
  --font-pixel: 'Press Start 2P', monospace;
  --font-mono: 'Share Tech Mono', 'Courier New', monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-mono);
  min-height: 100vh;
  overflow-x: hidden;
}

/* CRT scanline overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.08) 0px,
    rgba(0, 0, 0, 0.08) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 9999;
}

/* --- Game page navigation bar --- */
.game-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  background: rgba(0, 0, 0, 0.6);
  border-bottom: 1px solid var(--border-glow);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.back-btn {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--neon-cyan);
  text-decoration: none;
  padding: 8px 16px;
  border: 1px solid var(--neon-cyan);
  border-radius: 4px;
  transition: all 0.2s;
  white-space: nowrap;
}

.back-btn:hover {
  background: rgba(0, 229, 255, 0.1);
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
}

.game-nav .game-title {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: var(--neon-yellow);
  text-shadow: 0 0 10px rgba(255, 225, 86, 0.5);
}

/* --- Game container (used by all game pages) --- */
.game-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  padding: 24px;
  min-height: calc(100vh - 53px);
}

.game-canvas-container {
  position: relative;
}

.game-canvas-container canvas {
  display: block;
  border: 2px solid rgba(0, 229, 255, 0.3);
  border-radius: 4px;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.15);
  background: rgba(0, 0, 0, 0.5);
}

/* --- Side panel for score/info --- */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 150px;
}

.info-box {
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: 6px;
  padding: 14px;
}

.info-box h3 {
  font-family: var(--font-pixel);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--neon-cyan);
  margin-bottom: 6px;
}

.info-box .value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: bold;
  color: var(--text-primary);
}

.info-box .controls-list {
  font-size: 12px;
  line-height: 2.2;
  color: var(--text-dim);
}

.info-box kbd {
  display: inline-block;
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid rgba(0, 229, 255, 0.2);
  border-radius: 3px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--neon-cyan);
}

/* --- Overlay (start/pause/game-over screens) --- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 4px;
  z-index: 10;
  text-align: center;
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  font-family: var(--font-pixel);
  font-size: 24px;
  color: var(--neon-pink);
  margin-bottom: 8px;
  text-shadow: 0 0 20px rgba(255, 45, 149, 0.5);
}

.overlay h2 {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: var(--neon-yellow);
  margin-bottom: 20px;
}

.overlay p {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-primary);
  animation: blink 1.2s ease-in-out infinite;
}

.overlay .final-score {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--neon-green);
  margin-bottom: 16px;
}

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

/* --- Grid-based games (Minesweeper, Lights Out, etc.) --- */
.grid-game {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  min-height: calc(100vh - 53px);
}

.grid-game .game-grid {
  display: inline-grid;
  gap: 2px;
  margin: 20px 0;
}

.grid-game .cell {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: bold;
  border: 1px solid rgba(0, 229, 255, 0.15);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

/* --- Buttons --- */
.arcade-btn {
  font-family: var(--font-pixel);
  font-size: 10px;
  padding: 12px 24px;
  background: transparent;
  color: var(--neon-cyan);
  border: 2px solid var(--neon-cyan);
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.2s;
}

.arcade-btn:hover {
  background: rgba(0, 229, 255, 0.15);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
  transform: translateY(-1px);
}

.arcade-btn.primary {
  color: var(--neon-pink);
  border-color: var(--neon-pink);
}

.arcade-btn.primary:hover {
  background: rgba(255, 45, 149, 0.15);
  box-shadow: 0 0 20px rgba(255, 45, 149, 0.3);
}

/* --- Retro Visitor Counter --- */
.game-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  margin-left: auto;
}

.game-counter .counter-label {
  font-family: var(--font-pixel);
  font-size: 7px;
  color: rgba(57, 255, 20, 0.5);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.game-counter .counter-digits {
  display: inline-flex;
  gap: 2px;
}

.game-counter .counter-digit {
  display: inline-block;
  width: 16px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: bold;
  color: #39ff14;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(57, 255, 20, 0.2);
  border-radius: 2px;
  text-shadow: 0 0 6px rgba(57, 255, 20, 0.5);
}

/* --- Donation footer --- */
.donate-footer {
  text-align: center;
  padding: 10px 20px 36px;
  max-width: 700px;
  margin: 0 auto;
}

.donate-footer .donate-cta {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.donate-footer .donate-cta a {
  color: var(--neon-pink);
  text-decoration: none;
  transition: all 0.2s;
}

.donate-footer .donate-cta a:hover {
  text-shadow: 0 0 10px rgba(255, 45, 149, 0.5);
}

.donate-footer .donate-cta .coffee {
  font-size: 18px;
}

.donate-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin: 6px 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
}

.donate-row svg {
  flex-shrink: 0;
}

.donate-row .addr {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  word-break: break-all;
  text-align: left;
  user-select: all;
  line-height: 1.4;
}

@media (max-width: 500px) {
  .donate-row .addr {
    font-size: 9px;
  }
}

/* --- Genre Tab Navigation --- */
.genre-tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 8px;
}

.genre-tab {
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: 1px;
  padding: 10px 20px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  white-space: nowrap;
}

.genre-tab:hover {
  color: var(--neon-cyan);
  border-color: rgba(0, 229, 255, 0.3);
  background: rgba(0, 229, 255, 0.04);
}

.genre-tab:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

.genre-tab.active {
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
  border-bottom-color: var(--bg-dark);
  background: rgba(0, 229, 255, 0.06);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}

/* ============================================
   DOPAMINE EFFECTS — Keyframes & Utility Classes
   ============================================ */

/* Float-up text ("+10" score popups) */
@keyframes fx-float-up {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  70% { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(-60px) scale(1.2); }
}

.fx-float-text {
  position: absolute;
  font-family: var(--font-pixel);
  font-size: 14px;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px rgba(255, 225, 86, 0.6);
  pointer-events: none;
  z-index: 50;
  animation: fx-float-up 0.9s ease-out forwards;
}

/* Score pulse (scale + glow) */
@keyframes fx-score-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); filter: brightness(1.5) drop-shadow(0 0 8px var(--neon-cyan)); }
  100% { transform: scale(1); filter: brightness(1) drop-shadow(0 0 0 transparent); }
}

.fx-score-pulse {
  animation: fx-score-pulse 0.45s ease-out !important;
}

/* Flash overlay */
@keyframes fx-flash {
  0% { opacity: 0.8; }
  100% { opacity: 0; }
}

.fx-flash-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  border-radius: inherit;
  animation: fx-flash 0.15s ease-out forwards;
}

/* Confetti particles */
@keyframes fx-confetti-fall {
  0% { opacity: 1; transform: translateY(0) translateX(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(350px) translateX(var(--fx-x, 0)) rotate(var(--fx-r, 360deg)); }
}

.fx-confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 1px;
  pointer-events: none;
  z-index: 50;
  animation: fx-confetti-fall 1.5s ease-in forwards;
}

/* High-score glow */
@keyframes fx-highscore-glow {
  0%, 100% { box-shadow: 0 0 15px rgba(255, 225, 86, 0.2); }
  50% { box-shadow: 0 0 40px rgba(255, 225, 86, 0.4), 0 0 80px rgba(255, 45, 149, 0.2); }
}

.fx-highscore-glow {
  animation: fx-highscore-glow 0.8s ease-in-out 2;
}

/* Sound toggle button */
.sfx-toggle {
  font-size: 20px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
  flex-shrink: 0;
}

.sfx-toggle:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

/* --- Tutorial Panel (How to Play) --- */
.tutorial-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 200px;
  min-width: 160px;
  flex-shrink: 0;
}

.tutorial-panel .tutorial-box {
  background: var(--bg-card);
  border: 1px solid rgba(255, 225, 86, 0.15);
  border-radius: 6px;
  padding: 14px;
}

.tutorial-panel .tutorial-box h3 {
  font-family: var(--font-pixel);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--neon-yellow);
  margin-bottom: 10px;
}

.tutorial-panel .tutorial-goal {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.tutorial-panel .tutorial-tips {
  list-style: none;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-dim);
}

.tutorial-panel .tutorial-tips li {
  padding-left: 14px;
  position: relative;
  margin-bottom: 6px;
}

.tutorial-panel .tutorial-tips li::before {
  content: '>';
  position: absolute;
  left: 0;
  color: var(--neon-cyan);
  font-weight: bold;
}

/* Wrapper for centered games with tutorial */
.game-with-tutorial {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  padding: 24px;
  min-height: calc(100vh - 53px);
}

.game-with-tutorial > .game-2048,
.game-with-tutorial > .grid-game,
.game-with-tutorial > .memory-container,
.game-with-tutorial > .simon-container,
.game-with-tutorial > .doom-wrapper {
  min-height: auto;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .tutorial-panel {
    display: none;
  }
  .game-with-tutorial {
    display: contents;
  }
}

@media (max-width: 700px) {
  .game-wrapper {
    flex-direction: column;
    align-items: center;
  }
  .side-panel {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    min-width: auto;
  }
}
