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

html {
    height: 100%;
    background-color: #000;
}

body {
    width: 100%;
    min-height: 100%;
    min-height: 100dvh;
    overflow: hidden;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

#background {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    background-image: url('bgs/day.webp');
}

#background::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

#drake {
    position: absolute;
    bottom: env(safe-area-inset-bottom, 0px);
    left: 52%;
    transform: translateX(-52%);
    width: auto;
    height: 75%;
    pointer-events: none;
    transition: cubic-bezier(0.075, 0.82, 0.165, 1) 0.5s;
}

@media screen and (max-width: 700px) {
    #drake {
        height: 60%;
        transition: cubic-bezier(0.075, 0.82, 0.165, 1) 0.5s;
    }


}

#time-text {
    position: absolute;
    top: max(8%, calc(env(safe-area-inset-top) + 16px));
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 2rem;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-variant-numeric: tabular-nums;
}

#time-text span {
    transition: opacity 0.2s ease;
}

#city-name {
    cursor: pointer;
}

#time-text:has(#city-name:hover) #time-prefix {
    opacity: 0.2;
}

body.search-mode #time-prefix {
    opacity: 0.2;
}

/* Temperature Display */
#temperature-display {
    position: absolute;
    top: calc(max(8%, calc(env(safe-area-inset-top) + 16px)) + 4rem);
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 2rem;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    cursor: pointer;
}

#temperature-display.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Temperature above blur in settings mode */
body.settings-mode #temperature-display {
    z-index: 200;
}

/* Blur overlay */
#blur-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#blur-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Search mode styles */
body.search-mode #time-text {
    z-index: 200;
}

/* Settings mode styles */
body.settings-mode #time-text {
    z-index: 200;
}

/* City input field (replaces city name when editing) */
#city-input {
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    text-shadow: inherit;
    width: auto;
    min-width: 50px;
}

#city-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* City name container */
#city-name-container {
    position: relative;
    display: inline;
}

/* Keep city name in place but invisible when editing */
body.search-mode #city-name {
    visibility: hidden;
}

/* Position input exactly over the city name */
#city-input {
    position: absolute;
    left: 0;
    top: 0;
}

/* City dropdown */
#city-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    z-index: 200;
    display: none;
}

body.search-mode #city-dropdown {
    display: block;
}

.city-option {
    color: white;
    font-size: 2rem;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

#city-dropdown:hover .city-option {
    opacity: 0.2;
}

#city-dropdown .city-option:hover {
    opacity: 1;
}

.city-loading {
    color: white;
    font-size: 2rem;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}


/* Music Player */
#music-player {
    position: fixed;
    bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
    right: 20px;
    width: 350px;
    height: 72px;
    transform: translateY(150%);
    transition: transform 0.4s ease;
    z-index: 300;
}

#music-player-glass {
    position: absolute;
    inset: 0;
    border-radius: 50px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.1),
        rgba(34, 34, 34, 0.16) 0px 4px 9px,
        rgba(34, 34, 34, 0.2) 0px 2px 24px inset,
        rgba(255, 255, 255, 0.2) 0px -2px 24px inset;
    backdrop-filter: url('#liquid-glass-filter');
    -webkit-backdrop-filter: url('#liquid-glass-filter');
}

#music-player-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 12px 16px;
    height: 100%;
    color: white;
}

#music-player.visible {
    transform: translateY(0);
}

#song-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

#player-album {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
}

#player-info {
    display: flex;
    flex-direction: column;
}

#player-title {
    font-size: 1rem;
    font-weight: 600;
}

#player-artist {
    font-size: 0.875rem;
    opacity: 1;
}

#player-toggle {
    background: none;
    border: none;
    padding: 8px;
    position: relative;
    width: 40px;
    height: 40px;
}

#player-toggle i {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: white;
    transition: transform 0.15s ease;
}

#player-toggle .pause-icon {
    transform: translate(-50%, -50%) scale(1);
}

#player-toggle .play-icon {
    transform: translate(-50%, -50%) scale(0);
}

#player-toggle.paused .pause-icon {
    transform: translate(-50%, -50%) scale(0);
}

#player-toggle.paused .play-icon {
    transform: translate(-50%, -50%) scale(1);
}

/* Settings Button */
#settings-btn {
    position: fixed;
    bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
    left: 20px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

#settings-btn:hover {
    transform: scale(1.05);
}

#settings-btn:active {
    transform: rotate(180deg);

}

#settings-btn i {
    font-size: 22px;
    color: white;
}

/* Settings Panel */
#settings-panel {
    position: fixed;
    bottom: max(74px, calc(env(safe-area-inset-bottom) + 74px));
    left: 20px;
    width: 260px;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 300;
}

#settings-panel.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#settings-glass {
    position: absolute;
    inset: 0;
    border-radius: 20px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.1),
        rgba(34, 34, 34, 0.16) 0px 4px 9px,
        rgba(34, 34, 34, 0.2) 0px 2px 24px inset,
        rgba(255, 255, 255, 0.2) 0px -2px 24px inset;
    backdrop-filter: url('#liquid-glass-filter');
    -webkit-backdrop-filter: url('#liquid-glass-filter');
}

#settings-content {
    position: relative;
    z-index: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 4px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
}

.setting-row-clickable {
    cursor: pointer;
    border-radius: 12px;
    margin: -8px;
    padding: 8px;
    transition: background-color 0.2s ease;
}

.setting-row-clickable:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.setting-row-clickable i {
    color: white;
    font-size: 1.1rem;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: 0.3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:focus + .slider {
    box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 28px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Unit Pill Toggle */
.setting-unit-row {
    display: none;
}

.setting-unit-row.visible {
    display: flex;
}

.pill-toggle {
    position: relative;
    display: flex;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    padding: 2px;
}

.pill-option {
    position: relative;
    z-index: 1;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 4px 12px;
    cursor: pointer;
    transition: color 0.3s ease;
}

.pill-option.active {
    color: white;
}

.pill-indicator {
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(50% - 2px);
    height: calc(100% - 4px);
    background: #2196F3;
    border-radius: 12px;
    transition: transform 0.3s ease;
}

.pill-toggle[data-selected="F"] .pill-indicator {
    transform: translateX(100%);
}

/* Time Travel Panel */
#time-travel-panel {
    position: fixed;
    bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
    left: 50%;
    transform: translate(-50%, 150%);
    min-width: 400px;
    height: 72px;
    transition: transform 0.4s ease;
    z-index: 1000;
}

#time-travel-panel.visible {
    transform: translate(-50%, 0);
}

#time-travel-glass {
    position: absolute;
    inset: 0;
    border-radius: 50px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.1),
        rgba(34, 34, 34, 0.16) 0px 4px 9px,
        rgba(34, 34, 34, 0.2) 0px 2px 24px inset,
        rgba(255, 255, 255, 0.2) 0px -2px 24px inset;
    backdrop-filter: url('#liquid-glass-filter');
    -webkit-backdrop-filter: url('#liquid-glass-filter');
}

#time-travel-content {
    position: relative;
    z-index: 1;
    padding: 12px 24px;
    height: 100%;
    display: flex;
    align-items: center;
}

.time-travel-row {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.time-travel-label {
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    min-width: 100px;
}

#debug-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

#debug-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#debug-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#time-travel-done {
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 14px;
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#time-travel-done .done-icon {
    display: none;
    font-size: 1rem;
}

#time-travel-done:hover {
    background-color: #1976D2;
}

/* Credit */
#credit {
    position: fixed;
    bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
    right: 20px;
    color: white;
    font-size: 0.9rem;
    font-weight: 400;
    opacity: 0.7;
    z-index: 100;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 8px;
}

#credit-text a {
    color: white;
    text-decoration: underline;
    transition: opacity 0.2s ease;
}

#credit-text a:hover {
    opacity: 0.8;
}

#credit-info-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    color: white;
}

#credit-info-btn:hover {
    transform: scale(1.05);
}

#credit-info-btn i {
    font-size: 22px;
}

/* Credit Modal */
#credit-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 400px;
    max-width: calc(100% - 40px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 400;
}

#credit-modal.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

#credit-modal-glass {
    position: absolute;
    inset: 0;
    border-radius: 20px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.1),
        rgba(34, 34, 34, 0.16) 0px 4px 9px,
        rgba(34, 34, 34, 0.2) 0px 2px 24px inset,
        rgba(255, 255, 255, 0.2) 0px -2px 24px inset;
    backdrop-filter: url('#liquid-glass-filter');
    -webkit-backdrop-filter: url('#liquid-glass-filter');
}

#credit-modal-content {
    position: relative;
    z-index: 1;
    padding: 24px;
    color: white;
}

#credit-modal-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 16px;
}

#credit-modal-text-desktop,
#credit-modal-text-mobile {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 20px;
    opacity: 0.9;
}

#credit-modal-text-desktop a,
#credit-modal-text-mobile a {
    color: white;
    text-decoration: underline;
}

#credit-modal-text-mobile {
    display: none;
}

#credit-modal-close {
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
}

#credit-modal-close:hover {
    background-color: #1976D2;
}

/* Show modal blur overlay */
body.credit-modal-open #blur-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* Mobile Responsiveness */
@media screen and (max-width: 700px) {
    /* Reduce font sizes and stack time text */
    #time-text {
        font-size: 1.5rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    /* Temperature display on mobile */
    #temperature-display {
        top: calc(max(8%, calc(env(safe-area-inset-top) + 16px)) + 5.5rem);
        font-size: 1.5rem;
    }

    /* City name on second line */
    #city-name-container {
        display: block;
        text-align: center;
    }

    /* Center the city input on mobile - keep absolute but center it */
    #city-input {
        left: 50%;
        transform: translateX(-50%);
        text-align: center;
    }

    /* Center city dropdown on mobile */
    #city-dropdown {
        left: 50%;
        transform: translateX(-50%);
        text-align: center;
    }

    .city-option,
    .city-loading {
        font-size: 1.5rem;
        text-align: center;
    }

    /* Center music player on mobile */
    #music-player {
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(150%);
        width: calc(100% - 40px);
        max-width: 350px;
        transition: transform 0.4s ease, bottom 0.4s ease;
    }

    #music-player.visible {
        transform: translateX(-50%) translateY(0);
    }

    /* Move music player above time travel panel when both are visible */
    body:has(#time-travel-panel.visible) #music-player.visible {
        bottom: calc(max(20px, calc(env(safe-area-inset-bottom) + 20px)) + 92px);
    }

    /* Make time travel panel responsive */
    #time-travel-panel {
        width: calc(100% - 40px);
        min-width: auto;
        max-width: 350px;
    }

    /* Responsive settings panel */
    #settings-panel {
        width: calc(100% - 40px);
        max-width: 260px;
    }

    /* Show tick icon instead of Done text on mobile */
    #time-travel-done {
        padding: 6px 12px;
        border-radius: 50%;
        width: 32px;
        height: 32px;
    }

    #time-travel-done .done-text {
        display: none;
    }

    #time-travel-done .done-icon {
        display: block;
    }

    /* On mobile, show only info icon in bottom right */
    #credit {
        right: 20px;
        bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
    }

    #credit-text {
        display: none;
    }

    /* Show full message in modal on mobile */
    #credit-modal-text-desktop {
        display: none;
    }

    #credit-modal-text-mobile {
        display: block;
    }

    #credit-modal-title {
        display: none;
    }

    /* Hide settings and info buttons when time travel panel is open */
    body.time-travel-mode #settings-btn,
    body.time-travel-mode #credit {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
}
