* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    font-family: 'Orbitron', sans-serif;
    background: #000;
    cursor: grab;
    touch-action: none;
}

body.dragging {
    cursor: grabbing;
}

:root {
    --bottom-nav-height: 64px;
    --bottom-nav-safe-area: calc(var(--bottom-nav-height) + 18px);
}

#canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#spaceship {
    position: fixed;
    width: clamp(200px, 25vw, 400px);
    height: auto;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    filter: drop-shadow(0 0 20px rgba(100, 150, 255, 0.6));
}

/* ========================================
   MAIN LAYOUT - Flexbox Centered System
   ======================================== */

#content-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
    padding: 2vh 0 var(--bottom-nav-safe-area);
    overflow: hidden;
}

#content-wrapper > * {
    pointer-events: auto;
    flex-shrink: 0;
}

/* ========================================
   PLANET SECTION
   ======================================== */

.planet-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5vh;
    margin-bottom: 3.5vh;
}

#planet-container {
    width: clamp(280px, 35vmin, 450px);
    height: clamp(280px, 35vmin, 450px);
    opacity: 0;
    transition: opacity 1s ease-in;
    cursor: grab;
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#planet-container.visible {
    opacity: 1;
}

#planet-container.grabbing {
    cursor: grabbing;
}

#planet-canvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: 0 0 50px rgba(100, 150, 255, 0.4),
                0 0 100px rgba(100, 150, 255, 0.2),
                inset 0 0 50px rgba(0, 0, 0, 0.5);
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.5s ease;
}

#planet-loading {
    position: absolute;
    width: 320px;
    height: 140px;
    display: none;
    z-index: 5;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

#planet-loading.active {
    display: flex;
}

.loading-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top-color: rgba(100, 200, 255, 0.8);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-ring:nth-child(2) {
    width: 70%;
    height: 70%;
    top: 15%;
    left: 15%;
    border-top-color: rgba(150, 100, 255, 0.8);
    animation: spin 1.5s linear infinite reverse;
}

.loading-ring:nth-child(3) {
    width: 40%;
    height: 40%;
    top: 30%;
    left: 30%;
    border-top-color: rgba(255, 150, 100, 0.8);
    animation: spin 2s linear infinite;
}

.loading-star {
    position: absolute;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(100, 200, 255, 0.8),
                0 0 20px rgba(100, 200, 255, 0.5);
    animation: pulse-star 1s ease-in-out infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse-star {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0.5;
    }
}

.loading-spinner-container {
    position: relative;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

#loading-message {
    margin-top: 15px;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    color: rgba(100, 200, 255, 0.9);
    text-align: center;
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(100, 200, 255, 0.5);
    animation: fade-in-message 0.5s ease-in;
    min-width: 280px;
    max-width: 320px;
    line-height: 1.5;
    padding: 0 10px;
}

@keyframes fade-in-message {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

#planet-name {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(14px, 2vmin, 18px);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.5s ease;
    text-shadow: 0 0 10px rgba(100, 200, 255, 0.6),
                 0 0 20px rgba(100, 200, 255, 0.4);
    margin: 0;
    padding: 0;
}

#planet-name.visible {
    opacity: 1;
}

#regenerate-planet {
    padding: 6px 16px;
    background: rgba(100, 150, 255, 0.3);
    border: 2px solid rgba(100, 200, 255, 0.6);
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.95);
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(9px, 1.1vmin, 11px);
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 20px rgba(100, 150, 255, 0.3);
    pointer-events: auto;
}

#regenerate-planet.visible {
    opacity: 1;
}

#regenerate-planet:hover {
    background: rgba(100, 150, 255, 0.5);
    border-color: rgba(100, 200, 255, 1);
    box-shadow: 0 0 30px rgba(100, 150, 255, 0.6);
    transform: translateY(-2px);
}

#regenerate-planet:active {
    transform: translateY(0px);
}

/* ========================================
   TITLE SECTION
   ======================================== */

#title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.5rem, 5.5vw, 3.5rem);
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 10px rgba(100, 200, 255, 0.8),
                 0 0 20px rgba(100, 200, 255, 0.6),
                 0 0 30px rgba(100, 200, 255, 0.4),
                 0 0 40px rgba(100, 200, 255, 0.3),
                 0 0 70px rgba(100, 200, 255, 0.2),
                 0 0 100px rgba(100, 200, 255, 0.1);
    letter-spacing: 0.2em;
    text-align: center;
    white-space: nowrap;
    padding: 0 2vw;
    margin: 0 0 2vh 0;
    opacity: 0;
    transition: opacity 1s ease-in;
    pointer-events: none;
    animation: float 6s ease-in-out infinite, glow-pulse 3s ease-in-out infinite;
}

#title.visible {
    opacity: 1;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes glow-pulse {
    0%, 100% {
        text-shadow: 0 0 10px rgba(100, 200, 255, 0.8),
                     0 0 20px rgba(100, 200, 255, 0.6),
                     0 0 30px rgba(100, 200, 255, 0.4),
                     0 0 40px rgba(100, 200, 255, 0.3),
                     0 0 70px rgba(100, 200, 255, 0.2),
                     0 0 100px rgba(100, 200, 255, 0.1);
    }
    50% {
        text-shadow: 0 0 15px rgba(100, 200, 255, 1),
                     0 0 30px rgba(100, 200, 255, 0.8),
                     0 0 45px rgba(100, 200, 255, 0.6),
                     0 0 60px rgba(100, 200, 255, 0.4),
                     0 0 90px rgba(100, 200, 255, 0.3),
                     0 0 120px rgba(100, 200, 255, 0.2);
    }
}

/* ========================================
   AUDIO SECTION
   ======================================== */

.audio-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1vh;
    margin-bottom: 2vh;
}

#sound-toggle {
    width: clamp(50px, 7vmin, 60px);
    height: clamp(50px, 7vmin, 60px);
    background: rgba(255, 100, 0, 0.2);
    border: 2px solid rgba(255, 150, 0, 0.6);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(255, 100, 0, 0.5),
                0 0 40px rgba(255, 100, 0, 0.3),
                inset 0 0 20px rgba(255, 150, 0, 0.2);
    animation: fireball-pulse 2s ease-in-out infinite;
    opacity: 0;
    pointer-events: none;
    position: relative;
}

#sound-toggle.visible {
    opacity: 1;
    pointer-events: auto;
}

@keyframes fireball-pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 100, 0, 0.5),
                    0 0 40px rgba(255, 100, 0, 0.3),
                    0 0 60px rgba(255, 50, 0, 0.2),
                    inset 0 0 20px rgba(255, 150, 0, 0.2);
        background: rgba(255, 100, 0, 0.2);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 100, 0, 0.8),
                    0 0 60px rgba(255, 100, 0, 0.5),
                    0 0 90px rgba(255, 50, 0, 0.3),
                    inset 0 0 30px rgba(255, 150, 0, 0.4);
        background: rgba(255, 100, 0, 0.4);
    }
}

#sound-toggle:hover {
    background: rgba(255, 100, 0, 0.4);
    border-color: rgba(255, 150, 0, 1);
    transform: scale(1.1);
    box-shadow: 0 0 40px rgba(255, 100, 0, 0.8),
                0 0 80px rgba(255, 100, 0, 0.5),
                0 0 120px rgba(255, 50, 0, 0.3),
                inset 0 0 30px rgba(255, 150, 0, 0.4);
}

#sound-toggle::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 100, 0, 0.3) 0%, transparent 70%);
    animation: fireball-rotate 3s linear infinite;
    z-index: -1;
}

@keyframes fireball-rotate {
    0% {
        transform: rotate(0deg) scale(1);
        opacity: 0.5;
    }
    50% {
        transform: rotate(180deg) scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: rotate(360deg) scale(1);
        opacity: 0.5;
    }
}

#sound-toggle svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    filter: drop-shadow(0 0 5px rgba(255, 150, 0, 0.8));
    display: block;
    pointer-events: none;
}

#sound-toggle svg path {
    fill: #fff;
}

#typing-text {
    color: rgba(100, 255, 100, 0.9);
    font-family: 'Courier New', monospace;
    font-size: clamp(12px, 1.4vmin, 14px);
    font-weight: 400;
    opacity: 0;
    pointer-events: none;
    text-align: center;
    max-width: 90%;
    text-shadow: 0 0 10px rgba(100, 255, 100, 0.5);
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

#typing-text.visible {
    opacity: 1;
}

#typing-text::after {
    content: '|';
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ========================================
   DASHBOARD SECTION - Fixed Height Structure
   ======================================== */

#galactic-dashboard {
    width: clamp(300px, 85vw, 600px);
    height: 200px;
    margin: 0;
    background: rgba(10, 20, 40, 0.85);
    border: 2px solid rgba(100, 150, 255, 0.4);
    border-radius: 12px;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: auto;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 30px rgba(100, 150, 255, 0.3),
                inset 0 0 20px rgba(100, 150, 255, 0.1);
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 14px;
}

#galactic-dashboard.visible {
    opacity: 1;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(100, 150, 255, 0.3);
}

.dashboard-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: rgba(100, 200, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.dashboard-lights {
    display: flex;
    gap: 8px;
}

.status-light {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse-light 2s ease-in-out infinite;
}

.status-light.red {
    background: #ff4444;
    box-shadow: 0 0 10px #ff4444;
    animation-delay: 0s;
}

.status-light.yellow {
    background: #ffaa00;
    box-shadow: 0 0 10px #ffaa00;
    animation-delay: 0.3s;
}

.status-light.green {
    background: #44ff44;
    box-shadow: 0 0 10px #44ff44;
    animation-delay: 0.6s;
}

.status-light.blue {
    background: #4444ff;
    box-shadow: 0 0 10px #4444ff;
    animation-delay: 0.9s;
}

@keyframes pulse-light {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

.dashboard-content {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: rgba(220, 235, 255, 0.95);
    text-shadow: 0 0 5px rgba(100, 200, 255, 0.3);
    font-weight: 500;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    align-self: start;
    max-height: 67.2px;
}

.dashboard-content::after {
    content: '▌';
    animation: blink 1s step-end infinite;
    color: rgba(100, 255, 100, 0.8);
}

.dashboard-source {
    padding-top: 10px;
    border-top: 1px solid rgba(100, 150, 255, 0.2);
    display: flex;
    align-items: center;
    height: 48px;
}

.dashboard-source a {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    transition: all 0.3s ease;
    font-weight: 600;
    display: inline-block;
    padding: 8px 16px;
    background: rgba(100, 150, 255, 0.3);
    border: 2px solid rgba(100, 200, 255, 0.6);
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(100, 150, 255, 0.3);
}

.dashboard-source a:hover {
    background: rgba(100, 150, 255, 0.5);
    border-color: rgba(100, 200, 255, 1);
    color: #fff;
    text-shadow: 0 0 10px rgba(100, 200, 255, 0.8);
    box-shadow: 0 0 25px rgba(100, 150, 255, 0.6);
    transform: translateY(-2px);
}

#easter-egg-counter {
    position: fixed;
    bottom: var(--bottom-nav-safe-area);
    left: 20px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    font-weight: 400;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

#easter-egg-counter.visible {
    opacity: 1;
}

#contact-link {
    position: fixed;
    bottom: var(--bottom-nav-safe-area);
    right: 20px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    font-weight: 400;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.5s ease, color 0.3s ease;
    pointer-events: auto;
    text-decoration: none;
}

#contact-link.visible {
    opacity: 1;
}

#contact-link:hover {
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.discovery-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(147, 112, 219, 0.9);
    color: #fff;
    padding: 20px 40px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 400;
    z-index: 30;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.discovery-notification.show {
    opacity: 1;
}

/* ========================================
   BOTTOM NAVIGATION
   ======================================== */

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding: 10px 14px max(10px, env(safe-area-inset-bottom));
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.bottom-nav__inner {
    pointer-events: auto;
    width: min(920px, calc(100vw - 28px));
    height: var(--bottom-nav-height);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
    border-radius: 18px;
    background: rgba(10, 20, 40, 0.82);
    border: 1px solid rgba(100, 150, 255, 0.35);
    backdrop-filter: blur(12px);
    box-shadow: 0 0 30px rgba(100, 150, 255, 0.22),
                inset 0 0 18px rgba(100, 150, 255, 0.08);
}

.bottom-nav__link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.85);
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: rgba(100, 150, 255, 0.12);
    border: 1px solid rgba(100, 200, 255, 0.22);
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
}

@media (max-width: 520px) {
    .bottom-nav__inner {
        gap: 6px;
        padding: 7px;
        border-radius: 16px;
    }

    .bottom-nav__link {
        font-size: 11px;
        letter-spacing: 0.5px;
    }
}

.bottom-nav__link:hover {
    transform: translateY(-1px);
    background: rgba(100, 150, 255, 0.22);
    border-color: rgba(100, 200, 255, 0.5);
    box-shadow: 0 0 18px rgba(100, 150, 255, 0.25);
}

.bottom-nav__link[aria-current="page"] {
    background: rgba(100, 150, 255, 0.35);
    border-color: rgba(100, 200, 255, 0.8);
    box-shadow: 0 0 22px rgba(100, 150, 255, 0.35);
    color: rgba(255, 255, 255, 0.95);
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    :root {
        --bottom-nav-height: 56px;
        --bottom-nav-safe-area: calc(var(--bottom-nav-height) + 16px);
    }

    #content-wrapper {
        padding: 1vh 0 var(--bottom-nav-safe-area);
    }
    
    .planet-section {
        gap: 1vh;
        margin-bottom: 2vh;
    }
    
    #planet-container {
        width: clamp(220px, 38vmin, 320px);
        height: clamp(220px, 38vmin, 320px);
    }
    
    #planet-name {
        font-size: clamp(12px, 2.2vmin, 16px);
        letter-spacing: 1.5px;
    }
    
    #regenerate-planet {
        font-size: clamp(8px, 1vmin, 10px);
        padding: 5px 12px;
    }
    
    #loading-message {
        font-size: 12px;
        min-width: 240px;
        max-width: 280px;
    }
    
    #title {
        font-size: clamp(1.2rem, 5vw, 2.8rem);
        margin: 0 0 1.5vh 0;
        white-space: normal;
        word-break: break-word;
    }
    
    .audio-section {
        gap: 1vh;
        margin-bottom: 1.5vh;
    }
    
    #sound-toggle {
        width: 50px;
        height: 50px;
    }
    
    #sound-toggle svg {
        width: 22px;
        height: 22px;
        display: block;
    }
    
    #sound-toggle svg path {
        fill: #fff;
    }
    
    #typing-text {
        font-size: 12px;
        white-space: normal;
        max-width: 85%;
    }
    
    #galactic-dashboard {
        width: 92vw;
        height: 180px;
        padding: 14px;
        gap: 12px;
    }
    
    .dashboard-header {
        padding-bottom: 8px;
    }
    
    .dashboard-title {
        font-size: 11px;
        letter-spacing: 1px;
    }
    
    .dashboard-content {
        font-size: 12px;
        line-height: 1.5;
        max-height: 54px;
    }
    
    .dashboard-source {
        padding-top: 8px;
        height: 42px;
    }
    
    .dashboard-source a {
        font-size: 10px;
        padding: 6px 12px;
    }
    
    #easter-egg-counter {
        font-size: 12px;
        top: 15px;
        bottom: auto;
        left: 15px;
    }
    
    #contact-link {
        font-size: 12px;
        top: 15px;
        bottom: auto;
        right: 15px;
    }
}
