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

[hidden] {
    display: none !important;
}

/* Arcade cabinet palette. The game (js/utils.js and friends) uses the same colors. */
:root {
    --bg: #07060d;
    --panel: rgba(7, 6, 13, 0.82);
    --text: #f3f0ff;
    --muted: #9790b3;
    --pink: #ff4fa3;
    --cyan: #3de8ff;
    --yellow: #ffe14d;
    --line: #2a2340;
    --pixel: 'Press Start 2P', monospace;
    --mono: 'IBM Plex Mono', monospace;
}

body {
    font-family: var(--mono);
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* CRT: scanlines and a soft vignette over everything, game included */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    background:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px),
        radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.45) 100%);
}

:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 3px;
}

/* Star field */
.stars {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.7;
}

.stars-layer {
    position: absolute;
    inset: 0;
    background-repeat: repeat;
}

.stars-small {
    background-image:
        radial-gradient(1px 1px at 20px 30px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 40px 70px, rgba(255,255,255,0.6), transparent),
        radial-gradient(1px 1px at 50px 160px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.6), transparent),
        radial-gradient(1px 1px at 160px 120px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 200px 50px, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 220px 150px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 270px 90px, rgba(255,255,255,0.6), transparent),
        radial-gradient(1px 1px at 300px 180px, rgba(255,255,255,0.5), transparent);
    background-size: 320px 200px;
    animation: drift 120s linear infinite;
}

.stars-medium {
    background-image:
        radial-gradient(1.5px 1.5px at 100px 50px, rgba(255,255,255,0.9), transparent),
        radial-gradient(1.5px 1.5px at 200px 150px, rgba(61,232,255,0.7), transparent),
        radial-gradient(1.5px 1.5px at 300px 100px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1.5px 1.5px at 50px 200px, rgba(255,79,163,0.6), transparent),
        radial-gradient(1.5px 1.5px at 350px 250px, rgba(255,255,255,0.7), transparent);
    background-size: 400px 300px;
    animation: drift 180s linear infinite reverse;
}

.stars-large {
    background-image:
        radial-gradient(2px 2px at 150px 100px, rgba(61,232,255,1), transparent),
        radial-gradient(2px 2px at 350px 200px, rgba(255,225,77,0.9), transparent),
        radial-gradient(2.5px 2.5px at 250px 350px, rgba(255,79,163,1), transparent);
    background-size: 500px 450px;
    animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes drift {
    from { transform: translateY(0); }
    to { transform: translateY(-200px); }
}

@keyframes twinkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Page */
.container {
    position: relative;
    z-index: 1;
    max-width: 620px;
    margin: 0 auto;
    padding: 1rem 1.25rem 2.5rem;
    text-align: center;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.container.game-active {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.scorebar {
    display: flex;
    justify-content: space-between;
    font-family: var(--pixel);
    font-size: 0.625rem;
    color: var(--muted);
    text-transform: uppercase;
}

.scorebar b {
    font-weight: 400;
    color: var(--pink);
    margin-left: 0.5em;
}

/* Leaves room for the three rows of bikes the game draws at the top of the screen
   (js/enemy.js: rows at 60-132px). */
.header {
    margin-top: 150px;
}

.name {
    font-family: var(--pixel);
    font-weight: 400;
    font-size: clamp(1.35rem, 5.6vw, 2.4rem);
    line-height: 1.4;
    color: var(--yellow);
    text-shadow: 0 0 18px rgba(255, 225, 77, 0.45), 3px 3px 0 rgba(255, 79, 163, 0.55);
    text-transform: uppercase;
}

.tagline {
    margin-top: 1rem;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    color: var(--cyan);
    text-transform: uppercase;
}

/* Links as an arcade menu. The cursor (▶) follows hover and keyboard focus and rests on the
   first item otherwise. */
.menu {
    margin-top: 2.5rem;
    text-align: left;
    background: var(--panel);
    border: 2px solid var(--pink);
    box-shadow: 0 0 24px rgba(255, 79, 163, 0.25), inset 0 0 24px rgba(255, 79, 163, 0.08);
    padding: 0.75rem;
}

.menu ul {
    list-style: none;
}

.menu li + li a {
    border-top: 1px dashed var(--line);
}

.menu a {
    position: relative;
    display: block;
    padding: 0.9rem 0.75rem 0.9rem 2.25rem;
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s ease;
}

.menu a::before {
    content: "▶";
    position: absolute;
    left: 0.75rem;
    top: 0.95rem;
    font-size: 0.75rem;
    color: var(--pink);
    visibility: hidden;
}

.menu a:hover,
.menu a:focus-visible,
.menu ul:not(:hover):not(:focus-within) li:first-child a {
    background: rgba(61, 232, 255, 0.08);
}

.menu a:hover::before,
.menu a:focus-visible::before,
.menu ul:not(:hover):not(:focus-within) li:first-child a::before {
    visibility: visible;
    animation: blink 1s steps(2) infinite;
}

.menu a:focus-visible {
    outline-offset: -2px;
}

.menu-label {
    display: block;
    font-family: var(--pixel);
    font-size: clamp(0.66rem, 2.6vw, 0.78rem);
    line-height: 1.6;
    text-transform: uppercase;
}

.menu a:hover .menu-label,
.menu a:focus-visible .menu-label {
    color: var(--yellow);
}

.menu-desc {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--muted);
}

.game-prompt {
    margin-top: 2.5rem;
    padding: 0.75rem 1.25rem;
    background: none;
    border: 0;
    font-family: var(--pixel);
    font-size: 0.85rem;
    color: var(--pink);
    text-transform: uppercase;
    cursor: pointer;
    animation: blink 1s steps(2) infinite;
}

.game-prompt:hover,
.game-prompt:focus-visible {
    color: var(--yellow);
    animation: none;
}

.controls {
    margin-top: 0.5rem;
    font-size: 0.72rem;
    color: var(--muted);
}

.controls-touch {
    display: none;
}

@media (pointer: coarse) {
    .controls-keys { display: none; }
    .controls-touch { display: inline; }
}

.footer {
    margin-top: 2.5rem;
    font-family: var(--pixel);
    font-size: 0.6rem;
    color: var(--muted);
    text-transform: uppercase;
}

@keyframes blink {
    50% { opacity: 0.25; }
}

/* Game canvas: behind the page while idle, in front of it during play */
#galaga {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.55;
    transition: opacity 0.8s ease, z-index 0s 0.8s;
}

#galaga.game-active {
    opacity: 1;
    z-index: 10;
    touch-action: none;
    transition: opacity 0.8s ease, z-index 0s 0s;
}

/* Game control buttons */
#exitButton, #muteButton {
    position: fixed;
    bottom: 20px;
    z-index: 100;
    padding: 10px 16px;
    background: rgba(7, 6, 13, 0.9);
    border: 2px solid var(--pink);
    color: var(--text);
    font-family: var(--pixel);
    font-size: 12px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 0 16px rgba(255, 79, 163, 0.3);
    transition: background 0.2s ease, color 0.2s ease;
}

#exitButton { right: 20px; }
#exitButton::before { content: '← '; }
#muteButton { left: 20px; }

#exitButton:hover, #muteButton:hover {
    background: rgba(255, 79, 163, 0.2);
    color: var(--yellow);
}

@media (max-width: 480px) {
    .header { margin-top: 140px; }
    .menu { padding: 0.5rem; }
    .menu a { padding-left: 2rem; }
    .menu a::before { left: 0.6rem; }

    #exitButton, #muteButton {
        bottom: 14px;
        padding: 8px 12px;
        font-size: 10px;
    }
    #exitButton { right: 14px; }
    #muteButton { left: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .stars-layer,
    .game-prompt,
    .menu a::before {
        animation: none !important;
    }
}
