:root {
    --bg-dark: #0f2417;
    --bg-medium: #1a3a25;
    --green-primary: #2d5a3d;
    --green-light: #3d7a52;
    --red-primary: #c41e3a;
    --red-dark: #8b1528;
    --gold: #d4af37;
    --gold-light: #f4d03f;
    --cream: #faf3e0;
    --white: #ffffff;
}

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

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-medium) 50%, var(--bg-dark) 100%);
    min-height: 100vh;
    color: var(--cream);
    overflow-x: hidden;
}

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

.title {
    font-family: 'Mountains of Christmas', cursive;
    font-size: clamp(2rem, 5vw, 3.5rem);
    text-align: center;
    color: var(--gold);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 1rem;
    padding-top: 0.5rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
    flex: 1;
    align-content: center;
}

.day-card {
    aspect-ratio: 1;
    perspective: 1000px;
    cursor: pointer;
}

.day-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.day-card.opened .day-card-inner {
    transform: rotateY(180deg);
}

.day-card-front,
.day-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.day-card-front {
    background: linear-gradient(145deg, var(--red-primary) 0%, var(--red-dark) 100%);
    border: 3px solid var(--gold);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 2px 10px rgba(255, 255, 255, 0.1);
}

.day-card-front::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gold);
    transform: translateY(-50%);
}

.day-card-front::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gold);
    transform: translateX(-50%);
}

.day-number {
    font-family: 'Mountains of Christmas', cursive;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    color: var(--cream);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 1;
    background: var(--red-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
}

.day-card-back {
    background: linear-gradient(145deg, var(--green-light) 0%, var(--green-primary) 100%);
    border: 3px solid var(--gold);
    transform: rotateY(180deg);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 2px 10px rgba(255, 255, 255, 0.1);
}

.day-card-back .day-number {
    background: var(--green-primary);
}

.day-card:not(.opened):hover .day-card-inner {
    transform: scale(1.05);
}

.day-card:not(.opened):hover .day-card-front {
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.4),
        inset 0 2px 10px rgba(255, 255, 255, 0.2),
        0 0 20px var(--gold-light);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 1rem;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: linear-gradient(145deg, var(--bg-medium) 0%, var(--bg-dark) 100%);
    border: 3px solid var(--gold);
    border-radius: 20px;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
    position: relative;
    transform: scale(0.8);
    transition: transform 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--gold);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--gold-light);
}

.modal-day {
    font-family: 'Mountains of Christmas', cursive;
    font-size: 4rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 0.5rem;
}

.modal-title {
    font-family: 'Nunito', sans-serif;
    font-size: 1.5rem;
    color: var(--cream);
    margin-bottom: 1.5rem;
}

.password-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    border: 2px solid var(--gold);
    border-radius: 10px;
    background: var(--bg-dark);
    color: var(--cream);
    text-align: center;
    margin-bottom: 1rem;
    font-family: 'Nunito', sans-serif;
}

.password-input:focus {
    outline: none;
    border-color: var(--gold-light);
    box-shadow: 0 0 10px var(--gold);
}

.password-input::placeholder {
    color: rgba(250, 243, 224, 0.5);
}

.error-message {
    color: var(--red-primary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.error-message.visible {
    opacity: 1;
}

.submit-btn {
    background: linear-gradient(145deg, var(--red-primary) 0%, var(--red-dark) 100%);
    color: var(--cream);
    border: 2px solid var(--gold);
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(196, 30, 58, 0.4);
}

.modal-instructions {
    max-width: 500px;
}

.instructions-content {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--cream);
    text-align: left;
    white-space: pre-wrap;
}

.snowflakes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

.snowflake {
    position: absolute;
    top: -20px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.5rem;
    animation: fall linear infinite;
}

.snowflake:nth-child(1) { left: 5%; animation-duration: 12s; animation-delay: 0s; font-size: 1.2rem; }
.snowflake:nth-child(2) { left: 15%; animation-duration: 15s; animation-delay: 2s; font-size: 1.8rem; }
.snowflake:nth-child(3) { left: 25%; animation-duration: 10s; animation-delay: 4s; font-size: 1rem; }
.snowflake:nth-child(4) { left: 35%; animation-duration: 18s; animation-delay: 1s; font-size: 1.5rem; }
.snowflake:nth-child(5) { left: 45%; animation-duration: 13s; animation-delay: 3s; font-size: 2rem; }
.snowflake:nth-child(6) { left: 55%; animation-duration: 16s; animation-delay: 5s; font-size: 1.3rem; }
.snowflake:nth-child(7) { left: 65%; animation-duration: 11s; animation-delay: 2s; font-size: 1.7rem; }
.snowflake:nth-child(8) { left: 75%; animation-duration: 14s; animation-delay: 4s; font-size: 1.1rem; }
.snowflake:nth-child(9) { left: 85%; animation-duration: 17s; animation-delay: 1s; font-size: 1.9rem; }
.snowflake:nth-child(10) { left: 95%; animation-duration: 12s; animation-delay: 3s; font-size: 1.4rem; }

@keyframes fall {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0.3;
    }
}

@media (max-width: 900px) {
    .calendar-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 600px) {
    .calendar-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }
    
    .container {
        padding: 0.5rem;
    }
    
    .title {
        margin-bottom: 0.5rem;
    }
    
    .modal {
        padding: 1.5rem;
    }
    
    .modal-day {
        font-size: 3rem;
    }
}

@media (max-width: 400px) {
    .calendar-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-height: 700px) {
    .title {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
        padding-top: 0.25rem;
    }
    
    .calendar-grid {
        gap: 0.4rem;
    }
}

body.loading .day-card {
    pointer-events: none;
    opacity: 0.6;
}

body.loading .title::after {
    content: ' ⏳';
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.error-message-global {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--red-primary);
    font-size: 1.2rem;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 2px solid var(--red-primary);
}

