* {
    box-sizing: border-box;
}

:root {
    --paper: #eadfca;
    --ink: #2f261e;
    --panel: #251b14;
    --gold: #c8a264;
    --selected: #fff2b7;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top, #3a2a1d 0%, #16110d 75%);
    color: var(--paper);
    font-family: Georgia, "Times New Roman", serif;
}

body {
    padding: 18px;
}

.game-wrap {
    width: min(1180px, 100%);
    margin: 0 auto;
}

.intro {
    margin: 0 auto 14px;
    max-width: 950px;
    text-align: center;
}

.intro h1 {
    margin: 0 0 6px;
    font-size: clamp(1.6rem, 4vw, 2.6rem);
}

.intro p {
    margin: 0;
    line-height: 1.45;
    color: #e1d2b8;
}

.scene {
    position: relative;
    width: 100%;
    overflow: hidden;
    border: 2px solid #6c5437;
    border-radius: 12px;
    background: #120e0b;
    box-shadow: 0 15px 45px rgba(0,0,0,.45);
    user-select: none;
    touch-action: manipulation;
}

.scene-bg {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

.game-object {
    --object-scale: 1;
    --base-width: 8%;
    position: absolute;
    left: 50%;
    top: 80%;
    width: var(--base-width);
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    transform:
        translate(-50%, -100%)
        scale(var(--object-scale));
    transform-origin: 50% 100%;
    cursor: pointer;
    z-index: 20;
    filter: drop-shadow(0 .4rem .35rem rgba(0,0,0,.36));
    transition:
        left .18s ease,
        top .18s ease,
        transform .18s ease,
        filter .16s ease;
}

.game-object img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

.game-object .fallback {
    display: none;
    padding: 6px 7px;
    background: rgba(30,20,12,.88);
    border: 1px solid #d1ad6d;
    border-radius: 7px;
    color: white;
    font: 700 .8rem/1 Arial, sans-serif;
}

/* Falls ein PNG noch fehlt, erscheint wenigstens ein Platzhalter */
.game-object.image-missing img {
    display: none;
}
.game-object.image-missing .fallback {
    display: inline-block;
}

.game-object.selected {
    filter:
        drop-shadow(0 0 .3rem #fff)
        drop-shadow(0 0 .75rem #f3c65c)
        drop-shadow(0 .4rem .35rem rgba(0,0,0,.36));
}

.game-object.tree {
    --base-width: 26.5%;
}

.game-object.horse {
    --base-width: 20%;
}

.game-object.red {
    --base-width: 8.8%;
}

.game-object.green {
    --base-width: 7.4%;
}

.game-object.yellow {
    --base-width: 6%;
}

.game-object.tree-lit {
    filter:
        brightness(1.18)
        drop-shadow(0 0 .45rem #ffe77e)
        drop-shadow(0 0 1.3rem #ffd94f);
}

.game-object.tree-blink {
    animation: treeBlink .58s ease-in-out 6;
}

@keyframes treeBlink {
    0%, 45% {
        filter:
            brightness(1.25)
            drop-shadow(0 0 .5rem #fff0a0)
            drop-shadow(0 0 1.5rem #ffd94f);
    }
    55%, 100% {
        filter: brightness(.72);
    }
}

.controls {
    margin-top: 14px;
    padding: 14px;
    border: 1px solid #6c5437;
    border-radius: 12px;
    background: rgba(35,25,18,.92);
    text-align: center;
}

.object-select {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.object-select button,
.reset {
    padding: 8px 12px;
    border: 1px solid #9d7948;
    border-radius: 8px;
    background: #3a2b1e;
    color: #f1e4ce;
    font: 700 .95rem Georgia, serif;
    cursor: pointer;
}

.object-select button.active {
    background: #7b5b2b;
    color: #fff8d7;
    border-color: #e3c47b;
}

.selected-line {
    margin: 12px 0 6px;
    min-height: 1.5em;
}

.debug-position {
    display: none;
    margin-left: 10px;
    font: .85rem Consolas, monospace;
    color: #f9d97a;
}

body.debug .debug-position {
    display: inline;
}

.move-controls {
    width: min(310px, 100%);
    margin: 8px auto 10px;
    display: grid;
    grid-template-columns: 72px 1fr 72px;
    grid-template-rows: 56px 62px 56px;
    gap: 7px;
    align-items: stretch;
}

.arrow,
.finish {
    border: 1px solid #b08c53;
    border-radius: 9px;
    background: linear-gradient(#ead8b7, #c9aa78);
    color: #2d241b;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 3px 0 #715738;
}

.arrow {
    font-size: 1.65rem;
}

.finish {
    font: 800 1rem Georgia, serif;
}

.arrow:active,
.finish:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #715738;
}

.status {
    min-height: 1.5em;
    margin: 8px auto;
    color: #eadcbd;
}

.status.good {
    color: #fff2a6;
    font-weight: 700;
}

.status.bad {
    color: #f2c0b5;
}

.reset {
    margin-top: 5px;
    font-size: .85rem;
}

/* Debugpunkte */
.grid-debug {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 80;
}

.grid-point {
    position: absolute;
    width: 7px;
    height: 7px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(0,255,255,.75);
    outline: 1px solid rgba(0,0,0,.8);
}

.grid-point::after {
    content: attr(data-label);
    position: absolute;
    left: 8px;
    top: -8px;
    color: white;
    background: rgba(0,0,0,.55);
    padding: 1px 3px;
    border-radius: 3px;
    font: 8px/1.2 Consolas, monospace;
    white-space: nowrap;
}

body:not(.debug) .grid-debug {
    display: none;
}

/* Platzhalter für spätere Effekte */
.window-effect,
.fireplace-effect {
    position: absolute;
    pointer-events: none;
    opacity: 0;
    transition: opacity .6s ease;
}

.window-effect.active,
.fireplace-effect.active {
    opacity: 1;
}

@media (max-width: 700px) {
    body {
        padding: 8px;
    }

    .intro p {
        font-size: .95rem;
    }

    .controls {
        margin-top: 8px;
        padding: 10px 7px;
    }

    .object-select {
        gap: 5px;
    }

    .object-select button {
        padding: 7px 9px;
        font-size: .82rem;
    }

    .move-controls {
        grid-template-columns: 64px 1fr 64px;
    }
}


/* ============================================================
   WEIHNACHTLICHE BEDIENUNG / SCHUBLADE
   ============================================================ */

.christmas-controls {
    background:
        linear-gradient(rgba(35,25,18,.94), rgba(25,18,13,.96)),
        repeating-linear-gradient(
            90deg,
            rgba(255,255,255,.025) 0 2px,
            rgba(0,0,0,.025) 2px 5px
        );
}

/* Die alten generischen Arrow-/Finish-Regeln neutralisieren wir hier. */
.move-controls-christmas .wood-arrow,
.move-controls-christmas .bell-button {
    border: 0;
    cursor: pointer;
    color: #2a1d11;
    user-select: none;
}

.wood-arrow {
    position: relative;
    border-radius: 11px !important;
    background:
        linear-gradient(180deg, #b78348 0%, #81552e 52%, #643d22 100%) !important;
    box-shadow:
        inset 0 0 0 2px rgba(255,224,170,.32),
        inset 0 -6px 10px rgba(63,31,11,.35),
        0 4px 0 #422817,
        0 7px 12px rgba(0,0,0,.28) !important;
    font-size: 1.7rem;
    text-shadow: 0 1px 0 rgba(255,231,192,.5);
}

.wood-arrow::before {
    content: "";
    position: absolute;
    inset: 5px;
    border: 1px solid rgba(66,38,19,.55);
    border-radius: 7px;
    pointer-events: none;
}

.wood-arrow:hover {
    filter: brightness(1.08);
}

.wood-arrow:active {
    transform: translateY(3px);
    box-shadow:
        inset 0 0 0 2px rgba(255,224,170,.25),
        inset 0 -3px 8px rgba(63,31,11,.35),
        0 1px 0 #422817 !important;
}

/* Glocke an Stelle von "Fertig" */
.bell-button {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 4px 8px;
    border-radius: 50% 50% 13px 13px !important;
    background:
        radial-gradient(circle at 38% 27%, #fff0a9 0 6%, transparent 7%),
        linear-gradient(145deg, #f3cc61, #b97919 58%, #74400b) !important;
    box-shadow:
        inset 0 0 0 2px rgba(255,245,185,.55),
        inset 0 -6px 11px rgba(81,39,4,.35),
        0 4px 0 #56320f,
        0 7px 14px rgba(0,0,0,.32) !important;
    overflow: hidden;
}

.bell-button:hover {
    filter: brightness(1.08);
}

.bell-button:active {
    transform: translateY(3px);
    box-shadow:
        inset 0 0 0 2px rgba(255,245,185,.45),
        0 1px 0 #56320f !important;
}

.bell-button.ring {
    animation: bellRing .62s ease;
}

@keyframes bellRing {
    0%   { transform: rotate(0deg); }
    18%  { transform: rotate(-7deg); }
    38%  { transform: rotate(7deg); }
    58%  { transform: rotate(-4deg); }
    78%  { transform: rotate(3deg); }
    100% { transform: rotate(0deg); }
}

.bell-icon {
    font-size: 1.7rem;
    line-height: 1;
    filter: drop-shadow(0 1px 0 rgba(255,255,255,.35));
}

.bell-label {
    font: 700 .68rem/1 Georgia, serif;
    color: #38210d;
    white-space: nowrap;
}

/* ------------------------------------------------------------
   Schublade
   ------------------------------------------------------------ */

.drawer-wrap {
    width: min(700px, 100%);
    margin: 20px auto 14px;
    perspective: 900px;
}

.drawer-front {
    position: relative;
    width: 100%;
    min-height: 86px;
    padding: 10px 90px 10px 90px;
    border: 2px solid #4a2a16;
    border-radius: 8px;
    background:
        linear-gradient(rgba(255,255,255,.06), rgba(0,0,0,.10)),
        repeating-linear-gradient(
            4deg,
            #8a582d 0 5px,
            #825128 5px 11px,
            #925e31 11px 16px
        );
    box-shadow:
        inset 0 0 0 3px rgba(192,134,71,.24),
        inset 0 -13px 22px rgba(52,25,10,.28),
        0 6px 0 #3c2415,
        0 10px 18px rgba(0,0,0,.3);
    color: #f5ddb6;
    cursor: pointer;
    font-family: Georgia, serif;
}

.drawer-label {
    display: block;
    font-size: clamp(1.15rem, 3vw, 1.55rem);
    text-shadow: 0 2px 2px rgba(40,18,7,.85);
}

.drawer-hint {
    display: block;
    margin-top: 3px;
    font-size: .72rem;
    color: #d5b98e;
}

.drawer-handle {
    position: absolute;
    left: 50%;
    bottom: 12px;
    width: 58px;
    height: 14px;
    transform: translateX(-50%);
    border: 3px solid #2c2117;
    border-top: 0;
    border-radius: 0 0 22px 22px;
    background: linear-gradient(#c39a48, #76531d);
    box-shadow: 0 2px 3px rgba(0,0,0,.45);
}

.drawer-inside {
    padding: 17px 15px 16px;
    border: 2px solid #49301e;
    border-top: 0;
    border-radius: 0 0 10px 10px;
    background:
        radial-gradient(circle at 50% 0, rgba(172,119,61,.17), transparent 55%),
        #24170f;
    box-shadow:
        inset 0 12px 20px rgba(0,0,0,.42),
        0 7px 15px rgba(0,0,0,.28);
}

.drawer-inside[hidden] {
    display: none;
}

.drawer-intro {
    margin: 0 0 12px;
    color: #d8c2a2;
}

.drawer-items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.drawer-item {
    min-height: 118px;
    padding: 10px 8px;
    border: 1px solid #806344;
    border-radius: 8px;
    background: #ddc59e;
    color: #312315;
    cursor: pointer;
    font: 700 .9rem/1.2 Georgia, serif;
    box-shadow:
        0 4px 0 #5c4028,
        0 7px 10px rgba(0,0,0,.25);
}

.drawer-item:hover {
    transform: translateY(-2px);
    filter: brightness(1.04);
}

.item-picture {
    display: block;
    margin-bottom: 7px;
    font-size: 2.55rem;
    line-height: 1;
}

.book-picture {
    display: grid;
    width: 48px;
    height: 55px;
    margin: 0 auto 7px;
    place-items: center;
    border: 3px ridge #876326;
    border-radius: 4px 8px 8px 4px;
    background: #8f2e24;
    color: #dcb85f;
    font-size: 1.6rem;
}

/* ------------------------------------------------------------
   Overlays: Brief / Karte / Atlas
   ------------------------------------------------------------ */

.story-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(8,5,3,.78);
    backdrop-filter: blur(3px);
}

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

.story-card {
    position: relative;
    width: min(820px, 96vw);
    max-height: 90vh;
    overflow: auto;
    padding: 28px clamp(18px, 5vw, 44px);
    border: 2px solid #876b43;
    border-radius: 9px;
    background:
        radial-gradient(circle at 50% 0, rgba(255,255,255,.18), transparent 42%),
        #e8d2a7;
    color: #342718;
    box-shadow:
        0 18px 60px rgba(0,0,0,.65),
        inset 0 0 35px rgba(113,72,27,.16);
}

.story-card h2 {
    margin: 0 36px 18px 0;
    color: #642f22;
    font-size: clamp(1.35rem, 4vw, 2rem);
}

.close-panel {
    position: absolute;
    right: 11px;
    top: 9px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: #7c4b2a;
    color: white;
    cursor: pointer;
    font-size: 1.6rem;
    line-height: 1;
}

.letter-text {
    font-size: 1.02rem;
    line-height: 1.55;
}

.letter-text p {
    margin: 0 0 1em;
}

.look-hint {
    font-weight: 700;
    color: #6d321f;
}

.map-card {
    width: min(1100px, 97vw);
}

.christmas-map {
    display: block;
    width: 100%;
    height: auto;
    border: 2px solid #725235;
    border-radius: 5px;
    box-shadow: 0 6px 15px rgba(0,0,0,.25);
}

.map-note {
    text-align: center;
    font-style: italic;
}

.atlas-card {
    width: min(620px, 95vw);
    background:
        linear-gradient(90deg, rgba(112,59,29,.08) 49.5%, rgba(81,42,20,.16) 50%, rgba(112,59,29,.08) 50.5%),
        #e5cca0;
}

.atlas-field {
    display: block;
    margin: 17px 0;
}

.atlas-field span {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

.atlas-field input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #82613d;
    border-radius: 5px;
    background: rgba(255,250,229,.78);
    color: #332415;
    font: 1rem Georgia, serif;
}

.atlas-lookup {
    display: block;
    margin: 20px auto 8px;
    padding: 11px 18px;
    border: 1px solid #62431f;
    border-radius: 7px;
    background: linear-gradient(#9d6a32, #6f441e);
    color: #fff1d1;
    cursor: pointer;
    font: 700 1rem Georgia, serif;
    box-shadow: 0 3px 0 #432813;
}

.atlas-result {
    min-height: 2.7em;
    margin-top: 14px;
    padding: 9px;
    text-align: center;
    border-radius: 6px;
}

.atlas-result.correct {
    background: rgba(83,113,55,.16);
    color: #375225;
    font-weight: 700;
}

.atlas-result.wrong {
    background: rgba(137,55,37,.12);
    color: #7e3124;
}

@media (max-width: 650px) {
    .drawer-front {
        padding-left: 25px;
        padding-right: 25px;
    }

    .drawer-items {
        grid-template-columns: 1fr;
    }

    .drawer-item {
        min-height: 82px;
    }

    .item-picture {
        font-size: 2rem;
    }

    .bell-label {
        display: none;
    }
}


/* ============================================================
   V4 – ECHTE PNG-BEDIENUNG
   ============================================================ */

.move-controls-christmas {
    grid-template-columns: 86px minmax(105px, 150px) 86px;
    grid-template-rows: 70px 112px 70px;
    gap: 7px 12px;
}

.png-control {
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible;
}

.png-control img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 5px 5px rgba(0,0,0,.35));
    transition: transform .12s ease, filter .12s ease;
}

.png-control:hover img {
    transform: translateY(-2px);
    filter:
        brightness(1.08)
        drop-shadow(0 6px 6px rgba(0,0,0,.38));
}

.png-control:active img {
    transform: translateY(2px) scale(.97);
}

.png-arrow {
    width: 86px;
    height: 70px;
}

.bell-button-png {
    position: relative;
    width: 112px;
    height: 112px;
    justify-self: center;
    align-self: center;
}

.bell-button-png img {
    width: 100%;
    height: 92px;
}

.bell-caption {
    position: absolute;
    left: 50%;
    bottom: -1px;
    transform: translateX(-50%);
    white-space: nowrap;
    color: #ead7b4;
    font: 700 .74rem/1 Georgia, serif;
    text-shadow: 0 2px 2px #000;
}

.bell-button-png.ring img {
    animation: bellPngRing .6s ease;
}

@keyframes bellPngRing {
    0%   { transform: rotate(0); }
    18%  { transform: rotate(-8deg); }
    38%  { transform: rotate(8deg); }
    58%  { transform: rotate(-4deg); }
    78%  { transform: rotate(3deg); }
    100% { transform: rotate(0); }
}

/* ---------------- PNG-Schublade ---------------- */

.drawer-image-wrap {
    position: relative;
    width: min(760px, 100%);
    margin: 24px auto 16px;
}

.drawer-image-button {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.drawer-image-button img {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 8px 8px rgba(0,0,0,.4));
    transition: transform .18s ease, filter .18s ease;
}

.drawer-image-button:hover img {
    transform: translateY(-2px);
    filter:
        brightness(1.04)
        drop-shadow(0 10px 10px rgba(0,0,0,.42));
}

.drawer-open-hotspots {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 5;
    pointer-events: none;
}

.drawer-open-hotspots[hidden],
.drawer-labels[hidden] {
    display: none;
}

.drawer-hotspot {
    position: absolute;
    top: 5%;
    height: 45%;
    border: 0;
    background: transparent;
    cursor: pointer;
    pointer-events: auto;
    border-radius: 10px;
}

.drawer-hotspot:hover {
    background: rgba(255,244,184,.10);
    outline: 2px solid rgba(255,225,128,.22);
}

.hotspot-letter {
    left: 10%;
    width: 28%;
}

.hotspot-map {
    left: 37%;
    width: 26%;
}

.hotspot-atlas {
    left: 64%;
    width: 27%;
}

.drawer-labels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    margin-top: 5px;
    color: #dcc6a0;
    font: 700 .78rem/1.2 Georgia, serif;
    text-align: center;
}

/* alte V3-Schublade komplett ausblenden, falls noch Restregeln greifen */
.drawer-front,
.drawer-inside {
    display: none !important;
}

@media (max-width: 650px) {
    .move-controls-christmas {
        grid-template-columns: 66px minmax(90px, 120px) 66px;
        grid-template-rows: 56px 96px 56px;
    }

    .png-arrow {
        width: 66px;
        height: 56px;
    }

    .bell-button-png {
        width: 92px;
        height: 96px;
    }

    .bell-button-png img {
        height: 80px;
    }

    .bell-caption {
        display: none;
    }
}


/* Final-Ausgabe im Weihnachtsatlas */
.atlas-coordinates {
    display: inline-block;
    font-size: 1.12em;
    letter-spacing: .04em;
}
