:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #f59e0b;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(51, 65, 85, 0.5);
    /* Game Specific Colors */
    --life-color: #ef4444;
    --success-color: #10b981;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

.game-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 10;
    position: relative;
}

/* Header */
.game-header {
    padding: 1rem 2rem;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.back-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: 0.2s;
    font-size: 0.95rem;
}

.back-link:hover {
    color: var(--primary);
    transform: translateX(-5px);
}

.score-display {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--accent);
}

.lives-display {
    color: var(--life-color);
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Glass Panels */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
}

/* Main Game Area */
#game-stage {
    flex-grow: 1;
    display: flex;
    padding: 1rem;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#game-container {
    position: relative;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    border-radius: 20px;
    overflow: hidden;
    background: #87CEEB; /* Base sky color */
    border: 4px solid var(--border);
    width: 100%;
    height: 100%;
    max-width: 1200px;
    max-height: 600px;
    aspect-ratio: 16 / 8;
}

canvas {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    z-index: 5;
}

/* Parallax Background */
#bg-parallax {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 100%;
    background-repeat: repeat-x;
    background-position: bottom;
}

.layer-1 {
    background-image: linear-gradient(to bottom, #87CEEB, #e0f2fe);
    z-index: 1;
}

.layer-2 {
    /* Representing distant clouds or school buildings */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 100"><path d="M0 100 L0 80 Q50 60 100 80 T200 80 T300 80 T400 80 T500 80 T600 80 T700 80 T800 80 T900 80 T1000 80 L1000 100 Z" fill="rgba(255,255,255,0.3)"/></svg>');
    background-size: 50% 100px;
    z-index: 2;
    opacity: 0.5;
}

.layer-3 {
    /* Representing closer hills or trees */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 100"><path d="M0 100 L0 90 Q100 70 200 90 T400 90 T600 90 T800 90 T1000 90 L1000 100 Z" fill="rgba(255,255,255,0.5)"/></svg>');
    background-size: 100% 150px;
    z-index: 3;
}

/* Mobile Controls */
.mobile-only {
    display: none;
    position: absolute;
    bottom: 1.5rem;
    left: 0;
    width: 100%;
    padding: 0 1.5rem;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 50;
    pointer-events: none;
}

.control-btn {
    pointer-events: auto;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: all 0.1s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:active {
    background: var(--primary);
    transform: scale(0.9);
    border-color: white;
}

.d-pad {
    display: flex;
    gap: 1rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

.control-btn.action {
    width: 75px;
    height: 75px;
    background: rgba(37, 99, 235, 0.5);
    font-size: 2rem;
}

.control-btn.fire {
    background: rgba(245, 158, 11, 0.5);
}

/* Start Screen Details */
.instructions-mini {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.instructions-mini i {
    color: var(--accent);
    margin-right: 0.3rem;
}

/* Responsive adjustments */
@media (max-width: 900px) or (max-height: 600px) {
    .mobile-only {
        display: flex;
    }
    
    .game-header {
        padding: 0.5rem 1rem;
    }

    #game-stage {
        padding: 0;
    }

    #game-container {
        border: none;
        border-radius: 0;
        max-width: 100vw;
        max-height: 100vh;
    }
}

/* Modals */
.modal {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    padding: 2.5rem;
    text-align: center;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.modal h1 {
    font-family: 'Outfit';
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.modal h2 {
    font-family: 'Outfit';
    font-size: 1.8rem;
    color: var(--accent);
    margin-bottom: 1rem;
}

.modal p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.modal-icon, .victory-icon {
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 1rem;
}

.equation-box {
    background: rgba(0,0,0,0.3);
    padding: 1.5rem;
    border-radius: 8px;
    font-size: 2rem;
    color: white;
    font-weight: 800;
    margin-bottom: 2rem;
    border: 2px dashed var(--border);
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

input[type="number"] {
    flex-grow: 1;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.2rem;
    font-family: inherit;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.3s;
    font-family: 'Outfit', sans-serif;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.feedback {
    margin-top: 1rem;
    font-weight: 600;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.hidden { display: none !important; }

/* DECO Background */
.bg-deco {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at top left, var(--primary), transparent 40%),
                radial-gradient(circle at bottom right, var(--accent), transparent 40%);
    opacity: 0.1;
    z-index: 0;
}

/* Mobile Responsive */
@media (max-width: 1100px) {
    #game-stage {
        grid-template-columns: auto;
    }
    .controls-panel {
        display: none;
    }
}
