
:root {
    --day-bg: linear-gradient(to top, #89bde2 0%, #aadaf1 100%);
    --night-bg: linear-gradient(to top, #09203f 0%, #2a4a6b 100%);
    --text-color-day: #2c3e50;
    --text-color-night: #ecf0f1;
    --sun-color: #f1c40f;
    --moon-color: #fdfce8; /* Added yellow tint */
    --moon-glow: #f9e79f;
    --day-h3-color: #4a69bd; /* Distinct color for day mode fortune titles */
    --day-ground-grass-main: #7CFC00;
    --day-ground-grass-light: #90EE90;
    --day-ground-soil-light: #A0522D;
    --day-ground-soil-dark: #654321;
    --night-ground-grass-main: #006400;
    --night-ground-grass-dark: #228B22;
    --night-ground-soil-light: #6F4E37;
    --night-ground-soil-dark: #4A2A1A;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    transition: background 0.8s ease, color 0.8s ease;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.day-mode { background: var(--day-bg); color: var(--text-color-day); }
.night-mode { background: var(--night-bg); color: var(--text-color-night); }

.container {
    text-align: center;
    position: relative;
    z-index: 10;
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-bottom: 160px; /* Space for ground and banner */
}

header h1 {
    font-size: 3rem;
    margin-bottom: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    transition: opacity 0.5s ease;
}

header .subtitle {
    font-size: 1.2rem;
    margin-top: 10px;
    opacity: 0.8;
    transition: opacity 0.5s ease;
}

/* --- Theme Toggle Button (Sun/Moon) --- */
#theme-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.5s ease-in-out;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: #333;
    overflow: hidden;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

#theme-toggle.sun {
    background-color: var(--sun-color);
    box-shadow: 0 0 15px var(--sun-color);
    background-image: linear-gradient(to bottom right, #ffeb3b, #fbc02d);
}
#theme-toggle.sun::before {
    content: '';
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    border: 3px solid var(--sun-color);
    border-radius: 50%;
    animation: rotate 6s linear infinite;
    opacity: 0.6;
}

#theme-toggle.moon {
    background-color: var(--moon-color);
    background-image: linear-gradient(to bottom right, #fdfce8, #e0e0e0);
    animation: moon-glow 2s infinite alternate;
}

#theme-toggle .mode-text-large {
    font-size: 1.5rem;
    line-height: 1;
}

#theme-toggle .mode-text-small {
    font-size: 0.8rem;
    line-height: 1;
    opacity: 0.8;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes moon-glow {
    0% {
        box-shadow: 0 0 15px 7px var(--moon-glow);
    }
    100% {
        box-shadow: 0 0 30px 15px var(--moon-glow);
    }
}

/* Responsive size for PC */
@media (min-width: 769px) {
    #theme-toggle {
        width: 80px;
        height: 80px;
    }
    #theme-toggle.sun::before {
        top: -10px;
        left: -10px;
        right: -10px;
        bottom: -10px;
        border-width: 4px;
    }
    #theme-toggle .mode-text-large { font-size: 1.8rem; }
    #theme-toggle .mode-text-small { font-size: 1rem; }
}

/* --- Sky Elements (Stars & Clouds container) --- */
.sky-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none; /* Allow interaction with elements behind */
}

#stars, #stars2, #stars3, #stars-dim, .clouds {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%; display: block;
    pointer-events: none;
}

#stars, #stars2, #stars3, #stars-dim, .big-dipper {
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
}
.night-mode #stars, .night-mode #stars2, .night-mode #stars3, .night-mode #stars-dim, .night-mode .big-dipper {
    opacity: 1;
}

/* Using multiple box-shadows to create a starfield. */
#stars { box-shadow: 5vw 85vh #FFF, 9vw 28vh #FFF, 88vw 3vh #FFF, 42vw 85vh #FFF; animation: twinkle 7s infinite; }
#stars2 { box-shadow: 3vw 97vh #FFF, 8vw 9vh #FFF, 78vw 38vh #FFF, 9vw 81vh #FFF; animation: twinkle 5s infinite; }
#stars3 { box-shadow: 93vw 17vh #FFF, 18vw 29vh #FFF, 28vw 88vh #FFF, 19vw 91vh #FFF; animation: twinkle 3s infinite; }
#stars-dim { /* Dim, non-twinkling stars - made more visible */
    box-shadow: 40vw 50vh #999, 60vw 70vh #888, 80vw 90vh #777, 20vw 30vh #aaa,
                15vw 55vh #777, 85vw 10vh #666, 70vw 45vh #555, 30vw 90vh #888,
                25vw 20vh #999, 75vw 80vh #888, 50vw 15vh #777, 10vw 60vh #aaa;
    opacity: 0.8; /* Increased opacity to be more visible */
    filter: brightness(0.7); /* Slightly duller */
}

@keyframes twinkle { 0% { opacity: 0; } 50% { opacity: 0.7; } 100% { opacity: 0; } }

/* Big Dipper - Centered */
.big-dipper {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%) rotate(20deg); /* Centered horizontally */
    width: 250px;
    height: 150px;
}
.big-dipper div { position: absolute; background: white; border-radius: 50%; animation: twinkle-constellation 1.5s infinite alternate; }
.big-dipper .star1 { width: 8px; height: 8px; top: 0; left: 0; }
.big-dipper .star2 { width: 8px; height: 8px; top: 30px; left: 50px; }
.big-dipper .star3 { width: 8px; height: 8px; top: 45px; left: 110px; }
.big-dipper .star4 { width: 8px; height: 8px; top: 40px; left: 160px; }
.big-dipper .star5 { width: 8px; height: 8px; top: 70px; left: 200px; }
.big-dipper .star6 { width: 8px; height: 8px; top: 130px; left: 240px; }
.big-dipper .star7 { width: 8px; height: 8px; top: 145px; left: 190px; }

@keyframes twinkle-constellation {
    0% { transform: scale(1); box-shadow: 0 0 12px 4px rgba(255, 255, 255, 0.8); }
    100% { transform: scale(1.3); box-shadow: 0 0 18px 8px rgba(255, 255, 255, 1); }
}

/* Clouds - Centered and adjusted position */
.clouds { opacity: 0; transition: opacity 1.5s ease-in-out; }
.day-mode .clouds { opacity: 1; }
.cloud { position: absolute; background: white; border-radius: 50%; opacity: 0.8; }
.cloud1 { width: 220px; height: 70px; top: 15%; left: 50%; transform: translateX(-60%); animation: move-clouds 30s linear infinite alternate; } /* Centered and adjusted top */
.cloud2 { width: 170px; height: 50px; top: 12%; left: 50%; transform: translateX(-40%); animation: move-clouds 25s linear infinite alternate; } /* Centered and adjusted top */
.cloud::before, .cloud::after { content: ''; position: absolute; background: white; border-radius: 50%; }
.cloud1::before { width: 110px; height: 110px; top: -55px; left: 35px; }
.cloud1::after { width: 130px; height: 90px; top: -35px; right: 25px; }
.cloud2::before { width: 90px; height: 90px; top: -45px; left: 25px; }
.cloud2::after { width: 100px; height: 70px; top: -30px; right: 20px; }

@keyframes move-clouds {
    from { transform: translateX(calc(-50% - 40px)); } /* Wider movement, relative to center */
    to { transform: translateX(calc(-50% + 40px)); }
}
.cloud1 { animation: move-clouds-left 30s linear infinite alternate; }
.cloud2 { animation: move-clouds-right 25s linear infinite alternate; }

@keyframes move-clouds-left {
    from { transform: translateX(calc(-60% - 40px)); }
    to { transform: translateX(calc(-60% + 40px)); }
}

@keyframes move-clouds-right {
    from { transform: translateX(calc(-40% - 40px)); }
    to { transform: translateX(calc(-40% + 40px)); }
}

/* --- Info Bar --- */
#info-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.night-mode #info-bar {
    background: rgba(0, 0, 0, 0.2);
}

.info-item-small {
    font-size: 0.75rem;
    opacity: 0.7;
}
#weather-location-select {
    cursor: pointer;
    text-decoration: underline;
}

/* --- Form and Fortune Sections --- */
#user-input-section, #fortune-results { transition: opacity 0.5s ease; width: 100%; max-width: 600px; }
.container:hover header, .container:hover #user-input-section, .container:hover #fortune-results { opacity: 1; }
#fortune-form { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 15px; }
.input-group { display: flex; flex-direction: column; align-items: flex-start; }
.input-group label { font-size: 0.9rem; margin-bottom: 5px; opacity: 0.9; }
.input-group-checkbox { display: flex; align-items: center; justify-content: center; gap: 5px; align-self: flex-end; }
#fortune-form input[type="checkbox"] { margin-bottom: 0; }
#fortune-form input, #fortune-form select { padding: 8px 12px; border-radius: 5px; border: 1px solid rgba(0,0,0,0.2); background: rgba(255,255,255,0.7); color: #333; }
.night-mode #fortune-form input, .night-mode #fortune-form select { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.3); color: #FFF; }
#get-fortune-btn { padding: 10px 20px; border: none; border-radius: 20px; background: var(--sun-color); color: #333; font-weight: bold; cursor: pointer; transition: transform 0.2s ease; align-self: flex-end; }
.night-mode #get-fortune-btn { background: var(--moon-color); }
#get-fortune-btn:hover { transform: scale(1.05); }
#fortune-results { margin-top: 2rem; width: 80%; max-width: 600px; } /* Increased margin-top to prevent overlap */
.fortune-content { display: none; background: rgba(255, 255, 255, 0.2); padding: 20px; border-radius: 10px; backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.night-mode .fortune-content { background: rgba(0, 0, 0, 0.2); }
.day-mode .day-content { display: block; }
.night-mode .night-content { display: block; }
.fortune-content h3 { color: var(--day-h3-color); margin-top: 0; }
.night-mode .fortune-content h3 { color: var(--moon-color); }

/* --- Ground Element --- */
.ground {
    width: 100%;
    height: 150px;
    position: absolute; /* Changed to absolute to sit at bottom */
    bottom: 0; /* Position at the very bottom */
    left: 0;
    z-index: 10;
    transition: background 0.8s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    text-align: center;
    padding-bottom: 10px;
    box-sizing: border-box;
    overflow: hidden; /* Hide overflow from repeating elements */
}

.day-mode .ground {
    background-color: var(--day-ground-soil-light); /* Base soil color */
    background-image: 
        /* Grass Tufts - varied sizes and positions */
        radial-gradient(circle at 10% 80%, rgba(124, 252, 0, 0.5) 10%, transparent 10%),
        radial-gradient(circle at 40% 70%, rgba(124, 252, 0, 0.7) 12%, transparent 12%),
        radial-gradient(circle at 75% 90%, rgba(124, 252, 0, 0.4) 8%, transparent 8%),
        /* Repeating grass lines / texture */
        repeating-linear-gradient(120deg, var(--day-ground-grass-main) 0px, var(--day-ground-grass-main) 1px, transparent 1px, transparent 5px),
        repeating-linear-gradient(60deg, var(--day-ground-grass-main) 0px, var(--day-ground-grass-main) 1px, transparent 1px, transparent 5px),
        /* Soil Texture - subtle darker spots */
        radial-gradient(ellipse at 50% 100%, rgba(101, 67, 33, 0.3) 0%, transparent 70%),
        linear-gradient(to bottom, var(--day-ground-soil-dark), var(--day-ground-soil-light));
    background-size: 60px 60px, 80px 80px, 70px 70px, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
    background-position: 0 0, 20px 0, 40px 0, 0 0, 0 0, 0 0, 0 0, 0 0;
}

.night-mode .ground {
    background-color: var(--night-ground-soil-dark); /* Base dark soil color */
    background-image: 
        /* Darker Grass Tufts */
        radial-gradient(circle at 15% 75%, rgba(34, 139, 34, 0.4) 10%, transparent 10%),
        radial-gradient(circle at 60% 85%, rgba(34, 139, 34, 0.6) 12%, transparent 12%),
        radial-gradient(circle at 85% 95%, rgba(34, 139, 34, 0.3) 8%, transparent 8%),
        /* Repeating dark grass lines / texture */
        repeating-linear-gradient(120deg, var(--night-ground-grass-main) 0px, var(--night-ground-grass-main) 1px, transparent 1px, transparent 5px),
        repeating-linear-gradient(60deg, var(--night-ground-grass-main) 0px, var(--night-ground-grass-main) 1px, transparent 1px, transparent 5px),
        /* Dark Soil Texture */
        radial-gradient(ellipse at 50% 100%, rgba(74, 42, 26, 0.3) 0%, transparent 70%),
        linear-gradient(to bottom, var(--night-ground-soil-dark), var(--night-ground-soil-light));
    background-size: 60px 60px, 80px 80px, 70px 70px, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
    background-position: 0 0, 20px 0, 40px 0, 0 0, 0 0, 0 0, 0 0, 0 0;
}

/* --- AdSense Placeholder --- */
.banner-container {
    padding: 10px;
    background-color: rgba(100, 100, 100, 0.5);
    color: white;
    border: 1px dashed white;
    border-radius: 5px;
    font-size: 0.9rem;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    z-index: 11;
    position: absolute; /* Position relative to ground */
    bottom: 20px; /* Adjust as needed */
}

@media (max-width: 768px) {
    header h1 { font-size: 2.5rem; }
    header .subtitle { font-size: 1rem; }
    .big-dipper { left: 50%; transform: translateX(-50%) rotate(10deg); top: 10%; } /* Adjusted for mobile centering */
    .cloud1 { width: 180px; height: 50px; top: 15%; left: 50%; transform: translateX(-60%); }
    .cloud2 { width: 130px; height: 40px; top: 12%; left: 50%; transform: translateX(-40%); }
    #info-bar { gap: 10px; flex-direction: column; font-size: 0.8rem; }
    .ground { height: 100px; }
    .banner-container { width: 90%; }
}
