:root {
    --bg-primary: #040508;
    --bg-glass: rgba(10, 23, 14, 0.7);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(255, 255, 255, 0.2);
    
    --neon-green: #00ff66;
    --neon-cyan: #00f2fe;
    --neon-magenta: #ff007f;
    
    --text-main: #f0f6fc;
    --text-muted: #8b949e;
    
    --font-sans: 'Outfit', sans-serif;
    --font-arcade: 'Press Start 2P', monospace;
    
    --transition-speed: 0.3s;
    --border-radius: 16px;
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    font-family: var(--font-sans);
    height: 100vh;
    overflow: hidden;
}

.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius);
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    padding: 1rem;
    gap: 1rem;
    align-items: center;
    justify-content: center;
}

.workspace {
    display: flex;
    width: 100%;
    max-width: 960px;
    height: 100%;
    gap: 1rem;
    align-items: center;
}

/* Side HUD panels */
.side-hud {
    width: 200px;
    height: 80%;
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    gap: 1.25rem;
    justify-content: center;
}

.hud-box {
    border: 1px solid rgba(0, 255, 102, 0.08);
    background: rgba(0, 255, 102, 0.01);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
}

.hud-box h4 {
    font-family: var(--font-arcade);
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.hud-value {
    font-family: var(--font-arcade);
    font-size: 0.85rem;
    color: var(--neon-green);
    text-shadow: 0 0 10px rgba(0, 255, 102, 0.3);
    font-weight: 700;
}

.hud-value.status-neon {
    color: var(--neon-green);
}

.hud-value.status-thinking {
    color: var(--neon-magenta);
    text-shadow: 0 0 10px rgba(255, 0, 127, 0.3);
    animation: flash 1s infinite alternate;
}

.score-box {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.score-box h4 {
    text-align: center;
}

.score-line {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.score-line span {
    float: right;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-family: var(--font-arcade);
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
    width: 100%;
}

.btn-primary {
    background: var(--neon-green);
    color: #040508;
    box-shadow: 0 4px 12px rgba(0, 255, 102, 0.3);
}

.btn-primary:hover {
    background: #33ff85;
    transform: scale(1.02);
}

.btn-action {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    border: 1px solid var(--border-glass);
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-focus);
}

/* Central canvas box */
.canvas-container {
    flex-grow: 1;
    height: 90%;
    max-width: 440px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #020403;
    border: 1.5px solid var(--border-glass);
}

.mode-badge {
    position: absolute;
    top: 1rem;
    left: 1rem;
    padding: 0.4rem 0.8rem;
    background: rgba(4, 8, 6, 0.85);
    border: 1px solid var(--border-glass);
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--neon-green);
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Game Over Overlay Screen */
.game-over-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(4, 6, 5, 0.95);
    z-index: 20;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    text-align: center;
}

.retro-blink {
    font-family: var(--font-arcade);
    font-size: 1.4rem;
    color: var(--neon-green);
    text-shadow: 0 0 15px rgba(0, 255, 102, 0.6);
    animation: pulse 1.5s infinite alternate;
}

.game-over-overlay p {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.game-over-overlay p span {
    font-family: var(--font-arcade);
    color: var(--neon-magenta);
    font-weight: 700;
}

@keyframes pulse {
    from { opacity: 0.6; }
    to { opacity: 1.0; }
}

@keyframes flash {
    from { opacity: 0.3; }
    to { opacity: 1.0; }
}

/* Mobile responsiveness Stacking */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
    }

    .game-wrapper {
        height: auto;
        min-height: 100vh;
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .workspace {
        flex-direction: column;
        height: auto;
        gap: 0.5rem;
    }

    .side-hud {
        width: 100%;
        max-width: 440px;
        height: auto;
        flex-direction: row;
        padding: 0.5rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .side-hud .btn {
        width: calc(50% - 0.25rem);
    }

    .hud-box {
        flex: 1;
        min-width: 130px;
        padding: 0.5rem;
    }

    .hud-box h4 {
        font-size: 0.55rem;
        margin-bottom: 0.35rem;
    }

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

    .canvas-container {
        width: 100%;
        max-width: 440px;
        height: 60vh;
        min-height: 380px;
    }
}

/* Rules modal styling */
.rules-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-speed);
    z-index: 15;
}
.rules-btn:hover {
    color: var(--neon-green);
    border-color: var(--neon-green);
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.rules-modal {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(2, 3, 6, 0.7);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.rules-content {
    width: 100%;
    max-width: 350px;
    background: rgba(4, 8, 6, 0.95);
    border: 1px solid rgba(0, 255, 102, 0.25);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 0 35px rgba(0, 255, 102, 0.15);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    animation: modalSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideIn {
    from { transform: scale(0.93) translateY(-15px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.rules-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    transition: color 0.2s;
}
.rules-close:hover {
    color: var(--neon-magenta);
}

.rules-content h3 {
    font-family: var(--font-arcade);
    font-size: 0.8rem;
    color: var(--neon-green);
    text-shadow: 0 0 10px rgba(0, 255, 102, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.75rem;
    margin: 0;
    text-align: left;
}

.rules-text {
    font-size: 0.78rem;
    line-height: 1.6;
    color: #e0e5eb;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 0.5rem;
    text-align: left;
}

.rules-text p {
    margin: 0;
    padding-left: 1.25rem;
    position: relative;
}

.rules-text p strong {
    color: var(--neon-green);
}

.rules-text p::before {
    content: "▪";
    position: absolute;
    left: 0;
    top: 0;
    color: var(--neon-green);
    font-size: 1rem;
    line-height: 1;
}

.rules-text::-webkit-scrollbar {
    width: 4px;
}
.rules-text::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 2px;
}

.rules-link {
    font-family: var(--font-sans) !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    padding: 0.6rem 1rem !important;
    background: rgba(0, 255, 102, 0.08) !important;
    border: 1px solid rgba(0, 255, 102, 0.3) !important;
    color: #00ff66 !important;
    border-radius: 6px;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
}
.rules-link:hover {
    background: rgba(0, 255, 102, 0.18) !important;
    box-shadow: 0 0 15px rgba(0, 255, 102, 0.3);
    transform: translateY(-1px);
}
