body {
    margin: 0;
    font-family: 'Montserrat', Arial, sans-serif;
}

/* Christmas color tokens */
:root {
    --xmas-red: #C62828;
    --xmas-deep-red: #8B0000;
    --xmas-blue: #b1bcdb;
    --xmas-light: #FFF8E1;
    --xmas-accent: #FFD54F;
}

/* Main container styling */
.container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    margin: 20px auto;
    padding: 15px;
    max-width: 1200px;
}

/* Page header */
.site-header {
    text-align: center;
    padding: 24px 12px 8px;
    color: var(--xmas-light);
}
.site-header h1 {
    margin: 0;
    font-family: 'Merriweather', serif;
    font-weight: 700;
    color: var(--xmas-deep-red);
}

/* Box styling */
.box {
    aspect-ratio: 1;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    color: var(--xmas-light);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(16px, 4vw, 24px);
    cursor: pointer;
    transition: transform 0.3s ease;
    min-width: 80px;
    border-radius: 8px;
    position: relative;
    font-size: 0;
}

.box:hover {
    transform: scale(1.1);
}
/* Disabled state for future boxes */
.box.disabled {
    background-color: #ffffff;
    color: #242424;
    cursor: not-allowed;
    transform: none;
    opacity: 0.25;
    pointer-events: none; /* prevent clicks */
}

.box.disabled:hover {
    transform: none;
}

/* Modal overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: transparent;
    display: none; /* hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.overlay.open {
    display: flex;
}

/* Dark background on desktop only */
@media (min-width: 481px) {
    .overlay.open {
        background: rgba(0, 0, 0, 0.65);
    }
}

.modal {
    background: #fff;
    border-radius: 8px;
    max-width: 95vw;
    width: fit-content;
    max-height: 95vh;
    overflow: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    text-align: center;
    padding: 20px 20px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal img {
    width: auto;
    height: auto;
    display: block;
    margin: 12px auto 0;
    /* Constrain image to viewport so modal follows image shape on large screens */
    max-width: calc(100vw - 80px); /* leave space for overlay padding and margins */
    max-height: calc(100vh - 160px); /* leave space for title, caption and modal padding */
    object-fit: contain;
}

.modal h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #333;
    width: 100%;
}

#modalCaption {
    margin: 12px 0 0 0;
    font-size: 1.0rem;
    color: #333;
    max-width: 100%;
    text-align: center;
}

/* Close button in the top-right of the modal */
.close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 6px;
}

.close:hover {
    color: #000;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .modal {
        max-width: 90vw;
        max-height: 90vh;
        padding: 16px 16px 24px;
    }

    .modal img {
        max-width: 100%;
        margin: 10px auto 0;
    }

    .modal h2 {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }

    .close {
        font-size: 24px;
        top: 6px;
        right: 6px;
        padding: 8px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Snowflakes container (JS will populate with .flake elements) */
.snow {
    position: fixed;
    pointer-events: none;
    inset: 0;
    z-index: 1500;
    overflow: hidden;
}
.snow .flake {
    position: absolute;
    top: -10px;
    color: white;
    opacity: 0.85;
    user-select: none;
    will-change: transform;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    font-size: 18px;
    animation-name: fall;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

@keyframes fall {
    0% {
        transform: translateY(-10vh) rotate(0deg);
        opacity: 0.9;
    }
    100% {
        transform: translateY(110vh) rotate(360deg);
        opacity: 0.85;
    }
}

/* Snow toggle button (fixed, small) */
.theme-toggle {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 2000;
    background: var(--xmas-blue);
    color: var(--xmas-light);
    border: none;
    border-radius: 28px;
    padding: 10px 14px;
    font-size: 14px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.theme-toggle[aria-pressed="false"] {
    background: rgba(255,255,255,0.9);
    color: #333;
    border: 1px solid rgba(0,0,0,0.08);
}
.theme-toggle:focus {
    outline: 3px solid rgba(255,213,79,0.25);
}

@media (max-width: 480px) {
    .theme-toggle {
        right: 12px;
        bottom: 12px;
        padding: 10px;
        font-size: 13px;
    }
}

main {
    padding: 20px;
}

footer {
    background-color: #4CAF50;
    color: white;
    text-align: center;
    padding: 10px;
    position: fixed;
    bottom: 0;
    width: 100%;
}