/* PlayerGames — shared design tokens + base components.
   Every page links this once. Keep it small. */

:root {
  /* Brand */
  --grad-1: #ff5e8a;
  --grad-2: #6a5cff;
  --grad-3: #00d9c0;

  /* Surfaces */
  --bg-0: #0d0f1e;
  --bg-1: #161a2e;
  --card: rgba(255, 255, 255, 0.06);
  --card-solid: #ffffff;
  --card-border: rgba(255, 255, 255, 0.10);

  /* Ink */
  --ink: #ffffff;
  --ink-soft: rgba(255, 255, 255, 0.66);
  --ink-mute: rgba(255, 255, 255, 0.42);
  --ink-dark: #1a1d2e;
  --ink-dark-soft: #6b6f8b;

  /* Player marks */
  --x: #ff3d6e;
  --o: #4a8cff;
  --win: #ffd23f;

  /* Effects */
  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 12px 30px -10px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 8px 24px -6px rgba(106, 92, 255, 0.55);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg-0);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Ambient gradient background used on every page. */
body.has-bg::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(60vw 60vw at 12% 8%,  rgba(255, 94, 138, 0.35), transparent 65%),
    radial-gradient(50vw 50vw at 88% 12%, rgba(106, 92, 255, 0.32), transparent 60%),
    radial-gradient(60vw 60vw at 50% 100%, rgba(0, 217, 192, 0.18), transparent 65%);
  pointer-events: none;
  z-index: -1;
}

button { font-family: inherit; }
a { color: inherit; }

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 16px 26px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform .12s var(--ease-pop), box-shadow .15s, opacity .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--grad-1), var(--grad-2));
  color: white;
  box-shadow: var(--shadow-pop);
}
.btn-primary:hover { box-shadow: 0 12px 28px -6px rgba(106, 92, 255, 0.7); }
.btn-ghost {
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
}
.btn-ghost:hover { background: rgba(255,255,255,0.14); }

/* Card glass surface */
.card-glass {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
}

/* Top bar shared across game pages */
.gamebar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: linear-gradient(to bottom, rgba(13,15,30,0.85), rgba(13,15,30,0));
  z-index: 10;
}
.gamebar .back {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--card-border);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  backdrop-filter: blur(12px);
}
.gamebar .back:hover { background: rgba(255,255,255,0.14); }
.gamebar .title { font-size: 16px; font-weight: 700; opacity: 0.95; letter-spacing: 0.2px; }
.gamebar .spacer { width: 100px; }

/* Result modal — used by every game */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8, 9, 22, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
  z-index: 50;
}
.modal-backdrop.show { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--card-solid);
  color: var(--ink-dark);
  border-radius: 28px;
  padding: 36px 32px 28px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  transform: scale(0.85) translateY(20px);
  transition: transform .35s var(--ease-pop);
  box-shadow: var(--shadow-lg);
}
.modal-backdrop.show .modal { transform: scale(1) translateY(0); }
.modal h2 { margin: 0 0 8px; font-size: 30px; font-weight: 800; letter-spacing: -0.5px; }
.modal p  { margin: 0 0 24px; color: var(--ink-dark-soft); font-size: 15px; line-height: 1.4; }
.modal .actions { display: flex; gap: 12px; }
.modal .btn-primary { box-shadow: 0 8px 18px -6px rgba(106, 92, 255, 0.55); }
.modal .btn-ghost   { background: #f1f2fb; color: var(--ink-dark); border: none; backdrop-filter: none; }
.modal .btn-ghost:hover { background: #e7e9f7; }

/* Utility */
.hidden { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Seasonal themes ---------- */
/* Halloween — orange/purple, subtle */
body.theme-halloween::before {
  background:
    radial-gradient(60vw 60vw at 12% 8%,  rgba(255, 121, 30, 0.35), transparent 65%) !important,
    radial-gradient(50vw 50vw at 88% 12%, rgba(168, 60, 255, 0.34), transparent 60%) !important,
    radial-gradient(60vw 60vw at 50% 100%, rgba(255, 210, 63, 0.10), transparent 65%) !important;
}
body.theme-halloween .badge-today { background: linear-gradient(135deg, #ff7a1e, #a83cff) !important; color: white !important; }

/* Winter — cool blues + whites */
body.theme-winter::before {
  background:
    radial-gradient(60vw 60vw at 12% 8%,  rgba(150, 200, 255, 0.30), transparent 65%) !important,
    radial-gradient(50vw 50vw at 88% 12%, rgba(74, 140, 255, 0.30), transparent 60%) !important,
    radial-gradient(60vw 60vw at 50% 100%, rgba(255, 255, 255, 0.10), transparent 65%) !important;
}
body.theme-winter .badge-today { background: linear-gradient(135deg, #ffffff, #4a8cff) !important; }

/* New Year — gold + violet sparkle */
body.theme-newyear::before {
  background:
    radial-gradient(60vw 60vw at 12% 8%,  rgba(255, 210, 63, 0.30), transparent 65%) !important,
    radial-gradient(50vw 50vw at 88% 12%, rgba(168, 60, 255, 0.30), transparent 60%) !important;
}
body.theme-newyear .badge-today { background: linear-gradient(135deg, #ffd23f, #a83cff) !important; color: white !important; }

/* World Cup — green pitch energy */
body.theme-worldcup::before {
  background:
    radial-gradient(60vw 60vw at 12% 8%,  rgba(0, 217, 192, 0.30), transparent 65%) !important,
    radial-gradient(50vw 50vw at 88% 12%, rgba(255, 210, 63, 0.30), transparent 60%) !important,
    radial-gradient(60vw 60vw at 50% 100%, rgba(74, 140, 255, 0.18), transparent 65%) !important;
}
body.theme-worldcup .badge-today { background: linear-gradient(135deg, #00d9c0, #4a8cff) !important; }

/* Map picker row — used inside each game's picker card */
.pg-map-row {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 16px;
}
.pg-map-row .lbl {
  font-size: 11px; font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink-dark-soft);
  text-align: left;
}
.pg-map-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pg-map-opt {
  position: relative;
  text-align: left;
  background: white;
  border: 2px solid #e6e8f7;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all .15s;
  color: var(--ink-dark);
  font-family: inherit;
}
.pg-map-opt:hover { border-color: #c9ccff; }
.pg-map-opt.active {
  border-color: var(--grad-2);
  background: linear-gradient(135deg, rgba(106,92,255,0.05), rgba(255,94,138,0.05));
}
.pg-map-opt .map-name {
  font-size: 14px; font-weight: 800;
  color: var(--ink-dark);
  margin-bottom: 2px;
}
.pg-map-opt .map-desc {
  font-size: 11px; font-weight: 500;
  color: var(--ink-dark-soft);
  line-height: 1.3;
}
.pg-map-opt .map-badge {
  position: absolute; top: 8px; right: 10px;
  background: linear-gradient(135deg, #ffd23f, #ff7a3d);
  color: #1a1d2e;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 9px; font-weight: 800;
  letter-spacing: 0.5px;
}

/* Season banner above the hero (rendered by landing page if active) */
.season-banner {
  display: flex; align-items: center; gap: 10px;
  justify-content: center;
  margin: 8px auto 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.20);
  color: var(--ink);
  font-size: 12px; font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  max-width: max-content;
  backdrop-filter: blur(10px);
}
.season-banner .icon { font-size: 16px; }

/* ============================================================
   SMOOTHNESS PASS — global performance + tactile feedback
   ============================================================
   Applied after the rest of theme so it can override defaults
   where needed. Goal: 60fps on mid-tier mobile + instant tap
   feedback + zero ghost-click delays. */

/* --- Touch behavior baseline --- */
* {
  /* Kill the iOS Safari highlight flash on every interactive thing */
  -webkit-tap-highlight-color: transparent;
}
html, body {
  /* Disable pull-to-refresh + double-tap-zoom inside the app */
  overscroll-behavior: contain;
  touch-action: manipulation;
}
body {
  /* Smoother type rendering on retina screens */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Anything tappable: instant response, no text selection, no callouts */
button, a, .pill, .opt, .tile, .pad, .cell, .hole,
[role="button"], [data-tappable] {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Game canvases — fully suppress browser gestures so drags + multi-touch
   reach the game cleanly */
canvas, .arena, .court, .game-canvas, .stage, .play-area {
  touch-action: none;
}

/* --- GPU compositing hints for the things that animate most.
       NOTE: do NOT include .modal here — it has its own intentional
       transform: scale(...) translateY(...) for the open/close anim
       that we'd clobber. --- */
.tile, .cell, .hole, .pad, .pill, .opt, .ans,
.toast, .flash, .bomb, .mole, .puck {
  backface-visibility: hidden;
}

/* --- Smooth tap feedback (subtle scale + opacity) --- */
@keyframes pgTapPulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.94); }
  100% { transform: scale(1); }
}
button:active:not(:disabled),
.pill:active:not(:disabled),
.opt:active:not(:disabled),
[data-tappable]:active {
  animation: pgTapPulse 180ms var(--ease-pop) both;
}

/* --- Modal backdrop fade — the .modal scale animation already exists
       above with cubic-bezier; just add will-change for GPU hint --- */
.modal { will-change: transform, opacity; }

/* --- Countdown numbers never block input behind them --- */
.countdown, .toast { pointer-events: none; }

/* --- Skeleton shimmer for game-list / leaderboard while data loads --- */
@keyframes pgShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background:
    linear-gradient(90deg,
      rgba(255,255,255,0.06) 0%,
      rgba(255,255,255,0.12) 50%,
      rgba(255,255,255,0.06) 100%);
  background-size: 200% 100%;
  animation: pgShimmer 1.4s linear infinite;
  border-radius: 12px;
}

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

/* --- Containment for game shells so they don't trigger reflow upstream --- */
.arena, .court, .stage, main.card, main.card-glass {
  contain: layout paint style;
}

/* --- iOS Safari: stop highlight on long-press --- */
img, svg { -webkit-user-drag: none; }
