@font-face {
    font-family: TimeTraveler;
    src: url(font/TimeTravelerPal-Normal-Regular.ttf);
}

:root {
    --bg-color: #fafafa;
    --text-main: #111111;
    --text-sec: #666666;
    --text-faded: #999999;
    --accent: #000000;
    --scale: 1;
}

[data-theme="dark"] {
    --bg-color: #0c0c0c;
    --text-main: #ffffff;
    --text-sec: #a0a0a0;
    --text-faded: #555555;
    --accent: #ffffff;
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    transition: background-color 0.5s ease, color 0.5s ease;
    margin: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.minimal-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100%;
}

.content-center {
    text-align: center;
    transform: translateY(-5vh); /* Lift slightly above strict center for optical balance */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    width: 100%;
    min-height: 50vh;
}

/* Astronomical Info */
.sun-text {
    font-size: calc(clamp(0.7rem, 1.5vw, 1rem) * var(--scale));
    color: var(--text-sec);
    margin-top: 0.5rem;
    letter-spacing: 0.5px;
    min-height: 1.5rem;
}

/* Progress Bar */
.time-container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.progress-wrapper {
    width: 45%;
    max-width: calc(400px * var(--scale));
    height: calc(3px * var(--scale));
    background: rgba(150, 150, 150, 0.15);
    border-radius: calc(3px * var(--scale));
    margin-top: calc(1rem * var(--scale));
    overflow: hidden;
}

[data-theme="dark"] .progress-wrapper {
    background: rgba(255, 255, 255, 0.1);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--text-sec);
    transition: width 1s linear;
}
[data-theme="dark"] .progress-bar {
    background: var(--text-faded);
}

.progress-text {
    font-size: calc(0.65rem * var(--scale));
    color: var(--text-faded);
    margin-top: 0.4rem;
    letter-spacing: 1px;
}

/* Typography */
.fade-text {
    font-size: calc(clamp(1rem, 2vw, 1.5rem) * var(--scale));
    font-weight: 300;
    color: var(--text-sec);
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

#title strong {
    color: var(--text-main);
    font-weight: 500;
}

.time-text {
    font-family: TimeTraveler, sans-serif;
    font-size: calc(20vw * var(--scale));
    line-height: 1;
    margin: 0;
    color: var(--text-main);
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.time-text span.no {
    display: inline-block;
    width: 0.58em;
    text-align: center;
}

.time-text span.dot {
    margin: 0 0.05em;
    opacity: 1;
    display: inline-block;
    width: 0.25em;
    text-align: center;
}

.sub-text {
    font-size: calc(clamp(0.7rem, 1vw, 0.9rem) * var(--scale));
    color: var(--text-faded);
    margin-top: 0.8rem;
    letter-spacing: 0.5px;
}

/* Footer Info */
.bottom-footer {
    position: absolute;
    bottom: 2rem;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0 1.5rem;
}

.device-text {
    font-size: calc(0.75rem * var(--scale));
    color: var(--text-sec);
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    row-gap: 0.5rem;
}

.ip-text {
    font-family: monospace;
    font-size: calc(0.85rem * var(--scale));
    color: var(--text-sec);
    letter-spacing: 1px;
}

.isp-text {
    font-size: calc(0.75rem * var(--scale));
    color: var(--text-sec);
    letter-spacing: 0.5px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 0.1rem;
    opacity: 0.8;
}

.isp-text svg {
    margin-right: 6px;
    opacity: 0.7;
}

.ua-text {
    font-size: calc(0.7rem * var(--scale));
    color: var(--text-sec);
    letter-spacing: 0.5px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ua-text {
    font-size: calc(0.65rem * var(--scale));
    color: var(--text-faded);
    max-width: 90%;
    margin-top: 0.2rem;
}

.version-text {
    font-size: calc(0.55rem * var(--scale));
    margin-top: 0.5rem;
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    align-items: center;
}

.version-text > span.divider {
    color: var(--text-faded);
    opacity: 0.4;
}

#version, #accuracy-info {
    color: var(--text-faded);
    opacity: 0.85; /* จางกว่า User Agent ประมาณ 15% */
}

/* Top Controls */
.top-controls {
    position: fixed;
    top: 2rem;
    right: 2.5rem;
    display: flex;
    gap: 0.5rem;
    z-index: 10;
}

.control-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    opacity: 0.5;
    transition: opacity 0.3s ease, transform 0.3s ease;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.control-btn svg {
    width: calc(24px * var(--scale));
    height: calc(24px * var(--scale));
}

.sun-text svg {
    width: calc(16px * var(--scale));
    height: calc(16px * var(--scale));
}

.device-text svg {
    width: calc(14px * var(--scale));
    height: calc(14px * var(--scale));
}

@media (max-width: 768px) {
    .content-center {
        height: 65vh;
        justify-content: space-between; /* Creates the empty distribution on mobile */
        gap: 0;
        transform: translateY(-8vh);
    }

    .time-container {
        margin: 0;
    }

    .progress-wrapper {
        width: 70%;
    }

    .top-controls {
        top: 1rem;
        right: 1.5rem;
        gap: 0.25rem;
    }
    
    .bottom-footer {
        bottom: 1.5rem;
    }
}

/* Mobile Landscape Overlap Fixes */
@media screen and (max-height: 600px) and (orientation: landscape) {
    .content-center {
        transform: translateY(-2vh);
        gap: 0.2rem;
        min-height: auto;
    }
    
    .time-text {
        font-size: calc(32vh * var(--scale)); /* Scale with height rather than width */
    }
    
    .fade-text {
        font-size: calc(1rem * var(--scale));
        margin-bottom: 0.1rem;
    }
    
    .sub-text, .sun-text {
        margin-top: 0.1rem;
        min-height: auto;
    }

    .progress-wrapper {
        margin-top: 0.3rem;
    }
    
    .progress-text {
        margin-top: 0.1rem;
    }
    
    .bottom-footer {
        bottom: 0.2rem;
        gap: 0;
    }
    
    .device-text {
        margin-bottom: 0;
        row-gap: 0.1rem;
        font-size: calc(0.7rem * var(--scale));
    }
    
    .ip-text {
        font-size: calc(0.8rem * var(--scale));
    }

    .ua-text {
        margin-top: 0.1rem;
        max-width: 95%;
        font-size: calc(0.6rem * var(--scale));
    }

    .version-text {
        margin-top: 0.1rem;
        font-size: calc(0.5rem * var(--scale));
    }
    
    .top-controls {
        top: 0.5rem;
        right: 1.5rem;
    }
}

/* Layout Toggle & Vertical Mode for Mobile Portrait */
#layout-toggle {
    display: none;
}

@media screen and (max-width: 768px) and (orientation: portrait) {
    #layout-toggle {
        display: flex;
    }
    
    .time-text.vertical-layout {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        font-size: calc(16vh * var(--scale));
        line-height: 0.85;
        margin-top: -1vh;
        margin-bottom: 1vh;
    }

    .time-text.vertical-layout .dot {
        transform: rotate(90deg);
        font-size: 0.4em;
        margin: 0.1em 0;
        opacity: 0.2;
    }
}

/* Zen / Focus Mode */
body.zen-mode .top-info,
body.zen-mode .progress-wrapper,
body.zen-mode #day-progress-text,
body.zen-mode .date-info,
body.zen-mode .bottom-footer {
    display: none !important;
}

body.zen-mode .content-center {
    transform: none !important; /* Make it strict center both vertically and horizontally */
    min-height: 100vh !important;
    height: 100vh !important;
    justify-content: center !important;
}

/* Maximize time text strictly in Zen Mode */
body.zen-mode .time-text {
    font-size: min(21.5vw, 80vh) !important;
    white-space: nowrap;
}

body.zen-mode .time-text.vertical-layout {
    font-size: min(60vw, 25vh) !important;
}

#time {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.3s ease;
}