:root {
    --happy: #FFD400;
    --bat: #7F27A8;
    --pond: #53B0C9;
    --juice: #F76400;
    --heart: #C1008F;
    --cheek: #E885CF;
    --bg-dark: #0D0D0D;
    --bg-panel: #1A1A1A;
    --text-light: #FFFFFF;
    --text-dim: #AAAAAA;
    --border: rgba(255,255,255,0.08);
    --gold: #FFD400;

    --glow-happy: 0 0 20px var(--happy);
    --glow-heart: 0 0 20px var(--heart);
    --glow-pond: 0 0 20px var(--pond);
    --glow-bat: 0 0 30px rgba(127, 39, 168, 0.7);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: 'DM Sans', sans-serif;
    overflow: hidden;
    user-select: none;
    background-image:
        radial-gradient(2px 2px at 40px 60px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 120px 150px, var(--pond), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 200px 40px, #fff, rgba(0,0,0,0)),
        radial-gradient(3px 3px at 350px 220px, var(--bat), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 450px 100px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 550px 300px, var(--happy), rgba(0,0,0,0)),
        radial-gradient(3px 3px at 50px 400px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 250px 450px, var(--cheek), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 600px 50px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 150px 350px, #fff, rgba(0,0,0,0));
    background-size: 650px 650px;
    animation: animateStars 40s linear infinite;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(1px 1px at 10px 10px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 150px 200px, #aaa, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 300px 80px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 400px 300px, var(--bat), rgba(0,0,0,0)),
        radial-gradient(1px 1px at 500px 150px, #fff, rgba(0,0,0,0));
    background-size: 500px 500px;
    animation: animateStars 25s linear infinite;
    z-index: -1;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(3px 3px at 80px 80px, var(--happy), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 200px 250px, #fff, rgba(0,0,0,0)),
        radial-gradient(3px 3px at 400px 100px, var(--juice), rgba(0,0,0,0));
    background-size: 800px 800px;
    animation: animateStars 60s linear infinite;
    z-index: -2;
    pointer-events: none;
}

@keyframes animateStars {
    from { background-position: 0 0; }
    to { background-position: -1000px 1000px; }
}

h1,
h2,
h3,
h4,
.retro-text {
    font-family: 'Press Start 2P', cursive;
    line-height: 1.4;
}

button,
.button-style {
    font-family: 'Press Start 2P', cursive;
    background-color: var(--juice);
    color: var(--text-light);
    border: 4px solid var(--text-light);
    padding: 15px 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-transform: uppercase;
    display: inline-block;
    text-align: center;
    user-select: none;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.5);
}

button:hover,
.button-style:hover {
    background-color: var(--happy);
    color: var(--bg-dark);
    border-color: var(--bg-dark);
    box-shadow: var(--glow-happy);
    transform: translateY(-2px);
}

button:active,
.button-style:active {
    transform: translateY(2px);
    box-shadow: none;
}

button:disabled {
    background-color: #333 !important;
    color: #666 !important;
    border-color: #444 !important;
    cursor: not-allowed;
    box-shadow: none !important;
    transform: none !important;
}

.hidden {
    display: none !important;
}

.retro-input,
.retro-select {
    background-color: var(--bg-dark);
    color: var(--happy);
    border: 4px solid var(--text-dim);
    padding: 15px;
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    width: 100%;
    max-width: 400px;
    margin-bottom: 20px;
    box-shadow: inset 4px 4px 0 rgba(0,0,0,0.8);
    transition: all 0.3s ease;
}

.retro-input:focus,
.retro-select:focus {
    outline: none;
    border-color: var(--juice);
    box-shadow: var(--glow-happy), inset 4px 4px 0 rgba(0,0,0,0.8);
}

.retro-select option {
    background-color: var(--bg-dark);
    color: var(--happy);
}

#launchpad {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(13, 13, 13, 0.95);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    backdrop-filter: blur(10px);
    overflow-y: auto;
}

#launchpad h1 {
    color: var(--happy);
    text-shadow: 4px 4px var(--bat);
    font-size: 36px;
    margin-bottom: 20px;
    max-width: 900px;
}

#launchpad p {
    color: var(--pond);
    font-size: 16px;
    margin-bottom: 40px;
    font-family: 'Press Start 2P', cursive;
}

.mission-title-accent {
    color: var(--text-light);
}

.completion-title {
    margin-bottom: 0;
}

.completion-subtitle {
    color: var(--happy) !important;
    margin-top: 10px;
}

.form-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
}

.auth-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.auth-copy {
    max-width: 580px;
    margin-bottom: 25px;
    color: var(--text-light);
    font-size: 18px;
    line-height: 1.7;
}

.auth-status {
    min-height: 58px;
    max-width: 720px;
    margin-bottom: 25px;
    padding: 16px 18px;
    border: 3px solid var(--border);
    background: rgba(0,0,0,0.45);
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    line-height: 1.6;
    border-radius: 12px;
}

.auth-status--info {
    color: var(--pond);
    border-color: rgba(83, 176, 201, 0.5);
    box-shadow: 0 0 18px rgba(83, 176, 201, 0.2);
}

.auth-status--error {
    color: var(--heart);
    border-color: rgba(193, 0, 143, 0.55);
    box-shadow: 0 0 18px rgba(193, 0, 143, 0.25);
}

.auth-user-card {
    width: 100%;
    max-width: 620px;
    margin-bottom: 24px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    border: 4px solid var(--bat);
    border-radius: 18px;
    background: rgba(26, 26, 26, 0.92);
    box-shadow: var(--glow-bat);
}

.auth-avatar,
.session-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--happy);
    background: rgba(255,255,255,0.08);
}

.auth-user-meta {
    text-align: left;
}

.auth-kicker {
    color: var(--pond);
    font-size: 10px;
    margin-bottom: 12px;
}

.auth-name {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 8px;
}

.auth-email {
    color: var(--happy);
    font-size: 16px;
    word-break: break-word;
}

#btn-lfg {
    font-size: 20px;
    padding: 20px 40px;
    background-color: var(--bat);
    animation: pulse 2s infinite;
    margin-top: 10px;
}

.admin-toggle {
    margin-top: 40px;
    color: var(--text-dim);
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.3s;
}

.admin-toggle:hover {
    color: var(--juice);
}

.error-msg {
    color: var(--heart);
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    margin-bottom: 15px;
    text-shadow: 0 0 10px var(--heart);
    height: 10px;
}

.login-button,
.utility-button {
    background-color: var(--bat);
}

#session-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 18px rgba(0,0,0,0.45);
}

.session-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.session-identity {
    text-align: left;
}

.session-name {
    color: var(--happy);
    font-size: 10px;
    margin-bottom: 6px;
}

.session-email {
    color: var(--text-light);
    font-size: 13px;
    line-height: 1.3;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(127, 39, 168, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 20px rgba(127, 39, 168, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(127, 39, 168, 0); }
}

#map-viewport {
    width: 100vw;
    height: 100vh;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    position: relative;
}

#map-viewport::-webkit-scrollbar {
    display: none;
}

#map-track {
    height: 100%;
    display: flex;
    align-items: center;
    position: relative;
    padding: 0 50vw;
    width: max-content;
}

#path-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 6px;
    background-color: var(--pond);
    transform: translateY(-50%);
    box-shadow: var(--glow-pond);
    z-index: 1;
}

#stations-container {
    display: flex;
}

.station {
    position: relative;
    width: 300px;
    height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.planet {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--bg-panel);
    border: 4px solid var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    color: var(--text-dim);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: inset -10px -10px 20px rgba(0,0,0,0.5);
}

.station.active .planet {
    border-color: var(--happy);
    color: var(--happy);
    box-shadow: var(--glow-happy), inset -10px -10px 20px rgba(0,0,0,0.5);
    background-color: var(--bat);
    transform: scale(1.2);
}

.station.completed .planet {
    border-color: var(--pond);
    color: var(--pond);
    background-color: rgba(83, 176, 201, 0.2);
}

.station-label {
    margin-top: 30px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    text-align: center;
    color: var(--text-dim);
    width: 200px;
    line-height: 1.5;
    text-shadow: 2px 2px #000;
}

.station.active .station-label {
    color: var(--happy);
    font-size: 12px;
    text-shadow: 0 0 10px rgba(255, 212, 0, 0.5);
}

#rocket-container {
    position: absolute;
    top: 50%;
    left: 50vw;
    transform: translate(-50%, -50%);
    z-index: 10;
    transition: left 1.5s cubic-bezier(0.42, 0, 0.17, 1);
    pointer-events: none;
}

@keyframes floatRetro {
    0%,
    100% { transform: rotate(90deg) translateY(0); }
    50% { transform: rotate(90deg) translateY(-12px); }
}

#rocket-svg {
    width: 60px;
    height: 60px;
    filter: drop-shadow(0 0 15px var(--juice));
    transform: rotate(90deg);
    animation: floatRetro 2.5s ease-in-out infinite;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

@keyframes popInModal {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

#transmission-modal:not(.hidden) .panel-box {
    animation: popInModal 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.panel-box {
    background-color: var(--bg-panel);
    border: 4px solid var(--border);
    padding: 30px;
    max-width: 800px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    position: relative;
    border-radius: 8px;
}

.panel-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--bat), var(--cheek), var(--juice), var(--happy));
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.transmission-title {
    color: var(--juice);
}

.transmission-subtitle {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 10px;
}

.video-placeholder {
    width: 100%;
    height: 300px;
    background-color: #0b0b0b;
    border: 2px solid #333;
    margin: 20px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.9);
    animation: crtFlicker 4s infinite;
}

.video-placeholder__fallback,
.video-placeholder__media {
    position: relative;
    z-index: 1;
}

.video-placeholder__fallback {
    padding: 20px;
    text-align: center;
}

.video-placeholder__media {
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
}

@keyframes crtFlicker {
    0% { opacity: 0.95; }
    5% { opacity: 0.85; }
    10% { opacity: 0.95; }
    15% { opacity: 1; }
    100% { opacity: 1; }
}

.scanline {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 4px, 3px 100%;
    pointer-events: none;
    z-index: 2;
}

.controls-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    align-items: center;
    margin-top: 25px;
}

.hidden-checkbox {
    display: none;
}

.override-label:has(input:checked) {
    background-color: var(--pond);
    border-color: var(--text-light);
    color: var(--bg-dark);
    box-shadow: var(--glow-pond);
}

@keyframes popInCenter {
    0% { transform: translate(-50%, -40%) scale(0.85); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

#clearance-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 900px;
    background-color: var(--bg-panel);
    border: 6px solid var(--bat);
    padding: 40px;
    z-index: 600;
    box-shadow: var(--glow-bat), inset 0 0 20px rgba(127, 39, 168, 0.3), 0 30px 60px rgba(0,0,0,0.8);
    border-radius: 20px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

#clearance-panel:not(.hidden) {
    animation: popInCenter 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#clearance-panel::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 250vw;
    height: 250vh;
    background: rgba(13, 13, 13, 0.6);
    backdrop-filter: blur(8px);
    z-index: -1;
    pointer-events: none;
}

.dept-title {
    color: var(--pond);
    font-size: 14px;
    margin-bottom: 25px;
    border-bottom: 2px solid rgba(255,255,255,0.1);
    padding-bottom: 15px;
    text-shadow: 0 0 10px rgba(83, 176, 201, 0.4);
}

.question-text {
    font-size: 26px;
    margin-bottom: 35px;
    line-height: 1.4;
    color: var(--text-light);
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.option-btn {
    background-color: transparent;
    border: 2px solid var(--text-dim);
    color: var(--text-light);
    text-align: left;
    padding: 20px;
    font-family: 'DM Sans', sans-serif;
    font-size: 18px;
    font-weight: 700;
    text-transform: none;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.option-btn:hover {
    border-color: var(--juice);
    background-color: rgba(247, 100, 0, 0.15);
    color: var(--happy);
    box-shadow: 0 0 20px rgba(247, 100, 0, 0.4);
    transform: scale(1.03) translateY(-3px);
    z-index: 10;
}

.option-btn.correct {
    background-color: var(--happy);
    border-color: var(--happy);
    color: var(--bg-dark);
    animation: pulseCorrect 0.5s ease forwards;
}

@keyframes pulseCorrect {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: var(--glow-happy); }
    100% { transform: scale(1); box-shadow: var(--glow-happy); }
}

.option-btn.wrong {
    background-color: var(--heart);
    border-color: var(--heart);
    color: var(--text-light);
    opacity: 0.6;
    transform: scale(0.95);
}

.feedback-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 50px;
    margin-top: 20px;
}

.feedback-msg {
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
}

.msg-wrong {
    color: var(--heart);
    text-shadow: 0 0 10px var(--heart);
}

.msg-correct {
    color: var(--happy);
    text-shadow: 0 0 10px var(--happy);
}

@keyframes shake {
    0%,
    100% { transform: translate(-50%, -50%) translateX(0); }
    20% { transform: translate(-50%, -50%) translateX(-15px); }
    40% { transform: translate(-50%, -50%) translateX(15px); }
    60% { transform: translate(-50%, -50%) translateX(-10px); }
    80% { transform: translate(-50%, -50%) translateX(10px); }
}

.shake-animation {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both !important;
}

.flash-wrong {
    background-color: #3a002a !important;
    border-color: var(--heart) !important;
    box-shadow: var(--glow-heart), inset 0 0 30px var(--heart) !important;
}

.flash-correct {
    background-color: #2a2200 !important;
    border-color: var(--happy) !important;
    box-shadow: var(--glow-happy), inset 0 0 30px var(--happy) !important;
}

#hud {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    font-family: 'Press Start 2P', cursive;
    color: var(--gold);
    font-size: 12px;
    background: rgba(0,0,0,0.7);
    padding: 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    line-height: 1.8;
    min-width: 260px;
}

.hud-highlight {
    color: var(--pond);
}

.hud-score {
    color: var(--happy);
}

.leaderboard-container {
    width: 100%;
    max-width: 800px;
    margin: 40px auto 0;
    background: rgba(0,0,0,0.6);
    border: 4px solid var(--bat);
    padding: 30px;
    border-radius: 12px;
}

.lb-title {
    color: var(--juice);
    font-size: 18px;
    margin-bottom: 30px;
    text-shadow: var(--glow-bat);
}

.lb-row {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
}

.lb-name {
    width: 160px;
    text-align: left;
    color: var(--text-light);
}

.lb-track {
    flex-grow: 1;
    height: 6px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    position: relative;
    margin: 0 20px;
    border-radius: 3px;
}

.lb-rocket-icon {
    position: absolute;
    top: -15px;
    left: 0;
    width: 30px;
    height: 30px;
    transform: rotate(90deg) translateX(0);
    transition: left 2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: drop-shadow(0 0 5px var(--pond));
}

.lb-score {
    width: 100px;
    text-align: right;
    color: var(--happy);
}

.lb-row.current-player .lb-name {
    color: var(--happy);
    text-shadow: var(--glow-happy);
}

.lb-row.current-player .lb-rocket-icon {
    filter: drop-shadow(0 0 10px var(--happy));
}

@media (max-width: 900px) {
    #session-controls {
        left: 20px;
        right: 20px;
        top: auto;
        bottom: 20px;
        justify-content: space-between;
    }

    .auth-user-card {
        flex-direction: column;
        text-align: center;
    }

    .auth-user-meta,
    .session-identity {
        text-align: center;
    }

    .feedback-area,
    .controls-row {
        flex-direction: column;
    }
}

@media (max-width: 720px) {
    .options-grid {
        grid-template-columns: 1fr;
    }

    #launchpad h1 {
        font-size: 28px;
    }

    .auth-name {
        font-size: 22px;
    }

    .auth-copy,
    .auth-email {
        font-size: 14px;
    }

    .question-text {
        font-size: 22px;
    }

    #session-controls {
        flex-direction: column;
    }
}
