:root {
    --bg-dark: #070812;
    --card-bg: rgba(14, 16, 28, 0.92);
    --border-color: #1f2338;
    --neon-green: #39ff14;
    --neon-green-glow: rgba(57, 255, 20, 0.4);
    --neon-purple: #bc13fe;
    --neon-purple-glow: rgba(188, 19, 254, 0.4);
    --neon-cyan: #00f3ff;
    --neon-cyan-glow: rgba(0, 243, 255, 0.4);
    --neon-red: #ff003c;
    --neon-red-glow: rgba(255, 0, 60, 0.4);
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --font-arcade: 'Press Start 2P', cursive;
    --font-body: 'Comfortaa', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    position: fixed;
    inset: 0;
    overscroll-behavior: none;
    overscroll-behavior-y: none;
    touch-action: none;
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: var(--font-body);
    -webkit-text-size-adjust: 100%;
}

/* Background Cyber Grid */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(188, 19, 254, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(57, 255, 20, 0.04) 1px, transparent 1px);
    background-size: 32px 32px;
    z-index: 0;
    pointer-events: none;
}

/* --- GAME CONTAINER --- */
.game-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    z-index: 1;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
}

/* --- TOP NAVIGATION & HUD --- */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    height: 56px;
    background: rgba(9, 10, 18, 0.85);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    z-index: 20;
    flex-shrink: 0;
}

/* Project Standard Pill Back Button */
.arcade-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    transition: all 0.2s ease;
}

.arcade-back-btn:hover {
    color: #ffffff;
    border-color: var(--neon-green);
    background: rgba(57, 255, 20, 0.08);
    box-shadow: 0 0 12px rgba(57, 255, 20, 0.25);
    transform: translateX(-2px);
}

/* In-Game HUD */
.hud {
    display: flex;
    align-items: center;
    gap: 20px;
    transition: opacity 0.25s ease;
}

.hud.hidden {
    opacity: 0;
    pointer-events: none;
}

.hud-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
}

.hud-label {
    font-family: var(--font-arcade);
    font-size: 0.55rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.hud-value {
    font-family: var(--font-arcade);
    font-size: 1rem;
    font-weight: 700;
}

.neon-green-text {
    color: var(--neon-green);
    text-shadow: 0 0 8px var(--neon-green-glow);
}

.neon-purple-text {
    color: var(--neon-purple);
    text-shadow: 0 0 8px var(--neon-purple-glow);
}

.hud-mode-tag {
    font-family: var(--font-arcade);
    font-size: 0.58rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(57, 255, 20, 0.15);
    color: var(--neon-green);
    border: 1px solid var(--neon-green);
    text-shadow: 0 0 6px var(--neon-green-glow);
    letter-spacing: 0.5px;
}

.hud-mode-tag.zen-mode {
    background: rgba(0, 243, 255, 0.15);
    color: var(--neon-cyan);
    border-color: var(--neon-cyan);
    text-shadow: 0 0 6px var(--neon-cyan-glow);
}

/* Quick Tools */
.top-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-btn.hidden {
    display: none !important;
}

.hidden {
    display: none !important;
}

.tool-btn svg {
    display: block;
    pointer-events: none;
}

.tool-btn:hover {
    border-color: var(--neon-green);
    background: rgba(57, 255, 20, 0.1);
    box-shadow: 0 0 10px rgba(57, 255, 20, 0.25);
    transform: translateY(-1px);
}

.tool-btn:active {
    transform: scale(0.94);
}

/* --- ARENA WRAPPER --- */
.arena-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 10px;
    overflow: hidden;
    touch-action: none;
    overscroll-behavior: none;
}

.canvas-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
    border-radius: 8px;
    touch-action: none;
}

canvas {
    display: block;
    border-radius: 8px;
    background: #04050a;
    touch-action: none;
}

/* --- OVERLAYS --- */
.screen-overlay {
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 6, 12, 0.82);
    backdrop-filter: blur(8px);
    z-index: 30;
    padding: 16px;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.screen-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(188, 19, 254, 0.15);
    border-radius: 16px;
    padding: clamp(18px, 3.5vh, 30px) clamp(16px, 4vw, 28px);
    max-width: 480px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(10px, 2.2vh, 16px);
    animation: cardFloatIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardFloatIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.brand-badge {
    font-family: var(--font-arcade);
    font-size: clamp(0.5rem, 1.8vw, 0.58rem);
    color: var(--neon-purple);
    background: rgba(188, 19, 254, 0.12);
    border: 1px solid rgba(188, 19, 254, 0.35);
    padding: 4px 10px;
    border-radius: 9999px;
    letter-spacing: 1px;
}

.screen-title {
    font-family: var(--font-arcade);
    font-size: clamp(1.25rem, 3.8vw, 2rem);
    letter-spacing: 1.5px;
    line-height: 1.25;
}

.neon-green-title {
    color: var(--neon-green);
    text-shadow: 3px 3px 0px var(--neon-purple), 0 0 20px var(--neon-green-glow);
}

.neon-cyan-title {
    color: var(--neon-cyan);
    text-shadow: 3px 3px 0px var(--neon-purple), 0 0 20px var(--neon-cyan-glow);
}

.neon-red-title {
    color: var(--neon-red);
    text-shadow: 3px 3px 0px #000, 0 0 20px var(--neon-red-glow);
}

.screen-sub {
    color: var(--text-muted);
    font-size: clamp(0.75rem, 2.2vw, 0.85rem);
    margin-top: -4px;
    line-height: 1.4;
}

/* --- MODE SELECTOR --- */
.mode-selector {
    width: 100%;
    margin-top: 2px;
}

.selector-label {
    display: block;
    font-family: var(--font-arcade);
    font-size: clamp(0.52rem, 1.8vw, 0.62rem);
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.mode-pills {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
}

.mode-pill {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: clamp(8px, 1.8vh, 12px) clamp(6px, 2vw, 10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-muted);
}

.mode-pill-icon {
    font-size: 1.25rem;
}

.mode-pill-name {
    font-family: var(--font-arcade);
    font-size: clamp(0.58rem, 2vw, 0.68rem);
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.5px;
}

.mode-pill-desc {
    font-family: var(--font-body);
    font-size: clamp(0.6rem, 1.8vw, 0.68rem);
    line-height: 1.3;
    color: var(--text-muted);
    text-align: center;
}

.mode-pill:hover {
    border-color: rgba(57, 255, 20, 0.4);
    background: rgba(57, 255, 20, 0.04);
}

.mode-pill.active {
    border-color: var(--neon-green);
    background: rgba(57, 255, 20, 0.08);
    box-shadow: 0 0 16px rgba(57, 255, 20, 0.25);
    color: #ffffff;
}

.mode-pill[data-mode="zen"].active {
    border-color: var(--neon-cyan);
    background: rgba(0, 243, 255, 0.08);
    box-shadow: 0 0 16px rgba(0, 243, 255, 0.25);
}

/* Stat Highlight */
.stat-highlight {
    background: rgba(0, 0, 0, 0.4);
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    padding: clamp(6px, 1.5vh, 10px) clamp(16px, 4vw, 24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.stat-highlight-label {
    font-family: var(--font-arcade);
    font-size: clamp(0.5rem, 1.8vw, 0.58rem);
    color: var(--text-muted);
    letter-spacing: 1px;
    line-height: 1.2;
}

.stat-highlight-value {
    font-family: var(--font-arcade);
    font-size: clamp(1.15rem, 3.5vw, 1.5rem);
    line-height: 1.2;
    color: var(--neon-green);
    text-shadow: 0 0 12px var(--neon-green-glow);
}

/* Launch Button */
.btn-launch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: clamp(10px, 2vh, 13px) clamp(12px, 3vw, 20px);
    border-radius: 10px;
    font-family: var(--font-arcade);
    font-size: clamp(0.64rem, 2.2vw, 0.78rem);
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.neon-btn {
    background: var(--neon-green);
    color: #04050a;
    border: 2px solid var(--neon-green);
    box-shadow: 0 0 20px var(--neon-green-glow);
}

.neon-btn:hover {
    background: #ffffff;
    border-color: #ffffff;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.7);
    transform: translateY(-2px);
}

.neon-btn:active {
    transform: scale(0.98);
}

/* Secondary Buttons */
.btn-secondary {
    width: 100%;
    padding: clamp(10px, 2vh, 13px) clamp(12px, 3vw, 20px);
    border-radius: 10px;
    font-family: var(--font-arcade);
    font-size: clamp(0.62rem, 2.2vw, 0.75rem);
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--neon-purple);
}

.btn-link {
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: underline;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-link:hover {
    color: #ffffff;
}

.control-hints {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.76rem;
    color: var(--text-muted);
}

.control-hints strong {
    color: var(--text-light);
}

/* --- OVERLAY ACTIONS & SUMMARY --- */
.overlay-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.crash-badge {
    font-family: var(--font-arcade);
    font-size: 0.6rem;
    color: var(--neon-red);
    background: rgba(255, 0, 60, 0.12);
    border: 1px solid var(--neon-red);
    padding: 4px 10px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.score-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

.score-summary-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.summary-label {
    font-family: var(--font-arcade);
    font-size: 0.55rem;
    color: var(--text-muted);
}

.summary-value {
    font-family: var(--font-arcade);
    font-size: clamp(1.2rem, 4vw, 1.7rem);
    line-height: 1.2;
    font-weight: 700;
}

.new-record-banner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-arcade);
    font-size: 0.68rem;
    font-weight: 700;
    color: #04050a;
    background: var(--neon-green);
    padding: 6px 14px;
    border-radius: 6px;
    letter-spacing: 1px;
    box-shadow: 0 0 15px var(--neon-green-glow);
    animation: bannerPulse 1.2s infinite alternate;
}

@keyframes bannerPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.04); }
}

/* Media Queries for Mobile Screens */
@media (max-width: 768px) {
    .top-nav {
        padding: 8px 12px;
        height: 48px;
    }

    .arcade-back-btn span {
        display: inline;
    }

    .hud {
        gap: 12px;
    }

    .hud-value {
        font-size: 0.88rem;
    }

    .overlay-card {
        padding: 18px 16px;
        gap: 12px;
        max-height: calc(100dvh - 72px);
        overflow-y: auto;
    }

    .screen-title {
        font-size: 1.4rem;
    }

    .arena-wrapper {
        padding: 8px;
    }
}


