html, body {
    overflow-x: hidden;
    max-width: 100%;
  width: 100%;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #fafbff;
    --bg-alt: #eef2ff;
    --card: #ffffff;
    --border: #e5e7eb;
    --accent: #004494;
    --accent-soft: #eef2ff;
    --text: #111827;
    --muted: #4b5563;
    --green: #15803d;
    --green-soft: #dcfce7;
    --orange: #c2410c;
    --orange-soft: #ffedd5;
    --link-color: #2563eb;
    --pink: #db2777;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(17, 24, 39, 0.06), 0 1px 2px rgba(17, 24, 39, 0.04);
}

[data-theme="dark"] {
    --bg: #0d1117;
    --bg-alt: #161b22;
    --card: #161b22;
    --border: #21262d;
    --accent: #0ec2e6;
    --accent-soft: rgba(0, 212, 255, 0.12);
    --text: #e6edf3;
    --muted: #a3a3a3;
    --green: #34d399;
    --green-soft: rgba(52, 211, 153, 0.14);
    --orange: #fb923c;
    --orange-soft: rgba(251, 146, 60, 0.14);
    --link-color: #60a5fa;
    --pink: #f472b6;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
    min-height: 100vh;
    padding: 12px 16px 96px;
    max-width: 1200px;
    margin: 0 auto;
}

/* HERO */
.hero-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 24px;
    margin-bottom: 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.hero-location {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-flag {
    font-size: 2rem;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-flag {
    width: 1.2em;
    height: 1.2em;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    vertical-align: -0.2em;
    display: inline-block;
    flex-shrink: 0;
}

.hero-country {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
    min-height: 1.4em;
}

.hero-clock {
    font-family: 'Space Mono', monospace;
    font-size: clamp(2rem, 7vw, 4rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.hero-clock .sec {
    color: var(--accent);
}

.hero-date {
    font-size: 0.95rem;
    color: var(--muted);
    margin-top: 10px;
}

.custom-mode-banner {
    display: none;
    margin-top: 14px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 100px;
    padding: 5px 14px;
    font-size: 0.78rem;
    color: var(--accent);
    letter-spacing: 0.05em;
    font-weight: 600;
}

.custom-mode-banner.visible {
    display: inline-block;
}

/* TOP BAR */
.topbar {
    position: relative;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    margin-bottom: 24px;
    min-height: 140px;
    padding-top: 10px;
}

.app-title {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text);
    margin: 0;
    font-family: 'Space Mono', monospace;
    text-align: center;
    white-space: nowrap;
}

.bg-earth {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.4;
    background-image: url('world-map.svg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    filter: sepia(1) hue-rotate(80deg) saturate(3) brightness(1.2);
    pointer-events: none;
}

[data-theme="dark"] .bg-earth {
    opacity: 0.14;
}

.icon-btn {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text);
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s, color 0.3s, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.08);
}

.icon-btn svg {
    position: absolute;
    width: 20px;
    height: 20px;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease;
}

.sun-icon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.moon-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

[data-theme="dark"] .sun-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

[data-theme="dark"] .moon-icon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* INTRO SECTION */
.intro-section {
    text-align: center;
    margin-bottom: 32px;
    padding: 0 10px;
}

.quick-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

@media (min-width: 1024px) {
    .quick-links {
        display: grid;
        grid-template-columns: repeat(10, auto);
        justify-content: center;
    }
}

.show-all-wrapper {
    grid-column: 1 / -1;
}

#showAllCitiesBtn:hover {
    transform: translateY(-2px);
    border-color: var(--accent) !important;
    color: var(--accent) !important;
    box-shadow: 0 4px 12px rgba(0, 68, 148, 0.15);
}

[data-theme="dark"] #showAllCitiesBtn:hover {
    box-shadow: 0 4px 12px rgba(14, 194, 230, 0.2);
}

.btn {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text);
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    min-height: 44px;
    padding: 0 16px;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
}

.btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

/* SECTION HEADER */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.search-container {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--muted);
    pointer-events: none;
}

.search-icon path {
    stroke: currentColor;
}

.search-input {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text);
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    min-height: 44px;
    padding: 0 16px 0 44px;
    width: 220px;
    max-width: 100%;
    outline: none;
    transition: border-color 0.15s;
}

.search-input:focus {
    border-color: var(--accent);
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-top: 6px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    visibility: hidden;
}

.search-suggestions.active {
    display: block;
    visibility: visible;
}

.suggestion-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--bg-alt);
}

/* GRID */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    min-height: 420px;
}

/* CLOCK CARD */
.clock-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}
.clock-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.card-country {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    min-width: 0;
}

.card-country span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-flag {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.diff-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 100px;
    white-space: nowrap;
    flex-shrink: 0;
    border: 1px solid transparent;
}

.diff-ahead {
    background: var(--green-soft);
    color: var(--green);
    border-color: rgba(21, 128, 61, 0.2);
}

[data-theme="dark"] .diff-ahead {
    border-color: rgba(52, 211, 153, 0.2);
}

.diff-behind {
    background: var(--orange-soft);
    color: var(--orange);
    border-color: rgba(194, 65, 12, 0.2);
}

[data-theme="dark"] .diff-behind {
    border-color: rgba(251, 146, 60, 0.2);
}

.diff-same {
    background: var(--bg-alt);
    color: var(--muted);
    border-color: rgba(163, 163, 163, 0.2);
}

.footer-link {
    color: var(--link-color) !important;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.footer-link:hover {
    color: var(--accent) !important;
    text-decoration: underline;
}

.card-clock {
    font-family: 'Space Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.card-date {
    font-size: 0.75rem;
    color: var(--muted);
}

/* MODAL */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

[data-theme="dark"] .modal-backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(17, 24, 39, 0.18);
    padding: 28px;
    width: min(420px, 92vw);
}

.modal h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.modal p {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 18px;
}

.time-picker-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.tp-input-container {
    position: relative;
}

.tp-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: 'Space Mono', monospace;
    font-size: 1.6rem;
    text-align: center;
    width: 76px;
    height: 60px;
    outline: none;
    transition: border-color 0.15s;
    appearance: textfield;
    -moz-appearance: textfield;
    padding: 0;
}

.tp-input::-webkit-outer-spin-button,
.tp-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tp-input:focus {
    border-color: var(--accent);
}

.tp-input.error {
    border-color: #ef4444;
}

.tp-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-height: 180px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    flex-direction: column;
    margin-top: 6px;
}

.tp-dropdown.open {
    display: flex;
}

.tp-option {
    padding: 10px;
    text-align: center;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
    font-size: 1.2rem;
    color: var(--text);
    transition: background 0.15s, color 0.15s;
}

.tp-option:hover {
    background: var(--bg-alt);
    color: var(--accent);
}

.modal-actions {
    display: flex;
    gap: 8px;
}

.modal-actions .btn {
    flex: 1;
    justify-content: center;
    display: flex;
    align-items: center;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s, box-shadow 0.2s, background 0.15s, color 0.15s;
}

.btn-primary svg {
    transition: transform 0.2s ease;
}

.btn-primary:hover {
    background: var(--accent);
    color: #ffffff;
    filter: brightness(1.08);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover svg {
    transform: translateX(4px);
}

[data-theme="dark"] .btn-primary {
    color: #0d1117;
    font-weight: 700;
}

[data-theme="dark"] .btn-primary:hover {
    color: #0d1117;
}

.modal-error {
    font-size: 0.8rem;
    color: #ef4444;
    min-height: 1.2em;
    margin-top: -6px;
    margin-bottom: 10px;
}



@media (max-width: 768px) {
    .topbar {
        flex-direction: column-reverse;
        justify-content: center;
        gap: 16px;
        margin-bottom: 24px;
    }

    .app-title {
        position: relative;
        left: 0;
        transform: none;
        white-space: normal;
        font-size: 1.15rem;
        text-align: center;
    }

    .hero-card {
        padding: 16px 12px;
    }

    .hero-clock {
        font-size: clamp(2rem, 10vw, 3rem);
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .btn-group {
        justify-content: center;
        width: 100%;
    }

    .search-input {
        width: 100%;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    body {
        padding: 16px 12px 96px;
    }

    footer div {
        flex-direction: column;
        gap: 10px;
    }

    .btn, .search-input, .tp-input, .location-select {
        min-height: 48px;
    }

    .icon-btn {
        width: 48px;
        height: 48px;
    }

    .tp-input {
        width: 60px;
        height: 55px;
        font-size: 1.3rem;
    }
}

.app-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.globe-icon {
    width: 96px;
    height: 96px;
    object-fit: contain;
    border-radius: 50%;
}

@media (max-width: 768px) {
    .globe-icon {
        width: 64px;
        height: 64px;
    }
}

@media (max-width: 768px) {
    .globe-icon {
        width: 108px;
        height: 108px;
    }

    .app-title {
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .globe-icon {
        width: 64px;
        height: 64px;
    }

    .hero-clock {
        font-size: clamp(2rem, 14vw, 3.5rem);
    }

    .btn {
        min-height: 48px;
        padding: 0 18px;
        font-size: 0.9rem;
    }

    .quick-links {
        gap: 8px;
    }

    .hero-card {
        padding: 16px 12px;
    }

    .section-title {
        font-size: 1rem;
    }
}

.hidden-city {
    display: none !important;
}

/* Country Modal Styles */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.country-modal {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -45%) scale(0.95);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 90%; max-width: 420px;
    z-index: 10001;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    opacity: 0; visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
}
[data-theme="dark"] .country-modal { box-shadow: 0 20px 40px rgba(0,0,0,0.6); }
.country-modal.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1; visibility: visible;
}

.modal-close {
    position: absolute; top: 16px; right: 16px;
    background: none; border: none; cursor: pointer; color: var(--muted);
    padding: 8px; border-radius: 50%; transition: background 0.2s, color 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-alt); color: var(--accent); }

.modal-content-grid {
    display: flex; flex-direction: column; gap: 16px; margin-top: 20px;
}
.modal-item {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.modal-item:last-child { border-bottom: none; padding-bottom: 0; }
.modal-item-label { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
.modal-item-value { color: var(--text); font-weight: 600; font-size: 0.95rem; text-align: right; }

.modal-time-large {
    font-size: 2.4rem; font-weight: 700; color: var(--accent);
    font-family: 'Space Mono', monospace;
    text-align: center; margin: 16px 0 8px;
    letter-spacing: -1px;
}


img, video, iframe {
  max-width: 100%;
  height: auto;
}
