/* ================================================================
   GAMES — games.css
   Shared overlay, HUD, CRT layer, and D-pad for all mini-games.
   Each game sets its own --game-bg, --game-fg, --game-accent vars.
   ================================================================ */

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

/* ── DEFAULTS ─────────────────────────────────────────────────── */
.game-overlay {
  --game-bg:     #0e0c0a;
  --game-fg:     #b89d6e;
  --game-fg-dim: rgba(184,157,110,0.45);
  --game-accent: #d4462a;
  --game-head:   #e8d4a4;
  --game-border: rgba(184,157,110,0.18);
}

/* ── OVERLAY ─────────────────────────────────────────────────── */
.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 9600;
  background: var(--game-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overflow: hidden;
}

.game-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

body.game-open {
  overflow: hidden !important;
}

/* ── HUD ─────────────────────────────────────────────────────── */
.game-hud {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--game-border);
  flex-shrink: 0;
  box-sizing: border-box;
}

.game-hud-scores {
  display: flex;
  gap: 28px;
}

.game-score-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.game-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--game-fg-dim);
  letter-spacing: 0.08em;
  line-height: 1;
}

.game-value {
  font-family: 'Press Start 2P', monospace;
  font-size: 18px;
  color: var(--game-fg);
  line-height: 1;
}

.game-title-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: var(--game-fg);
  letter-spacing: 0.2em;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.game-close {
  background: none;
  border: 1px solid var(--game-border);
  color: var(--game-fg);
  font-size: 14px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.game-close:hover {
  border-color: var(--game-fg);
  color: var(--game-head);
  background: rgba(255,255,255,0.04);
}

/* ── CANVAS WRAPPER ──────────────────────────────────────────── */
.game-canvas-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
}

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

/* scanlines over canvas only */
.game-canvas-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.10) 2px,
    rgba(0,0,0,0.10) 4px
  );
}

/* ── D-PAD ───────────────────────────────────────────────────── */
.game-dpad {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 0 22px;
  flex-shrink: 0;
}

.dpad-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* The center spacer keeps the cross shape */
.dpad-center {
  width: 60px;
  height: 60px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--game-border);
  box-sizing: border-box;
}

.dpad-btn {
  width: 60px;
  height: 60px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--game-border);
  color: var(--game-fg);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background 0.08s, border-color 0.08s, color 0.08s;
  box-sizing: border-box;
  /* Ensure minimum touch target even if visually 60px */
  min-width: 60px;
  min-height: 60px;
}

.dpad-btn:active,
.dpad-btn.is-pressed {
  background: rgba(184,157,110,0.18);
  border-color: var(--game-fg);
  color: var(--game-head);
}

/* Show d-pad only on tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  .game-dpad {
    display: flex;
  }
}

/* ── LONG PRESS HINT ─────────────────────────────────────────── */
/* Progress ring shown on nav icons during long press */
.nav-icons.press-active::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(184,157,110,0.6);
  animation: press-ring 3s linear forwards;
  pointer-events: none;
}

@keyframes press-ring {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0% 0 0); }
}

/* ── PONG D-PAD: two wide side-by-side buttons ──────────────── */
.pong-dpad {
  flex-direction: row !important;
  gap: 12px;
  padding: 14px 24px 22px !important;
}

.pong-dpad .dpad-btn {
  flex: 1;
  max-width: 200px;
  height: 64px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  gap: 8px;
}

/* ── BLINK ANIMATION ─────────────────────────────────────────── */
@keyframes game-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.game-blink {
  animation: game-blink 1s step-end infinite;
}
