:root {
    --bg: #0b0e1a;
    --bg-dark: #060812;
    --accent: #00ff9d;
    --accent2: #00d4ff;
    --accent3: #7c9eff;
    --text: #e0f0ff;
    --text-dim: #a3bffa;
    --glow: 0 0 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: var(--bg);
    font-family: 'Inter', system-ui, sans-serif;
    touch-action: manipulation;
}

#game-container {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #000814;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    touch-action: none;
    display: block;
    flex: 1;
}

#start-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-family: 'Orbitron', monospace;
    font-size: clamp(2.5rem, 12vw, 6rem);
    font-weight: 900;
    text-shadow: 0 0 30px rgba(0, 255, 157, 0.8);
    cursor: pointer;
    z-index: 20;
    user-select: none;
    transition: opacity 0.6s ease;
}

#start-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#start-overlay .subtitle {
    font-family: 'Inter', sans-serif;
    font-size: clamp(1.1rem, 5vw, 1.8rem);
    margin-top: 1.2rem;
    opacity: 0.85;
}

#game-hud {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 15;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}

.hud-badge {
    background: rgba(0, 255, 157, 0.15);
    border: 1px solid rgba(0, 255, 157, 0.5);
    color: var(--accent);
    padding: 6px 12px;
    border-radius: 30px;
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    font-weight: 600;
    backdrop-filter: blur(6px);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
}

/* Sound toggle button */
.sound-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 15;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 255, 157, 0.5);
    color: var(--accent);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: all 0.2s;
    font-size: 1.2rem;
}

.sound-toggle:hover {
    background: rgba(0, 255, 157, 0.2);
    transform: scale(1.05);
}

#exit-fullscreen-hint {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #a3bffa;
    padding: 8px 16px;
    border-radius: 40px;
    font-size: 0.9rem;
    z-index: 15;
    pointer-events: none;
    opacity: 0.8;
    display: none;
}

@media (orientation: landscape) and (max-height: 500px) {
    #exit-fullscreen-hint {
        display: block;
    }
}

@media (max-width: 600px) {
    #game-hud {
        top: 8px;
        left: 8px;
    }

    .hud-badge {
        font-size: 0.85rem;
        padding: 5px 10px;
    }

    .sound-toggle {
        top: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}

/* Game Over Modal */
.game-over-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.4s ease;
    padding: 1rem;
}

.modal-content {
    background: linear-gradient(145deg, #1a1f35, #0b0e1a);
    border: 2px solid var(--accent);
    border-radius: 1.5rem;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 0 40px rgba(0, 255, 157, 0.25);
    animation: slideUp 0.4s ease;
}

@media (min-width: 768px) {
    .modal-content {
        max-width: 380px;
        padding: 1.6rem;
    }
}

@media (min-width: 1024px) {
    .modal-content {
        max-width: 400px;
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 1.2rem;
        max-width: 320px;
    }
}

.modal-content h2 {
    font-family: 'Orbitron', monospace;
    font-size: clamp(1.5rem, 5vw, 2rem);
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 0.5rem;
}

.confetti {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin: 0.25rem 0;
    animation: bounce 0.8s ease infinite;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin: 1rem 0;
}

@media (max-width: 480px) {
    .stats-grid {
        gap: 0.5rem;
        margin: 0.75rem 0;
    }
}

.stat-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.75rem 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(0, 255, 157, 0.15);
}

@media (max-width: 480px) {
    .stat-item {
        padding: 0.5rem 0.25rem;
    }
}

.stat-label {
    font-size: clamp(0.7rem, 2.5vw, 0.8rem);
    color: var(--text-dim);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-family: 'Orbitron', monospace;
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

@media (max-width: 480px) {
    .stat-value {
        font-size: 1.2rem;
    }
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.25rem;
}

@media (max-width: 480px) {
    .modal-buttons {
        gap: 0.5rem;
        margin-top: 1rem;
    }
}

.modal-btn {
    padding: 0.5rem 1.2rem;
    border-radius: 50vmax;
    font-family: 'Orbitron', monospace;
    font-weight: 600;
    font-size: clamp(0.8rem, 3vw, 0.9rem);
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

@media (max-width: 480px) {
    .modal-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

.modal-btn-primary {
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    color: #0b1121;
}

.modal-btn-secondary {
    background: transparent;
    border: 2px solid var(--accent);
    color: var(--accent);
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 255, 157, 0.25);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}