:root {
    /* Cosmic color palette */
    --night-deep: #0a0e27;
    --night-mid: #1a1f3a;
    --star-glow: #e8f4f8;
    --star-active: #00e5ff;
    --connection: #4dd0e1;
    --text-primary: #e8f4f8;
    --text-secondary: #a5c9d4;
    --control-bg: rgba(26, 31, 58, 0.8);
    --control-border: rgba(232, 244, 248, 0.2);
}

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

body {
    font-family: 'Manrope', sans-serif;
    overflow: hidden;
    background: var(--night-deep);
    color: var(--text-primary);
    height: 100vh;
    width: 100vw;
    
    /* Prevent mobile behaviors */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.starbox-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ============================================
   SKY LAYER - Starry background
   ============================================ */

.sky-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        180deg,
        #0a0e27 0%,
        #1a1f3a 50%,
        #0d1425 100%
    );
    z-index: 1;
}

/* Twinkling stars background */
.stars {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(1px 1px at 20% 30%, white, transparent),
        radial-gradient(1px 1px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 50% 50%, white, transparent),
        radial-gradient(1px 1px at 80% 10%, white, transparent),
        radial-gradient(1px 1px at 33% 85%, white, transparent),
        radial-gradient(1px 1px at 15% 60%, white, transparent),
        radial-gradient(1px 1px at 45% 20%, white, transparent),
        radial-gradient(1px 1px at 70% 40%, white, transparent),
        radial-gradient(1px 1px at 25% 45%, white, transparent),
        radial-gradient(1px 1px at 85% 25%, white, transparent),
        radial-gradient(1px 1px at 95% 50%, white, transparent),
        radial-gradient(1px 1px at 5% 90%, white, transparent);
    background-size: 
        200% 200%, 200% 200%, 150% 150%, 180% 180%,
        190% 190%, 210% 210%, 160% 160%, 195% 195%,
        175% 175%, 205% 205%, 225% 225%, 240% 240%;
    background-position:
        0% 0%, 30% 40%, 60% 20%, 80% 70%,
        40% 80%, 70% 30%, 25% 60%, 55% 45%,
        15% 25%, 85% 65%, 90% 35%, 5% 90%;
    opacity: 0.4;
    animation: twinkle 20s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* ============================================
   RETURN BUTTON
   ============================================ */

.return-hint {
    position: fixed;
    top: 5vh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    cursor: pointer;
    user-select: none;
}

.return-hint p {
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    text-shadow: 0 0 15px rgba(165, 201, 212, 0.4);
    transition: all 0.3s ease;
}

.return-hint:hover p {
    color: var(--text-primary);
    text-shadow: 0 0 25px rgba(232, 244, 248, 0.7);
    transform: translateY(5px);
}

/* ============================================
   HEADER
   ============================================ */

.header {
    position: fixed;
    top: 12vh;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 10;
    user-select: none;
}

.header h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 400;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    color: var(--star-glow);
    text-shadow: 0 0 30px rgba(232, 244, 248, 0.6);
}

.subtitle {
    font-size: 1rem;
    font-weight: 300;
    color: var(--text-secondary);
    font-style: italic;
}

/* ============================================
   INSTRUCTIONS
   ============================================ */

.instructions {
    position: fixed;
    top: 25vh;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 10;
    opacity: 1;
    transition: opacity 0.5s ease;
    user-select: none;
    pointer-events: none;
}

.instructions.hidden {
    opacity: 0;
}

.instructions p {
    font-size: 0.95rem;
    font-weight: 300;
    color: var(--text-secondary);
    margin: 0.3rem 0;
    text-shadow: 0 0 10px rgba(165, 201, 212, 0.3);
}

.instructions .hint {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--connection);
    font-style: italic;
}

/* ============================================
   CANVAS
   ============================================ */

#starCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    cursor: crosshair;
}

/* ============================================
   CONTROLS
   ============================================ */

.controls {
    position: fixed;
    bottom: 5vh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1.5rem 2rem;
    background: var(--control-bg);
    border: 1px solid var(--control-border);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    border: 1px solid var(--control-border);
    border-radius: 12px;
    background: rgba(13, 27, 42, 0.6);
    color: var(--text-primary);
    font-family: 'Manrope', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: rgba(13, 27, 42, 0.9);
    box-shadow: 0 0 20px rgba(77, 208, 225, 0.3);
    transform: translateY(-2px);
}

.control-btn:active {
    transform: translateY(0);
}

.play-btn {
    background: linear-gradient(135deg, #4dd0e1 0%, #00b8d4 100%);
    color: #0a0e27;
    border-color: #4dd0e1;
}

.play-btn:hover {
    box-shadow: 0 0 25px rgba(77, 208, 225, 0.6);
}

.play-btn.playing {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
}

.btn-icon {
    font-size: 1.1rem;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.control-group label {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-secondary);
}

input[type="range"] {
    width: 120px;
    height: 4px;
    border-radius: 2px;
    background: rgba(77, 208, 225, 0.2);
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--connection);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(77, 208, 225, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--connection);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(77, 208, 225, 0.5);
    border: none;
}

select {
    padding: 0.5rem 1rem;
    background: rgba(13, 27, 42, 0.6);
    border: 1px solid var(--control-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Manrope', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--connection);
}

#tempoValue {
    font-size: 0.85rem;
    color: var(--connection);
    min-width: 60px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .controls {
        flex-wrap: wrap;
        padding: 1rem 1.5rem;
        gap: 0.8rem;
    }
    
    .control-btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .control-group {
        flex: 1 1 auto;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .instructions {
        top: 22vh;
    }
    
    .instructions p {
        font-size: 0.85rem;
    }
    
    .controls {
        bottom: 2vh;
        width: 95%;
        padding: 1rem;
    }
    
    input[type="range"] {
        width: 80px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .stars,
    .control-btn {
        animation: none;
        transition: none;
    }
}
