:root {
    --bg-color: #050505;
    --text-primary: #33ff33;
    --text-muted: #22aa22;
    --border-color: #33ff33;
}

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

body {
    font-family: 'VT323', monospace;
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

/* CRT/Dot Matrix Overlay */
body::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), 
                linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    z-index: 2;
    background-size: 100% 3px, 3px 100%;
    pointer-events: none;
    animation: scanline 6s linear infinite;
}

@keyframes scanline {
    0% { background-position: 0 0; }
    100% { background-position: 0 100%; }
}

/* Dot pattern background */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(#ffffff0a 1px, transparent 1px);
    background-size: 4px 4px;
    z-index: 0;
}

.container {
    width: 95%;
    max-width: 650px;
    margin: 20px auto;
    text-align: center;
    z-index: 1;
    border: 2px solid var(--border-color);
    padding: 40px;
    background: #000;
    position: relative;
}

header {
    margin-bottom: 40px;
    border-bottom: 2px dashed var(--border-color);
    padding-bottom: 20px;
}

h1 {
    font-size: clamp(3.5rem, 15vw, 8rem);
    line-height: 1;
    margin-bottom: 10px;
    text-shadow: 0 0 2px var(--text-primary);
}

.location-select {
    font-size: 1.5rem;
    color: #000;
    background: var(--text-primary);
    display: inline-block;
    padding: 5px 10px;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-family: inherit;
    border: none;
    cursor: pointer;
    max-width: 100%;
}

#main-city-time {
    font-size: clamp(2rem, 10vw, 4rem);
    font-weight: bold;
    margin: 10px 0;
    text-shadow: 0 0 3px var(--text-primary);
}

#current-date-info {
    font-size: 1.5rem;
    text-transform: uppercase;
}

.progress-section {
    margin-bottom: 50px;
}

.progress-container {
    height: 30px;
    background: #000;
    border: 2px solid var(--border-color);
    position: relative;
    margin-bottom: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--text-primary);
    /* Blocky progress bar effect */
    background-image: linear-gradient(90deg, #000 2px, transparent 2px);
    background-size: 10px 100%;
    transition: width 1s ease-in-out;
}

#progress-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-primary);
    mix-blend-mode: difference;
}

.label {
    font-size: 1.2rem;
    text-transform: uppercase;
}

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

.stat-card {
    border: 1px solid var(--border-color);
    padding: 20px;
    background: #000;
}

.stat-card h3 {
    font-size: 3rem;
    margin-bottom: 5px;
}

.stat-card p {
    font-size: 1.1rem;
    text-transform: uppercase;
}

.world-clocks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 40px;
    border: 1px dashed var(--border-color);
    padding: 20px;
}

.add-clock-section {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

#add-clock-select {
    font-size: 1.2rem;
}

#add-clock-btn {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--text-primary);
    padding: 5px 15px;
    font-family: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

#add-clock-btn:hover {
    background: var(--text-primary);
    color: #000;
}

.clock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px;
    position: relative;
}

.remove-clock-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.remove-clock-btn:hover {
    color: #ff4444;
}

.city-name {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.city-time {
    font-size: 1.4rem;
    font-weight: bold;
}

footer {
    border-top: 2px dashed var(--border-color);
}

.week-info {
    font-size: 1.4rem;
    text-transform: uppercase;
    margin-top: 10px;
    letter-spacing: 1px;
}

#current-week-num {
    margin-left: 10px;
    font-weight: bold;
}

/* Flicker Animation */
@keyframes flicker {
    0% { opacity: 0.97; }
    5% { opacity: 0.95; }
    10% { opacity: 0.9; }
    15% { opacity: 0.98; }
    30% { opacity: 0.95; }
    50% { opacity: 0.99; }
    80% { opacity: 0.9; }
    100% { opacity: 1; }
}

.container {
    animation: flicker 0.15s infinite;
}

@media (max-width: 600px) {
    .container { 
        padding: 20px;
        border-width: 1px;
    }
    header { margin-bottom: 25px; }
    #main-city-label { font-size: 1.2rem; }
    .stat-card { padding: 15px; }
    .stat-card h3 { font-size: 2.2rem; }
    .world-clocks { padding: 10px; }
}

@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Fullscreen Toggle */
.fullscreen-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    z-index: 10;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    padding: 5px;
}

.fullscreen-btn:hover {
    opacity: 1;
}

.fullscreen-btn svg {
    display: block;
}

/* Fullscreen mode and Volume Control */
.container.is-fullscreen {
    max-width: 1000px;
    padding: 60px;
}

.volume-control {
    display: none;
    position: absolute;
    top: 20px;
    left: 20px;
    align-items: center;
    gap: 10px;
    z-index: 10;
    color: var(--text-primary);
}

.container.is-fullscreen .volume-control {
    display: flex;
}

#volume-slider {
    width: 100px;
    accent-color: var(--text-primary);
    cursor: pointer;
}

/* Background Animation Canvas */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0; /* Behind everything except body background */
    opacity: 0;
    transition: opacity 2s ease-in-out;
    pointer-events: none;
}

body.is-fullscreen #bg-canvas {
    opacity: 1;
}
