/* ============================================
   Drift — Sleep Preparation
   Night sky, gentle descent, progressive dimming
   ============================================ */

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

:root {
    --sky-top: #0d1b2a;
    --sky-mid: #1b263b;
    --sky-bottom: #415a77;
    --moon-color: #ffecd2;
    --moon-glow: rgba(255, 236, 210, 0.3);
    --star-color: rgba(255, 255, 255, 0.8);
    --text-primary: #e8e8ed;
    --text-secondary: #8a8a9a;
    --text-muted: #5a5a6a;
    --accent: #b794f6;
    --accent-dim: rgba(183, 148, 246, 0.15);
    --accent-glow: rgba(183, 148, 246, 0.3);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 50%;
    --transition: 0.5s ease;
    --transition-slow: 2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--sky-top);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

.game-container {
    width: 100%;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* Sky Background */
.sky-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, 
        var(--sky-top) 0%, 
        var(--sky-mid) 50%, 
        var(--sky-bottom) 100%);
    transition: filter 10s ease, opacity 10s ease;
}

/* Stars */
.stars {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--star-color);
    border-radius: 50%;
    animation: twinkle var(--twinkle-duration, 3s) ease-in-out infinite;
    animation-delay: var(--twinkle-delay, 0s);
}

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

/* Moon */
.moon {
    position: absolute;
    top: 15%;
    right: 20%;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle at 30% 30%, 
        var(--moon-color) 0%, 
        #e0c3a8 70%, 
        #c9a882 100%);
    border-radius: 50%;
    box-shadow: 
        0 0 40px var(--moon-glow),
        0 0 80px var(--moon-glow),
        inset -10px -10px 20px rgba(0, 0, 0, 0.1);
    transition: transform 20s ease, opacity 10s ease;
}

/* Clouds */
.clouds {
    position: absolute;
    bottom: 20%;
    left: 0;
    right: 0;
    height: 200px;
    pointer-events: none;
}

.cloud {
    position: absolute;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 100px;
    filter: blur(20px);
}

.cloud.c1 {
    width: 300px;
    height: 60px;
    bottom: 40%;
    left: -50px;
    animation: float 60s ease-in-out infinite;
}

.cloud.c2 {
    width: 200px;
    height: 40px;
    bottom: 60%;
    right: 10%;
    animation: float 45s ease-in-out infinite reverse;
}

.cloud.c3 {
    width: 250px;
    height: 50px;
    bottom: 20%;
    left: 30%;
    animation: float 55s ease-in-out infinite;
    animation-delay: -20s;
}

@keyframes float {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(30px); }
}

/* Horizon */
.horizon {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30%;
    background: linear-gradient(180deg, 
        transparent 0%, 
        rgba(13, 27, 42, 0.5) 50%,
        rgba(13, 27, 42, 0.9) 100%);
}

/* Dimming Overlay */
.dim-overlay {
    position: absolute;
    inset: 0;
    background: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 5s ease;
    z-index: 5;
}

/* Navigation */
.game-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    transition: opacity 5s ease;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.7;
    transition: opacity var(--transition);
}

.back-link:hover {
    opacity: 1;
}

.progress-indicator {
    width: 100px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
    opacity: 0;
    transition: opacity var(--transition);
}

.progress-indicator.visible {
    opacity: 1;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: var(--radius-full);
    transition: width 1s linear;
}

/* Screens */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 2s ease, visibility 2s ease;
    z-index: 10;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* Title Screen */
.title-content {
    text-align: center;
    padding: 20px;
    max-width: 400px;
}

.moon-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: gentle-float 6s ease-in-out infinite;
}

@keyframes gentle-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.title {
    font-size: 4rem;
    font-weight: 200;
    letter-spacing: 0.2em;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.3em;
    margin-bottom: 20px;
    font-weight: 300;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 40px;
    font-weight: 300;
}

/* Duration Select */
.duration-select {
    margin-bottom: 30px;
}

.select-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.duration-options {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.duration-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 15px 25px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.duration-btn:hover {
    border-color: var(--accent);
}

.duration-btn.selected {
    background: var(--accent-dim);
    border-color: var(--accent);
}

.duration-time {
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--text-primary);
}

.duration-unit {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Start Button */
.start-btn {
    background: linear-gradient(135deg, var(--accent) 0%, #9b7ed9 100%);
    color: #0d1b2a;
    border: none;
    padding: 18px 50px;
    border-radius: var(--radius-full);
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 30px;
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 40px var(--accent-glow);
}

/* Options */
.options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.option-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    justify-content: center;
}

.option-toggle input {
    display: none;
}

.toggle-switch {
    width: 40px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    position: relative;
    transition: background var(--transition);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--text-secondary);
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: all var(--transition);
}

.option-toggle input:checked + .toggle-switch {
    background: var(--accent-dim);
}

.option-toggle input:checked + .toggle-switch::after {
    background: var(--accent);
    transform: translateX(18px);
}

.tip {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Journey Screen */
.journey-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    gap: 60px;
}

/* Breath Guide */
.breath-guide {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.breath-orb {
    position: relative;
    width: 150px;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orb-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    animation: pulse-glow 8s ease-in-out infinite;
}

.orb-core {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, 
        var(--accent) 0%, 
        #8b6fc6 50%, 
        #6b4f9e 100%);
    box-shadow: 0 0 40px var(--accent-glow);
    transition: transform 4s ease-in-out, opacity 1s ease;
}

.orb-core.inhale {
    transform: scale(1.5);
}

.orb-core.hold {
    transform: scale(1.5);
    opacity: 0.9;
}

.orb-core.exhale {
    transform: scale(0.8);
    opacity: 0.7;
}

@keyframes pulse-glow {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

.breath-instruction {
    font-size: 1.5rem;
    font-weight: 200;
    letter-spacing: 0.2em;
    color: var(--text-primary);
    text-transform: uppercase;
    opacity: 0.9;
    transition: opacity var(--transition);
}

/* Phase Message */
.phase-message {
    text-align: center;
    max-width: 400px;
    transition: opacity 2s ease;
}

.phase-title {
    font-size: 1.8rem;
    font-weight: 200;
    letter-spacing: 0.1em;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.phase-text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.8;
    font-weight: 300;
}

/* Ambient Text */
.ambient-text {
    position: fixed;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 200;
    letter-spacing: 0.1em;
    opacity: 0;
    transition: opacity 3s ease;
    text-align: center;
    max-width: 300px;
}

.ambient-text.visible {
    opacity: 0.6;
}

/* Sleep Screen */
.sleep-content {
    text-align: center;
}

.sleep-text {
    font-size: 2rem;
    font-weight: 200;
    letter-spacing: 0.3em;
    color: var(--text-secondary);
    opacity: 0.5;
    animation: fade-text 10s ease-in-out infinite;
}

@keyframes fade-text {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* Progressive Dimming States */
.game-container.phase-1 .sky-bg { filter: brightness(0.9); }
.game-container.phase-2 .sky-bg { filter: brightness(0.7); }
.game-container.phase-3 .sky-bg { filter: brightness(0.5); }
.game-container.phase-4 .sky-bg { filter: brightness(0.3); }
.game-container.phase-5 .sky-bg { filter: brightness(0.15); }
.game-container.phase-final .sky-bg { filter: brightness(0.05); }

.game-container.phase-1 .dim-overlay { opacity: 0; }
.game-container.phase-2 .dim-overlay { opacity: 0.1; }
.game-container.phase-3 .dim-overlay { opacity: 0.2; }
.game-container.phase-4 .dim-overlay { opacity: 0.4; }
.game-container.phase-5 .dim-overlay { opacity: 0.6; }
.game-container.phase-final .dim-overlay { opacity: 0.85; }

.game-container.phase-final .game-nav { opacity: 0; }
.game-container.phase-final .breath-guide { opacity: 0.3; }
.game-container.phase-final .phase-message { opacity: 0.4; }

/* Responsive */
@media (max-width: 600px) {
    .title {
        font-size: 3rem;
    }
    
    .duration-options {
        flex-direction: column;
        width: 100%;
    }
    
    .duration-btn {
        flex-direction: row;
        justify-content: center;
        gap: 8px;
    }
    
    .breath-orb {
        width: 120px;
        height: 120px;
    }
    
    .orb-core {
        width: 60px;
        height: 60px;
    }
    
    .phase-title {
        font-size: 1.4rem;
    }
}

/* Hide cursor after inactivity */
.game-container.hide-cursor {
    cursor: none;
}

.game-container.hide-cursor * {
    cursor: none;
}



