/* ================== 1. GENERAL PAGE STYLES ================== */
body {
    background-image: url('bg.png');
    background-repeat: no-repeat;
    background-attachment: fixed;  
    background-size: cover;
    background-position: top left;
    color: white;
    font-family: 'Courier New', Courier, monospace;
    margin: 20px;
    transition: background 0.5s ease;
}

/* Mobile portrait: fill top to bottom, crop left/right */
@media (max-width: 768px) and (orientation: portrait) {
    body {
        background-size: auto 100%;
        background-position: center top;
        background-attachment: scroll;
    }
}

@media (max-width: 400px) and (orientation: portrait) {
    body {
        background-size: auto 100%;
        background-position: center top;
        background-attachment: scroll;
    }
}

h1, h2 {
    text-align: center;
    text-shadow: 3px 3px #000;
}

h2 {
    margin-top: 40px;
    color: #ffcc00;
}

/* ================== 2. NAVIGATION BUTTON ================== */
.nav-button {
    display: block;
    margin: 20px auto;
    padding: 16px 30px;
    background-color: darkblue;
    color: aliceblue;
    border: 2px solid #ffcc00;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.3s;
}

.nav-button:hover {
    background-color: navy;
}

/* ================== 3. TIMERS CONTAINERS ================== */
#current-events,
#upcoming-events {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

/* ================== 4. ENDED EVENTS GRID ================== */
#ended-events {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}

/* Medium screens: prefer 2–3 columns */
@media (max-width: 768px) {
    #ended-events {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 8px;
    }
}

/* Small screens: prefer 2 columns, fall back to stacking */
@media (max-width: 500px) {
    #ended-events {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 6px;
    }
}

/* Extra small screens: stack vertically if needed */
@media (max-width: 350px) {
    #ended-events {
        grid-template-columns: 1fr;
        gap: 5px;
    }
}

/* Timer wrapper flexibility */
#ended-events .timer-wrapper,
#current-events .timer-wrapper,
#upcoming-events .timer-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
}

/* ================== 5. TIMER BOX ================== */
.timer {
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: bold;
    text-align: center;
    box-shadow: 2px 2px 5px #000;
    color: #fff;
    font-size: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* TIMER COLORS */
.timer.red { background-color: rgba(255, 77, 77, 0.6); }
.timer.blue { background-color: rgba(77, 121, 255, 0.6); }
.timer.green { background-color: rgba(77, 255, 136, 0.6); }
.timer.purple { background-color: rgba(184, 77, 255, 0.6); }
.timer.orange { background-color: rgba(255, 148, 77, 0.6); }
.timer.teal { background-color: rgba(77, 255, 255, 0.6); }

/* ================== 6. DAILY RESET FIX ================== */
.timer.grey {
    background-color: rgba(128, 128, 128, 0.6);
    max-width: 160px;  /* keep original width */
    min-width: 140px;
    margin: 0 auto;    /* center in grid cell */
}

.timer-wrapper .timer.grey {
    width: auto;       /* override 100% width for grey timers */
}

/* ================== 7. TIMER TITLE ================== */
.timer-title {
    margin-bottom: 5px;
    font-weight: 900;
    text-align: center;
    text-shadow: 2px 2px #000;
    font-size: clamp(18px, 4vw, 28px);
    white-space: normal;       /* wrap event names */
    word-break: break-word;    /* break long words */
}

/* TITLE COLORS */
.timer-title.red { color: rgba(255, 77, 77, 0.9); }
.timer-title.blue { color: rgba(77, 121, 255, 0.9); }
.timer-title.green { color: rgba(77, 255, 136, 0.9); }
.timer-title.purple { color: rgba(184, 77, 255, 0.9); }
.timer-title.orange { color: rgba(255, 148, 77, 0.9); }
.timer-title.teal { color: rgba(77, 255, 255, 0.9); }
.timer-title.grey {
    color: white;
    -webkit-text-stroke: 0.5px black;
    text-shadow: 2px 2px 2px black;
}

/* ================== 8. EVENT NAME INSIDE TIMER ================== */
.timer-event-name {
    color: #fff;
    font-weight: bold;
    text-align: center;
    text-shadow: 1px 1px #000;
    margin-bottom: 5px;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 3px;
}

/* ================== 9. INNER NUMBER BOXES ================== */
.numbers-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex-wrap: nowrap; /* never wrap numbers */
}

.number-box {
    background-color: #fff;
    color: #000;
    font-weight: bold;
    padding: 3px 6px;
    border-radius: 3px;
    min-width: 18px;
    text-align: center;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    font-size: 12px;
    flex-shrink: 0;
}

.colon {
    display: inline-block;
    padding: 0 2px;
    font-weight: bold;
    font-size: 12px;
    line-height: 1;
}

/* ================== 10. SECTION TITLES ================== */
.section-title {
    text-align: center;
    color: #ffcc00;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 20px 0 10px 0;
    text-shadow: 2px 2px #000;
    font-family: 'Courier New', Courier, monospace;
    font-weight: 900;
    font-size: clamp(22px, 5vw, 36px);
}

/* ================== 11. RESPONSIVE ADJUSTMENTS ================== */
@media (max-width: 900px) {
    .number-box { font-size: 11px; min-width: 16px; padding: 2px 4px; }
    .colon { font-size: 11px; padding: 0 2px; }
}

@media (max-width: 600px) {
    #current-events,
    #upcoming-events {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 6px;
    }
    .number-box { font-size: 10px; min-width: 14px; padding: 2px 3px; }
    .section-title { margin: 15px 0 8px 0; }
}

@media (max-width: 400px) {
    #current-events,
    #upcoming-events {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 5px;
    }
    .number-box { font-size: 9px; min-width: 12px; padding: 2px 3px; }
    .section-title { margin: 12px 0 6px 0; font-size: clamp(20px, 6vw, 32px); }
}
#error-panel {
    max-width: 700px;
    margin: 15px auto;
    padding: 12px 16px;
    background: rgba(90, 0, 0, 0.9);
    border: 2px solid #ff6666;
    border-radius: 6px;
    color: #fff;
    font-family: 'Courier New', monospace;
    box-shadow: 0 0 12px rgba(0,0,0,0.7);
    z-index: 9999;
}

.error-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

#error-panel button {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}

#error-list {
    margin: 8px 0 0 18px;
    padding: 0;
}

#error-list li {
    margin-bottom: 6px;
    font-size: 14px;
}

#error-list li.warning {
    color: #ffcc66;
}

#error-list li.fatal {
    color: #ff7777;
}
