@font-face {
    font-family: Caveat;
    src: url("vendor/caveat.ttf") format("truetype");
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
}

:root {
    color-scheme: light;
    --scene-ink: #4d303d;
    --scene-plum: #67465f;
    --scene-paper: #fff3de;
    --scene-font: Caveat, "Segoe Print", Georgia, serif;
}

.advent-world {
    margin: 0;
    color: var(--scene-ink);
    background: #d6c9e2;
    font-family: system-ui, sans-serif;
    overscroll-behavior: none;
}

.advent-world button, .advent-world select, .advent-world input {
    font: inherit;
}

.advent-stage {
    position: fixed;
    inset: 0;
    overflow: hidden;
    isolation: isolate;
}

.scene-mount, .scene-poster {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.scene-mount:focus-visible {
    outline: 3px solid #fff8ee;
    outline-offset: -3px;
}

.scene-mount canvas {
    position: absolute;
    inset: 0;
    display: block;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.scene-poster {
    display: grid;
    place-items: center;
    background: #d9ceec;
    pointer-events: none;
}

.scene-poster__art {
    position: relative;
    width: min(100vw, calc(100dvh * 1215 / 1280));
    aspect-ratio: 1215 / 1280;
}

.scene-poster__reference {
    display: block;
    width: 100%;
    height: auto;
}

.scene-poster__day {
    position: absolute;
    left: 93.3333%;
    top: 83.125%;
    width: 2.71605%;
    height: auto;
}

.scene-entry {
    position: absolute;
    inset: max(.75rem, env(safe-area-inset-top)) max(.75rem, env(safe-area-inset-right)) auto auto;
}

.scene-controls {
    position: absolute;
    inset: auto auto max(.75rem, env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left));
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .35rem;
}

.scene-small-button, .scene-primary, .scene-close {
    box-sizing: border-box;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 2.5rem;
    padding: .3rem .72rem;
    background: #fff5ebee;
    border: 1px solid #9b738766;
    border-radius: .7rem;
    text-decoration: none;
    color: var(--scene-ink);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px #49394b23;
}

.scene-entry .scene-entry__link, .scene-sheet .scene-primary {
    font: 700 1.46rem/1 var(--scene-font);
}

.scene-small-button:hover, .scene-close:hover { background: #fffaf5; }
.scene-primary:hover { background: #795771; }
.scene-primary:disabled { opacity: .6; cursor: wait; }
.advent-world :focus-visible { outline: 2px solid #7a466e; outline-offset: 3px; }

.scene-settings { position: relative; }
.scene-settings summary { list-style: none; min-width: 2.5rem; }
.scene-settings summary::-webkit-details-marker { display: none; }
.scene-settings__panel {
    position: absolute;
    bottom: calc(100% + .45rem);
    left: 0;
    width: min(14rem, 50vw);
    padding: .8rem;
    display: grid;
    gap: .53rem;
    border: 1px solid #bd9fab;
    background: #fff9ed;
    border-radius: .7rem;
    box-shadow: 0 7px 24px #49394b32;
}
.scene-settings__panel label { display: block; font-size: .88rem; }
.scene-settings__field select { display: block; width: 100%; margin-top: .22rem; }

.scene-status, .scene-noscript {
    position: absolute;
    left: 50%;
    bottom: max(4.1rem, calc(env(safe-area-inset-bottom) + 3.6rem));
    transform: translateX(-50%);
    box-sizing: border-box;
    width: max-content;
    max-width: min(30rem, calc(100% - 1.4rem));
    margin: 0;
    padding: .62rem .93rem;
    border-radius: .65rem;
    background: #fff8ed;
    color: #503746;
    overflow-wrap: anywhere;
    pointer-events: none;
    text-align: center;
    box-shadow: 0 4px 20px #4e385234;
    font-size: .93rem;
}
.scene-status:empty { clip-path: inset(50%); padding: 0; }

.scene-sheet {
    --sheet-space: clamp(1.3rem, 4vw, 2.45rem);
    position: fixed;
    box-sizing: border-box;
    width: min(37rem, calc(100vw - 1.5rem));
    max-height: min(87dvh, 50rem);
    margin: auto;
    padding: var(--sheet-space);
    border: 1px solid #d0a9a6;
    border-radius: 1.1rem;
    background: radial-gradient(ellipse at 7% 2%, #fae4c2, transparent 38%),
        radial-gradient(ellipse at 95% 90%, #f2d7cf, transparent 35%),
        var(--scene-paper);
    box-shadow: 0 18px 70px #4d335657, inset 0 0 0 .32rem #fffbf09c;
    color: var(--scene-ink);
    overflow: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}
.scene-sheet::backdrop { background: #4936574f; }
.scene-sheet h2 {
    margin: 0 2rem .85rem 0;
    font: 700 clamp(2.1rem, 6vw, 3.3rem)/.96 var(--scene-font);
    outline: none;
}
.scene-sheet__close { position: absolute; top: .65rem; right: .65rem; margin: 0; }
.scene-sheet .scene-close { min-width: 2.5rem; padding: .15rem; font-size: 1.55rem; }
.scene-letter__date { margin: 0 2.75rem .6rem 0; color: #815269; font: 700 1.43rem/1 var(--scene-font); }
.scene-letter__body, .scene-letter__closing {
    font: 600 clamp(1.34rem, 2.5vw, 1.55rem)/1.28 var(--scene-font);
    overflow-wrap: anywhere;
}
.scene-letter__body p, .scene-letter__closing p { margin: 0 0 .7rem; white-space: pre-wrap; }
.scene-letter__closing { margin: .8rem 0 0; padding-top: .78rem; border-top: 1px solid #be88916b; }
.scene-letter__actions { margin-top: 1.2rem; }
.scene-letter__feedback { margin: .52rem 0 0; font-size: .91rem; }
.scene-letter__feedback:empty { display: none; }
.scene-primary { background: var(--scene-plum); color: #fff9f4; border-color: var(--scene-plum); min-height: 2.75rem; padding: .51rem 1.08rem; }
.scene-progress { min-height: 1em; margin: 0 0 1rem; font-size: .95rem; }
.scene-dates { width: min(24rem, calc(100vw - 1.5rem)); }
.scene-dates select {
    display: block;
    box-sizing: border-box;
    width: 100%;
    padding: .5rem .62rem;
    margin: .4rem 0 1rem;
    min-height: 2.75rem;
    border: 1px solid #cfaeaa;
    border-radius: .48rem;
    color: var(--scene-ink);
    background: #fffaf0;
}
.scene-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.scene-confetti i { position: absolute; left: 50%; top: 75%; width: .45rem; height: .8rem; border-radius: .1rem; }

.scene-auth {
    min-height: 100dvh;
    background:
        url("../img/story-house-bank.webp") center bottom / max(100%, 80rem) auto no-repeat fixed,
        url("../img/story-house.webp") calc(50% + 21rem) bottom / auto min(88vh, 49rem) no-repeat fixed,
        url("../img/sky_day.webp") center / cover no-repeat fixed #ded5ed;
}
.scene-auth__nav { display: flex; padding: max(.75rem, env(safe-area-inset-top)) .75rem 0; }
.scene-auth__nav .scene-entry__link { font: 700 1.5rem/1 var(--scene-font); }
.scene-auth__main { display: grid; justify-items: center; padding: clamp(1rem, 5vw, 4.5rem) .75rem 2.5rem; }
.scene-sheet.scene-auth__paper {
    position: relative;
    width: min(28rem, 100%);
    margin: 0;
    overflow: visible;
    max-height: none;
    background: #f6e4c7 url("../img/story-letter-paper.webp") center / 100% 100%;
    border-color: #b18558;
}

@media (max-width: 680px) {
    .scene-auth { background-position: center bottom, center bottom, center; }
}
.scene-auth__paper h1 { margin: 0 0 1rem; font: 700 clamp(2rem, 7vw, 3rem)/1 var(--scene-font); }
.scene-auth__paper p { line-height: 1.48; }
.scene-auth__paper p:last-child { margin-bottom: 0; }
.scene-sheet.scene-auth__paper--policy {
    width: min(46rem, 100%);
    background: #fff6e7;
    overflow-wrap: anywhere;
}
.scene-auth__paper--policy h2 {
    margin: 1.55rem 0 .45rem;
    font-size: 1.2rem;
    line-height: 1.3;
}
.scene-auth__paper form > div { margin-bottom: .9rem; }
.scene-auth__paper form label { display: block; margin-bottom: .25rem; font-weight: 600; }
.scene-auth__paper form input:not([type="hidden"]) {
    box-sizing: border-box;
    width: 100%;
    min-height: 2.75rem;
    padding: .45rem .56rem;
    border: 1px solid #c2a1ad;
    border-radius: .45rem;
    color: var(--scene-ink);
    background: #fffaf3;
}
.scene-auth__paper a { color: #65385f; }
.scene-auth__paper .helptext { display: block; margin: .35rem 0; font-size: .83rem; }
.scene-auth__paper .errorlist, .scene-auth__paper .status-message { color: #85364d; }
.scene-auth__paper .button {
    display: inline-flex;
    min-height: 2.75rem;
    padding: .4rem 1rem;
    border: 1px solid #664661;
    border-radius: .6rem;
    background: #664661;
    color: #fff9f5;
    font: 700 1.45rem/1 var(--scene-font);
    cursor: pointer;
}

.scene-calibration {
    position: absolute;
    right: max(.6rem, env(safe-area-inset-right));
    bottom: max(.6rem, env(safe-area-inset-bottom));
    width: min(16rem, 49vw);
    padding: .75rem;
    background: #fffaf0;
    border: 1px solid #cfaeaa;
    border-radius: .6rem;
    font-size: .9rem;
}
.scene-calibration label { display: block; margin-top: .35rem; }
.scene-calibration textarea { box-sizing: border-box; width: 100%; margin-bottom: .25rem; resize: vertical; }
.scene-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (pointer: coarse) {
    .scene-small-button, .scene-settings summary, .scene-close { min-height: 44px; }
    .scene-settings__panel { left: auto; right: 0; }
}
