/* ========================================
   Babayagas Arcade — Shared Game Styles
   All games load this for consistent look
   ======================================== */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #111111;
  --bg-surface: #1a1a1a;
  --bg-elevated: #222222;
  --bg-card: #252525;
  --border: #333333;
  --border-light: #444444;

  --cyan: #06B6D4;
  --cyan-light: #22D3EE;
  --cyan-dark: #0891B2;
  --cyan-glow: rgba(6, 182, 212, 0.3);
  --cyan-subtle: rgba(6, 182, 212, 0.08);

  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --orange: #f97316;
  --purple: #a855f7;
  --pink: #ec4899;

  --text: #EBEBEB;
  --text-bright: #FFFFFF;
  --text-muted: #999999;
  --text-dim: #666666;

  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-body: 'Inter', -apple-system, sans-serif;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --- Game Header --- */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.game-header .back-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.game-header .back-link:hover {
  color: var(--cyan);
}

.game-header .game-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: -0.5px;
}

.game-header .game-score {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- HUD Bar (in-game stats) --- */
.game-hud {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 0.6rem 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.game-hud .hud-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.game-hud .hud-label {
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 1px;
}

.game-hud .hud-value {
  color: var(--cyan-light);
  font-weight: 600;
}

/* --- Game Canvas Container --- */
.game-canvas-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  flex: 1;
}

.game-canvas-wrap canvas {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  touch-action: none;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.5rem;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.3;
}

.btn-primary {
  background: var(--cyan);
  color: #000;
}

.btn-primary:hover {
  background: var(--cyan-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--cyan-glow);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--cyan);
  color: var(--cyan-light);
}

.btn-sm {
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.85rem 2rem;
  font-size: 1.05rem;
}

/* --- Overlays (start screen, game over, etc) --- */
.game-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 2rem;
}

.game-overlay-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.game-overlay-content h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-bright);
  margin-bottom: 0.75rem;
  letter-spacing: -0.5px;
}

.game-overlay-content h2 .cyan { color: var(--cyan); }
.game-overlay-content h2 .green { color: var(--green); }
.game-overlay-content h2 .red { color: var(--red); }

.game-overlay-content p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.game-overlay-content .stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.game-overlay-content .stat-row .stat-label { color: var(--text-muted); }
.game-overlay-content .stat-row .stat-value { color: var(--text-bright); font-weight: 600; }

.game-overlay-content .btn {
  margin-top: 1.25rem;
  width: 100%;
}

/* --- New High Score --- */
.new-highscore {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
  animation: highscore-pulse 1s ease-in-out infinite;
}

@keyframes highscore-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- Mobile Controls --- */
.mobile-controls {
  display: none;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

.mobile-btn {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}

.mobile-btn:active {
  background: var(--cyan-dark);
  border-color: var(--cyan);
}

@media (max-width: 768px) {
  .mobile-controls { display: flex; }
}

/* --- Difficulty Selector --- */
.difficulty-bar {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  flex-wrap: wrap;
}

.diff-btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.4rem 1rem;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.diff-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.diff-btn.active {
  background: var(--cyan);
  color: #000;
  border-color: var(--cyan);
  font-weight: 600;
}

/* --- Grid Games (board games, puzzles) --- */
.game-board {
  display: grid;
  gap: 2px;
  margin: 0 auto;
  padding: 1rem;
}

.game-cell {
  aspect-ratio: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.game-cell:hover {
  border-color: var(--cyan);
  background: rgba(6, 182, 212, 0.05);
}

.game-cell.active {
  border-color: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
}

/* --- Card Games --- */
.playing-card {
  width: 70px;
  height: 100px;
  background: var(--text-bright);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.playing-card:hover {
  transform: translateY(-4px);
}

.playing-card.face-down {
  background: linear-gradient(135deg, var(--cyan-dark), #0e4f5c);
  color: transparent;
}

.playing-card .suit-red { color: #dc2626; }
.playing-card .suit-black { color: #1f2937; }

/* --- 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(--border-light); }

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 4px var(--cyan-glow); }
  50% { box-shadow: 0 0 16px var(--cyan-glow); }
}

.animate-fadeIn { animation: fadeIn 0.3s ease; }
.animate-scaleIn { animation: scaleIn 0.3s ease; }
.animate-shake { animation: shake 0.3s ease; }

/* --- Utility --- */
.text-cyan { color: var(--cyan); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }
.font-display { font-family: var(--font-display); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none !important; }

/* --- Responsive --- */
@media (max-width: 480px) {
  .game-header { padding: 0.5rem 0.75rem; }
  .game-header .game-title { font-size: 0.95rem; }
  .game-hud { gap: 0.75rem; font-size: 0.7rem; }
  .game-overlay-content { padding: 1.5rem; }
  .game-overlay-content h2 { font-size: 1.4rem; }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
