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

:root {
    --primary-color: #1a1a2e;
    --secondary-color: #16213e;
    --accent-color: #0f3460;
    --text-color: #eaeaea;
    --highlight-color: #00d4ff;
    --success-color: #00ff88;
    --warning-color: #ff6b35;
    /* Secondary text and hairlines. These used to be hard-coded white, which meant every
       one of them turned invisible in light mode — the theme variables were there but the
       rules below reached past them. */
    --muted-color: rgba(255, 255, 255, 0.7);
    --hairline-color: rgba(0, 212, 255, 0.3);
    --card-tint: rgba(15, 52, 96, 0.3);
    --card-tint-strong: rgba(15, 52, 96, 0.6);
}

body.light-mode {
    --primary-color: #ffffff;
    --secondary-color: #f5f5f5;
    --accent-color: #e0e0e0;
    --text-color: #333333;
    --highlight-color: #0077a3;
    --success-color: #00753a;
    --warning-color: #cc5522;
    --muted-color: rgba(0, 0, 0, 0.62);
    --hairline-color: rgba(0, 119, 163, 0.28);
    --card-tint: rgba(0, 119, 163, 0.06);
    --card-tint-strong: rgba(0, 119, 163, 0.12);
}

body {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    padding: 20px;
    transition: background-color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Labels the screen reader needs and the design does not. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 0;
}

header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--highlight-color) 0%, var(--success-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    font-size: 1.2em;
    color: var(--muted-color);
}

.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.search-box {
    padding: 12px 20px;
    border: 2px solid var(--highlight-color);
    border-radius: 8px;
    background-color: var(--card-tint);
    color: var(--text-color);
    font-size: 1em;
    width: 100%;
    max-width: 400px;
    transition: all 0.3s ease;
}

.search-box:focus {
    outline: 2px solid var(--highlight-color);
    outline-offset: 2px;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
    background-color: var(--card-tint-strong);
}

.theme-toggle {
    padding: 12px 20px;
    border: 2px solid var(--highlight-color);
    border-radius: 8px;
    background-color: var(--card-tint);
    color: var(--text-color);
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
}

.theme-toggle:focus-visible,
.search-box:focus-visible {
    outline: 2px solid var(--highlight-color);
    outline-offset: 2px;
}

.clock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.clock-card {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--card-tint) 100%);
    border: 2px solid var(--highlight-color);
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 212, 255, 0.1);
    position: relative;
    overflow: hidden;
    animation: slideIn 0.5s ease-out both;
    animation-delay: calc(0.05s * var(--index, 0));
}

.clock-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.clock-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 12px 48px rgba(0, 212, 255, 0.3);
    border-color: var(--success-color);
}

.clock-card:hover::before {
    left: 100%;
}

.timezone-name {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--highlight-color);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.timezone-offset {
    font-size: 0.9em;
    color: var(--success-color);
    margin-bottom: 20px;
    font-weight: 500;
}

.digital-time {
    font-family: 'Courier New', monospace;
    font-size: 3em;
    font-weight: bold;
    color: var(--highlight-color);
    text-shadow: 0 0 10px var(--highlight-color), 0 0 20px rgba(0, 212, 255, 0.3);
    margin: 20px 0;
    letter-spacing: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80px;
    font-variant-numeric: tabular-nums;
}

.digital-time .blink {
    animation: blink 1s steps(1, end) infinite;
    margin: 0 2px;
}

@keyframes blink {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0.3;
    }
}

.date-info {
    font-size: 1.1em;
    color: var(--muted-color);
    margin-top: 15px;
    border-top: 1px solid var(--hairline-color);
    padding-top: 15px;
}

.time-details {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--hairline-color);
    font-size: 0.9em;
    gap: 10px;
}

.time-detail {
    flex: 1;
}

.time-detail-label {
    color: var(--muted-color);
    font-size: 0.8em;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.time-detail-value {
    color: var(--success-color);
    font-weight: bold;
}

footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid var(--hairline-color);
    color: var(--muted-color);
}

.no-results {
    text-align: center;
    padding: 40px 20px;
    font-size: 1.2em;
    color: var(--warning-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }

    .digital-time {
        font-size: 2em;
    }

    .clock-grid {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-direction: column;
    }

    .search-box {
        max-width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .clock-card {
        animation: none;
        transition: none;
    }

    .clock-card:hover {
        transform: none;
    }

    .digital-time .blink {
        animation: none;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: #000;
    }

    .controls {
        display: none;
    }
}
