/* ============================================
   ARCADE VAULT — Design System
   Palette: Acid Neon (#CCFF00, #FF3CAC, #0D0D0D)
   Fonts: Clash Display + Space Mono
   ============================================ */

:root {
  --neon-green: #CCFF00;
  --neon-pink: #FF3CAC;
  --neon-blue: #00F5FF;
  --neon-orange: #FF6B2B;
  --neon-purple: #B44FFF;
  --bg: #0D0D0D;
  --bg2: #141414;
  --bg3: #1A1A1A;
  --border: #2a2a2a;
  --text: #F0F0F0;
  --muted: #666;
  --font-display: 'Clash Display', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

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

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  overflow: hidden;
}

/* ============ SCREENS ============ */
.screen { display: none; width: 100%; height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ============ HUB ============ */
#hub {
  overflow-y: auto;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(204,255,0,0.08) 0%, transparent 60%),
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(255,255,255,0.02) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,0.02) 40px);
}

.hub-header {
  text-align: center;
  padding: 48px 24px 32px;
  position: relative;
}

.logo-glitch {
  font-family: var(--font-display);
  font-size: clamp(36px, 7vw, 80px);
  font-weight: 700;
  color: var(--neon-green);
  letter-spacing: 0.08em;
  text-shadow: 0 0 20px rgba(204,255,0,0.6), 0 0 60px rgba(204,255,0,0.2);
  position: relative;
  display: inline-block;
  animation: flicker 6s infinite;
}

.logo-glitch::before,
.logo-glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}
.logo-glitch::before {
  color: var(--neon-pink);
  animation: glitch1 4s infinite;
  clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
}
.logo-glitch::after {
  color: var(--neon-blue);
  animation: glitch2 4s infinite;
  clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
}

@keyframes glitch1 {
  0%,90%,100% { transform: translate(0); opacity: 0; }
  92% { transform: translate(-3px, 1px); opacity: 0.8; }
  94% { transform: translate(3px, -1px); opacity: 0.8; }
  96% { transform: translate(0); opacity: 0; }
}
@keyframes glitch2 {
  0%,88%,100% { transform: translate(0); opacity: 0; }
  90% { transform: translate(3px, 2px); opacity: 0.8; }
  93% { transform: translate(-3px, -2px); opacity: 0.8; }
  95% { transform: translate(0); opacity: 0; }
}
@keyframes flicker {
  0%,95%,100% { opacity: 1; }
  96% { opacity: 0.85; }
  97% { opacity: 1; }
  98% { opacity: 0.9; }
}

.hub-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--muted);
  margin-top: 8px;
  text-transform: uppercase;
}

.scanline {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ============ GAMES GRID ============ */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  padding: 0 24px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.game-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px 20px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--neon-green);
}
.game-card:hover .card-glow {
  opacity: 1;
}
.game-card:hover .card-icon {
  transform: scale(1.2) rotate(-5deg);
}

.card-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(204,255,0,0.12) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.card-icon {
  font-size: 36px;
  transition: transform 0.2s;
  display: block;
}

.card-info h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
}

.tag {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--neon-pink);
  font-family: var(--font-mono);
  background: rgba(255,60,172,0.1);
  padding: 2px 6px;
  border-radius: 2px;
  border: 1px solid rgba(255,60,172,0.3);
}

.card-score {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  margin-top: auto;
}

.hub-footer {
  text-align: center;
  padding: 16px;
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--muted);
  animation: pulse-text 2s infinite;
}
@keyframes pulse-text {
  0%,100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ============ GAME OVERLAY ============ */
#game-overlay {
  background: var(--bg);
  flex-direction: column;
}

.game-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.back-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 12px;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.15s;
  border-radius: 2px;
}
.back-btn:hover {
  border-color: var(--neon-pink);
  color: var(--neon-pink);
}

.game-title-bar {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--neon-green);
  letter-spacing: 0.1em;
  flex: 1;
}

.game-score-bar {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--neon-pink);
  letter-spacing: 0.1em;
}

.game-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.game-panel {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
  width: 100%;
  height: 100%;
}
.game-panel.active { display: flex; }

.game-controls-hint {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* ============ START OVERLAY ============ */
.start-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13,13,13,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 10;
  backdrop-filter: blur(4px);
}
.start-overlay.hidden { display: none; }

.overlay-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--neon-green);
  letter-spacing: 0.1em;
  text-shadow: 0 0 20px rgba(204,255,0,0.5);
}

.play-btn {
  background: var(--neon-green);
  color: #000;
  border: none;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.15em;
  padding: 14px 40px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s;
  text-transform: uppercase;
}
.play-btn:hover {
  background: #fff;
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(204,255,0,0.5);
}

/* ============ CANVAS GAMES ============ */
canvas {
  border: 1px solid var(--border);
  border-radius: 2px;
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 160px);
}

/* ============ MODAL ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
}
.modal.hidden { display: none; }

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--neon-green);
  border-radius: 4px;
  padding: 40px;
  text-align: center;
  min-width: 300px;
  box-shadow: 0 0 60px rgba(204,255,0,0.2);
  animation: modal-in 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modal-in {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-emoji { font-size: 48px; margin-bottom: 8px; }
.modal-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--neon-green);
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}
.modal-score {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--text);
  margin-bottom: 8px;
}
.modal-hi {
  font-size: 12px;
  color: var(--neon-pink);
  letter-spacing: 0.1em;
  margin-bottom: 24px;
  min-height: 20px;
}
.modal-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ============ MEMORY GAME ============ */
.memory-board {
  display: grid;
  grid-template-columns: repeat(4, 80px);
  grid-template-rows: repeat(4, 80px);
  gap: 8px;
}

.memory-card {
  width: 80px; height: 80px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  transition: transform 0.3s, background 0.2s;
  transform-style: preserve-3d;
  position: relative;
}
.memory-card.flipped { background: var(--bg2); border-color: var(--neon-green); }
.memory-card.matched { background: rgba(204,255,0,0.1); border-color: var(--neon-green); cursor: default; }
.memory-card .card-front {
  position: absolute;
  font-size: 28px;
  opacity: 0;
  transition: opacity 0.2s;
}
.memory-card.flipped .card-front,
.memory-card.matched .card-front { opacity: 1; }
.memory-card .card-back {
  font-size: 20px;
  color: var(--muted);
  transition: opacity 0.2s;
}
.memory-card.flipped .card-back,
.memory-card.matched .card-back { opacity: 0; }

.memory-info {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.1em;
}

/* ============ WHACK A MOLE ============ */
.whack-timer {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--neon-pink);
  letter-spacing: 0.2em;
}

.whack-grid {
  display: grid;
  grid-template-columns: repeat(3, 100px);
  grid-template-rows: repeat(3, 100px);
  gap: 12px;
}

.mole-hole {
  width: 100px; height: 100px;
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  user-select: none;
  position: relative;
  overflow: hidden;
}
.mole-hole.active {
  background: rgba(204,255,0,0.1);
  border-color: var(--neon-green);
  animation: mole-pop 0.15s ease-out;
}
.mole-hole.whacked {
  background: rgba(255,60,172,0.2);
  border-color: var(--neon-pink);
}
@keyframes mole-pop {
  from { transform: scale(0.5); }
  to { transform: scale(1); }
}

/* ============ TETRIS ============ */
.tetris-panel {
  flex-direction: row !important;
  gap: 20px;
}

.tetris-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.tetris-stat {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.15em;
  text-align: center;
  line-height: 2;
}
.tetris-stat span {
  display: block;
  font-size: 22px;
  color: var(--neon-green);
  font-family: var(--font-display);
  font-weight: 700;
}

/* ============ FLAPPY BIRD ============ */
#flappy-canvas { border-color: var(--neon-blue); }

/* ============ 2048 ============ */
.g2048-board {
  display: grid;
  grid-template-columns: repeat(4, 80px);
  grid-template-rows: repeat(4, 80px);
  gap: 8px;
  background: var(--bg3);
  padding: 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.tile-2048 {
  width: 80px; height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  border-radius: 3px;
  transition: all 0.1s;
  animation: tile-appear 0.15s ease-out;
}
@keyframes tile-appear {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.tile-0    { background: var(--bg2); color: transparent; }
.tile-2    { background: #1a2a0a; color: var(--neon-green); border: 1px solid #2a4a10; }
.tile-4    { background: #1a1a2a; color: #88aaff; border: 1px solid #2a2a4a; }
.tile-8    { background: #2a1a0a; color: var(--neon-orange); border: 1px solid #4a2a10; }
.tile-16   { background: #2a0a1a; color: var(--neon-pink); border: 1px solid #4a1030; }
.tile-32   { background: #1a0a2a; color: var(--neon-purple); border: 1px solid #3a1050; }
.tile-64   { background: #0a1a2a; color: var(--neon-blue); border: 1px solid #1030aa; }
.tile-128  { background: #2a2a0a; color: #ffff00; border: 1px solid #4a4a10; font-size: 18px; }
.tile-256  { background: #2a1a1a; color: #ff8800; border: 1px solid #4a2a2a; font-size: 18px; }
.tile-512  { background: #1a2a2a; color: #00ffaa; border: 1px solid #1a4a4a; font-size: 18px; }
.tile-1024 { background: #2a0a0a; color: #ff4444; border: 1px solid #4a1010; font-size: 14px; }
.tile-2048 { background: var(--neon-green); color: #000; font-size: 14px; box-shadow: 0 0 20px rgba(204,255,0,0.5); }

/* ============ TYPING SPEED ============ */
.typing-timer {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 700;
  color: var(--neon-green);
  text-shadow: 0 0 20px rgba(204,255,0,0.4);
}

.typing-text {
  max-width: 600px;
  font-family: var(--font-mono);
  font-size: 18px;
  line-height: 1.8;
  color: var(--muted);
  text-align: center;
  padding: 20px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  letter-spacing: 0.05em;
}
.typing-text .correct { color: var(--neon-green); }
.typing-text .wrong { color: var(--neon-pink); background: rgba(255,60,172,0.15); }
.typing-text .current { border-bottom: 2px solid var(--neon-green); }

.typing-input {
  width: 600px;
  max-width: 90vw;
  background: var(--bg2);
  border: 1px solid var(--neon-green);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  padding: 12px 16px;
  border-radius: 2px;
  outline: none;
  caret-color: var(--neon-green);
}
.typing-input:focus { box-shadow: 0 0 15px rgba(204,255,0,0.2); }

.typing-stats {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.1em;
}

/* ============ COLOR MATCH ============ */
.cm-timer {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 700;
  color: var(--neon-green);
}

.cm-word {
  font-family: var(--font-display);
  font-size: 72px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-shadow: 0 0 30px currentColor;
  transition: color 0.1s;
}

.cm-question {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.cm-buttons {
  display: flex;
  gap: 20px;
}

.cm-btn {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 16px 40px;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.1s;
}
.yes-btn { background: var(--neon-green); color: #000; }
.no-btn  { background: var(--neon-pink); color: #fff; }
.cm-btn:hover { transform: scale(1.08); }
.cm-btn:active { transform: scale(0.95); }

.cm-streak {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.2em;
}

/* ============ REACTION TIME ============ */
.reaction-area {
  width: 400px;
  height: 300px;
  max-width: 90vw;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.1s;
  border: 2px solid var(--border);
  background: var(--bg2);
  user-select: none;
}
.reaction-area.waiting { background: #1a0a0a; border-color: var(--neon-pink); }
.reaction-area.go { background: rgba(204,255,0,0.15); border-color: var(--neon-green); animation: reaction-pulse 0.3s ease-out; }
@keyframes reaction-pulse {
  from { transform: scale(0.97); }
  to { transform: scale(1); }
}

.reaction-msg {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text);
}
.reaction-area.go .reaction-msg { color: var(--neon-green); text-shadow: 0 0 20px rgba(204,255,0,0.6); }
.reaction-area.waiting .reaction-msg { color: var(--neon-pink); }

.reaction-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  letter-spacing: 0.1em;
}

.reaction-results {
  display: flex;
  gap: 32px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.1em;
}
.reaction-results span { color: var(--neon-green); }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--neon-green); }

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
  .games-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0 12px 12px; }
  .memory-board { grid-template-columns: repeat(4, 65px); grid-template-rows: repeat(4, 65px); }
  .memory-card { width: 65px; height: 65px; font-size: 24px; }
  .g2048-board { grid-template-columns: repeat(4, 65px); grid-template-rows: repeat(4, 65px); }
  .tile-2048 { width: 65px; height: 65px; font-size: 18px; }
  .whack-grid { grid-template-columns: repeat(3, 80px); grid-template-rows: repeat(3, 80px); }
  .mole-hole { width: 80px; height: 80px; }
  .tetris-panel { flex-direction: column !important; }
  .cm-word { font-size: 48px; }
  .reaction-area { width: 90vw; }
}