/* ═══════════════════════════════════════════════
   WebGames — Cyberpunk Neon Theme
   Dark neon-futuristic design system.
   Import in every game HTML:
     <link rel="stylesheet" href="css/theme.css">
   ═══════════════════════════════════════════════ */

/* ── Google Fonts (loaded via <link> in HTML) ──
   Orbitron for display, Exo 2 for body, Share Tech Mono for HUD
   ─────────────────────────────────────────────── */

/* ── Tokens ── */
:root {
    /* Backgrounds */
    --bg-base: #050508;
    --bg-raised: #0a0c14;
    --bg-card: #0e1018;
    --bg-card-hover: #141622;
    --bg-surface: rgba(14, 16, 24, 0.85);

    /* Neon palette */
    --neon-cyan: #00f0ff;
    --neon-magenta: #ff00aa;
    --neon-purple: #bc13fe;
    --neon-green: #39ff14;
    --neon-yellow: #ffe600;
    --neon-orange: #ff6a00;
    --neon-blue: #4d7cff;
    --neon-pink: #ff2d95;

    /* Primary accent (cyan by default, games override) */
    --accent: var(--neon-cyan);
    --accent-rgb: 0, 240, 255;
    --accent-glow: rgba(var(--accent-rgb), 0.4);
    --accent-dim: rgba(var(--accent-rgb), 0.12);
    --accent-border: rgba(var(--accent-rgb), 0.25);

    /* Semantic */
    --success: #39ff14;
    --danger: #ff3333;
    --warning: #ffe600;

    /* Borders */
    --border: rgba(255, 255, 255, 0.04);
    --border-hover: rgba(255, 255, 255, 0.1);
    --border-neon: rgba(var(--accent-rgb), 0.2);

    /* Text */
    --text: #e0e6f0;
    --text-secondary: #7a8194;
    --text-muted: #444a5e;

    /* Radii */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 4px;

    /* Fonts */
    --font-display: 'Orbitron', 'Bricolage Grotesque', system-ui, sans-serif;
    --font-body: 'Exo 2', 'DM Sans', -apple-system, system-ui, sans-serif;
    --font-mono: 'Share Tech Mono', 'Courier New', monospace;

    /* Grid pattern */
    --grid-color: rgba(var(--accent-rgb), 0.03);
    --grid-size: 60px;
}

/* ── Reset ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* ── Base ── */
html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bg-base);
    color: var(--text);
    min-height: 100vh;
    padding-top: 60px !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: none;
    position: relative;
}

/* Subtle grid background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: var(--grid-size) var(--grid-size);
    pointer-events: none;
    z-index: 0;
}

/* Vignette overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.6) 100%);
    pointer-events: none;
    z-index: 0;
}

/* Ensure all content sits above grid */
body > * {
    position: relative;
    z-index: 1;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

h1 {
    text-shadow: 0 0 30px rgba(var(--accent-rgb), 0.5), 0 0 60px rgba(var(--accent-rgb), 0.2);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.6); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Game Nav ── */
.game-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 10000;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: rgba(5, 5, 8, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-neon);
    box-shadow: 0 1px 20px rgba(var(--accent-rgb), 0.08);
}

/* Corner accent lines on nav */
.game-nav::before,
.game-nav::after {
    content: '';
    position: absolute;
    bottom: -1px;
    width: 60px;
    height: 1px;
    background: var(--accent);
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.8);
}
.game-nav::before { left: 0; }
.game-nav::after { right: 0; }

.game-nav-left,
.game-nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.game-nav-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95em;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-shadow: 0 0 15px rgba(var(--accent-rgb), 0.5);
}

.game-nav-back {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.8em;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: 1px solid transparent;
    transition: all 0.2s;
}
.game-nav-back:hover {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.06);
    border-color: var(--border-neon);
    text-decoration: none;
    text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.4);
}

.game-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.2s;
}
.game-nav-btn:hover {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.08);
    border-color: var(--border-neon);
    box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.15);
}

/* ── HUD-Style Game Container ── */
.game-container {
    max-width: 1000px;
    width: 100%;
    margin: 72px auto 40px;
    padding: 28px;
    background: var(--bg-raised);
    border: 1px solid var(--border-neon);
    border-radius: var(--radius);
    position: relative;
    box-shadow:
        0 0 30px rgba(var(--accent-rgb), 0.05),
        inset 0 1px 0 rgba(var(--accent-rgb), 0.08);
}

/* Canvas elements fill their container responsively */
.game-container canvas {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Corner brackets - HUD style */
.game-container::before,
.game-container::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: rgba(var(--accent-rgb), 0.3);
    border-style: solid;
    pointer-events: none;
}
.game-container::before {
    top: -1px; left: -1px;
    border-width: 2px 0 0 2px;
    border-radius: var(--radius) 0 0 0;
}
.game-container::after {
    bottom: -1px; right: -1px;
    border-width: 0 2px 2px 0;
    border-radius: 0 0 var(--radius) 0;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius-xs);
    font-family: var(--font-body);
    font-size: 0.88em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    position: relative;
    overflow: hidden;
}

/* Sweep effect on hover */
.btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
    transition: left 0.4s;
}
.btn:hover::before { left: 100%; }

.btn-primary {
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.9), rgba(var(--accent-rgb), 0.6));
    color: var(--bg-base);
    border: 1px solid rgba(var(--accent-rgb), 0.5);
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.btn-primary:hover {
    box-shadow: 0 0 25px rgba(var(--accent-rgb), 0.5), 0 0 60px rgba(var(--accent-rgb), 0.15);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.06);
    border-color: var(--border-neon);
    box-shadow: 0 0 15px rgba(var(--accent-rgb), 0.1);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.06);
}

.btn-danger {
    background: linear-gradient(135deg, rgba(255,51,51,0.8), rgba(255,51,51,0.5));
    color: #fff;
    border: 1px solid rgba(255,51,51,0.4);
}
.btn-danger:hover {
    box-shadow: 0 0 25px rgba(255,51,51,0.4);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.78em;
}

/* ── Cards / Panels ── */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
}

/* Subtle top-edge glow on panels */
.panel::before {
    content: '';
    position: absolute;
    top: 0; left: 20px; right: 20px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.2), transparent);
    pointer-events: none;
}

.panel-header {
    font-family: var(--font-display);
    font-size: 0.9em;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.3);
}

/* ── Modals ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--bg-raised);
    border: 1px solid var(--border-neon);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    position: relative;
    box-shadow: 0 0 60px rgba(var(--accent-rgb), 0.1);
    animation: modalAppear 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalAppear {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Corner accents on modal */
.modal-content::before,
.modal-content::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: rgba(var(--accent-rgb), 0.4);
    border-style: solid;
    pointer-events: none;
}
.modal-content::before {
    top: -1px; left: -1px;
    border-width: 2px 0 0 2px;
    border-radius: var(--radius) 0 0 0;
}
.modal-content::after {
    bottom: -1px; right: -1px;
    border-width: 0 2px 2px 0;
    border-radius: 0 0 var(--radius) 0;
}

.modal-content h2 {
    font-size: 1.3em;
    margin-bottom: 12px;
    color: var(--accent);
    text-shadow: 0 0 20px rgba(var(--accent-rgb), 0.4);
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}

/* ── HUD Status Bar ── */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 12px 20px;
    background: rgba(var(--accent-rgb), 0.03);
    border: 1px solid var(--border-neon);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    flex-wrap: wrap;
    position: relative;
}

/* Scanline effect on status bar */
.status-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    pointer-events: none;
    border-radius: inherit;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.status-label {
    font-family: var(--font-mono);
    font-size: 0.65em;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

.status-value {
    font-family: var(--font-display);
    font-size: 1.3em;
    font-weight: 700;
    color: var(--accent);
    text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.5);
}

/* ── Tags / Badges ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.68em;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: rgba(var(--accent-rgb), 0.08);
    color: var(--accent);
    border: 1px solid rgba(var(--accent-rgb), 0.15);
}

/* ── Select / Inputs ── */
select, input[type="text"], input[type="number"], input[type="password"] {
    font-family: var(--font-body);
    font-size: 0.9em;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    outline: none;
    transition: all 0.25s;
}
select:focus, input:focus {
    border-color: rgba(var(--accent-rgb), 0.5);
    box-shadow: 0 0 15px rgba(var(--accent-rgb), 0.1);
    background: rgba(var(--accent-rgb), 0.03);
}

/* ── Tooltip ── */
.tooltip {
    position: relative;
    cursor: help;
}
.tooltip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.75em;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-neon);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.tooltip:hover::after { opacity: 1; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(var(--accent-rgb), 0.2);
    border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--accent-rgb), 0.4);
}

/* ── Neon Glow Utility Classes ── */
.neon-glow {
    box-shadow: 0 0 15px rgba(var(--accent-rgb), 0.3), 0 0 40px rgba(var(--accent-rgb), 0.1);
}
.neon-glow-strong {
    box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.5), 0 0 60px rgba(var(--accent-rgb), 0.2), 0 0 100px rgba(var(--accent-rgb), 0.1);
}
.neon-text {
    color: var(--accent);
    text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.6), 0 0 30px rgba(var(--accent-rgb), 0.3);
}
.neon-border {
    border-color: rgba(var(--accent-rgb), 0.4) !important;
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.15);
}

/* ── Color utilities ── */
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-mono { font-family: var(--font-mono); }

/* ── Animation keyframes ── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.3); }
    50% { box-shadow: 0 0 25px rgba(var(--accent-rgb), 0.6); }
}

@keyframes scanline {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    92% { opacity: 1; }
    93% { opacity: 0.8; }
    94% { opacity: 1; }
    96% { opacity: 0.9; }
    97% { opacity: 1; }
}

@keyframes neon-breathe {
    0%, 100% { text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.5), 0 0 30px rgba(var(--accent-rgb), 0.2); }
    50% { text-shadow: 0 0 15px rgba(var(--accent-rgb), 0.7), 0 0 45px rgba(var(--accent-rgb), 0.35); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes glitch-clip {
    0% { clip-path: inset(40% 0 61% 0); }
    20% { clip-path: inset(92% 0 1% 0); }
    40% { clip-path: inset(43% 0 1% 0); }
    60% { clip-path: inset(25% 0 58% 0); }
    80% { clip-path: inset(54% 0 7% 0); }
    100% { clip-path: inset(58% 0 43% 0); }
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .game-container { max-width: 100%; margin: 66px 12px 30px; padding: 20px; }
}

@media (max-width: 600px) {
    .game-nav { padding: 0 12px; }
    .game-nav-title { font-size: 0.85em; }
    .game-container { margin: 62px 6px 20px; padding: 12px; border-radius: 8px; }
    .status-bar { gap: 12px; padding: 8px 10px; }
    .status-label { font-size: 0.6em; }
    .status-value { font-size: 1.1em; }
    body::before { --grid-size: 40px; }
    .btn { padding: 10px 18px; font-size: 0.82em; }
    .panel { padding: 14px; }
    .modal-content { padding: 20px; }
}
