:root {
    --night: #13233d;
    --deep: #0b1427;
    --sky: #223d5d;
    --snow: #e8f2fb;
    --gold: #ffd77a;
    --green: #287060;
    --red: #b44752;
    --ink: #13233d;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: ui-monospace, 'Courier New', monospace;
    color: #f6f5ee;
    background: linear-gradient(180deg, #0b1427, #1a3555 65%, #284965);
}

button {
    font: inherit;
    cursor: pointer;
}

.site-header {
    text-align: center;
    padding: 38px 16px 20px;
    position: relative;
    z-index: 1;
}

.eyebrow {
    letter-spacing: .18em;
    text-transform: uppercase;
    font-size: .74rem;
    color: var(--gold);
    margin: 0 0 8px;
}

h1 {
    font-size: clamp(1.65rem, 5vw, 3rem);
    line-height: 1.3;
    margin: 0;
    text-shadow: 4px 4px 0 #09111e;
    letter-spacing: .035em;
}

h1 span {
    color: var(--gold);
}

.site-header>p:last-child {
    color: #cedcec;
    font-size: .94rem;
}

.site-main {
    width: min(1050px, calc(100% - 28px));
    margin: auto;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #0d1b2f;
    border: 3px solid #607893;
    border-bottom: 0;
    color: #d9e8f6;
    font-size: .84rem;
}

.village {
    position: relative;
    min-height: 570px;
    background: linear-gradient(180deg, #152744 2%, #2c567b 72%, #92b1c2);
    overflow: hidden;
    border: 3px solid #607893;
    isolation: isolate;
}

.village-title {
    position: relative;
    z-index: 3;
    padding-top: 16px;
    text-align: center;
    color: #ffdf93;
    font-size: .9rem;
    letter-spacing: .12em;
    text-shadow: 2px 2px #111;
}

.moon {
    position: absolute;
    top: 35px;
    right: 12%;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: #fff0b5;
    box-shadow: 0 0 45px #fff4b780;
}

.stars {
    position: absolute;
    top: 20px;
    left: 4%;
    color: #fff6d3;
    opacity: .85;
    letter-spacing: 28px;
    white-space: nowrap;
}

.mountains {
    position: absolute;
    inset: auto 0 65px;
    height: 230px;
    background: #617c97;
    clip-path: polygon(0% 100%, 0% 75%, 15% 35%, 30% 80%, 47% 20%, 65% 80%, 83% 32%, 100% 85%, 100% 100%);
    opacity: .55;
}

.ground {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 78px;
    background: repeating-linear-gradient(90deg, #d5e8f3 0 18px, #e6f4fb 18px 40px);
    clip-path: polygon(0 10%, 15% 20%, 32% 4%, 50% 18%, 76% 5%, 100% 16%, 100% 100%, 0 100%);
}

.scene-items {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.house {
    position: absolute;
    bottom: 65px;
    width: 190px;
    height: 135px;
    background: #a7555a;
    border: 8px solid #683d53;
    box-shadow: 12px 0 0 #48354d;
}

.house-left {
    left: 7%;
}

.house-right {
    right: 8%;
    width: 175px;
    height: 155px;
    background: #b38c5f;
    border-color: #785c58;
}

.roof {
    position: absolute;
    width: calc(100% + 35px);
    height: 48px;
    top: -44px;
    left: -18px;
    background: #e5ebee;
    clip-path: polygon(50% 0, 100% 90%, 100% 100%, 0 100%, 0 90%);
}

.window {
    position: absolute;
    top: 24px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: #ffda78;
    border: 6px solid #69475b;
    box-shadow: inset 17px 0 0 -13px #69475b;
}

.door {
    position: absolute;
    bottom: 0;
    left: 22px;
    width: 50px;
    height: 76px;
    background: #5c3950;
    border: 6px solid #392941;
}

.tree {
    position: absolute;
    bottom: 60px;
    width: 0;
    height: 0;
    border-left: 65px solid transparent;
    border-right: 65px solid transparent;
    border-bottom: 190px solid #235a50;
    filter: drop-shadow(7px 5px 0 #163c42);
}

.tree:after {
    content: '★';
    position: absolute;
    left: -14px;
    top: 30px;
    color: #f5d57c;
    font-size: 32px;
}

.tree-left {
    left: 37%;
    transform: scale(.65);
    transform-origin: bottom;
}

.tree-middle {
    left: 45%;
}

.tree-right {
    right: 0%;
    transform: scale(.6);
    transform-origin: bottom;
}

.doors {
    position: relative;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 12px;
    padding: 48px clamp(15px, 5%, 65px) 105px;
    max-width: 960px;
    margin: auto;
}

.day-door {
    width: 100%;
    aspect-ratio: 1/1;
    min-width: 0;
    position: relative;
    border: 4px solid #304660;
    background: #9e4253;
    color: #fff4d7;
    box-shadow: 5px 5px 0 #10223a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-shadow: 2px 2px #4e2533;
    transition: transform .12s, background .12s;
}

.day-door:nth-child(3n) {
    background: #2e786b;
}

.day-door:nth-child(4n) {
    background: #a06b42;
}

.day-door:nth-child(5n) {
    background: #4b668f;
}

.day-door .number {
    font-weight: 900;
    font-size: clamp(1rem, 2.4vw, 1.6rem);
}

.day-door .symbol {
    font-size: 1rem;
    line-height: 1;
}

.day-door:not(:disabled):hover,
.day-door:not(:disabled):focus-visible {
    transform: translate(-2px, -3px);
    outline: 3px solid #fce093;
    outline-offset: 2px;
}

.day-door:disabled {
    cursor: not-allowed;
    filter: brightness(.64) saturate(.6);
}

.day-door.today {
    outline: 3px solid #ffd878;
    outline-offset: 3px;
    animation: glow 2s infinite alternate;
}

.day-door.visited {
    background: #32596b;
    border-color: #779d9e;
}

@keyframes glow {
    to {
        box-shadow: 5px 5px 0 #10223a, 0 0 25px #f3c870aa;
    }
}

.hint {
    text-align: center;
    color: #e1eaf4;
    font-size: .88rem;
    margin: 20px 0;
    line-height: 1.6;
}

footer {
    text-align: center;
    color: #a4bcd0;
    font-size: .75rem;
    padding: 4px 0 38px;
}


/* Modal window */

.day-modal {
    width: min(740px, calc(100% - 32px));
    max-width: 740px;
    max-height: min(90dvh, 900px);

    padding: 0;
    overflow: hidden;

    color: #f2eee5;
    background: #102139;

    border: 4px solid #e2be78;
    border-radius: 3px;

    box-shadow:
        0 0 0 5px #0a1527,
        12px 12px 0 rgba(0, 0, 0, 0.45);
}

.day-modal[open] {
    display: flex;
    flex-direction: column;
    animation: modalAppear 220ms ease-out;
}

.day-modal::backdrop {
    background: rgba(3, 9, 20, 0.85);
    backdrop-filter: blur(4px);
}

/* Title bar */

.modal-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;

    padding: 18px 22px;
    flex-shrink: 0;

    background: #29445a;
    border-bottom: 3px solid #e2be78;
}

.modal-bar .eyebrow {
    color: #f0cb83;
    margin-bottom: 8px;
}

.modal-bar h2 {
    margin: 0;
    color: #fff4df;
    font-size: clamp(1.1rem, 3vw, 1.6rem);
    line-height: 1.4;
}

/* Modal content */

.modal-content {
    padding: 24px;
    overflow-y: auto;
    min-height: 0;
    line-height: 1.65;
}

.modal-content>p:first-child {
    margin-top: 0;
}

.modal-content img {
    display: block;
    max-width: 100%;
    max-height: 65vh;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 16px auto;
}

/* Preserve the game boards' own dimensions */

.modal-content iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    background: #050e1b;
}

/* Close button */

.pixel-button.close {
    flex-shrink: 0;
    padding: 5px 11px;
    background: #9b3947;
    color: #fff4df;
    border: 2px solid #e9bd83;
    box-shadow: 3px 3px 0 #172639;
}

.pixel-button.close:hover {
    background: #c04b58;
}

/* Opening animation */

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 600px) {
    .day-modal {
        width: calc(100% - 16px);
    }

    .modal-bar {
        padding: 14px 16px;
    }

    .modal-content {
        padding: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .day-modal[open] {
        animation: none;
    }
}


.pixel-button {
    background: #d8ae61;
    border: 3px solid #fff0bd;
    color: #152238;
    box-shadow: 3px 3px #091423;
    padding: 9px 15px;
    font-weight: bold;
}

.pixel-button:hover {
    background: #ffdb88;
}

.pixel-button:focus-visible {
    outline: 3px solid white;
    outline-offset: 3px;
}

.pixel-button.close {
    padding: 4px 10px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin: 12px 0;
    flex-wrap: wrap;
}

.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 420px;
    margin: 18px auto;
}

.memory-card {
    aspect-ratio: 1;
    background: #315577;
    border: 3px solid #8ca7b6;
    color: #ffe1a1;
    font-size: clamp(1.2rem, 5vw, 2.5rem);
}

.memory-card.revealed {
    background: #f4e7c6;
    color: #1e3141;
}

.memory-card.matched {
    background: #64a18f;
    color: #152b2c;
}

.maze-grid {
    display: grid;
    grid-template-columns: repeat(15, minmax(0, 1fr));
    width: min(100%, 405px);
    margin: 18px auto;
    border: 4px solid #dae6ed;
    --cell-size: 28px;
}

.maze-cell {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    font-size: clamp(15px, 3vw, 20px);
    background: #d8e6e8;
    color: #20324b;
}

.maze-cell {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    line-height: 1;
}

.maze-cell.wall {
    background: #31556b;
    box-shadow: inset 0 0 0 2px #244458;
}

.maze-controls {
    display: grid;
    grid-template-columns: repeat(3, 55px);
    justify-content: center;
    gap: 8px;
    margin: 14px auto;
}

.maze-controls button:nth-child(1) {
    grid-column: 2
}

.maze-controls button:nth-child(2) {
    grid-column: 1
}

.maze-controls button:nth-child(3) {
    grid-column: 2
}

.maze-controls button:nth-child(4) {
    grid-column: 3
}

.snow {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 9;
    opacity: .5;
    background-image: radial-gradient(white 1.5px, transparent 2px), radial-gradient(white 2px, transparent 2.5px);
    background-size: 83px 79px, 139px 113px;
    animation: snowfall 15s linear infinite;
}

@keyframes snowfall {
    to {
        background-position: 80px 650px, -90px 850px;
    }
}

@media(max-width:650px) {
    .village {
        min-height: 570px
    }

    .doors {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 10px;
        padding: 35px 22px 105px
    }

    .house-left {
        left: -8%;
        transform: scale(.7);
        transform-origin: bottom left
    }

    .house-right {
        right: -12%;
        transform: scale(.7);
        transform-origin: bottom right
    }

    .tree-middle {
        left: 34%
    }

    .tree-left {
        left: 15%
    }

    .status-bar {
        font-size: .72rem
    }

    .day-door {
        border-width: 3px
    }

    .day-door .number {
        font-size: 1.2rem
    }
}

@media(prefers-reduced-motion:reduce) {

    .snow,
    .day-door.today {
        animation: none
    }

    * {
        scroll-behavior: auto !important;
        transition: none !important
    }
}

/* Sokoban */
.sokoban-grid {
    display: grid;
    margin: 18px auto;
    gap: 2px;
    overflow: hidden;
}

.sokoban-cell {
    aspect-ratio: 1;
    min-width: 0;
    min-height: 0;
    box-sizing: border-box;

    display: grid;
    place-items: center;

    background: #d8e6e8;
    color: #243c50;

    font-size: clamp(14px, 3vw, 24px);
    line-height: 1;

    overflow: hidden;
}

.sokoban-cell.wall {
    background: #31556b;
    box-shadow: inset 0 0 0 2px #244458;
}

.sokoban-cell.goal {
    background: #b8d7b4;
    color: #426c4c;
    font-weight: bold;
}

.sokoban-cell.on-goal {
    background: #79b58d;
}

/* Sliding puzzle */

.sliding-grid {
    display: grid;
    grid-template-columns: repeat(var(--size), minmax(0, 1fr));
    width: min(100%, 420px);
    margin: 18px auto;
    border: 4px solid #e7c57c;
    background: #0b1727;
}

.sliding-tile {
    aspect-ratio: 1;
    min-width: 0;
    padding: 0;
    border: 2px solid #e7c57c;
    background-repeat: no-repeat;
    cursor: pointer;
}

.sliding-tile.empty {
    background: #0b1727;
    border-color: #243c50;
    cursor: default;
}

.sliding-tile:focus-visible {
    outline: 3px solid white;
    outline-offset: -3px;
}

.sliding-original {
    display: block;
    max-width: 300px !important;
    max-height: 300px;
    margin: 18px auto !important;
    object-fit: contain;
    border: 3px solid #e7c57c;
}

.sliding-original[hidden] {
    display: none;
}

.modal-content>.pixel-button {
    margin-right: 10px;
    margin-bottom: 10px;
}

/* --- Scene-based calendar layout --- */

.calendar-section {
    width: 100vw;
    max-width: none;
    margin-left: calc(50% - 50vw);
}

.calendar-scene-wrap {
    width: 100%;
    overflow-x: auto;
    padding: 0;
}

.calendar-scene {
    position: relative;
    width: 100%;
    min-width: 900px;
    max-width: none;
    margin: 0;
}

.calendar-background {
    display: block;
    width: 100%;
    height: auto;
    border: none;
    box-shadow: none;
    image-rendering: pixelated;
}

.calendar-scene,
.calendar-scene-wrap,
.calendar-background {
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.calendar-doors {
    position: absolute;
    inset: 0;
}


/* Calendar doors */

.calendar-door {
    position: absolute;
    left: var(--x);
    top: var(--y);
    transform: translate(-50%, -50%);

    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;

    padding: 0;
    border: 2px solid #e4c990;
    border-radius: 2px;

    background: rgba(25, 35, 49, 0.48);
    color: #fff1ce;

    font-size: 15px;
    font-weight: bold;
    line-height: 1;
    text-shadow: 1px 2px 1px #08121d;

    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.10),
        2px 3px 0 rgba(0, 0, 0, 0.35);

    cursor: pointer;
    z-index: 2;

    transition:
        background 0.2s,
        border-color 0.2s,
        box-shadow 0.2s,
        transform 0.2s;
}

/* Locked doors */

.calendar-door.locked {
    background: rgba(10, 18, 32, 0.42);
    border-color: rgba(195, 207, 220, 0.55);
    color: #d5dfeb;
    cursor: not-allowed;
}

/* Available doors */

.calendar-door.available {
    background: rgba(115, 65, 30, 0.48);
    border-color: #f3d28f;
    color: #fff2d5;
}

/* Visited doors */

.calendar-door.opened {
    background: rgba(25, 105, 73, 0.50);
    border-color: #9dd9ad;
    color: #e6ffed;
}

/* Hover */

.calendar-door:not(:disabled):hover {
    background: rgba(190, 115, 38, 0.82);
    border-color: #fff1b5;
    transform: translate(-50%, -50%) scale(1.14);

    box-shadow:
        0 0 16px rgba(255, 205, 105, 0.6),
        3px 4px 0 rgba(0, 0, 0, 0.4);
}

.calendar-door:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

/* Today's door */

.calendar-door.today {
    border-color: #ffe7a2;
    animation: doorGlow 2s ease-in-out infinite alternate;
}

@keyframes doorGlow {
    from {
        box-shadow: 0 0 5px rgba(255, 210, 100, 0.25);
    }

    to {
        box-shadow: 0 0 18px rgba(255, 210, 100, 0.9);
    }
}

/* Opening animation */

.calendar-door.opening {
    animation: doorOpen 220ms ease-in forwards !important;
    transform-origin: left center;
    pointer-events: none;
}

@keyframes doorOpen {
    from {
        transform: translate(-50%, -50%) rotateY(0deg);
        opacity: 1;
    }

    to {
        transform: translate(-50%, -50%) rotateY(-80deg);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {

    .calendar-door,
    .calendar-door.today,
    .calendar-door.opening {
        animation: none !important;
        transition: none !important;
    }
}


.status-text {
    margin-top: 14px;
    text-align: center;
}

/* Optional: slightly smaller buttons on smaller screens */
@media (max-width: 900px) {
    .calendar-door {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }
}

@media (min-width: 1200px) {
    .calendar-door {
        width: 48px;
        height: 48px;
        font-size: 16px;
    }
}

.mobile-notice {
    position: fixed;
    inset: 0;
    background: rgba(5, 10, 24, 0.78);
    display: grid;
    place-items: center;
    z-index: 1000;
    padding: 20px;
}

.mobile-notice-box {
    max-width: 420px;
    background: #1b2a4a;
    color: #fff;
    border: 4px solid #d9e6ff;
    padding: 20px;
    text-align: center;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.mobile-notice[hidden] {
    display: none;
}

/* Completed game indicator */

.calendar-door.completed::after {
    content: "★";
    position: absolute;
    top: -11px;
    right: -10px;

    display: grid;
    place-items: center;

    width: 19px;
    height: 19px;

    color: #fff3b5;
    background: #9c6728;
    border: 2px solid #f5d58d;
    border-radius: 50%;

    font-size: 12px;
    line-height: 1;
    text-shadow: 1px 1px 0 #63421c;

    box-shadow: 1px 2px 0 rgba(0, 0, 0, 0.4);
    pointer-events: none;
}


/* Christmas Lights game */

.lights-game {
    text-align: center;
}

.lights-board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 26px 34px;
    width: min(100%, 360px);
    margin: 26px auto 20px;
    padding: 26px 10px 10px;
}

/* wire */
.lights-board::before {
    content: "";
    position: absolute;
    left: 18px;
    right: 18px;
    top: 18px;
    height: 4px;
    background: #243244;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

/* bulb */
.light-button {
    position: relative;
    justify-self: center;

    width: 78px;
    height: 92px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;

    opacity: 0.9;
    transition:
        transform 0.12s ease,
        filter 0.12s ease,
        opacity 0.12s ease;
}

/* hanging cord */
.light-button::before {
    content: "";
    position: absolute;
    top: -18px;
    left: 50%;
    width: 4px;
    height: 20px;
    transform: translateX(-50%);
    background: #243244;
    border-radius: 2px;
}

/* bulb body */
.light-button::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 16px;
    width: 56px;
    height: 62px;
    transform: translateX(-50%);
    border-radius: 50% 50% 46% 46% / 44% 44% 56% 56%;
    border: 3px solid rgba(255, 255, 255, 0.35);
    box-shadow:
        inset -8px -10px 0 rgba(0, 0, 0, 0.10),
        inset 8px 8px 0 rgba(255, 255, 255, 0.12),
        0 4px 0 rgba(0, 0, 0, 0.18);
}

/* socket */
.light-button span {
    position: absolute;
    left: 50%;
    top: 4px;
    width: 26px;
    height: 18px;
    transform: translateX(-50%);
    background: #5c6673;
    border: 3px solid #d7dde7;
    border-bottom-width: 2px;
    border-radius: 4px 4px 6px 6px;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
    pointer-events: none;
}

.light-button.red::after {
    background: radial-gradient(circle at 35% 30%, #ffd0d0 0%, #ff8f8f 18%, #d84b4b 55%, #9e2020 100%);
    color: #d84b4b;
}

.light-button.green::after {
    background: radial-gradient(circle at 35% 30%, #d8ffe1 0%, #a2f2b8 18%, #42a96e 55%, #1f6a41 100%);
    color: #42a96e;
}

.light-button.yellow::after {
    background: radial-gradient(circle at 35% 30%, #fff8d6 0%, #ffe88b 18%, #e7bc48 55%, #a06e18 100%);
    color: #e7bc48;
}

.light-button.blue::after {
    background: radial-gradient(circle at 35% 30%, #d8ecff 0%, #9ecbff 18%, #468bd0 55%, #1e4f89 100%);
    color: #468bd0;
}

/* glowing / active state */
.light-button.active {
    opacity: 1;
    transform: scale(1.06);
    filter: brightness(1.18);
}

.light-button.active::after {
    box-shadow:
        inset -8px -10px 0 rgba(0, 0, 0, 0.08),
        inset 8px 8px 0 rgba(255, 255, 255, 0.18),
        0 0 10px currentColor,
        0 0 24px currentColor,
        0 0 40px color-mix(in srgb, currentColor 55%, transparent),
        0 4px 0 rgba(0, 0, 0, 0.18);
}

.light-button:not(:disabled):hover {
    opacity: 1;
    transform: translateY(-2px);
}

.light-button:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 4px;
    border-radius: 10px;
}

.light-button:disabled {
    cursor: default;
}

@media (max-width: 520px) {
    .lights-board {
        gap: 18px 20px;
        width: min(100%, 300px);
    }

    .light-button {
        width: 64px;
        height: 78px;
    }

    .light-button::after {
        width: 46px;
        height: 52px;
        top: 15px;
    }

    .light-button span {
        width: 22px;
        height: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .light-button {
        transition: none;
    }
}


/* Catch the Presents game */

.catch-game {
    text-align: center;
}

.catch-instructions {
    margin-bottom: 16px;
}

.catch-stats {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin: 12px auto;
    max-width: 480px;
    color: #f5d990;
    font-weight: bold;
    font-size: 14px;
}

#catchCanvas {
    display: block;
    width: 100%;
    max-width: 480px;
    height: auto;
    margin: 0 auto 16px;

    border: 4px solid #e2be78;
    background: #142943;

    image-rendering: pixelated;
    touch-action: none;
    cursor: crosshair;
}

#catchMessage {
    min-height: 3em;
    color: #f4e8ce;
}

.catch-game .pixel-button {
    margin: 8px auto;
}

@media (max-width: 520px) {
    .catch-stats {
        font-size: 12px;
    }
}


/* Christmas finale */

.finale {
    text-align: center;
}

.finale-scene {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 3px solid #e2be78;
    background: #071329;
    isolation: isolate;
}

.finale-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    filter: brightness(0.72) saturate(0.95);
}

/* Slight dark overlay at start */
.finale-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

/* Intro text */
.finale-intro {
    position: absolute;
    left: 10%;
    right: 10%;
    top: 9%;
    z-index: 5;

    color: #fff4d0;
    font-size: clamp(15px, 2.6vw, 26px);
    text-shadow: 2px 3px #071329;
    opacity: 0;
}

.finale-scene.playing .finale-intro {
    animation: finaleIntro 5.5s both;
}

@keyframes finaleIntro {

    0%,
    10% {
        opacity: 0;
    }

    20%,
    78% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* Illuminated background overlay */
/* Illuminated village - initially hidden */
.finale-bg-lit {
    position: absolute;
    inset: 0;
    z-index: 1;

    width: 100%;
    height: 100%;
    object-fit: cover;

    opacity: 0;
    visibility: hidden;
    transition:
        opacity 3s ease-in-out,
        visibility 0s linear 3s;
}

/* Gradually reveal the illuminated image */
.finale-scene.lights-on .finale-bg-lit {
    opacity: 1;
    visibility: visible;
    transition:
        opacity 3s ease-in-out,
        visibility 0s;
}

/* Sleigh image */
.finale-sleigh-img {
    position: absolute;
    top: 9%;
    left: -28%;
    width: min(32%, 320px);
    height: auto;
    z-index: 4;
    pointer-events: none;
    filter:
        drop-shadow(0 0 8px rgba(255, 220, 120, 0.55)) drop-shadow(0 8px 8px rgba(0, 0, 0, 0.3));
    opacity: 0;
}

.finale-scene.sleigh-fly .finale-sleigh-img {
    opacity: 1;
    animation: finaleSleighFly 5.6s linear both;
}

@keyframes finaleSleighFly {
    0% {
        left: -28%;
        top: 13%;
        transform: scale(0.9) rotate(-4deg);
    }

    18% {
        top: 10%;
    }

    45% {
        top: 8%;
        transform: scale(1) rotate(0deg);
    }

    70% {
        top: 11%;
    }

    100% {
        left: 108%;
        top: 6%;
        transform: scale(0.92) rotate(3deg);
    }
}

/* Snow */
.finale-snow {
    position: absolute;
    top: -10px;
    width: 4px;
    height: 4px;
    background: white;
    opacity: 0.8;
    border-radius: 50%;
    animation: finaleSnow linear infinite;
}

@keyframes finaleSnow {
    from {
        transform: translateY(-10px);
    }

    to {
        transform: translateY(520px);
    }
}

/* Greeting overlay */
.finale-greeting {
    position: absolute;
    inset: 0;
    z-index: 6;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;

    padding: 24px;
    background: rgba(5, 14, 29, 0.76);

    opacity: 0;
    visibility: hidden;
    transition: opacity 1.2s, visibility 1.2s;
}

.finale-scene.show-greeting .finale-greeting {
    opacity: 1;
    visibility: visible;
}

.finale-greeting h2 {
    margin: 0;
    color: #ffe3a1;
    font-size: clamp(22px, 4vw, 40px);
    text-shadow: 3px 3px #432e42;
}

.finale-greeting p {
    margin: 0;
    color: white;
    font-size: clamp(13px, 2vw, 18px);
    max-width: 700px;
}

.finale-photo {
    display: block;
    width: auto;
    max-width: min(80%, 320px) !important;
    max-height: 40%;
    object-fit: contain;
    margin: 6px auto 0 !important;
    border: 3px solid #e2be78;
}

.finale>.pixel-button {
    margin-top: 16px;
}

.day-modal.finale-modal {
    width: min(960px, calc(100% - 32px));
    max-width: 960px;
}

.day-modal.finale-modal {
    width: min(960px, calc(100% - 32px));
    max-width: 960px;
}

/* Santa's sparkle trail */

.finale-sparkles {
    position: absolute;
    inset: 0;
    z-index: 3;
    overflow: hidden;
    pointer-events: none;
}

.finale-sparkle {
    position: absolute;
    width: 5px;
    height: 5px;

    background: #ffeaa1;
    box-shadow:
        0 0 5px #ffdb72,
        0 0 10px rgba(255, 215, 100, 0.6);

    pointer-events: none;
    animation: sparkleFade 0.8s ease-out forwards;
}

.finale-sparkle:nth-child(3n) {
    width: 3px;
    height: 3px;
    background: #ffffff;
}

.finale-sparkle:nth-child(5n) {
    background: #b9e9ff;
}

@keyframes sparkleFade {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(var(--dx), var(--dy)) scale(0.2);
    }
}


/* Before / After comparison */

.before-after {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
}

.before-after-stage {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #142943;
    border: 3px solid #d8b978;
    user-select: none;
    touch-action: pan-y;
}

/* Images */

.before-after-image {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

.before-after-image.after {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    clip-path: inset(0 50% 0 0);
}

/* Labels */

.before-after-label {
    position: absolute;
    top: 12px;
    z-index: 3;

    padding: 5px 10px;
    color: white;
    background: rgba(10, 20, 35, 0.8);

    font-size: 13px;
    font-weight: bold;
    text-shadow: 1px 1px #000;
    pointer-events: none;
}

.before-label {
    right: 12px;
}

.after-label {
    left: 12px;
}

/* Divider */

.before-after-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;

    background: #fff4d0;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.7);

    transform: translateX(-50%);
    pointer-events: none;
    z-index: 4;
}

/* Slider handle */

.before-after-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    display: flex;
    align-items: center;
    justify-content: center;

    width: 44px;
    height: 44px;

    background: #29445a;
    border: 3px solid #f1d394;
    color: #fff4d0;

    font-size: 12px;
    letter-spacing: -3px;

    box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.4);
}

/* Invisible interactive range input */

.before-after-range {
    position: absolute;
    inset: 0;
    z-index: 5;

    width: 100%;
    height: 100%;
    margin: 0;

    opacity: 0;
    cursor: ew-resize;
    appearance: none;
    -webkit-appearance: none;
}

.before-after-range::-webkit-slider-runnable-track {
    height: 100%;
    background: transparent;
}

.before-after-range::-webkit-slider-thumb {
    width: 44px;
    height: 100%;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 0;
}

.before-after-range::-moz-range-track {
    height: 100%;
    background: transparent;
    border: 0;
}

.before-after-range::-moz-range-thumb {
    width: 44px;
    height: 100%;
    background: transparent;
    border: 0;
}

.before-after-stage:focus-within .before-after-handle {
    outline: 3px solid white;
    outline-offset: 3px;
}