body {
    margin: 0;
    background-color: #0a0a0a;
    color: #eeeeee;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.65;
}

* {
    box-sizing: border-box;
}

.site-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
}

h1 {
    text-align: center;
    font-size: clamp(1.5rem, 5vw, 2.2rem);
    line-height: 1.2;
    margin-bottom: 32px;
}

h2 {
    line-height: 1.3;
}

#start-screen,
#game {
    background-color: #171717;
    border: 1px solid #353535;
    border-radius: 12px;
    padding: 28px;
}

#start-screen {
    text-align: center;
}

#room-name {
    margin-top: 0;
    color: #e7c989;
}

#room-description {
    white-space: pre-line;
    margin-bottom: 28px;
}

button,
input {
    font: inherit;
}

button {
    min-height: 44px;
    padding: 10px 16px;
    color: #eeeeee;
    background-color: #292929;
    border: 1px solid #626262;
    border-radius: 6px;
    cursor: pointer;
}

button:hover {
    background-color: #3a3a3a;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid #e7c989;
    outline-offset: 3px;
}

#exits {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

#exits button {
    flex: 1 1 200px;
}

#exploration-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-top: 28px;
}

#exploration-form label {
    grid-column: 1 / -1;
}

#exploration-input {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    background-color: #0f0f0f;
    color: #eeeeee;
    border: 1px solid #626262;
    border-radius: 6px;
}

#exploration-input::placeholder {
    color: #aaaaaa;
}

#game-message {
    min-height: 1.65em;
    color: #e7c989;
    white-space: pre-line;
}

#inventory,
#achievements {
    color: #cccccc;
    overflow-wrap: anywhere;
}

#game-ending {
    margin: 28px 0;
    padding: 20px;
    border: 1px solid #e7c989;
    border-radius: 8px;
}

#start-screen > button,
#game > button {
    margin: 4px 4px 4px 0;
}

#reset-progress-button {
    color: #ffb4b4;
}

@media (max-width: 520px) {
    .site-container {
        padding: 24px 12px;
    }

    #start-screen,
    #game {
        padding: 20px 16px;
    }

    #exploration-form {
        grid-template-columns: 1fr;
    }

    #start-screen > button,
    #game > button {
        width: 100%;
        margin: 5px 0;
    }
}

#ending-message {
    white-space: pre-line;
}

#achievements ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#achievements li {
    padding: 12px 0;
    border-bottom: 1px solid #353535;
}

#achievements li:last-child {
    border-bottom: none;
}

#achievements-screen {
    background-color: #171717;
    border: 1px solid #353535;
    border-radius: 12px;
    padding: 28px;
}

#menu-achievements {
    color: #cccccc;
    overflow-wrap: anywhere;
}

#menu-achievements ul {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
}

#menu-achievements li {
    padding: 12px 0;
    border-bottom: 1px solid #353535;
}

#menu-achievements li:last-child {
    border-bottom: none;
}

@media (max-width: 520px) {
    #achievements-screen {
        padding: 20px 16px;
    }
}

/* Splash-screen artwork */

#start-screen {
    background-image:
        linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0.05) 0%,
            rgba(0, 0, 0, 0.15) 35%,
            rgba(0, 0, 0, 0.9) 75%,
            #101010 100%
        ),
        url("Images/0.Splash_Page.webp");

    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    padding-top: 340px;
    padding-bottom: 32px;
}

#start-screen h2 {
    color: #e7c989;
    margin-bottom: 8px;
}

#start-screen p {
    color: #dddddd;
    margin-top: 0;
}

#start-button {
    background-color: #e7c989;
    border-color: #e7c989;
    color: #17120a;
    font-weight: bold;
}

#start-button:hover {
    background-color: #f3dbab;
    border-color: #f3dbab;
}

@media (max-width: 520px) {
    #start-screen {
        padding-top: 240px;
        padding-bottom: 24px;
    }
}

#room-art {
    width: 100%;
    aspect-ratio: 3 / 2;
    margin-bottom: 24px;
    border-radius: 8px;

    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

#achievements-screen {
    background-image:
        linear-gradient(
            to bottom,
            rgba(23, 23, 23, 0.1),
            #171717 340px
        ),
        url("Images/b.Achievements.webp");

    background-size: 100% 100%, 100% auto;
    background-position: center top;
    background-repeat: no-repeat;

    padding-top: clamp(130px, 25vw, 210px);
}

@media (max-width: 520px) {
    #room-art {
        aspect-ratio: auto;
        height: 150px;
        height: clamp(100px, 22svh, 170px);

        background-size: contain;
        background-color: #0a0a0a;
        margin-bottom: 16px;
    }

    #game {
        padding: 16px;
    }

    #room-name {
        margin-bottom: 12px;
    }

    #room-description {
        margin-bottom: 16px;
    }

    #exploration-form {
        margin-top: 16px;
    }
}

/* A scene with a collapsible story panel. Controls stay outside the story scroller. */
[hidden] { display: none !important; }
.site-container { padding-top: 12px; }
#game { padding: 12px; }
#room-scene.pool-overlay {
    position: relative;
    isolation: isolate;
    height: min(780px, calc(100svh - 40px));
    min-height: 520px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    border-radius: 8px;
    background: #0a0a0a;
}
#room-scene.pool-overlay #room-art {
    position: absolute;
    inset: 0;
    z-index: -1;
    height: 100%;
    aspect-ratio: auto;
    margin: 0;
    background-size: cover;
    background-position: center;
}
#scene-toggle { align-self: flex-end; margin: 8px; background: #15130fec; border-color: #a28a59; }
#room-scene.pool-overlay #scene-panel {
    padding: 14px;
    background: rgba(10, 10, 10, .91);
    border-top: 1px solid #8a7754;
    max-height: 66%;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#room-scene.pool-overlay #scene-text {
    min-height: 64px;
    overflow-y: auto;
    scrollbar-color: #a28a59 #191919;
    padding-right: 8px;
}
#room-scene.pool-overlay #room-name { margin: 0 0 10px; font-size: 1.35rem; }
#room-scene.pool-overlay #room-description { margin: 0 0 8px; }
#room-scene.pool-overlay #exits { flex-shrink: 0; gap: 6px; }
#room-scene.pool-overlay #exits button { padding: 7px 10px; }
#game-message { margin: 8px 0; max-height: 160px; overflow-y: auto; }
#game-message:empty { display: none; }
#room-scene.pool-overlay #game-message {
    flex-shrink: 0;
    max-height: min(140px, 22svh);
    margin: 0;
    padding: 8px 10px;
    border-left: 2px solid #e7c989;
    background: #211c13;
}
#room-scene.pool-overlay #exploration-form {
    flex-shrink: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    margin: 0;
    gap: 6px;
}
#exploration-form label { font-size: .875rem; }
#room-scene.pool-overlay.scene-collapsed #room-art { background-size: contain; }
#room-scene.pool-overlay.scene-collapsed #scene-toggle { align-self: stretch; }
#scene-text:focus-visible { outline: 2px solid #e7c989; outline-offset: -2px; }
.game-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; }
.game-tools strong { font-size: .8rem; color: #aaa; }
#inventory { margin: 0; font-size: .9rem; }
#trophy-dialog {
    color: #eee;
    background: #171717 url("Images/b.Achievements.webp") center top / 100% auto no-repeat;
    border: 1px solid #8a7754;
    border-radius: 12px;
    width: min(540px, calc(100% - 24px));
    max-height: 85dvh;
    padding: 18px;
}
#trophy-dialog::backdrop { background: #000b; }
#close-trophies { display: block; margin-left: auto; }
#trophy-title { margin-top: 100px; }
#trophy-dialog #achievements { background: #171717ed; padding: 12px; border-radius: 8px; }
@media (max-width: 520px) {
    .site-container { padding: 8px; }
    #game { padding: 6px; }
    #room-scene.pool-overlay { height: calc(100svh - 30px); }
    #room-scene.pool-overlay #scene-panel { padding: 10px; }
    #room-scene.pool-overlay #exits button { flex-basis: 100%; }
    #exploration-input { padding: 8px; }
    .game-tools button { font-size: .85rem; padding: 8px; }
}

/* Shared achievement design: one wall header flowing into one list. */
#achievements-screen.discoveries,
#trophy-dialog.discoveries {
    position: relative;
    color: #eee;
    background: #171717;
    border: 1px solid #a28a59;
    border-radius: 12px;
    padding: 0;
    overflow: auto;
}
.discoveries-header {
    padding: clamp(130px, 30vw, 180px) 22px 20px;
    background: linear-gradient(to bottom, transparent 45%, #171717 100%),
        url("Images/b.Achievements.webp") center top / 100% auto no-repeat;
}
.discoveries-header h2, #trophy-title { margin: 0; }
#trophy-dialog #achievements, #menu-achievements {
    background: transparent;
    border-radius: 0;
    padding: 0 22px 20px;
    margin: 0;
}
#achievements p, #menu-achievements p { margin: 0 0 16px; }
#achievements ul, #menu-achievements ul { margin: 0; }
#close-trophies { position: absolute; right: 12px; top: 12px; border-color: #a28a59; }
#achievements-back-button { margin: 0 22px 22px; border-color: #a28a59; }
#open-trophies { border-color: #a28a59; }
#start-status { color: #e7c989; }
button:disabled { cursor: wait; opacity: .7; }

/* Wide screens have room for the whole picture and uncompressed story. */
@media (min-width: 768px) {
    .site-container { padding: 32px 20px; }
    #game { padding: 28px; }
    #room-scene.pool-overlay {
        display: block;
        height: auto;
        min-height: 0;
        overflow: visible;
        background: transparent;
    }
    #room-scene.pool-overlay #room-art {
        position: relative;
        inset: auto;
        z-index: auto;
        height: auto;
        aspect-ratio: 3 / 2;
        margin: 0 0 24px;
        background-size: contain;
    }
    #scene-toggle { display: none; }
    #room-scene.pool-overlay #scene-panel {
        display: block !important;
        max-height: none;
        padding: 0;
        overflow: visible;
        background: transparent;
        border: 0;
    }
    #room-scene.pool-overlay #scene-text { overflow: visible; padding: 0; }
    #room-scene.pool-overlay #room-name { font-size: 1.5rem; margin-bottom: 16px; }
    #room-scene.pool-overlay #room-description { margin-bottom: 28px; }
    #room-scene.pool-overlay #exits { gap: 10px; }
    #room-scene.pool-overlay #exits button { padding: 10px 16px; }
    #room-scene.pool-overlay #game-message { max-height: none; margin: 16px 0; }
    #room-scene.pool-overlay #exploration-form { margin-top: 24px; gap: 10px; }
    #exploration-form label { font-size: 1rem; }
}

/* The carried map stays readable on phones without changing the scene layout. */
#open-map[hidden] { display: none; }
#map-dialog { box-sizing: border-box; width: min(960px, 94vw); max-height: 90dvh; overflow: auto; padding: 1.2rem; color: #eee; background: #171715; border: 1px solid #ab9766; border-radius: 16px; }
#map-dialog::backdrop { background: rgb(0 0 0 / 75%); }
#map-dialog img { display: block; width: 100%; height: auto; border-radius: 6px; }
#close-map { float: right; margin: 0 0 1rem 1rem; }
#map-dialog h2 { clear: both; }

/* Celebration artwork uses the same desktop and mobile scene layout as other rooms. */
#hall-banner[hidden], #replay-button[hidden], #restart-run-button[hidden] { display: none; }
#hall-banner { margin: 0; padding: 28px 16px; text-align: center; color: #f8df9e; font-weight: bold; font-size: clamp(1.2rem, 4vw, 2rem); letter-spacing: .08em; }
#game-ending { border-top: 1px solid #b49a62; margin-top: 20px; padding-top: 14px; }
#game-ending h2 { color: #f8df9e; }
#ending-message { white-space: pre-line; }

/* A dedicated touch-friendly stage keeps the target clear of story overlays. */
#pinata-panel[hidden], #pinata-cracks[hidden], #pinata-replay[hidden], #pinata-retry[hidden] { display: none; }
#pinata-panel { max-width: 780px; margin: 0 auto; }
#pinata-panel h2 { margin: 0 0 8px; }
#pinata-help { color: #d2cab9; font-size: .95rem; margin: 0 0 12px; }
#pinata-stage { position: relative; height: min(48svh, 460px); min-height: 220px; overflow: hidden; border: 1px solid #a58c58; border-radius: 12px; background: url('Images/pinata/background.webp') center / cover; }
#pinata-target { display: block; position: relative; margin: 0 auto; height: 100%; width: min(100%, 552px); border: 0; padding: 0; border-radius: 0; background: transparent; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent; transform-origin: 55% 20%; }
#pinata-target:disabled { opacity: 1; cursor: default; }
#pinata-target:focus-visible { outline: 3px solid #ffe296; outline-offset: -5px; }
#pinata-target img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
#pinata-effects { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pinata-candy, .pinata-impact { position: absolute; object-fit: contain; pointer-events: none; }
.pinata-candy { width: 32px; height: 32px; }
.pinata-impact { width: 68px; height: 68px; }
#pinata-status { min-height: 2.8em; margin: 10px 0; color: #f5d991; }
#game.pinata-active #scene-text, #game.pinata-active #exploration-form, #game.pinata-active #game-message { display: none; }
#game.pinata-active #room-scene { margin-top: 12px; }
#pinata-replay, #pinata-retry { min-height: 44px; }
@media (max-width: 767px) { #pinata-help { font-size: .85rem; } #pinata-stage { height: 42svh; } }
@media (prefers-reduced-motion: reduce) { #pinata-target { transform: none !important; } }

/* Rope sits behind the llama; its lower loop follows the sprite's hanging point. */
#pinata-rope { position: absolute; top: 0; transform: translateX(-50%); pointer-events: none; user-select: none; }

/* Interactive constellation: the coordinates remain fixed as the surface scales. */
#hand-panel { max-width: 620px; margin: 0 auto; }
#hand-panel h2 { margin: 0 0 8px; }
#hand-help { color: #bbbfd3; font-size: .95rem; }
#hand-sky { display: block; width: 100%; height: auto; max-height: 65svh; background: #080c18; border: 1px solid #737f9f; border-radius: 12px; touch-action: none; user-select: none; }
#hand-sky:focus-visible { outline: 3px solid #f6d991; outline-offset: 3px; }
#hand-lines { stroke: #a8d9ff; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
#hand-stars circle { fill: #8999bb; }
#hand-stars .connected { fill: #d5edff; }
#hand-stars .next { fill: #ffe8aa; stroke: #ffe8aa55; stroke-width: 14; }
#hand-sky.solved #hand-lines { stroke: #e1f3ff; filter: drop-shadow(0 0 5px #88c9ff); }
#hand-sky.solved circle { fill: #e1f3ff; }
#hand-status { min-height: 3em; color: #e1d19f; white-space: pre-line; }
#game.hand-active #scene-text, #game.hand-active #exploration-form, #game.hand-active #game-message { display: none; }
#game.hand-active #room-scene { margin-top: 12px; }

/* A small, spoiler-free reference beside the exploration field. */
.exploration-heading { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#exploration-form .exploration-heading label { margin: 0; }
#open-help { min-width: 44px; min-height: 44px; margin: 0; padding: 4px 12px; border-color: #a28a59; font-size: 1rem; }
#help-dialog { box-sizing: border-box; width: min(540px, calc(100% - 24px)); max-height: 85dvh; overflow-y: auto; padding: 22px; color: #eee; background: #171717; border: 1px solid #a28a59; border-radius: 12px; line-height: 1.6; }
#help-dialog::backdrop { background: #000b; }
#help-dialog h2 { clear: both; font-size: 1.3rem; }
#help-dialog li { margin-bottom: 10px; }
#close-help { display: block; margin-left: auto; min-height: 44px; }

/* Keep the room view intact; studying the stars opens a closer interactive view. */
#hand-sky { background: #080c18; aspect-ratio: 9 / 8; }
#hand-stars circle { fill: #a0afcc; opacity: .28; }
#hand-stars .connected, #hand-stars .next, #hand-sky.solved circle { opacity: 1; }
#game.hand-active #room-art, #game.hand-active #scene-toggle { display: none; }
#game.hand-active #room-scene.pool-overlay { height: auto; min-height: 0; background: transparent; }
#game.hand-active #room-scene.pool-overlay #scene-panel { max-height: none; background: transparent; border: 0; }
#close-hand { min-height: 44px; }

/* Scene, constellation and reveal share the SVG's fixed room coordinates. */
#hand-reveal { opacity: 0; pointer-events: none; transition: opacity 650ms ease-out; }
#hand-sky.solved #hand-reveal { opacity: .94; }
#hand-sky.solved #hand-lines { stroke-width: 1.6; opacity: .7; }
@media (prefers-reduced-motion: reduce) { #hand-reveal { transition: none; } }

/* Keep the map directly beneath achievements on phones and wider screens. */
.game-tool-buttons { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.game-tool-buttons button { margin: 0; min-height: 44px; }
.game-tools > div:first-child { min-width: 0; overflow-wrap: anywhere; }

/* A hidden reaction uses the same gold-and-charcoal palette as the game. */
#llama-reaction-dialog { box-sizing: border-box; width: min(760px, calc(100% - 24px)); max-height: 90dvh; overflow: auto; padding: 0 0 18px; color: #f7e8ca; background: #171715; border: 1px solid #ab9766; border-radius: 14px; text-align: center; }
#llama-reaction-dialog::backdrop { background: rgb(0 0 0 / 80%); }
#llama-reaction-art { display: block; width: 100%; height: auto; max-height: 60dvh; object-fit: contain; }
#llama-reaction-message { margin: 18px 20px; font-size: clamp(1rem, 3vw, 1.3rem); line-height: 1.5; }
#close-llama-reaction { min-height: 44px; margin: 0 16px; }
/* Exploration remains available in side-activity rooms too. */
#game.pinata-active #exploration-form, #game.hand-active #exploration-form { display: grid; }

/* A temporary theatrical blackout, isolated from the actual game state. */
#catastrophe-dialog { box-sizing: border-box; width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); background: #050505; color: #f5d991; }
#catastrophe-dialog[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; }
#catastrophe-dialog::backdrop { background: #000; }
#catastrophe-message { text-align: center; font-size: clamp(1.2rem, 4vw, 2rem); line-height: 1.5; max-width: 32ch; }
#close-catastrophe { min-height: 44px; }
.catastrophe-shake #catastrophe-message { animation: catastrophe-rumble 350ms ease-out; }
@keyframes catastrophe-rumble { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .catastrophe-shake #catastrophe-message { animation: none; } }
#game.pinata-active #game-message, #game.hand-active #game-message { display: block; }

/* Existing pixel art framed more closely during courtyard interactions. */
#jeff-closeup[hidden], #close-scene-focus[hidden] { display: none; }
#jeff-closeup { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: hidden; image-rendering: pixelated; }
#close-scene-focus { align-self: flex-start; position: absolute; top: 8px; left: 8px; z-index: 2; margin: 0; min-height: 44px; background: #15130fec; border-color: #a28a59; }
#carving-dialog { box-sizing: border-box; width: min(960px, calc(100% - 24px)); max-height: 90dvh; overflow: auto; padding: 18px; color: #eee; background: #171715; border: 1px solid #ab9766; border-radius: 14px; }
#carving-dialog::backdrop { background: #000c; }
#close-carving { display: block; margin: 0 0 12px auto; min-height: 44px; }
#carving-title { margin: 0 0 16px; font-size: 1.3rem; }
.carving-frame { overflow-x: auto; border-radius: 8px; background: #090c10; }
#carving-detail { display: block; width: 100%; height: auto; max-height: 48dvh; image-rendering: pixelated; }
#carving-caption { white-space: pre-line; line-height: 1.6; margin: 18px 0 0; }
@media (min-width: 768px) { #room-scene.pool-overlay.jeff-focused { position: relative; } }

/* Map lettering is real vector text over the original paper floor plan. */
#map-zoom { min-height: 44px; margin: 0 0 12px; }
#map-viewport { overflow: auto; max-height: 65dvh; border-radius: 8px; overscroll-behavior: contain; }
#map-viewport:focus-visible { outline: 2px solid #f5d991; outline-offset: 3px; }
#map-sheet { width: 100%; }
#map-sheet svg { display: block; width: 100%; height: auto; }
#map-viewport.map-enlarged #map-sheet { width: 1536px; }
#map-pan-hint { margin: 0 0 10px; color: #d5c69f; }
#map-pan-hint[hidden] { display: none; }
.map-key { margin: 18px 0; }
.map-key summary { padding: 10px 0; min-height: 24px; cursor: pointer; color: #f5d991; }
.map-key ol { columns: 2; column-gap: 32px; padding-left: 30px; line-height: 1.7; }
.map-key li { break-inside: avoid; padding-left: 4px; }
@media (max-width: 420px) { .map-key ol { columns: 1; } }

/* The map is just the named paper plan. Tap/click it to enlarge. */
#map-dialog { position: fixed; padding: 0; border: 0; background: transparent; max-height: 94dvh; overflow: visible; }
#close-map { position: absolute; z-index: 2; top: 8px; right: 8px; float: none; margin: 0; width: 44px; height: 44px; padding: 0; font-size: 1.5rem; background: #211b14ed; }
#map-viewport { max-height: 90dvh; cursor: zoom-in; }
#map-viewport.map-enlarged { cursor: zoom-out; }
#open-birthday-card[hidden], #birthday-card-inside[hidden], #birthday-card-cover[hidden], #fold-card[hidden], #read-completed-card[hidden] { display: none; }
#open-birthday-card { margin: 6px 0 0; min-height: 44px; }
#card-reward-dialog, #birthday-card-dialog { box-sizing: border-box; color: #f4e4bf; background: #171715; border: 1px solid #ab9766; border-radius: 14px; max-height: 92dvh; overflow: auto; }
#card-reward-dialog { width: min(540px, calc(100% - 24px)); padding: 18px; text-align: center; }
#card-reward-dialog::backdrop, #birthday-card-dialog::backdrop { background: #000c; }
#close-card-reward { display: block; margin: 0 0 12px auto; min-height: 44px; }
#card-reward-title { font-size: 1.25rem; }
#card-fragment-image { display: block; max-width: 100%; width: auto; height: auto; max-height: 48dvh; margin: auto; }
#birthday-card-dialog { width: min(1040px, calc(100% - 20px)); padding: 12px; }
#close-birthday-card { display: block; margin: 0 0 10px auto; min-width: 44px; min-height: 44px; font-size: 1.5rem; }
#birthday-card-cover { text-align: center; }
#birthday-card-cover img { display: block; max-width: 100%; max-height: 65dvh; width: auto; height: auto; margin: auto; }
#unfold-card, #fold-card, #read-completed-card { min-height: 44px; }
#birthday-card-inside { display: grid; grid-template-columns: 1fr 1fr; min-height: 560px; background: #fff3d9 url('Images/card/inside.webp') center / 100% 100% no-repeat; color: #302016; }
.card-letter { grid-column: 2; padding: 65px 48px; font-family: Georgia, serif; font-size: 18px; line-height: 1.6; }
.card-letter p { margin-left: 12px; margin-right: 12px; }
.card-letter h2 { font-size: 1.45em; line-height: 1.3; }
@media (max-width: 680px) {
    #birthday-card-inside { grid-template-columns: 1fr; min-height: 0; background-size: 200% 100%; background-position: right; }
    .card-letter { grid-column: 1; padding: 48px 30px; font-size: 17px; }
}

/* One small Pool prompt, separate from story and action responses. */
.tutorial-prompt { margin: .35rem 0 .6rem; font-size: .9rem; line-height: 1.4; color: #e5cf9b; }

#birthday-song { position: fixed; z-index: 30; bottom: 1rem; left: 50%; transform: translateX(-50%); width: min(92vw, 42rem); box-sizing: border-box; background: #100e09f5; color: #ffe3a0; border: 1px solid #b59a60; border-radius: 1rem; padding: .75rem 1rem; box-shadow: 0 0 2rem #000; }
#birthday-song[hidden] { display: none; }
#close-birthday-song { display: block; margin-left: auto; }
.birthday-song-window { height: 13rem; overflow: hidden; }
.birthday-song-lyrics { margin: 0; font-size: clamp(1rem, 3.8vw, 1.3rem); line-height: 1.8; text-align: center; animation: birthday-song-rise 16s linear forwards; }
@keyframes birthday-song-rise { from { transform: translateY(13rem); } to { transform: translateY(-100%); } }
@media (prefers-reduced-motion: reduce) { .birthday-song-lyrics { animation: none; } .birthday-song-window { height: auto; padding: 1rem 0; } }

#playtest-tools { margin: 1rem auto; padding: 1rem; max-width: 48rem; border: 1px dashed #9e895b; }
#playtest-tools[hidden] { display: none; }
#playtest-tools summary { cursor: pointer; }

/* Keep the input within reach, independently of the scene's nested scrollers. */
:root { --interaction-height: 154px; --keyboard-inset: 0px; --interaction-response-height: 20dvh; }
body:has(#game:not([hidden])) { padding-bottom: calc(var(--interaction-height) + 24px); }
#interaction-dock {
    position: fixed; z-index: 20; bottom: var(--keyboard-inset); left: 50%; transform: translateX(-50%);
    width: min(760px, calc(100% - 16px)); padding: 10px 12px max(10px, env(safe-area-inset-bottom));
    background: #15130ff5; border: 1px solid #8a7754; border-bottom: 0; border-radius: 12px 12px 0 0;
    box-shadow: 0 -6px 22px #0007;
}
#interaction-dock #exploration-form { display: grid; margin: 0; gap: 6px; grid-template-columns: minmax(0, 1fr) auto; }
#interaction-dock #exploration-input { font-size: 16px; min-width: 0; }
#interaction-dock #game-message {
    display: block; margin: 0 0 8px; padding: 8px 10px; max-height: min(160px, var(--interaction-response-height));
    overflow-y: auto; overscroll-behavior: contain; white-space: pre-line; color: #e7c989;
    background: #211c13; border-left: 2px solid #e7c989;
}
#interaction-dock #game-message:empty { display: none; }
body:has(dialog[open]) #interaction-dock,
#game.hand-active #interaction-dock,
#game:has(.scene-collapsed) #interaction-dock { visibility: hidden; pointer-events: none; }
#game-message, #exits, .game-tools, #playtest-tools { scroll-margin-bottom: calc(var(--interaction-height) + 20px); }
@media (min-width: 768px) {
    #room-scene.pool-overlay #room-art { height: min(46svh, 430px); aspect-ratio: auto; }
}
@media (max-width: 767px) {
    #room-scene.pool-overlay { height: calc(100svh - var(--interaction-height) - 28px); min-height: 320px; }
    #room-scene.pool-overlay #scene-panel { max-height: 70%; }
    #room-scene.pool-overlay.scene-collapsed { height: calc(100svh - 28px); }
    #interaction-dock { padding-top: 8px; }
    #interaction-dock .tutorial-prompt { margin: 0; font-size: .8rem; }
}

/* The Great Hall erupts into song. Native dialog keeps focus in the celebration. */
#birthday-song {
    position: fixed; inset: 0; transform: none; margin: auto; width: 100%; max-width: none;
    height: 100dvh; max-height: none; padding: 20px; border: 0; border-radius: 0;
    background: transparent; color: #ffe3a0; box-shadow: none; overflow-y: auto;
}
#birthday-song[open] { display: grid; place-items: center; }
#birthday-song::backdrop { background: #080603d9; backdrop-filter: blur(2px); }
.celebration-panel {
    width: min(100%, 48rem); padding: clamp(16px, 4vw, 36px); border: 1px solid #b59a60;
    border-radius: 18px; background: radial-gradient(ellipse at center, #453316dd, #100e09f2);
    box-shadow: 0 0 70px #cf9c3333; text-align: center;
}
.birthday-song-window { height: min(45dvh, 22rem); overflow: hidden; }
.birthday-song-lyrics { font-family: Georgia, serif; font-size: clamp(1.2rem, 3.8vw, 2rem); line-height: 1.9; text-shadow: 0 0 18px #e9b54b55; }
@keyframes birthday-song-rise { from { transform: translateY(min(45dvh, 22rem)); } to { transform: translateY(-100%); } }
@media (prefers-reduced-motion: reduce) { .birthday-song-window { height: auto; padding: 2rem 0; } }

/* Mobile-first reading layout: preview, story, compact actions, response. */
#room-scene.pool-overlay {
    display: block; position: relative; isolation: auto; height: auto; min-height: 0;
    overflow: visible; background: transparent;
}
#room-scene.pool-overlay #room-art {
    display: block; position: relative; inset: auto; z-index: auto; width: 100%;
    height: clamp(140px, 38vw, 240px); min-height: 0; aspect-ratio: 16 / 7;
    margin: 0 0 18px; padding: 0; background-size: cover; background-position: center;
    border: 1px solid #454034; border-radius: 10px; overflow: hidden; cursor: zoom-in;
}
#room-scene.pool-overlay #scene-panel {
    display: block !important; padding: 0; max-height: none; min-height: 0;
    overflow: visible; border: 0; background: transparent;
}
#room-scene.pool-overlay #scene-text { overflow: visible; min-height: 0; padding: 0; }
#room-scene.pool-overlay #room-name { margin: 0 0 12px; font-size: 1.4rem; }
#room-scene.pool-overlay #room-description { margin: 0 0 16px; }
#room-scene.pool-overlay #exits { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
#room-scene.pool-overlay #exits button, #exits button {
    flex: 0 1 auto; width: auto; min-height: 44px; padding: 6px 12px;
    border-radius: 22px; font-size: .875rem; line-height: 1.3; background: #24221d;
}
#room-scene.pool-overlay #exits .backtrack-chip, #exits .backtrack-chip {
    border-color: transparent; background: transparent; color: #c5baa4; padding-left: 4px;
}
#exits .hint-chip { border-style: dashed; }
#game.suggestions-off #exits > button:not(.backtrack-chip):not(.hint-chip) { display: none; }
#room-scene.pool-overlay #game-message {
    max-height: none; overflow: visible; margin: 16px 0 0; padding: 10px 12px;
    white-space: pre-line; color: #e7c989; background: #211c13; border-left: 2px solid #e7c989;
}
#interaction-dock { padding: 8px 10px max(8px, env(safe-area-inset-bottom)); }
#interaction-dock #exploration-form { grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 6px; }
#interaction-dock #exploration-form button { min-height: 44px; padding: 6px 10px; }
#interaction-dock #exploration-input { padding: 8px; min-height: 44px; }
#interaction-dock #tutorial-prompt { grid-column: 1 / -1; margin: 0; font-size: .8rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
#utility-dialog {
    width: min(420px, calc(100% - 24px)); max-height: 85dvh; overflow: auto;
    padding: 18px; border: 1px solid #a28a59; border-radius: 14px; background: #171715; color: #eee;
}
#utility-dialog::backdrop, #scene-dialog::backdrop { background: #000c; }
.utility-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.utility-header h2 { margin: 0; font-size: 1.2rem; }
.utility-inventory { padding: 16px 0; margin-bottom: 14px; border-bottom: 1px solid #454034; }
.utility-inventory h3 { font-size: .9rem; color: #e7c989; margin: 0 0 6px; }
#utility-dialog #inventory { font-size: 1rem; overflow-wrap: anywhere; }
.utility-actions { display: grid; gap: 8px; }
.utility-actions button { text-align: left; margin: 0; }
#scene-dialog {
    position: fixed; inset: 0; width: 100%; max-width: none; height: 100dvh; max-height: none;
    margin: 0; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
    background: #080808f5; color: #eee; border: 0;
}
#scene-dialog[open] { display: flex; flex-direction: column; gap: 12px; }
#close-scene { align-self: flex-end; flex: 0 0 auto; }
#enlarged-scene { display: block; width: 100%; flex: 1; min-height: 0; object-fit: contain; }
#game.hand-active #room-art { display: none; }
@media (max-width: 767px) { .site-container { padding: 8px; } #game { padding: 12px; } }

/* Quiet context for the current reply; wraps safely on narrow phone screens. */
#last-action {
    margin: .7rem 0 .3rem;
    color: #aaa69c;
    font-size: .85rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
#last-action[hidden] { display: none; }
#start-screen .save-note {
    margin: 1rem auto;
    max-width: 36rem;
    font-size: .78rem;
    line-height: 1.45;
    color: #aaa69c;
}
