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

:root {
    /* Refined color palette - softer, more sophisticated */
    --color-bg: #0f172a;
    --color-bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --color-surface: #1e293b;
    --color-surface-elevated: #334155;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-accent: #d00000;
    --color-accent-muted: #a80000;

    /* Semantic colors - slightly muted for sophistication */
    --color-core: #4ade80;
    --color-core-muted: #22c55e;
    --color-stretch: #fbbf24;
    --color-stretch-muted: #f59e0b;
    --color-sleep: #475569;
    --color-overlap-core: #22d3ee;
    --color-overlap-stretch: #a78bfa;

    /* City colors - vibrant but balanced */
    --city-color-1: #f472b6;
    --city-color-2: #60a5fa;
    --city-color-3: #34d399;
    --city-color-4: #fbbf24;
    --city-color-5: #a78bfa;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(34, 211, 238, 0.15);

    /* Typography scale */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Monaco', 'Consolas', monospace;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg-gradient);
    color: var(--color-text);
    min-height: 100vh;
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Site navigation - back to main site */
.site-nav {
    padding: 0.75rem 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--color-surface-elevated);
}

.back-link {
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.back-link:hover {
    color: var(--color-accent);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 1.5rem 0 2rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, var(--color-text) 0%, var(--color-text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.01em;
}

main {
    flex: 1;
    display: flex;
    gap: 2rem;
    padding: 1rem 0;
}

/* City Panel */
.city-panel {
    width: 280px;
    flex-shrink: 0;
}

.city-panel h2 {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.city-search {
    position: relative;
    margin-bottom: 1rem;
}

#city-search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-surface-elevated);
    border-radius: 10px;
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

#city-search-input:focus {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-md), 0 0 0 3px rgba(59, 130, 246, 0.15);
}

#city-search-input::placeholder {
    color: var(--color-text-muted);
}

.suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-surface-elevated);
    border-radius: 10px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: all var(--transition-base);
}

.suggestions.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--color-surface-elevated);
    transition: background var(--transition-fast);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.highlighted {
    background: var(--color-surface-elevated);
}

.suggestion-city {
    font-weight: 500;
    color: var(--color-text);
}

.suggestion-country {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    margin-top: 2px;
}

.selected-cities {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.city-tag {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    background: var(--color-surface);
    border-radius: 10px;
    border-left: 4px solid var(--city-color);
    box-shadow: var(--shadow-sm);
    animation: slideIn var(--transition-base) ease-out;
    transition: all var(--transition-fast);
}

.city-tag:hover {
    background: var(--color-surface-elevated);
    box-shadow: var(--shadow-md);
    transform: translateX(2px);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.city-tag-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.city-tag-info {
    flex: 1;
    min-width: 0;
}

.city-tag-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.city-tag-time {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.city-tag-remove {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.25rem;
    line-height: 1;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.city-tag-remove:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.1);
}

.city-panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-surface-elevated);
}

.hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin: 0;
}

/* Clock Section */
.clock-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.clock-container {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1;
    padding: 1rem;
    border-radius: 50%;
    background: radial-gradient(circle at center, var(--color-surface) 0%, var(--color-bg) 70%);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
    transition: box-shadow var(--transition-slow);
}

.clock-container:hover {
    box-shadow: var(--shadow-xl), 0 0 60px rgba(34, 211, 238, 0.2);
}

#clock-svg {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    justify-content: center;
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color var(--transition-fast);
}

.legend-item:hover {
    color: var(--color-text);
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.legend-core {
    background: linear-gradient(135deg, var(--color-core) 0%, var(--color-core-muted) 100%);
}

.legend-stretch {
    background: linear-gradient(135deg, var(--color-stretch) 0%, var(--color-stretch-muted) 100%);
}

.legend-overlap-core {
    background: var(--color-overlap-core);
    box-shadow: 0 0 8px var(--color-overlap-core);
}

.legend-overlap-stretch {
    background: var(--color-overlap-stretch);
    box-shadow: 0 0 8px var(--color-overlap-stretch);
}

/* Selection hint */
.selection-hint {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 1rem;
    text-align: center;
    opacity: 0.7;
}

/* Controls */
.controls {
    padding: 1.5rem 0 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.time-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#time-slider {
    width: 200px;
    cursor: pointer;
    accent-color: var(--color-accent);
}

.time-display {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 500;
    min-width: 90px;
    padding: 0.5rem 0.75rem;
    background: var(--color-surface);
    border-radius: 8px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.btn {
    padding: 0.625rem 1.25rem;
    border: 1px solid var(--color-surface-elevated);
    border-radius: 8px;
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.btn:hover {
    background: var(--color-surface-elevated);
    border-color: var(--color-accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-small {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--color-surface-elevated);
    border-radius: 6px;
    background: transparent;
    color: var(--color-text-muted);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-small:hover {
    background: var(--color-surface-elevated);
    color: var(--color-text);
    border-color: var(--color-accent-muted);
}

.share-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.share-feedback,
.copy-feedback {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-core);
    animation: fadeInOut 2s ease-out;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(4px); }
    15% { opacity: 1; transform: translateY(0); }
    85% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-4px); }
}

/* Selection Panel */
.selection-panel {
    width: 280px;
    flex-shrink: 0;
    background: var(--color-surface);
    border-radius: 16px;
    padding: 1.25rem;
    height: fit-content;
    box-shadow: var(--shadow-lg);
    animation: slideInRight var(--transition-base) ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.selection-panel.hidden {
    display: none;
}

.selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.selection-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
}

.selection-duration {
    text-align: center;
    padding: 0.625rem;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.1) 0%, rgba(34, 211, 238, 0.05) 100%);
    border: 1px solid rgba(34, 211, 238, 0.2);
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-overlap-core);
}

.selection-times {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.selection-city {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0.75rem;
    background: var(--color-bg);
    border-radius: 8px;
    border-left: 3px solid var(--city-color);
    transition: all var(--transition-fast);
}

.selection-city:hover {
    background: var(--color-surface-elevated);
}

.selection-city-name {
    font-weight: 500;
    font-size: 0.85rem;
}

.selection-city-time {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.selection-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.selection-actions .btn {
    flex: 1;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    main {
        flex-direction: column;
    }

    .city-panel {
        width: 100%;
    }

    .clock-container {
        max-width: 350px;
    }

    .controls {
        flex-direction: column;
        gap: 1rem;
    }

    .time-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    #time-slider {
        width: 150px;
    }

    .selection-panel {
        width: 100%;
        order: -1;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--color-surface-elevated);
    border-radius: 4px;
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Focus styles for accessibility */
*:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Pulse animation for current time indicator */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Site footer - attribution */
.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--color-surface-elevated);
}

.site-footer p {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    opacity: 0.7;
    letter-spacing: 0.01em;
}

.site-footer a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.site-footer a:hover {
    color: var(--color-text);
}
