@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600&display=swap');

:root {
    /* Default Colors (Day) */
    --bg-color: #42A5F5; 
    --clock-face: #FFFFFF;
    --primary: #FF7043;  
    --secondary: #1565C0; 
    --accent: #66BB6A;    
    --text: #37474F;
    --panel-bg: #fff;
    --heading-color: #fff;
    --hint-color: rgba(255,255,255,0.8);
}

/* --- Day/Night Cycle States --- */
body.day { --bg-color: #42A5F5; --secondary: #1565C0; }
body.sunrise { --bg-color: #FFCC80; --secondary: #EF6C00; --text: #5D4037; }
body.sunset { --bg-color: #FF7043; --secondary: #BF360C; --text: #3E2723; }
body.night { --bg-color: #1A237E; --clock-face: #E8EAF6; --secondary: #304FFE; --text: #263238; --heading-color: #B39DDB; }

body {
    font-family: 'Fredoka', sans-serif;
    background-color: var(--bg-color);
    color: var(--text);
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow: hidden; 
    user-select: none;
    transition: background-color 1.5s ease, color 1.5s ease;
}

h1 {
    color: var(--heading-color);
    font-size: 2.5rem;
    margin: 20px 0 10px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    transition: color 1.5s ease;
    z-index: 10;
}

/* --- THE SKY LAYER --- */
.sky-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; 
    z-index: 0;
    overflow: hidden;
}

.sky-object {
    position: absolute;
    opacity: 0; 
    transition: opacity 1.5s ease;
    will-change: transform; 
}

/* Clouds */
.cloud { font-size: 5rem; }
.c1 { top: 15%; }
.c2 { top: 35%; scale: 0.8; }
.c3 { top: 5%; scale: 1.2; }
.c4 { top: 25%; scale: 0.9; }
.c5 { top: 10%; scale: 1.1; }

body.day .c1, body.sunrise .c1 { opacity: 0.6; }
body.day .c2, body.sunrise .c2 { opacity: 0.4; }
body.day .c3, body.sunrise .c3 { opacity: 0.7; }
body.day .c4, body.sunrise .c4 { opacity: 0.5; }
body.day .c5, body.sunrise .c5 { opacity: 0.3; }

/* Plane */
body.day .plane { opacity: 1; }
.plane { font-size: 3rem; top: 20%; }

/* Stars */
.stars {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 3px),
        radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 2px),
        radial-gradient(white, rgba(255,255,255,.1) 2px, transparent 3px);
    background-size: 550px 550px, 350px 350px, 250px 250px;
    background-position: 0 0, 40px 60px, 130px 270px;
    opacity: 0;
    transition: opacity 1.5s ease;
}

body.night .stars { 
    opacity: 1; 
    animation: starPulse 3s ease-in-out infinite alternate;
}
@keyframes starPulse {
    0% { opacity: 0.4; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1.02); filter: drop-shadow(0 0 5px white); }
}

/* Satellite & Shooting Stars */
body.night .satellite { opacity: 0.8; }
.satellite { font-size: 2.5rem; top: 10%; }
.shooting-star { font-size: 2rem; top: 10%; }

/* --- BUTTONS & CONTROLS --- */
.info-panel {
    background: var(--panel-bg);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    min-width: 300px;
    text-align: center;
    z-index: 10;
}

.controls-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.control-btn {
    background: #ECEFF1;
    border: none;
    padding: 10px 15px;
    border-radius: 12px;
    color: #546E7A;
    cursor: pointer;
    font-weight: 600;
    font-family: 'Fredoka', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}
.control-btn:hover { background: #CFD8DC; color: #37474F; transform: translateY(-2px); }

.eye-icon { stroke: currentColor; fill: none; }

/* Styles for "Now" Button when active */
.now-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 10px rgba(102, 187, 106, 0.4);
    animation: pulseBtn 2s infinite;
}

@keyframes pulseBtn {
    0% { box-shadow: 0 0 0 0 rgba(102, 187, 106, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(102, 187, 106, 0); }
    100% { box-shadow: 0 0 0 0 rgba(102, 187, 106, 0); }
}

/* --- CLOCK & OTHERS --- */
.container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 70px; 
    width: 100%;
    max-width: 1000px;
    padding: 20px;
    position: relative;
    z-index: 5;
}

.clock-wrapper-outer {
    position: relative;
    width: 450px; 
    height: 450px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.orbit-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    z-index: 0; 
}
.moon-orbit-offset { transform: rotate(180deg); }
.celestial-body {
    position: absolute;
    top: -230px; 
    left: -35px; 
    font-size: 4rem;
    transform: rotate(0deg); 
    filter: drop-shadow(0 0 10px rgba(255,255,0,0.5));
}
.moon { font-size: 3.5rem; filter: drop-shadow(0 0 10px rgba(255,255,255,0.5)); }

.clock-container { position: relative; z-index: 5; }
.clock {
    width: 350px;
    height: 350px;
    background: var(--clock-face);
    border-radius: 50%;
    border: 15px solid var(--secondary);
    position: relative;
    box-shadow: 0 20px 30px rgba(0,0,0,0.2);
    transition: transform 0.1s, border-color 1.5s ease, background-color 1.5s ease; 
}

.number {
    position: absolute;
    width: 100%;
    height: 100%;
    text-align: center;
    font-size: 2rem;
    font-weight: 600;
    color: var(--secondary);
    padding: 10px;
    box-sizing: border-box;
    transition: color 1.5s ease;
}

/* Rotate numbers */
.num1 { transform: rotate(30deg); } .num1 span { display: inline-block; transform: rotate(-30deg); }
.num2 { transform: rotate(60deg); } .num2 span { display: inline-block; transform: rotate(-60deg); }
.num3 { transform: rotate(90deg); } .num3 span { display: inline-block; transform: rotate(-90deg); }
.num4 { transform: rotate(120deg); } .num4 span { display: inline-block; transform: rotate(-120deg); }
.num5 { transform: rotate(150deg); } .num5 span { display: inline-block; transform: rotate(-150deg); }
.num6 { transform: rotate(180deg); } .num6 span { display: inline-block; transform: rotate(-180deg); }
.num7 { transform: rotate(210deg); } .num7 span { display: inline-block; transform: rotate(-210deg); }
.num8 { transform: rotate(240deg); } .num8 span { display: inline-block; transform: rotate(-240deg); }
.num9 { transform: rotate(270deg); } .num9 span { display: inline-block; transform: rotate(-270deg); }
.num10 { transform: rotate(300deg); } .num10 span { display: inline-block; transform: rotate(-300deg); }
.num11 { transform: rotate(330deg); } .num11 span { display: inline-block; transform: rotate(-330deg); }
.num12 { transform: rotate(0deg); } .num12 span { display: inline-block; transform: rotate(0deg); }

.hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    border-radius: 10px;
    z-index: 10;
    transition: transform 0.1s cubic-bezier(0.4, 2.08, 0.55, 0.44);
}
.hour-hand { width: 10px; height: 90px; background: var(--text); transition: background 1.5s ease, transform 0.1s;}
.minute-hand { width: 6px; height: 130px; background: var(--primary); }
.second-hand { width: 3px; height: 140px; background: var(--accent); z-index: 11; transition: none; }
.center-dot { width: 20px; height: 20px; background: var(--text); border-radius: 50%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 12; transition: background 1.5s ease;}

.digital-clock {
    background: #FFF3E0;
    padding: 10px 20px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 5px;
    border: 3px dashed var(--primary);
    transition: filter 0.3s ease;
}

.digital-clock.blur-mode input,
.digital-clock.blur-mode .colon,
.digital-clock.blur-mode .period {
    filter: blur(12px);
    pointer-events: none;
}

.time-input {
    font-family: 'Fredoka', sans-serif;
    font-size: 3.5rem;
    font-weight: 600;
    color: var(--primary);
    background: transparent;
    border: none;
    width: 90px;
    text-align: center;
    border-radius: 10px;
    cursor: pointer;
}
.time-input::-webkit-outer-spin-button, .time-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0;}
.time-input:hover { background-color: rgba(255, 112, 67, 0.1); }
.time-input:focus { background-color: #fff; outline: 2px solid var(--primary); }

.colon { font-size: 3rem; color: var(--primary); margin: 0 -5px 10px -5px; }

.period {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.5rem;
    color: var(--text);
    margin-left: 10px;
    cursor: pointer;
    background: none;
    border: 2px solid transparent;
    padding: 5px;
    border-radius: 5px;
}
.period:hover { background: #ECEFF1; border-color: #CFD8DC;}

.edit-hint { font-size: 0.8rem; color: #90A4AE; margin-bottom: 20px;}

.bar-container { margin: 15px 0; text-align: left; }
.label { font-size: 1rem; margin-bottom: 5px; display: flex; justify-content: space-between; }
.progress-track { background: #ECEFF1; height: 20px; border-radius: 10px; overflow: hidden; border: 1px solid #CFD8DC; }
.progress-fill { height: 100%; width: 0%; transition: width 0.1s linear; }
.seconds-fill { background: var(--accent); }
.minutes-fill { background: var(--primary); }

.explanation {
    margin-top: 20px;
    font-size: 1.2rem;
    background: #E8F5E9;
    color: #2E7D32;
    padding: 15px;
    border-radius: 10px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--accent);
}

.controls-hint {
    position: absolute;
    bottom: 20px;
    color: var(--hint-color);
    font-size: 0.9rem;
    animation: bounce 2s infinite;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    z-index: 10;
}

@media (max-width: 900px) {
    .container { flex-direction: column; gap: 50px; margin-top: 50px;}
    .clock-wrapper-outer { width: 300px; height: 300px; }
    .clock { width: 250px; height: 250px; }
    .celestial-body { top: -180px; font-size: 3rem; left: -25px;}
}