:root {
    --bg: #1a1a1f;
    --fg: #e8e3d6;
    --card-bg: #0e0d11;
    --card-border: #4a4750;
    --accent: #8a1f28;
    --accent-hover: #6b1720;
    --moon: #e8dfb8;
    --spook-green: #7a9463;
    --muted: #948da0;
    --overlay-bg: rgba(3, 3, 5, 0.95);
}

:root[data-theme="dark"] {
    --bg: #030305;
    --fg: #efe9dc;
    --card-bg: #08080a;
    --card-border: #322f38;
    --accent: #b23540;
    --accent-hover: #8f2932;
    --moon: #f0e7c0;
    --spook-green: #8caf6e;
    --muted: #837c8c;
    --overlay-bg: rgba(0, 0, 0, 0.97);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
    background:
        linear-gradient(to bottom, rgba(0,0,0,0.25), rgba(0,0,0,0.7) 55%, rgba(0,0,0,0.94)) center / 100% 100% no-repeat fixed,
        url('/assets/img/burton-bg.svg') center bottom / cover no-repeat fixed,
        var(--bg);
    color: var(--fg);
    transition: background-color 0.2s, color 0.2s;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 3px dashed var(--moon);
}

.site-header h1 {
    margin: 0;
    font-family: 'Butcherman', cursive;
    font-weight: 400;
    font-size: 2rem;
    letter-spacing: 0.02em;
    color: var(--accent);
    text-shadow: 2px 2px 0 var(--card-border), 0 0 18px rgba(122, 31, 43, 0.35);
}

.site-header__moon, .site-header__bat {
    display: inline-block;
    filter: grayscale(0.2);
}

.site-header__bat { transform: scaleX(-1); }

.theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    font-size: 1.25rem;
    width: 2.75rem;
    height: 2.75rem;
    cursor: pointer;
}

.intro {
    text-align: center;
    color: var(--muted);
    max-width: 40rem;
    margin: 1.25rem auto;
    padding: 0 1rem;
    font-style: italic;
}

main { padding: 0 1rem 3rem; }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.9rem;
    max-width: 60rem;
    margin: 0 auto;
}

@media (min-width: 640px) {
    .calendar-grid { grid-template-columns: repeat(6, 1fr); }
}

.slot {
    position: relative;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
    transform: rotate(var(--tilt, 0deg));
}

/* Hand-cut, slightly-crooked picture frames instead of uniform rounded cards */
.slot { border-radius: 13px 5px 15px 4px; }
.calendar-grid .slot:nth-child(3n+1) { --tilt: -1.6deg; border-radius: 6px 16px 5px 14px; }
.calendar-grid .slot:nth-child(3n+2) { --tilt: 1.1deg; border-radius: 16px 6px 14px 5px; }
.calendar-grid .slot:nth-child(3n+3) { --tilt: -0.6deg; border-radius: 9px 12px 8px 13px; }

.slot__picture {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: grayscale(0.8) contrast(1.15) brightness(0.85);
}

.slot__number {
    position: absolute;
    top: 0.35rem;
    left: 0.4rem;
    background: rgba(0, 0, 0, 0.6);
    color: var(--moon);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.1rem 0.45rem;
    border-radius: 6px;
    z-index: 2;
}

.slot__label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.3rem 0.25rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: var(--moon);
}

.slot--open_for_draw {
    border-color: var(--moon);
    box-shadow: 0 0 0 3px var(--moon), 0 0 16px rgba(217, 199, 122, 0.45);
}

.slot__draw-button {
    position: absolute;
    inset: auto 0.4rem 0.4rem 0.4rem;
    background: var(--accent);
    color: var(--moon);
    border: 1px solid rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 0.5rem 0.4rem;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.8rem;
    z-index: 2;
}

.slot__draw-button:hover { background: var(--accent-hover); }
.slot__draw-button:disabled { opacity: 0.6; cursor: not-allowed; }

.slot__done-label {
    position: absolute;
    top: 0.35rem;
    right: 0.4rem;
    background: rgba(0, 0, 0, 0.6);
    color: var(--spook-green);
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    z-index: 2;
}

.draw-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.draw-overlay[hidden] { display: none; }

.draw-overlay__content {
    text-align: center;
    color: var(--moon);
}

#draw-result-text {
    font-family: 'Butcherman', cursive;
    font-size: 1.4rem;
    font-weight: 400;
    max-width: 22rem;
    margin: 1.5rem auto 0;
}

/* The mascot hangs and swings from a thread, like a little marionette */
.draw-animation {
    position: relative;
    display: inline-block;
    padding-top: 2.5rem;
}

.draw-animation::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 2.5rem;
    background: var(--muted);
    transform-origin: top center;
}

.draw-animation img {
    display: block;
    width: 160px;
    height: auto;
    object-fit: contain;
    filter: grayscale(0.7) contrast(1.1) drop-shadow(0 0 18px rgba(232, 223, 184, 0.35));
    transform-origin: top center;
    animation: marionette-swing 0.9s ease-in-out infinite;
}

@keyframes marionette-swing {
    0%, 100% { transform: rotate(-9deg); }
    50% { transform: rotate(9deg); }
}

.button {
    background: var(--accent);
    color: var(--moon);
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.5rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 1.25rem;
}
