/* Road Shooter — all game styles, isolated from the rest of the site */

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

body {
    background: #1a1a2e;
    overflow: hidden;
}

canvas {
    display: block;
}

/* ── HUD (desktop) ───────────────────────────────────────────────────────────
   Fixed box at top-left: dark bg, green accent border, score + progress bar. */
#hud {
    position: fixed;
    top: 16px;
    left: 16px;
    background: rgba(10, 10, 30, 0.82);
    border: 2px solid #7fff7f;
    border-radius: 10px;
    padding: 10px 16px 8px;
    color: #ffffff;
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: bold;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    z-index: 10;
    pointer-events: none;
    min-width: 170px;
    box-shadow: 0 0 12px rgba(127, 255, 127, 0.3);
}

#hudProgress {
    margin-top: 6px;
    height: 7px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    overflow: hidden;
}

#hudBar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #7fff7f, #00e676);
    border-radius: 4px;
    transition: width 0.15s ease;
}

/* ── Help button ─────────────────────────────────────────────────────────────
   Small "?" button that re-opens the tutorial overlay.
   Desktop: sits just below the HUD box, aligned to its left edge.
   Mobile: moves to the bottom-right so it doesn't crowd the top header. */
#helpBtn {
    position: fixed;
    top: 82px;   /* clears the HUD box (~16px top + ~58px box height) + 8px gap */
    left: 16px;
    width: 30px;
    height: 30px;
    background: rgba(10, 10, 30, 0.82);
    border: 2px solid #7fff7f;
    border-radius: 50%;
    color: #7fff7f;
    font-family: monospace;
    font-size: 1rem;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 0 8px rgba(127, 255, 127, 0.25);
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#helpBtn:hover {
    background: #7fff7f;
    color: #0a0020;
}

/* ── HUD (mobile) ────────────────────────────────────────────────────────────
   Full-width sticky header — single row to save vertical space. */
@media (max-width: 499px) {
    #hud {
        top: 0;
        left: 0;
        right: 0;
        border-radius: 0;
        border: none;
        border-bottom: 2px solid #7fff7f;
        padding: 6px 12px 5px;
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: unset;
    }

    #hudProgress {
        flex: 1;
        margin-top: 0;
    }

    /* On mobile the HUD is a full-width bar, so shift the help button
       to the bottom-right corner where it won't overlap the game area. */
    #helpBtn {
        top: auto;
        bottom: 16px;
        left: auto;
        right: 16px;
    }
}

/* ── Win overlay ─────────────────────────────────────────────────────────────
   Festive deep-purple overlay shown when the player reaches WIN_SCORE. */
#winOverlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #2d0a4e 0%, #0a0020 100%);
    color: #ffffff;
    z-index: 20;
    text-align: center;
    overflow: hidden;
}

#winOverlay h1 {
    font-family: monospace;
    font-size: clamp(2rem, 6vw, 3.5rem);
    color: #ffd700;
    text-shadow:
        0 0 20px rgba(255, 215, 0, 0.6),
        0 2px 8px rgba(0, 0, 0, 0.9);
    margin-bottom: 12px;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
    will-change: transform, opacity;
}

#winScore {
    font-family: monospace;
    font-size: 1.3rem;
    color: #7fff7f;
    margin-bottom: 8px;
}

#winSubtitle {
    font-family: monospace;
    font-size: 1rem;
    color: #e0c0ff;
    margin-bottom: 16px;
}

#winCountdown {
    font-family: monospace;
    font-size: 0.95rem;
    opacity: 0.7;
}

/* Confetti pieces injected by spawnConfetti() */
.confetti-wrap {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.confetti-piece {
    position: absolute;
    top: -20px;
    opacity: 0;
    animation: confettiFall linear infinite;
    will-change: transform, opacity;
}

@keyframes confettiFall {
    0%   { transform: translateY(-20px) rotate(0deg);   opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

/* ── Tutorial overlay ────────────────────────────────────────────────────────
   Shown on first hard-refresh load only (sessionStorage-gated). */
#tutorialOverlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
}

#tutorialBox {
    background: #1a1a2e;
    border: 2px solid #7fff7f;
    border-radius: 14px;
    padding: 28px 32px;
    max-width: 340px;
    width: 90%;
    color: #ffffff;
    font-family: monospace;
    text-align: center;
    box-shadow: 0 0 30px rgba(127, 255, 127, 0.25);
}

#tutorialBox h2 {
    color: #7fff7f;
    margin-bottom: 16px;
    font-size: 1.4rem;
}

.tut-grid {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 8px 10px;
    text-align: left;
    margin-bottom: 18px;
    align-items: center;
}

.tut-swatch {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: inline-block;
    justify-self: center;
}

/* Individual swatch colours */
.tut-red   { background: #e74c3c; }
.tut-blue  { background: #2980b9; }
.tut-gray  { background: #555555; outline: 1px solid #888888; }
.tut-tesla { background: #f0f0f0; outline: 1px solid #999999; }

.tut-penalty { color: #ff6666; }

#tutorialBox p {
    margin-bottom: 16px;
    font-size: 0.9rem;
    opacity: 0.85;
}

#tutDismiss {
    background: #7fff7f;
    color: #0a0020;
    border: none;
    border-radius: 8px;
    padding: 10px 28px;
    font-family: monospace;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 10px;
    display: block;
    width: 100%;
}

#tutDismiss:hover {
    background: #00e676;
}

#tutTimer {
    font-size: 0.75rem;
    opacity: 0.5;
    margin: 0;
}

.hidden {
    display: none;
}
