body {
    background-color: #000;
    color: #fff;
    margin: 0;
    height: 100vh;
    box-sizing: border-box;
    padding-bottom: 80px; /* reserve space for the fixed complications bar */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease;
}

body.night-mode {
    background-color: #0a0000;
}

body.night-mode .watch {
    background: radial-gradient(circle at 30% 30%, #1a0000, #050000);
}

body.night-mode .indice,
body.night-mode .numeral,
body.night-mode .hour-hand,
body.night-mode .minute-hand {
    opacity: 0.3;
}

body.night-mode .second-hand {
    opacity: 0.5;
}

body.night-mode .time,
body.night-mode .analog-digital-time {
    color: #ff0000;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.3);
}

body.night-mode .analog-date-detail,
body.night-mode .analog-timezone,
body.night-mode .toggle-label {
    opacity: 0.15;
}

/* Dark mode toggle colors - darker green and red tints */
body.night-mode .toggle-switch {
    background-color: #1a0000; /* Very dark red when off in night mode */
}

body.night-mode .toggle-switch.active {
    background-color: #1a3d1f; /* Dark forest green when active in night mode */
}

body.night-mode .toggle-slider {
    background-color: #660000; /* Dim red slider in night mode */
}

body.night-mode .toggle-switch.active .toggle-slider {
    background-color: #2d5a2d; /* Dim green slider when active in night mode */
}

/* Controls bar — stacks vertically on desktop, flips horizontal on mobile */
.controls-bar {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 16px;
    gap: 10px;
}

.toggle-container,
.night-mode-container,
.beep-mute-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sync-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

@media (max-width: 560px) {
    body {
        padding-top: 70px;
    }

    .controls-bar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-end;
        right: 0;
        left: 0;
        padding: 10px 14px 8px;
        gap: 8px 16px;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    }

    .sync-container {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .sync-status {
        font-size: 9px;
    }
}

.sync-button {
    background-color: #333;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: background-color 0.3s;
}

.sync-button:hover {
    background-color: #555;
}

.sync-button:active {
    background-color: #222;
}

.sync-status {
    font-size: 10px;
    opacity: 0.5;
    letter-spacing: 0.1em;
}

.toggle-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.5;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
    background-color: #333;
    border-radius: 13px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.toggle-switch.active {
    background-color: #34C759; /* Apple green when active */
}

.toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background-color: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch.active .toggle-slider {
    transform: translateX(24px);
}

/* Digital Clock Styles */
.digital-view {
    display: none;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.digital-view.active {
    display: block;
}

.digital-view .analog-info {
    margin-top: 30px;
}

.time {
    font-size: 15vw;
    font-weight: 700;
    letter-spacing: -0.05em;
    line-height: 1;
}

.seconds {
    font-size: 8vw;
    font-weight: 300;
    opacity: 0.6;
    margin-left: 10px;
}

.centis {
    font-size: 4vw;
    font-weight: 300;
    opacity: 0.4;
    margin-left: 2px;
    font-variant-numeric: tabular-nums;
}

.ampm {
    font-size: 3vw;
    font-weight: 400;
    opacity: 0.5;
    margin-left: 8px;
    letter-spacing: 0.08em;
    vertical-align: middle;
}

/* Analog Clock Styles */
.analog-view {
    display: none;
}

.analog-view.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.watch {
    position: relative;
    width: min(80vw, 80vh, 400px);
    height: min(80vw, 80vh, 400px);
    border: 8px solid #333;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #2a2a2a, #0a0a0a);
    box-shadow: 
        0 0 0 2px #111,
        inset 0 0 30px rgba(0,0,0,0.5),
        0 10px 40px rgba(0,0,0,0.8);
}

.indices {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.indice, .beat {
    position: absolute;
    background-color: #ddd;
    left: 50%;
    top: 50%;
    transform-origin: center;
}

.indice {
    width: 3px;
    height: 12%;
    background: linear-gradient(to bottom, #fff, #999);
}

.beat {
    width: 2px;
    height: 6%;
    background-color: #666;
}

.numerals {
    position: absolute;
    width: 100%;
    height: 100%;
}

.numeral {
    position: absolute;
    font-size: clamp(18px, 4vw, 28px);
    color: #fff;
    font-weight: 600;
    text-align: center;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    transform: translateX(-50%);
    border-radius: 2px;
}

.hour-hand {
    width: 6px;
    height: 25%;
    background: linear-gradient(to top, #fff, #ccc);
    z-index: 3;
    box-shadow: 0 0 8px rgba(0,0,0,0.5);
}

.minute-hand {
    width: 4px;
    height: 35%;
    background: linear-gradient(to top, #fff, #aaa);
    z-index: 2;
    box-shadow: 0 0 6px rgba(0,0,0,0.5);
}

.second-hand {
    width: 2px;
    height: 40%;
    background: #ff3333;
    z-index: 4;
    box-shadow: 0 0 4px rgba(255,0,0,0.5);
}

.gmt-hand {
    width: 3px;
    height: 22%;
    background: linear-gradient(to top, #ffb347, #e88a1a);
    border-radius: 2px 2px 0 0;
    z-index: 1;
    box-shadow: 0 0 6px rgba(232, 138, 26, 0.4);
    display: none;
}

.gmt-hand.active {
    display: block;
}

.gmt-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.gmt-ring.active {
    opacity: 1;
}

.gmt-tick {
    position: absolute;
    width: 1px;
    height: 1.5%;
    background: rgba(255, 179, 71, 0.35);
    left: 50%;
    top: 50%;
    transform-origin: center;
}

.gmt-tick.major {
    width: 2px;
    height: 2.2%;
    background: rgba(255, 179, 71, 0.6);
}

.gmt-numeral {
    position: absolute;
    font-size: clamp(8px, 1.5vw, 11px);
    color: #ffb347;
    opacity: 0.75;
    font-weight: 500;
    letter-spacing: 0.05em;
    width: 20px;
    text-align: center;
    transform: translate(-50%, -50%);
    font-variant-numeric: tabular-nums;
}

.gmt-label {
    font-size: clamp(10px, 2vw, 14px);
    font-weight: 400;
    letter-spacing: 0.12em;
    color: #ffb347;
    opacity: 0;
    margin-top: 5px;
    transition: opacity 0.3s;
}

.gmt-label.active {
    opacity: 0.75;
}

.gmt-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gmt-select {
    background: #1a1a1a;
    color: #fff;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 11px;
    font-family: inherit;
    letter-spacing: 0.05em;
    max-width: 180px;
    cursor: pointer;
}

body.night-mode .gmt-hand,
body.night-mode .gmt-ring {
    filter: hue-rotate(-30deg) saturate(0.6) brightness(0.5);
}

body.night-mode .gmt-label {
    color: #662200;
}

.center-dot {
    position: absolute;
    width: 14px;
    height: 14px;
    background: radial-gradient(circle, #fff, #999);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    box-shadow: 0 0 6px rgba(0,0,0,0.8);
}

/* Analog info display below watch */
.analog-info {
    margin-top: 30px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.analog-digital-time {
    font-size: clamp(24px, 6vw, 48px);
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.analog-date-detail {
    font-size: clamp(12px, 2.5vw, 16px);
    font-weight: 400;
    letter-spacing: 0.1em;
    opacity: 0.7;
    text-transform: uppercase;
}

.analog-timezone {
    font-size: clamp(10px, 2vw, 14px);
    font-weight: 300;
    letter-spacing: 0.15em;
    opacity: 0.5;
    margin-top: 5px;
}


/* Complications Bar */
.complications-bar {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 10px 0;
    z-index: 50;
    backdrop-filter: blur(4px);
}

.complication-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 0 20px;
}

.complication-divider {
    width: 1px;
    height: 42px;
    background: rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.complication-value {
    font-size: 20px;
    font-weight: 300;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.complication-label {
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.25em;
    opacity: 0.35;
    text-transform: uppercase;
}

.complication-value.is-leap {
    color: #f0d060;
}

.complication-label.is-leap {
    opacity: 0.7;
    color: #f0d060;
}

body.night-mode .complications-bar {
    background: rgba(255, 0, 0, 0.03);
    border-color: rgba(255, 0, 0, 0.08);
}

body.night-mode .complication-value,
body.night-mode .moon-display svg circle,
body.night-mode .leap-cycle-display {
    opacity: 0.4;
}

/* Progress bar */
.progress-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: #111;
}

.progress-bar {
    height: 100%;
    background: #fff;
    width: 0%;
    transition: width 0.1s linear;
}