/* ═══════════════════════════════════════════════════════════════════
   NEON GRID — Retro-Futurist Styles
   ═══════════════════════════════════════════════════════════════════ */
:root {
  color-scheme: light;
  --primary: #d6009a;
  --secondary: #8a2be2;
  --accent-cyan: #007b8f;
  --bg-primary: #ffffff;
  --bg-secondary: #f4f0fa;
  --bg-tertiary: #ece4f7;
  --text-primary: #1a1030;
  --text-secondary: #55446e;
  --border-color: #d9ccee;
  --shadow-color: rgba(26, 16, 48, 0.12);
  --hero-gradient: linear-gradient(160deg, #fdeaf6 0%, #f0e6ff 55%, #e2f6fb 100%);
  --radius-md: 8px;
  --radius-lg: 16px;
  --space-md: 24px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --primary: #ff10f0;
  --secondary: #b026ff;
  --accent-cyan: #00f0ff;
  --bg-primary: #0a0a0a;
  --bg-secondary: #131018;
  --bg-tertiary: #1c1626;
  --text-primary: #f2f0f7;
  --text-secondary: #b9aecb;
  --border-color: #35284a;
  --shadow-color: rgba(0, 240, 255, 0.12);
  --hero-gradient: linear-gradient(160deg, #12001a 0%, #0a0a0a 60%, #001318 100%);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Space Mono', system-ui, monospace;
  line-height: 1.6;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  line-height: 1.2;
}
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h3 { font-size: clamp(1.2rem, 2.5vw, 1.5rem); }
p { font-size: clamp(1rem, 2vw, 1.125rem); }

.container { max-width: 1200px; margin: 0 auto; padding: 0 2rem; }

/* Grid overlay decoration */
.grid-overlay {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--border-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.25;
}
header, main, footer { position: relative; z-index: 1; }

/* NAV */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg-primary) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
}
.nav { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 24px; }
.logo { font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 1.3rem; color: var(--text-primary); text-decoration: none; letter-spacing: 1px; }
.logo span { color: var(--accent-cyan); }
.nav-links { display: flex; list-style: none; gap: 24px; }
.nav-links a {
  color: var(--text-secondary); text-decoration: none; letter-spacing: 1px;
  padding: 12px 4px; display: inline-block; transition: color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-links a:hover { color: var(--accent-cyan); }
.nav-links a.active { color: var(--primary); text-shadow: 0 0 8px var(--shadow-color); }

.mobile-nav-toggle {
  display: none; width: 44px; height: 44px; border: 1px solid var(--border-color);
  background: var(--bg-secondary); border-radius: var(--radius-md); cursor: pointer;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.mobile-nav-toggle .bar { width: 20px; height: 2px; background: var(--text-primary); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }

/* HERO */
.hero { background: var(--hero-gradient); padding: clamp(4rem, 10vw, 7rem) 0; text-align: center; }
.kicker { color: var(--accent-cyan); letter-spacing: 2px; font-size: 0.9rem; margin-bottom: 16px; }
.neon-title { letter-spacing: 2px; }
[data-theme="dark"] .neon-title { text-shadow: 0 0 12px rgba(255, 16, 240, 0.6), 0 0 32px rgba(0, 240, 255, 0.35); }
.glitch { color: var(--primary); }
[data-theme="dark"] .glitch { text-shadow: 0 0 16px rgba(255, 16, 240, 0.8); }
.hero-sub { color: var(--text-secondary); max-width: 620px; margin: 24px auto; }
.hero-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* BUTTONS */
.btn {
  font-family: 'Orbitron', sans-serif; font-size: 0.9rem; letter-spacing: 1px;
  padding: 12px 24px; border-radius: 24px; cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-primary {
  background: var(--primary); color: #ffffff; border: none;
  box-shadow: 0 2px 8px var(--shadow-color);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 16px var(--shadow-color); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  background: transparent; color: var(--accent-cyan); border: 2px solid var(--accent-cyan);
}
.btn-secondary:hover { transform: translateY(-2px); box-shadow: 0 4px 12px var(--shadow-color); background: color-mix(in srgb, var(--accent-cyan) 12%, transparent); }
.btn-secondary:active { transform: scale(0.98); }
.btn:focus-visible, .cell:focus-visible, .theme-toggle:focus-visible, .mobile-nav-toggle:focus-visible {
  outline: 2px solid var(--accent-cyan); outline-offset: 2px;
}

/* SECTIONS */
.section { padding: 64px 0; }
.section-alt { background: var(--bg-secondary); }
.section-title { letter-spacing: 1px; margin-bottom: 8px; }
.section-sub { color: var(--text-secondary); margin-bottom: 32px; }
.accent-cyan { color: var(--accent-cyan); }
.accent-pink { color: var(--primary); }
.accent-purple { color: var(--secondary); }

/* GRID / CARDS */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.card {
  background: var(--bg-primary); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 24px;
  box-shadow: 0 2px 8px var(--shadow-color);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.card:hover { box-shadow: 0 8px 24px var(--shadow-color); transform: translateY(-4px); }
.card h3 { margin: 16px 0 8px; }
.card p { color: var(--text-secondary); }
.media-frame { border-radius: 12px; overflow: hidden; }
.media-frame img { display: block; width: 100%; max-width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; }
figcaption { font-size: 0.8rem; color: var(--text-secondary); margin-top: 8px; }
figcaption a { color: var(--accent-cyan); }

/* GAME PANEL */
.game-wrap { display: flex; justify-content: center; }
.game-panel {
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 24px;
  box-shadow: 0 4px 16px var(--shadow-color); width: 100%; max-width: 480px;
}
.game-status {
  text-align: center; font-family: 'Orbitron', sans-serif; letter-spacing: 1px;
  color: var(--accent-cyan); margin-bottom: 16px; min-height: 1.5em;
}
[data-theme="dark"] .game-status { text-shadow: 0 0 10px rgba(0, 240, 255, 0.5); }
.board {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  max-width: 360px; margin: 0 auto;
}
.cell {
  aspect-ratio: 1 / 1; min-height: 88px;
  font-family: 'Orbitron', sans-serif; font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 700;
  background: var(--bg-tertiary); color: var(--text-primary);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  cursor: pointer; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.cell:hover:not(:disabled) { box-shadow: 0 0 12px var(--shadow-color); transform: scale(1.02); }
.cell.x-mark { color: var(--primary); }
.cell.o-mark { color: var(--accent-cyan); }
[data-theme="dark"] .cell.x-mark { text-shadow: 0 0 14px rgba(255, 16, 240, 0.7); }
[data-theme="dark"] .cell.o-mark { text-shadow: 0 0 14px rgba(0, 240, 255, 0.7); }

/* CPU turn state */
.board.cpu-turn .cell:not(.x-mark):not(.o-mark) { opacity: 0.35; cursor: not-allowed; }
.cell:disabled { cursor: not-allowed; }
.cell.win-cell {
  color: var(--secondary);
  text-shadow: 0 0 12px var(--shadow-color);
  box-shadow: 0 0 16px var(--shadow-color), inset 0 0 12px var(--shadow-color);
  border-color: var(--secondary);
}

.game-footer { margin-top: 24px; text-align: center; }
.scoreboard { display: flex; justify-content: center; gap: 24px; margin-bottom: 16px; font-family: 'Orbitron', sans-serif; }
.score { letter-spacing: 1px; }
.score-x span { color: var(--primary); }
.score-o span { color: var(--accent-cyan); }
.score-draw span { color: var(--text-secondary); }
.btn[data-action="reset-scores"] { margin-top: 12px; }

/* ABOUT */
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: center; }
.about-copy p { color: var(--text-secondary); margin-bottom: 16px; }
.about-facts { list-style: none; margin-top: 16px; }
.about-facts li { margin-bottom: 8px; color: var(--text-secondary); }
.about-facts strong { color: var(--text-primary); }

/* CONTACT */
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: center; }
.contact-grid p { color: var(--text-secondary); margin-bottom: 16px; }
.contact-list { list-style: none; margin-bottom: 24px; }
.contact-list li { margin-bottom: 8px; color: var(--text-secondary); }
.contact-list a { color: var(--accent-cyan); }
.social-links { display: flex; gap: 16px; }
.social-links a { color: var(--primary); text-decoration: none; letter-spacing: 1px; padding: 8px 4px; }
.social-links a:hover { text-shadow: 0 0 8px var(--shadow-color); }

/* FOOTER */
.site-footer { border-top: 1px solid var(--border-color); padding: 32px 0; text-align: center; color: var(--text-secondary); font-size: 0.9rem; }
.footer-credit { margin-top: 8px; font-size: 0.8rem; opacity: 0.8; }

/* THEME TOGGLE */
.theme-toggle {
  position: fixed; bottom: 24px; right: 24px; z-index: 30;
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--border-color);
  background: var(--bg-secondary); cursor: pointer; font-size: 1.2rem;
  box-shadow: 0 4px 12px var(--shadow-color);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.theme-toggle:hover { transform: scale(1.05); }

/* REVEAL */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1); }
.reveal.revealed { opacity: 1; transform: none; }

/* BREAKPOINTS */
@media (max-width: 1024px) {
  .about-grid, .contact-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .grid { grid-template-columns: 1fr; }
  .about-grid, .contact-grid { grid-template-columns: 1fr; }
  .mobile-nav-toggle { display: flex; }
  .nav-links {
    position: absolute; top: 100%; right: 0;
    flex-direction: column; gap: 8px;
    background: var(--bg-primary); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); padding: 16px 24px;
    box-shadow: 0 8px 24px var(--shadow-color);
    display: none;
  }
  .nav-links.open { display: flex; }
  .cell { min-height: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .reveal { opacity: 1; transform: none; }
}


/* Header nav spacing floor (normalizer): keep the brand and the
   menu separated when the flex container runs out of width. */
header nav, header nav > div { gap: 1rem; flex-wrap: wrap; }
@media (max-width: 1280px) { header nav ul { gap: 1rem; } }
