﻿:root {
    --sky-top: #120a3a;
    --sky-mid: #2b1f74;
    --sky-low: #5c3aa4;
    --text-main: #fff7d6;
    --text-soft: #ffe7a3;
    --outline: #1a1038;
    --mint: #75ffd9;
    --pink: #ff8de1;
    --sun: #ffd057;
    --planet-a: #ff8b6a;
    --planet-b: #d9577e;
    --planet-c: #7a2f72;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    color: var(--text-main);
    font-family: 'Press Start 2P', cursive;
}

.scene {
    position: relative;
    width: 100%;
    height: 100%;
    isolation: isolate;
    image-rendering: pixelated;
    background:
        radial-gradient(600px 280px at 80% 16%, rgba(255, 141, 225, 0.3), transparent 68%),
        radial-gradient(520px 280px at 18% 24%, rgba(117, 255, 217, 0.25), transparent 70%),
        linear-gradient(180deg, var(--sky-top), var(--sky-mid) 52%, var(--sky-low));
}

.stars,
.stars2,
.stars3,
.nebula,
.scanlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.stars,
.stars2,
.stars3 {
    z-index: 2;
}

.stars {
    background-image:
        radial-gradient(2px 2px at 24px 34px, #fff, transparent),
        radial-gradient(2px 2px at 120px 88px, #fff, transparent),
        radial-gradient(2px 2px at 198px 42px, #d9fffb, transparent),
        radial-gradient(2px 2px at 240px 190px, #ffe9ff, transparent);
    background-size: 280px 260px;
    animation: star-sway-a 20s steps(40, end) infinite;
}

.stars2 {
    opacity: 0.75;
    background-image:
        radial-gradient(3px 3px at 36px 124px, #fff, transparent),
        radial-gradient(2px 2px at 168px 36px, #ffdcff, transparent),
        radial-gradient(3px 3px at 260px 144px, #dcfffe, transparent);
    background-size: 360px 330px;
    animation: star-sway-b 30s steps(50, end) infinite;
}

.stars3 {
    opacity: 0.5;
    background-image:
        radial-gradient(3px 3px at 42px 54px, #fff, transparent),
        radial-gradient(3px 3px at 220px 220px, #ffe8c2, transparent),
        radial-gradient(3px 3px at 340px 92px, #e7f2ff, transparent);
    background-size: 460px 420px;
    animation: star-sway-c 40s steps(60, end) infinite;
}

.nebula {
    z-index: 3;
    opacity: 0.65;
    background:
        radial-gradient(480px 220px at 72% 24%, rgba(255, 141, 225, 0.28), transparent 70%),
        radial-gradient(420px 210px at 30% 66%, rgba(117, 255, 217, 0.2), transparent 68%);
}

.hero {
    position: absolute;
    left: 50%;
    top: 42%;
    z-index: 9;
    transform: translate(-50%, -50%);
    width: min(92vw, 860px);
    padding: clamp(18px, 3vw, 32px) clamp(14px, 3.6vw, 42px);
    text-align: center;
    border: 4px solid var(--outline);
    background:
        linear-gradient(180deg, rgba(46, 28, 112, 0.88), rgba(59, 34, 133, 0.88));
    box-shadow:
        0 0 0 4px #fff7d6,
        10px 10px 0 rgba(11, 6, 32, 0.45);
}

.badge {
    margin: 0 0 18px;
    font-size: clamp(0.5rem, 1vw, 0.68rem);
    letter-spacing: 0.08em;
    color: #9fffe0;
    text-shadow: 2px 2px 0 #112043;
}

.title {
    margin: 0;
    line-height: 1.1;
    font-size: clamp(1.8rem, 5.4vw, 4.5rem);
    color: #fff2bd;
    text-shadow:
        3px 3px 0 #35205f,
        0 0 16px rgba(255, 208, 87, 0.65);
    animation: title-pop 1.8s steps(8, end) infinite;
}

.subtitle {
    margin: clamp(14px, 2.2vw, 24px) auto 0;
    width: min(94%, 640px);
    font-size: clamp(0.58rem, 1.3vw, 0.86rem);
    line-height: 1.9;
    color: var(--text-soft);
    text-shadow: 2px 2px 0 #2b1a58;
}

.subtitle-trigger {
    cursor: pointer;
    transition: transform 0.2s ease, color 0.2s ease, text-shadow 0.2s ease;
}

.subtitle-trigger:hover,
.subtitle-trigger:focus-visible {
    color: #fff8cf;
    transform: translateY(-2px);
    text-shadow:
        2px 2px 0 #2b1a58,
        0 0 12px rgba(255, 241, 166, 0.72);
    outline: none;
}

.subtitle-note {
    margin: 12px auto 0;
    font-size: clamp(0.45rem, 0.9vw, 0.58rem);
    color: #9fffe0;
    text-shadow: 2px 2px 0 #2a1a57;
    letter-spacing: 0.04em;
}

.hero,
.planet,
.spaceship-wrapper {
    transition: opacity 0.48s ease, filter 0.48s ease;
}

.scene.is-galaxy .hero,
.scene.is-galaxy .planet,
.scene.is-galaxy .spaceship-wrapper {
    opacity: 0;
    filter: blur(2px);
    pointer-events: none;
}

.galaxy-screen {
    position: absolute;
    inset: 0;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transform: scale(1.03);
    transition: opacity 0.5s ease, transform 0.5s ease;
    background:
        radial-gradient(820px 420px at 20% 20%, rgba(140, 220, 255, 0.22), transparent 70%),
        radial-gradient(860px 520px at 85% 8%, rgba(255, 142, 214, 0.2), transparent 72%),
        linear-gradient(180deg, rgba(10, 6, 29, 0.92), rgba(24, 12, 62, 0.95));
}

.scene.is-galaxy .galaxy-screen {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.galaxy-header {
    position: absolute;
    top: 24px;
    left: 24px;
    right: 24px;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.galaxy-title {
    margin: 0;
    font-size: clamp(0.75rem, 1.8vw, 1.25rem);
    color: #fdf3c5;
    text-shadow: 3px 3px 0 #2a1859, 0 0 12px rgba(255, 228, 141, 0.45);
}

.galaxy-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.galaxy-back,
.galaxy-reset {
    border: 3px solid #2a1859;
    color: #2a1859;
    padding: 10px 14px;
    font-family: inherit;
    font-size: clamp(0.46rem, 0.95vw, 0.56rem);
    cursor: pointer;
    box-shadow: 4px 4px 0 rgba(21, 12, 48, 0.42);
    transition: transform 0.16s steps(2, end), filter 0.16s steps(2, end);
}

.galaxy-back {
    background: #ffe083;
}

.galaxy-reset {
    background: #87f7da;
}

.galaxy-back:hover,
.galaxy-reset:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
}

.planet-field {
    position: absolute;
    inset: 90px 22px 24px;
    border: 3px solid rgba(197, 174, 255, 0.45);
    background:
        radial-gradient(ellipse at center, rgba(26, 25, 78, 0.38), rgba(8, 8, 28, 0.18)),
        repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.04) 0,
            rgba(255, 255, 255, 0.04) 2px,
            transparent 2px,
            transparent 10px
        );
    overflow: hidden;
    box-shadow:
        inset 0 0 0 3px rgba(33, 18, 69, 0.82),
        0 0 22px rgba(130, 167, 255, 0.2);
}

.mini-planet {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 28% 24%, var(--planet-core), var(--planet-shadow) 68%);
    box-shadow:
        0 0 0 3px rgba(15, 13, 48, 0.35),
        0 0 18px var(--planet-glow);
    animation: planet-drift var(--drift-dur) steps(22, end) infinite alternate;
    cursor: pointer;
    transition: filter 0.2s steps(2, end), opacity 0.24s ease;
}

.mini-planet::before {
    content: "";
    position: absolute;
    inset: 18% 20% 52% 22%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    mix-blend-mode: screen;
}

.mini-planet::after {
    content: "";
    position: absolute;
    inset: 50% -18%;
    border: 3px solid rgba(246, 224, 176, 0.65);
    border-radius: 50%;
    opacity: var(--ring-opacity);
    transform: rotate(var(--ring-rotate));
}

.mini-planet:hover,
.mini-planet:focus-visible {
    filter: brightness(1.18) saturate(1.15);
    outline: none;
}

.planet-label {
    position: absolute;
    left: 50%;
    top: calc(100% + 9px);
    transform: translateX(-50%);
    color: #fff7d1;
    font-size: clamp(0.42rem, 0.75vw, 0.52rem);
    text-shadow: 2px 2px 0 #180f3e;
    white-space: nowrap;
    pointer-events: none;
}

.planet-burst {
    position: absolute;
    inset: -38%;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.3);
    pointer-events: none;
    background:
        radial-gradient(circle, rgba(255, 247, 206, 0.95) 0, rgba(255, 159, 90, 0.85) 34%, rgba(255, 96, 88, 0.42) 62%, transparent 86%);
    box-shadow:
        0 0 24px rgba(255, 188, 110, 0.65),
        0 0 42px rgba(255, 118, 97, 0.5);
}

.mini-planet.is-exploding {
    animation-play-state: paused;
    opacity: 0;
    filter: brightness(2.2) saturate(1.7);
}

.mini-planet.is-exploding .planet-burst {
    animation: planet-burst 0.62s steps(8, end) forwards;
}

.mini-planet.is-gone {
    visibility: hidden;
    pointer-events: none;
}

.planet {
    position: absolute;
    left: 50%;
    bottom: -27vh;
    z-index: 6;
    width: 166vw;
    height: 50vh;
    transform: translateX(-50%);
    border-radius: 50% 50% 0 0;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 50% 4%, var(--planet-a), var(--planet-b) 56%, var(--planet-c));
    box-shadow:
        0 -6px 0 rgba(255, 229, 187, 0.45),
        0 -18px 0 rgba(255, 156, 123, 0.24),
        0 -34px 50px rgba(122, 47, 114, 0.55);
}

.planet::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            180deg,
            rgba(255, 220, 178, 0.12) 0,
            rgba(255, 220, 178, 0.12) 6px,
            rgba(255, 146, 116, 0.08) 6px,
            rgba(255, 146, 116, 0.08) 12px
        );
}

.nuke {
    position: absolute;
    --nuke-x: 50%;
    --nuke-scale: 1;
    --nuke-delay: 0s;
    --nuke-duration: 9s;
    left: var(--nuke-x);
    top: -22px;
    width: 240px;
    height: 230px;
    transform: translateX(-50%) scale(var(--nuke-scale));
    transform-origin: center bottom;
    z-index: 7;
    pointer-events: none;
}

.nuke-flash,
.nuke-ring,
.nuke-stem,
.nuke-cap,
.nuke-smoke {
    position: absolute;
    animation-duration: var(--nuke-duration);
    animation-delay: var(--nuke-delay);
    animation-iteration-count: infinite;
    animation-fill-mode: both;
}

.nuke-flash {
    left: 111px;
    top: 136px;
    width: 18px;
    height: 18px;
    border-radius: 2px;
    background: #fffde8;
    box-shadow:
        0 0 0 8px #ffe28f,
        0 0 0 20px #ffaf52,
        0 0 24px 18px rgba(255, 128, 58, 0.65);
    animation-timing-function: cubic-bezier(0.15, 0.8, 0.35, 1);
    animation-name: nuke-flash;
}

.nuke-ring {
    left: 76px;
    top: 148px;
    width: 88px;
    height: 14px;
    border: 3px solid #ffd07d;
    background: rgba(255, 154, 72, 0.32);
    box-shadow:
        0 0 0 5px rgba(132, 41, 31, 0.32),
        0 0 16px rgba(255, 161, 89, 0.35);
    animation-timing-function: cubic-bezier(0.22, 0.7, 0.28, 1);
    animation-name: nuke-ring;
}

.nuke-stem {
    left: 102px;
    top: 78px;
    width: 34px;
    height: 94px;
    border-radius: 2px;
    background: linear-gradient(180deg, #fff4c6 0%, #ffbf61 35%, #e5763e 68%, #8f4546 100%);
    box-shadow:
        -8px 12px 0 rgba(255, 164, 84, 0.5),
        8px 14px 0 rgba(104, 51, 57, 0.55);
    animation-timing-function: cubic-bezier(0.21, 0.72, 0.3, 1);
    animation-name: nuke-stem-rise;
}

.nuke-cap {
    left: 44px;
    top: 24px;
    width: 146px;
    height: 90px;
    background: linear-gradient(180deg, #fff8d8 0%, #ffc872 42%, #dd7842 68%, #734149 100%);
    clip-path: polygon(8% 76%, 14% 52%, 25% 30%, 38% 16%, 50% 12%, 62% 16%, 75% 30%, 86% 52%, 92% 76%, 78% 100%, 22% 100%);
    box-shadow:
        -14px 16px 0 rgba(230, 126, 69, 0.45),
        14px 14px 0 rgba(89, 49, 55, 0.48);
    animation-timing-function: cubic-bezier(0.2, 0.7, 0.3, 1);
    animation-name: nuke-cap-rise;
}

.nuke-smoke {
    left: 58px;
    top: 48px;
    width: 124px;
    height: 86px;
    border-radius: 40% 40% 36% 36%;
    background: radial-gradient(ellipse at 50% 50%, rgba(118, 115, 128, 0.78), rgba(77, 71, 85, 0.38) 58%, transparent 78%);
    filter: blur(2px);
    animation-timing-function: ease-out;
    animation-name: nuke-smoke-rise;
}

.nuke-large {
    --nuke-x: 68%;
    --nuke-scale: 1.36;
    --nuke-delay: 2.2s;
    --nuke-duration: 11.2s;
    z-index: 8;
}

.nuke-medium {
    --nuke-x: 50%;
    --nuke-scale: 1;
    --nuke-delay: 0.4s;
    --nuke-duration: 9.2s;
}

.nuke-small {
    --nuke-x: 34%;
    --nuke-scale: 0.78;
    --nuke-delay: 4.6s;
    --nuke-duration: 8.2s;
}

.nuke-tiny {
    --nuke-x: 20%;
    --nuke-scale: 0.56;
    --nuke-delay: 6.1s;
    --nuke-duration: 7.4s;
    opacity: 0.9;
}

.spaceship-wrapper {
    position: absolute;
    top: 18%;
    left: -190px;
    z-index: 8;
    width: 120px;
    height: 60px;
    animation: fly-by 12s steps(90, end) infinite;
}

.spaceship {
    width: 100%;
    height: 100%;
    transform: rotate(-14deg);
}

.ship {
    position: absolute;
    top: 18px;
    left: 30px;
    width: 60px;
    height: 24px;
    background: #d0d0d0;
    clip-path: polygon(0% 50%, 20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%);
    box-shadow:
        inset -2px -2px 0 #8f8f8f,
        2px 2px 0 #2f2f58;
}

.ship::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 18px;
    width: 12px;
    height: 12px;
    background: #9de9ff;
    box-shadow:
        inset 1px 1px 0 #ffffff,
        0 0 0 2px #27496d;
}

.exhaust-flame {
    position: absolute;
    top: 20px;
    left: 0;
    width: 0;
    height: 0;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    border-right: 28px solid #ff9837;
    animation: flicker 0.12s steps(2, end) infinite;
}

.scanlines {
    z-index: 12;
    opacity: 0.08;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.12) 0,
        rgba(255, 255, 255, 0.12) 1px,
        transparent 1px,
        transparent 5px
    );
}

@keyframes title-pop {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-2px) scale(1.03);
    }
}

@keyframes star-sway-a {
    0% { transform: translateY(0); }
    100% { transform: translateY(-26px); }
}

@keyframes star-sway-b {
    0% { transform: translateY(0); }
    100% { transform: translateY(-18px); }
}

@keyframes star-sway-c {
    0% { transform: translateY(0); }
    100% { transform: translateY(-12px); }
}

@keyframes fly-by {
    0% {
        opacity: 0;
        transform: translateX(0) translateY(0) rotate(0deg);
    }
    8% { opacity: 1; }
    88% { opacity: 1; }
    100% {
        opacity: 0;
        transform: translateX(calc(100vw + 280px)) translateY(10vh) rotate(8deg);
    }
}

@keyframes flicker {
    0%, 100% {
        border-right-color: #ffc85a;
        transform: scale(1, 1);
    }
    50% {
        border-right-color: #ff6d3d;
        transform: scale(1.24, 0.82);
    }
}

@keyframes nuke-flash {
    0%, 12% {
        opacity: 0;
        transform: scale(0.4);
    }
    15% {
        opacity: 1;
        transform: scale(1.72);
    }
    24% {
        opacity: 0.95;
        transform: scale(1.15);
    }
    44% {
        opacity: 0.22;
        transform: scale(0.74);
    }
    100% {
        opacity: 0;
        transform: scale(0.4);
    }
}

@keyframes nuke-ring {
    0%, 14% {
        opacity: 0;
        transform: scaleX(0.24) scaleY(0.82);
    }
    21% {
        opacity: 1;
        transform: scaleX(1.05) scaleY(1);
    }
    37% {
        opacity: 0.82;
        transform: scaleX(2.08) scaleY(1.35);
    }
    56% {
        opacity: 0.22;
        transform: scaleX(3.06) scaleY(1.6);
    }
    100% {
        opacity: 0;
        transform: scaleX(3.4) scaleY(1.72);
    }
}

@keyframes nuke-stem-rise {
    0%, 14% {
        opacity: 0;
        transform: translateY(42px) scale(0.36);
    }
    26% {
        opacity: 1;
        transform: translateY(12px) scale(0.92);
    }
    48% {
        opacity: 1;
        transform: translateY(-16px) scale(1.1);
    }
    72% {
        opacity: 0.84;
        transform: translateY(-24px) scale(1.04);
    }
    90% {
        opacity: 0.62;
        transform: translateY(-26px) scale(0.98);
    }
    100% {
        opacity: 0.45;
        transform: translateY(-28px) scale(0.94);
    }
}

@keyframes nuke-cap-rise {
    0%, 16% {
        opacity: 0;
        transform: translateY(40px) scale(0.3);
    }
    28% {
        opacity: 0.95;
        transform: translateY(10px) scale(0.9);
    }
    50% {
        opacity: 1;
        transform: translateY(-18px) scale(1.12);
    }
    70% {
        opacity: 0.88;
        transform: translateY(-30px) scale(1.1);
    }
    100% {
        opacity: 0.55;
        transform: translateY(-36px) scale(1.02);
    }
}

@keyframes nuke-smoke-rise {
    0%, 24% {
        opacity: 0;
        transform: translateY(18px) scale(0.72);
    }
    42% {
        opacity: 0.76;
        transform: translateY(0) scale(1);
    }
    72% {
        opacity: 0.72;
        transform: translateY(-16px) scale(1.25);
    }
    100% {
        opacity: 0.36;
        transform: translateY(-26px) scale(1.42);
    }
}

@keyframes planet-drift {
    0% {
        transform: translateY(0) translateX(0);
    }
    100% {
        transform: translateY(var(--drift-y)) translateX(var(--drift-x));
    }
}

@keyframes planet-burst {
    0% {
        opacity: 0.3;
        transform: scale(0.3);
    }
    34% {
        opacity: 1;
        transform: scale(1.25);
    }
    100% {
        opacity: 0;
        transform: scale(2.5);
    }
}

@media (max-width: 768px) {
    .hero {
        top: 43%;
        width: min(95vw, 640px);
        padding: 16px 12px 20px;
        box-shadow:
            0 0 0 3px #fff7d6,
            6px 6px 0 rgba(11, 6, 32, 0.45);
    }

    .badge {
        margin-bottom: 14px;
        letter-spacing: 0.05em;
    }

    .subtitle {
        width: 96%;
        line-height: 1.75;
    }

    .subtitle-note {
        margin-top: 10px;
    }

    .nuke {
        top: -2px;
        transform: translateX(-50%) scale(calc(var(--nuke-scale) * 0.72));
        transform-origin: center top;
    }

    .spaceship-wrapper {
        transform: scale(0.82);
        transform-origin: left center;
        animation-duration: 14s;
    }

    .galaxy-header {
        top: 14px;
        left: 14px;
        right: 14px;
        flex-direction: column;
        align-items: flex-start;
    }

    .galaxy-actions {
        width: 100%;
    }

    .galaxy-back,
    .galaxy-reset {
        flex: 1;
        padding: 9px 10px;
    }

    .planet-field {
        inset: 88px 10px 12px;
    }
}
