/* ==========================================================================
   PlayDuelHub - Dark Gaming Theme
   File: /assets/style.css
   Mobile-first, responsive grid, no external dependencies
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
:root {
  --bg: #07080f;
  --bg-alt: #0d0f1c;
  --surface: #121528;
  --surface-2: #181c35;
  --border: #23284a;
  --text: #e8eaf6;
  --text-muted: #9aa0c3;
  --cyan: #22d3ee;
  --magenta: #e879f9;
  --lime: #a3e635;
  --amber: #fbbf24;
  --violet: #8b5cf6;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --glow-cyan: 0 0 18px rgba(34, 211, 238, 0.45);
  --glow-magenta: 0 0 18px rgba(232, 121, 249, 0.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --container: 1180px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------- 2. Reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(139, 92, 246, 0.18), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(34, 211, 238, 0.12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; height: auto; }

a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--magenta); }

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.2;
  margin: 0 0 0.6em;
  letter-spacing: 0.01em;
}

p { margin: 0 0 1em; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 3. Utilities ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1rem;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--cyan);
  color: #000;
  padding: 0.6rem 1rem;
  z-index: 100;
  font-weight: 700;
}
.skip-link:focus { left: 1rem; top: 1rem; color: #000; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.gradient-text {
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- 4. Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(7, 8, 15, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text);
}
.logo:hover { color: var(--text); }
.logo svg { width: 34px; height: 34px; filter: drop-shadow(var(--glow-cyan)); }

.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
}
.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  display: block;
  width: 20px; height: 2px;
  background: currentColor;
  border-radius: 2px;
  position: relative;
  transition: transform 0.25s var(--ease), opacity 0.25s;
}
.nav-toggle span::before,
.nav-toggle span::after { content: ""; position: absolute; left: 0; }
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after { top: 6px; }
.nav-toggle[aria-expanded="true"] span { background: transparent; }
.nav-toggle[aria-expanded="true"] span::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span::after { transform: translateY(-6px) rotate(-45deg); }

.site-nav {
  display: none;
  position: absolute;
  top: 64px; left: 0; right: 0;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem 1rem;
}
.site-nav.is-open { display: block; }
.site-nav ul { list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: block;
  padding: 0.75rem 0.5rem;
  color: var(--text-muted);
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.site-nav a:hover,
.site-nav a[aria-current="page"] { color: var(--text); background: var(--surface); }

/* ---------- 5. Hero ---------- */
.hero {
  padding: 3rem 0 2rem;
  text-align: center;
}
.hero .eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lime);
  background: rgba(163, 230, 53, 0.08);
  border: 1px solid rgba(163, 230, 53, 0.3);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}
.hero h1 { font-size: clamp(1.9rem, 6vw, 3.4rem); font-weight: 800; }
.hero p {
  max-width: 640px;
  margin: 0 auto 1.6rem;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 46px;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.98rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s;
}
.btn-primary {
  color: #05060b;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  box-shadow: var(--glow-cyan);
}
.btn-primary:hover { color: #05060b; transform: translateY(-2px); box-shadow: var(--glow-magenta); }
.btn-ghost { color: var(--text); background: var(--surface); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--cyan); }

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; }

/* ---------- 6. Sections ---------- */
.section { padding: 2.5rem 0; }
.section-head { margin-bottom: 1.5rem; }
.section-head h2 { font-size: clamp(1.4rem, 4vw, 2rem); }
.section-head p { color: var(--text-muted); margin: 0; }

/* ---------- 7. Game grid + cards ---------- */
.game-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.game-card {
  --accent: var(--cyan);
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.25s var(--ease), border-color 0.25s, box-shadow 0.25s;
}
.game-card:hover,
.game-card:focus-within {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 22px color-mix(in srgb, var(--accent) 40%, transparent);
}
.game-card--cyan { --accent: var(--cyan); }
.game-card--magenta { --accent: var(--magenta); }
.game-card--amber { --accent: var(--amber); }
.game-card--lime { --accent: var(--lime); }

.game-thumb {
  aspect-ratio: 16 / 10;
  background: #05060b;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.game-thumb svg { width: 100%; height: 100%; transition: transform 0.4s var(--ease); }
.game-card:hover .game-thumb svg { transform: scale(1.05); }

.game-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1rem 1.1rem 1.2rem;
}
.game-body h3 { font-size: 1.2rem; margin-bottom: 0.35rem; }
.game-body h3 a { color: var(--text); }
.game-body h3 a::after {
  /* whole card is clickable */
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}
.game-body p { color: var(--text-muted); font-size: 0.94rem; margin-bottom: 0.9rem; }

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0 0 1rem; padding: 0; }
.tags li {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.play-btn {
  margin-top: auto;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 800;
  font-size: 0.9rem;
  color: #05060b;
  background: var(--accent);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
}

/* ---------- 8. AIO overview ---------- */
.aio {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.2rem;
}
.aio .aio-summary {
  font-size: 1.05rem;
  color: var(--text);
  border-left: 3px solid var(--cyan);
  padding-left: 0.9rem;
  margin-bottom: 1.4rem;
}
.aio-facts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
  margin: 0 0 1.4rem;
}
.aio-facts div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
}
.aio-facts dt { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700; }
.aio-facts dd { margin: 0.2rem 0 0; font-weight: 700; }

.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.6rem;
}
.faq summary {
  cursor: pointer;
  list-style: none;
  padding: 0.9rem 2.4rem 0.9rem 1rem;
  font-weight: 700;
  position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 1rem; top: 50%;
  transform: translateY(-50%);
  color: var(--cyan);
  font-size: 1.3rem;
  font-weight: 800;
}
.faq details[open] summary::after { content: "\2212"; }
.faq details p { padding: 0 1rem 1rem; margin: 0; color: var(--text-muted); }

/* ---------- 9. Footer ---------- */
.site-footer {
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.footer-inner { display: flex; flex-direction: column; gap: 1rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; list-style: none; margin: 0; padding: 0; }
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--cyan); }

/* ---------- 10. Breakpoints (mobile-first) ---------- */
@media (min-width: 560px) {
  .game-grid { grid-template-columns: repeat(2, 1fr); }
  .aio-facts { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 860px) {
  .container { padding: 0 1.5rem; }
  .nav-toggle { display: none; }
  .site-nav {
    display: block;
    position: static;
    background: none;
    border: 0;
    padding: 0;
  }
  .site-nav ul { display: flex; gap: 0.3rem; }
  .site-nav a { padding: 0.5rem 0.9rem; }
  .hero { padding: 4.5rem 0 3rem; }
  .section { padding: 3.5rem 0; }
  .aio { padding: 2rem; }
  .aio-facts { grid-template-columns: repeat(4, 1fr); }
  .footer-inner { flex-direction: row; justify-content: space-between; align-items: center; }
}

@media (min-width: 1100px) {
  .game-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ==========================================================================
   11. Game pages (/games/*.html)
   ========================================================================== */
.breadcrumb { padding: 1rem 0 0; font-size: 0.85rem; color: var(--text-muted); }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; }
.breadcrumb li + li::before { content: "/"; margin-right: 0.4rem; color: var(--border); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--cyan); }

.game-header { padding: 1.2rem 0 1rem; }
.game-header h1 { font-size: clamp(1.6rem, 5vw, 2.6rem); margin-bottom: 0.3rem; }
.game-header p { color: var(--text-muted); margin: 0; }

.game-stage {
  --accent: var(--cyan);
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #05060b;
  box-shadow: var(--shadow), 0 0 28px color-mix(in srgb, var(--accent) 25%, transparent);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.game-stage--magenta { --accent: var(--magenta); }
.canvas-wrap { position: relative; }
.game-stage canvas {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: calc(100vh - 140px);
  max-height: calc(100dvh - 140px);
  object-fit: contain;
  background: #05060b;
  cursor: crosshair;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.8rem;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.hud span b { color: var(--accent); }
.hud-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  min-width: 36px;
  height: 32px;
  cursor: pointer;
  font-size: 0.95rem;
}
.hud-btn:hover { border-color: var(--accent); }
.hud-actions { display: flex; gap: 0.35rem; }

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.5rem;
  text-align: center;
  background: rgba(5, 6, 11, 0.78);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.game-overlay[hidden] { display: none; }
.game-overlay h2 { font-size: 1.7rem; margin: 0; }
.game-overlay p { color: var(--text-muted); margin: 0; max-width: 320px; }
.game-overlay .big-score { font-size: 2.4rem; font-weight: 800; color: var(--accent); line-height: 1; }

.controls-help {
  max-width: 480px;
  margin: 0.9rem auto 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.controls-help div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
}
.controls-help strong { color: var(--text); }
kbd {
  font-family: inherit;
  font-size: 0.78rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.05rem 0.4rem;
  color: var(--text);
}

.aio-box {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-left: 4px solid var(--cyan);
  border-radius: var(--radius);
  padding: 1.2rem 1.2rem 0.6rem;
}
.aio-box h2 { font-size: 1.2rem; }
.aio-box ul { margin: 0 0 1rem; padding-left: 1.2rem; color: var(--text-muted); }
.aio-box li { margin-bottom: 0.3rem; }
.aio-box li strong { color: var(--text); }

.prose { max-width: 760px; }
.prose h2 { font-size: clamp(1.3rem, 4vw, 1.8rem); margin-top: 0.4rem; }
.prose h3 { font-size: 1.1rem; margin-top: 1.4rem; color: var(--cyan); }
.prose p, .prose li { color: var(--text-muted); }
.prose ul { padding-left: 1.2rem; }

@media (min-width: 560px) {
  .controls-help { grid-template-columns: repeat(2, 1fr); }
}

/* ==========================================================================
   12. 2048 board, square canvas, D-pad
   ========================================================================== */
.game-stage--amber { --accent: var(--amber); }
.game-stage--lime { --accent: var(--lime); }
.game-stage canvas.is-square { aspect-ratio: 1 / 1; }

.board-2048 {
  --gap: 10px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
  padding: var(--gap);
  aspect-ratio: 1 / 1;
  background: #05060b;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.cell-2048 {
  position: relative;
  border-radius: 10px;
  background: #0f1226;
  border: 1px solid #191d3a;
}
.tile-2048 {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.2rem, 7vw, 2.2rem);
  font-variant-numeric: tabular-nums;
  color: var(--t, #22d3ee);
  border: 2px solid var(--t, #22d3ee);
  background: color-mix(in srgb, var(--t, #22d3ee) 14%, #0b0d1c);
  box-shadow: 0 0 14px color-mix(in srgb, var(--t, #22d3ee) 45%, transparent), inset 0 0 12px color-mix(in srgb, var(--t, #22d3ee) 20%, transparent);
  text-shadow: 0 0 10px color-mix(in srgb, var(--t, #22d3ee) 70%, transparent);
}
.tile-2048.is-new { animation: tile-pop-in 0.18s var(--ease); }
.tile-2048.is-merged { animation: tile-bump 0.2s var(--ease); }
.tile-2048[data-v="2"] { --t: #22d3ee; }
.tile-2048[data-v="4"] { --t: #38bdf8; }
.tile-2048[data-v="8"] { --t: #818cf8; }
.tile-2048[data-v="16"] { --t: #8b5cf6; }
.tile-2048[data-v="32"] { --t: #c084fc; }
.tile-2048[data-v="64"] { --t: #e879f9; }
.tile-2048[data-v="128"] { --t: #f472b6; font-size: clamp(1.05rem, 6vw, 1.9rem); }
.tile-2048[data-v="256"] { --t: #fb7185; font-size: clamp(1.05rem, 6vw, 1.9rem); }
.tile-2048[data-v="512"] { --t: #fb923c; font-size: clamp(1.05rem, 6vw, 1.9rem); }
.tile-2048[data-v="1024"] { --t: #fbbf24; font-size: clamp(0.9rem, 5vw, 1.6rem); }
.tile-2048[data-v="2048"] { --t: #a3e635; font-size: clamp(0.9rem, 5vw, 1.6rem); }
.tile-2048.is-big { --t: #ffffff; font-size: clamp(0.8rem, 4.2vw, 1.35rem); }

@keyframes tile-pop-in { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes tile-bump { 0% { transform: scale(1); } 50% { transform: scale(1.14); } 100% { transform: scale(1); } }

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(2, 56px);
  gap: 8px;
  justify-content: center;
  padding: 0.8rem 0 0.9rem;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  touch-action: manipulation;
}
.dpad button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--accent);
  font-size: 1.4rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dpad button:active { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); border-color: var(--accent); }
.dpad .d-up { grid-column: 2; grid-row: 1; }
.dpad .d-left { grid-column: 1; grid-row: 2; }
.dpad .d-down { grid-column: 2; grid-row: 2; }
.dpad .d-right { grid-column: 3; grid-row: 2; }

@media (hover: hover) and (pointer: fine) and (min-width: 860px) {
  .dpad { display: none; }
}
