/* ============================================
   NYZA GAMES GAME STYLES
   Theme-aware via CSS custom properties (--t-*)
   Set by js/game-themes.js
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Orbitron:wght@400;500;600;700;800;900&display=swap');

/* Dark cinematic theme — matches the main site backdrop */
:root {
    --t-bg: #07050a;
    --t-bg-grad: radial-gradient(ellipse at 50% -20%, rgba(20,15,25,0.85) 0%, rgba(7,5,10,0.95) 70%);
    --t-text: #f3e6c4;
    --t-text-muted: rgba(243,230,196,0.88);
    --t-text-subtle: rgba(243,230,196,0.72);
    --t-primary: #d4a017;
    --t-primary-dark: #8b6914;
    --t-primary-mid: #b8860b;
    --t-glass-bg: rgba(247,236,210,0.05);
    --t-glass-border: rgba(212,160,23,0.22);
    --t-card-bg: rgba(247,236,210,0.04);
    --t-card-border: rgba(212,160,23,0.18);
    --t-btn-grad: linear-gradient(135deg, #f5d672, #d4a017 55%, #a07810);
    --t-correct: #6aaa64;
    --t-present: #c9b458;
    --t-absent: #4a4a4a;
}

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

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--t-bg);
    color: var(--t-text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- Back Link ---- */
.back-link {
    position: fixed; top: 1rem; left: 1rem;
    display: flex; align-items: center; gap: 0.4rem;
    color: var(--t-text-muted); text-decoration: none;
    font-size: 0.85rem; font-weight: 500; z-index: 100;
    transition: color 0.3s;
}
.back-link:hover { color: var(--t-primary); }

/* ---- Header ---- */
.hub-header {
    position: relative; text-align: center; padding: 5rem 1rem 2rem;
}
.header-glow {
    position: absolute; top: -80px; left: 50%; transform: translateX(-50%);
    width: 500px; height: 300px;
    background: radial-gradient(ellipse, rgba(212,160,23,0.12) 0%, transparent 70%);
    pointer-events: none;
}
.hub-title {
    font-family: 'Orbitron', monospace;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
    background: linear-gradient(135deg, var(--t-primary) 0%, var(--t-primary-mid) 50%, var(--t-primary-dark) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hub-subtitle {
    margin-top: 0.5rem; color: var(--t-text-muted);
    font-size: 1.1rem; font-weight: 300;
}

/* ---- Games Grid ---- */
.games-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem; max-width: 1000px; margin: 2rem auto; padding: 0 1.5rem;
}

/* ---- Game Card ---- */
.game-card {
    position: relative; display: flex; flex-direction: column;
    align-items: center; text-align: center;
    padding: 2.5rem 1.5rem 2rem; border-radius: 20px;
    text-decoration: none; color: var(--t-text); overflow: hidden;
    cursor: pointer; transition: transform 0.35s cubic-bezier(0.4,0,0.2,1), box-shadow 0.35s;
}
.game-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 50px rgba(139,105,20,0.15);
}
.card-bg {
    position: absolute; inset: 0;
    background: var(--t-glass-bg); border: 1px solid var(--t-glass-border);
    border-radius: 20px; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    transition: border-color 0.3s, box-shadow 0.3s;
}
.game-card:hover .card-bg {
    border-color: rgba(212,160,23,0.4);
    box-shadow: 0 0 20px rgba(212,160,23,0.08);
}
.card-category {
    position: relative; z-index: 1;
    font-family: 'Orbitron', monospace; font-size: 0.6rem;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.15em;
    color: var(--t-primary); margin-bottom: 1rem;
}
.card-icon {
    position: relative; z-index: 1; font-size: 3.5rem; margin-bottom: 1rem;
    filter: drop-shadow(0 4px 8px rgba(139,105,20,0.15));
}
.card-title {
    position: relative; z-index: 1; font-size: 1.5rem;
    font-weight: 600; margin-bottom: 0.5rem; color: var(--t-text);
}
.card-desc {
    position: relative; z-index: 1; font-size: 0.85rem;
    color: var(--t-text-muted); line-height: 1.5; margin-bottom: 1.2rem;
}
.card-play {
    position: relative; z-index: 1; font-size: 0.85rem;
    font-weight: 600; color: var(--t-primary); transition: letter-spacing 0.3s;
}
.game-card:hover .card-play { letter-spacing: 0.05em; }

/* Category accent colors */
[data-category="puzzle"] .card-category,
[data-category="puzzle"] .card-play { color: var(--t-primary-mid); }
[data-category="puzzle"]:hover .card-bg { border-color: rgba(184,134,11,0.4); }

[data-category="arcade"] .card-category,
[data-category="arcade"] .card-play { color: #2d8a4e; }
[data-category="arcade"]:hover .card-bg { border-color: rgba(45,138,78,0.4); }

[data-category="strategy"] .card-category,
[data-category="strategy"] .card-play { color: var(--t-primary-dark); }
[data-category="strategy"]:hover .card-bg { border-color: rgba(139,105,20,0.4); }

[data-category="ai"] .card-category,
[data-category="ai"] .card-play { color: #a67c00; }
[data-category="ai"]:hover .card-bg { border-color: rgba(166,124,0,0.5); }

[data-category="word"] .card-category,
[data-category="word"] .card-play { color: var(--t-present); }
[data-category="word"]:hover .card-bg { border-color: rgba(201,180,88,0.4); }

/* ---- Footer ---- */
.hub-footer {
    text-align: center; padding: 3rem 1rem;
    color: var(--t-text-subtle); font-size: 0.85rem;
}
.hub-footer a { color: var(--t-text-muted); text-decoration: none; transition: color 0.3s; }
.hub-footer a:hover { color: var(--t-primary); }

/* ---- Shared Game Page Layout ---- */
.game-page {
    display: flex; flex-direction: column; align-items: center;
    min-height: 100vh; padding: 1rem;
    background: var(--t-bg-grad);
    touch-action: manipulation; /* prevent double-tap zoom on mobile */
}
.game-nav {
    width: 100%; max-width: 700px;
    display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap;
    padding: 1rem 0; margin-bottom: 0.5rem;
}
.game-nav a {
    color: var(--t-text-muted); text-decoration: none;
    font-size: 0.85rem; font-weight: 500;
    display: flex; align-items: center; gap: 0.4rem;
    transition: color 0.3s;
}
.game-nav a:hover { color: var(--t-primary); }
.game-name {
    font-family: 'Orbitron', monospace; font-size: 1.1rem; font-weight: 600;
    margin-left: auto;
    background: linear-gradient(135deg, var(--t-primary), var(--t-primary-dark));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
@media (max-width: 480px) {
    .game-nav { gap: 0.8rem; }
    .game-nav a { font-size: 0.78rem; }
    .game-name { font-size: 0.95rem; }
}

.game-container {
    background: var(--t-glass-bg); border: 1px solid var(--t-glass-border);
    border-radius: 20px; padding: 1.5rem;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    position: relative;
}

.game-score-bar {
    display: flex; justify-content: center; gap: 2rem; margin-bottom: 1rem;
}
.score-item { text-align: center; }
.score-label {
    font-family: 'Orbitron', monospace; font-size: 0.6rem;
    text-transform: uppercase; letter-spacing: 0.12em; color: var(--t-text-subtle);
}
.score-value {
    font-family: 'Orbitron', monospace; font-size: 1.5rem; font-weight: 700;
    background: linear-gradient(135deg, var(--t-primary), var(--t-primary-mid));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.game-btn {
    display: inline-block; padding: 0.6rem 1.5rem; border: none;
    border-radius: 30px; font-family: inherit; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
    color: #fff; background: var(--t-btn-grad); text-decoration: none;
}
.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(212,160,23,0.35);
}
.game-btn-secondary {
    background: var(--t-glass-bg); color: var(--t-primary-dark); margin-left: 0.5rem;
    border: 1px solid var(--t-glass-border);
}

.game-over-overlay {
    position: fixed; inset: 0;
    background: rgba(7,5,10,0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.game-over-overlay.active { opacity: 1; pointer-events: auto; }
.game-over-box {
    text-align: center; padding: 2.5rem;
    background: rgba(12,10,14,0.78);
    border: 1px solid var(--t-glass-border);
    border-radius: 20px; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.game-over-box h2 {
    font-family: 'Orbitron', monospace; font-size: 1.8rem; margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--t-primary), var(--t-primary-dark));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.game-over-box .final-score {
    font-family: 'Orbitron', monospace; font-size: 3rem; font-weight: 700;
    background: linear-gradient(135deg, var(--t-primary), var(--t-primary-mid));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    margin: 0.5rem 0;
}
.game-over-box p { color: var(--t-text-muted); margin-bottom: 1.5rem; }

/* ---- Theme Bar — HIDDEN.
   Each game now has its own permanent palette via body.game-page CSS-var
   overrides, which beat the Cinematic/Dark/Ocean/Forest themes the JS
   tries to apply. The switcher would render but click nothing visible —
   confusing dead UI. Hide it. The container div + JS render call are left
   intact across all game HTMLs so we don't churn 12 files for one line. */
.theme-bar {
    display: none !important;
}
#themeBar:empty,
#themeBar { display: none !important; }

/* Cinematic poster backdrop also gets killed on game pages — it mounts
   automatically when the JS-default 'gold' theme is set, and it covers
   the per-game body backgrounds with the music-poster collage. */
body.game-page .ht-cinematic-bg { display: none !important; }
html.ht-cinematic-active body.game-page { background: var(--t-bg, #07050a) !important; }
.theme-label {
    font-family: 'Orbitron', monospace; font-size: 0.5rem;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--t-text-subtle); margin-right: 0.2rem;
}
.theme-btn {
    padding: 0.25rem 0.6rem; border: 1px solid var(--t-card-border);
    border-radius: 20px; font-family: inherit; font-size: 0.65rem;
    font-weight: 600; cursor: pointer; background: transparent;
    color: var(--t-text-muted); transition: all 0.2s;
}
.theme-btn:hover { border-color: var(--t-primary); color: var(--t-primary); }
.theme-btn.active {
    background: var(--t-btn-grad); color: #fff; border-color: transparent;
    box-shadow: 0 2px 6px rgba(212,160,23,0.3);
}

/* ---- Audio Toggle ---- */
/* Visible on light AND dark per-game backgrounds: uses theme primary as
   the pill bg so it always pops, with the game-page text color for
   readable label/icon contrast against that primary. */
.audio-toggle {
    position: fixed; top: 0.8rem; right: 0.8rem;
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 1rem;
    /* FIXED dark-glass pill + FIXED light text + theme-primary border. Neither
       --t-primary nor --t-text is safe here: the old solid primary background
       failed AA for white (~1.4:1 on light golds) AND for dark text (~2.9:1 on
       crossword's dark blue); and --t-text tracks the PAGE bg (dark on the
       light-bg games like 2048/wordle/crossword), so it fails on its own pill.
       Because the pill bg is fixed dark, the foreground must be fixed light:
       #f5efe0 on this near-black glass is ~13:1+ on every game (allowing for
       the page bleeding through the alpha). The primary border keeps it on-theme. */
    border: 2px solid var(--t-primary);
    border-radius: 30px;
    background: rgba(10,8,12,0.9);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    cursor: pointer; font-family: 'Poppins', sans-serif;
    font-size: 0.78rem; font-weight: 700; z-index: 200;
    transition: transform 0.18s, box-shadow 0.18s, filter 0.18s;
    color: #f5efe0;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    box-shadow: 0 6px 18px rgba(0,0,0,0.28), 0 0 0 4px rgba(255,255,255,0.06) inset;
}
.audio-toggle svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 2.4; }
.audio-toggle:hover {
    transform: translateY(-1px) scale(1.03);
    filter: brightness(1.06);
    box-shadow: 0 10px 26px rgba(0,0,0,0.36), 0 0 0 4px rgba(255,255,255,0.1) inset;
}
.audio-toggle:active { transform: translateY(0) scale(0.97); }
.audio-toggle.muted {
    background: rgba(0,0,0,0.55);
    border-color: rgba(255,255,255,0.35);
    color: rgba(255,255,255,0.78);
    text-decoration: line-through;
}

/* ============================================================
   Nyza Games games — shared overlay UX hardening (2026-05-18)
   Applies to ALL games at once:
   1. Gold ::selection so accidental tap-and-hold doesn't paint
      titles with the browser's default electric blue.
   2. user-select: none on every overlay-title variant across the
      codebase, so the highlight can't appear on titles in the
      first place — even if a browser ignores ::selection.
   ============================================================ */
::selection {
    background: rgba(245, 214, 114, 0.4);
    color: #fff8dc;
}
::-moz-selection {
    background: rgba(245, 214, 114, 0.4);
    color: #fff8dc;
}
.overlay-title,
.ht-overlay-title,
.modal-title,
.pause-text,
.gover-title,
.win-title,
.game-over-title,
#endTitle,
#gameOverTitle,
#goverTitle,
.game-over-box h2 {
    -webkit-user-select: none;
    user-select: none;
}

/* ---- Mobile ---- */
@media (max-width: 600px) {
    .games-grid { grid-template-columns: 1fr; padding: 0 1rem; }
    .game-container { padding: 1rem; }
    .game-nav { padding: 0.5rem 0; }
    .game-score-bar { gap: 1rem; }
    .hub-header { padding: 3.5rem 1rem 1.5rem; }
    .theme-bar { flex-wrap: wrap; }
    .game-over-box { padding: 1.5rem; margin: 0 1rem; }
    .game-over-box .final-score { font-size: 2.2rem; }
    .game-over-box h2 { font-size: 1.4rem; }
}

/* ============================================================
   Mobile: hide the redundant "Game Setup" rail card (2026-06-04).
   On mobile the rail stacks BELOW the board, but the full-screen
   start / game-over overlays now carry the complete setup
   (difficulty + every secondary setting), and during play the
   rail's buttons are disabled. So the Game Setup card is only ever
   on screen when it's unusable — hide it to kill the long scroll
   below the board. Tagged `.rail-card-setup` on each game's first
   rail card; the overlay copies remain reachable.
   ============================================================ */
@media (max-width: 899px) {
    .game-rail .rail-card-setup { display: none; }
}

/* ============================================================
   Accessibility (2026-05-28) — shared across all 19 games.
   The layer previously had NO keyboard-focus affordance and did
   NOT honor prefers-reduced-motion (only the cinematic backdrop
   did). Both are added here once, for every game at once.
   ============================================================ */

/* Keyboard focus ring. :focus-visible fires on keyboard nav (not mouse
   clicks), so a broad rule is safe and doesn't disturb pointer users. Uses
   the per-game primary so it reads on each theme. */
:focus-visible {
    outline: 2px solid var(--t-primary, #d4a017);
    outline-offset: 2px;
    border-radius: 6px;
}
/* Keep the outline visible above glassy/blurred surfaces. */
.game-btn:focus-visible,
.audio-toggle:focus-visible,
.back-link:focus-visible,
.game-nav a:focus-visible {
    outline-offset: 3px;
}

/* Respect reduced-motion: make CSS transitions/animations effectively instant
   so juice (fades, pops, shakes, confetti CSS) doesn't trigger vestibular
   discomfort. Gameplay driven by requestAnimationFrame is unaffected. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
