:root {
    --bg-color: #020617;
    --card-bg: rgba(15, 23, 42, 0.6);
    --primary: #6366f1;
    --accent: #a5b4fc;
    --text: #e2e8f0;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.lang-btn, .home-btn {
    position: absolute;
    top: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 20px;
    transition: 0.3s;
    user-select: none;
    z-index: 1000;
    text-decoration: none;
}
.lang-btn { right: 20px; }
.home-btn { left: 20px; }
.lang-btn:hover, .home-btn:hover { background: rgba(255, 255, 255, 0.2); transform: scale(1.1); }

.home-btn {
    position: absolute; top: 20px; left: 20px;
    font-size: 1.5rem; text-decoration: none;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px; border-radius: 20px;
    z-index: 1000; transition: 0.3s;
}
.home-btn:hover { background: rgba(255, 255, 255, 0.2); transform: scale(1.1); }

.stars, .twinkling {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%; display: block;
}

.stars {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #020617;
    z-index: 0;
    
    background-image: 
        radial-gradient(1px 1px at 20px 30px, #eee, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 40px 70px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 50px 160px, #ddd, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 90px 40px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 130px 80px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 160px 120px, #ddd, rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: stars-move 100s linear infinite;
}

.twinkling {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1;
    background: transparent;
    
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.1), transparent 60%),
        radial-gradient(circle at 20% 80%, rgba(139, 92, 246, 0.1), transparent 50%);
    
    animation: twinkle-pulse 10s ease-in-out infinite alternate;
}

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

@keyframes twinkle-pulse {
    0% { opacity: 0.5; transform: scale(1); }
    100% { opacity: 0.8; transform: scale(1.05); }
}

.container {
    position: relative; 
    z-index: 10;
}
@keyframes move-twink-back {
    from {background-position:0 0;}
    to {background-position:-10000px 5000px;}
}

.container {
    position: relative; z-index: 10;
    width: 100%; max-width: 400px; padding: 20px;
    transition: opacity 1s ease;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    padding: 40px 30px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    text-align: center;
}

h1 { font-weight: 700; letter-spacing: 2px; margin-bottom: 5px; color: white; }
.subtitle { color: var(--accent); font-size: 0.9rem; margin-bottom: 30px; }

.time-control {
    display: flex; align-items: center; justify-content: center; gap: 20px;
    margin-bottom: 30px;
}

.time-display {
    font-size: 2.5rem;
    font-weight: 700;
    min-width: 140px; 
    font-variant-numeric: tabular-nums;
    
    white-space: nowrap;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 5px;
}

@media (max-width: 400px) {
    .time-display {
        font-size: 1.8rem;
    }
    .unit {
        font-size: 0.8rem;
    }
}
.unit { font-size: 1rem; color: var(--accent); margin-left: 5px; font-weight: 300; }

.adjust-btn {
    background: rgba(255,255,255,0.1); border: none; color: white;
    width: 50px; height: 50px; border-radius: 50%; font-size: 1.5rem;
    cursor: pointer; transition: 0.2s;
}
.adjust-btn:hover { background: var(--primary); transform: scale(1.1); }

.visualizer {
    height: 120px; display: flex; justify-content: center; align-items: center; margin-bottom: 20px;
}
.sleep-circle {
    width: 80px; height: 80px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    box-shadow: 0 0 30px var(--primary);
    opacity: 0.8;
    transform: scale(1);
    transition: transform 4s ease-in-out, opacity 4s ease-in-out;
}
.breathing {
    animation: breathe 8s infinite ease-in-out;
}

@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 0.6; box-shadow: 0 0 30px var(--primary); }
    50% { transform: scale(1.5); opacity: 0.9; box-shadow: 0 0 60px var(--accent); }
}

#status-text { color: var(--text); margin-bottom: 25px; min-height: 1.2em; }

.glow-btn {
    width: 100%; padding: 18px; border: none; border-radius: 15px;
    background: white; color: var(--bg-color);
    font-size: 1.1rem; font-weight: 700; cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    transition: 0.3s; letter-spacing: 1px;
}
.glow-btn:hover { background: #e0e7ff; box-shadow: 0 0 30px rgba(255, 255, 255, 0.5); }
.stop-mode { background: #ef4444; color: white; box-shadow: 0 0 20px rgba(239, 68, 68, 0.4); }
.stop-mode:hover { background: #dc2626; }

#blackout {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: black; z-index: 9999;
    opacity: 0; transition: opacity 2s ease; pointer-events: none;
}
#blackout.active { opacity: 1; pointer-events: all; cursor: none; }
.hidden { display: none; }