:root {
    --pulseframe-page-top-offset: 16px; /* INSTÄLLNING - Ändra hur långt ner Pulseframe börjar från navbaren. Lägre värde = mindre scroll. */
    --pulseframe-section-gap: 20px; /* INSTÄLLNING - Ändra vertikalt avstånd mellan sektioner. */
    --pulseframe-panel-size: min(800px, calc(100vh - 220px)); /* INSTÄLLNING - Ändra spelets storlek. Baseras på skärmhöjd för att undvika scroll. */
}

.game-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--pulseframe-page-top-offset) var(--spacing-2);
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: var(--pulseframe-panel-size);
    aspect-ratio: 1 / 1;
    max-height: 100%;
    border-radius: var(--radius-md);
    background-color: #050507;
    box-shadow: 0 0 50px rgba(139, 108, 255, 0.05), inset 0 0 30px rgba(0, 0, 0, 0.9);
    overflow: hidden;
    cursor: crosshair;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(5, 5, 7, 0.9);
    backdrop-filter: blur(12px); /* INSTÄLLNING - Ändra hur mycket bakgrunden suddas ut när menyer är uppe. */
    z-index: 10;
    text-align: center;
    transition: opacity 0.5s ease; /* INSTÄLLNING - Ändra hur snabbt menyer tonas in/ut. */
}

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

.overlay h1 {
    font-size: clamp(2.5rem, 6vw, 4rem);
    color: var(--text);
    margin-bottom: var(--spacing-3);
    text-shadow: 0 0 30px var(--accent-glow);
    font-weight: 700;
    letter-spacing: -0.05em;
}

.overlay p {
    margin-bottom: var(--spacing-4);
    line-height: 1.8;
    color: var(--text-muted);
    font-size: 1.125rem;
}

.score-board {
    background-color: transparent;
    padding: var(--spacing-4) var(--spacing-6);
    margin-bottom: var(--spacing-5);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
}

.score-board p {
    margin-bottom: 0;
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.score-board p:first-child {
    color: var(--text);
}

.score-board p:first-child span {
    color: var(--accent);
    font-weight: 600;
    text-shadow: 0 0 15px var(--accent-glow);
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    padding: var(--spacing-4);
    display: flex;
    justify-content: space-between;
    transition: opacity 0.3s ease;
}

#hud.hidden {
    opacity: 0;
}

#scoreDisplay, #waveDisplay {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 1.25rem;
    color: rgba(250, 250, 250, 0.9);
    text-shadow: 0 2px 10px rgba(0,0,0,1);
    letter-spacing: 0.02em;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.score-pulse {
    transform: scale(1.15);
    color: #fff !important;
    text-shadow: 0 0 15px var(--accent) !important;
}

#nearMissIndicator {
    position: absolute;
    top: 0;
    left: 0;
    color: #fff;
    font-weight: 600;
    font-size: 0.875rem;
    text-shadow: 0 0 10px rgba(139, 108, 255, 0.8), 0 0 20px rgba(139, 108, 255, 0.4);
    pointer-events: none;
    will-change: transform, opacity;
}

#nearMissIndicator.hidden {
    display: none;
}

.near-miss-anim {
    animation: nearMissFloat 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards; /* INSTÄLLNING - Ändra hur snabbt "+15" texten animeras. */
}

@keyframes nearMissFloat {
    0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); }
    15% { opacity: 1; transform: translate(-50%, -15px) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -40px) scale(0.9); }
}
