* { box-sizing: border-box; }
body {
    margin: 0;
    overflow: hidden;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: #0d0a08;
}

.screen {
    position: relative;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background: #14100c;
}

.scene-art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.scene-art svg { width: 100%; height: 100%; display: block; }

.scene-art.fading { opacity: 0; transform: scale(1.015); }
.scene-art {
    opacity: 1;
    transform: scale(1);
    transition: opacity .35s ease, transform .35s ease;
}

.scene-art.cam-cut { filter: blur(8px) brightness(.6) contrast(1.15); transition: filter .09s ease-in; }

.vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(130% 100% at 50% 38%, rgba(0,0,0,0) 46%, rgba(0,0,0,.55) 100%);
    mix-blend-mode: multiply;
}

.text-box {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    width: min(92%, 920px);
    background: #f3ecd6;
    color: #262a52;
    padding: 16px 22px 18px 54px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.15em;
    line-height: 1.4;
    letter-spacing: .2px;
    border: 3px solid #262a52;
    border-radius: 16px 13px 17px 12px / 13px 17px 12px 16px;
    box-shadow: 3px 5px 0 #8c6b9a, 0 10px 26px rgba(30,22,40,.35);
    z-index: 30;
}

.text-box::before {
    content: "✒";
    position: absolute;
    left: 18px; top: 50%;
    transform: translateY(-50%) rotate(-8deg);
    font-size: 1.2em;
    color: #8c6b9a;
}

.text-box.typing::after {
    content: "▋";
    margin-left: 2px;
    color: #b56a5a;
    animation: caret .75s steps(1) infinite;
}
@keyframes caret { 0%,50% { opacity: 1; } 51%,100% { opacity: 0; } }

.text-box.more::after {
    content: "▸";
    margin-left: 8px;
    color: #b56a5a;
    animation: nudge 1s ease-in-out infinite;
}
@keyframes nudge { 0%,100%{opacity:.4;} 50%{opacity:1;} }

.modal {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(40,30,22,.42);
    backdrop-filter: blur(1.5px);
    opacity: 0;
    transition: opacity .2s ease;
}
.modal.show { opacity: 1; }
.modal-card {
    position: relative;
    max-width: min(92vw, 860px);
    max-height: 86vh;
    overflow: auto;
    padding: 26px 28px 22px;
    color: #33386e;
    background: #f3ecd6;
    border: 3px solid #33386e;
    border-radius: 20px 16px 22px 14px / 16px 22px 14px 20px;
    box-shadow: 4px 6px 0 #8c6b9a, 0 30px 60px rgba(40,30,22,.4);
    transform: translateY(14px) scale(.9) rotate(-.4deg);
    transition: transform .28s cubic-bezier(.2,.9,.3,1.25);
}
.modal.show .modal-card { transform: translateY(0) scale(1) rotate(-.4deg); }
.modal-close {
    position: absolute; top: 10px; right: 12px;
    width: 32px; height: 32px; border-radius: 50%;
    background: #f6efd8; color: #33386e;
    border: 2.5px solid #33386e; font-size: 18px; line-height: 1; cursor: pointer;
    transition: background .15s, transform .15s;
}
.modal-close:hover { background: #edc9d2; transform: rotate(6deg) scale(1.08); }
.modal-h { margin: 0 0 16px; font-family: Georgia, serif; font-size: 24px; letter-spacing: 2px; color: #8c6b9a; text-align: center; }
.modal-sub { margin-top: 12px; text-align: center; font-size: 12.5px; color: #6a8f86; font-style: italic; }

.item-overlay { position: absolute; z-index: 31; }
.piano-ov { left: 50%; bottom: 120px; transform: translateX(-50%); }
.piano-ov .piano-scroll { background: rgba(243,236,214,.85); border: 2.5px solid #33386e; border-radius: 12px; box-shadow: 3px 4px 0 #8c6b9a; }

.ledger-ov { left: 50%; top: 47%; transform: translate(-50%, -50%); width: min(92vw, 1180px); perspective: 2600px; }
.bk-frame { background: linear-gradient(160deg, #6a8f86, #4c6a63); border: 7px solid #26413c; border-radius: 16px; padding: 22px 20px; box-shadow: 0 22px 60px rgba(0,0,0,.55), inset 0 0 0 2px rgba(201,162,74,.5); }
.book2 { position: relative; display: flex; gap: 0; transform-style: preserve-3d; height: min(72vh, 600px); }
.book2::after { content: ''; position: absolute; left: 50%; top: 0; width: 3px; height: 100%; transform: translateX(-50%); background: linear-gradient(#b9a97f, #8a6a3a); opacity: .55; z-index: 1; pointer-events: none; }
.bpage { flex: 1 1 50%; min-width: 0; color: #2e2a24; padding: 30px 34px 22px; box-sizing: border-box; overflow: hidden; cursor: pointer; background: linear-gradient(90deg, #efe4c8, #f8f1dd); }
.bp-left { border-radius: 8px 0 0 8px; box-shadow: inset -26px 0 34px -20px rgba(70,50,30,.55); }
.bp-right { border-radius: 0 8px 8px 0; box-shadow: inset 26px 0 34px -20px rgba(70,50,30,.55); }
.bp-left:hover, .bp-right:hover { filter: brightness(1.03); }
.lhd { text-align: center; font-family: Georgia, serif; font-size: 17px; color: #8c6b9a; letter-spacing: .5px; border-bottom: 2px solid #b9a97f; padding-bottom: 8px; margin-bottom: 10px; }
.lrow { display: grid; grid-template-columns: 38px 1fr auto 52px; gap: 14px; align-items: baseline; font-size: 21px; padding: 10px 2px; border-bottom: 1px dotted #c3b48a; }
.lrow b { color: #8c6b9a; font-weight: 700; }
.lrow .nm { font-family: Georgia, serif; }
.lrow .dt { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 17px; color: #3a3222; }
.lrow i { text-align: right; font-style: normal; font-family: ui-monospace, monospace; color: #6a8f86; }
.lpg { text-align: center; margin-top: 14px; font-family: Georgia, serif; font-size: 16px; color: #f3ecd6; text-shadow: 0 1px 2px rgba(0,0,0,.5); }

.leaf { position: absolute; top: 0; height: 100%; width: 50%; transform-style: preserve-3d; z-index: 8; }
.leaf.fwd { right: 0; transform-origin: left center; animation: leafFwd .62s ease-in-out forwards; }
.leaf.bwd { left: 0; transform-origin: right center; animation: leafBwd .62s ease-in-out forwards; }
.leaf-face { position: absolute; inset: 0; backface-visibility: hidden; background: linear-gradient(90deg, #efe4c8, #f8f1dd); border: 1px solid #b9a97f; box-shadow: 0 0 30px rgba(30,22,40,.28); overflow: hidden; }
.leaf-face.back { transform: rotateY(180deg); }
.leaf-face .bpage { width: 100%; height: 100%; }
@keyframes leafFwd { from { transform: rotateY(0deg); } to { transform: rotateY(-180deg); } }
@keyframes leafBwd { from { transform: rotateY(0deg); } to { transform: rotateY(180deg); } }

.globe-ov { left: 50%; bottom: 118px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px;
  background: rgba(243,236,214,.9); border: 2.5px solid #33386e; border-radius: 12px; padding: 8px 16px; box-shadow: 3px 4px 0 #8c6b9a; }
.globe-ov .glab { font-family: Georgia, serif; font-size: 13px; color: #33386e; letter-spacing: .3px; }
.globe-ov input[type=range] { width: 160px; accent-color: #8c6b9a; cursor: pointer; }
.globe-ov .gbtn { width: 32px; height: 32px; border-radius: 50%; border: 2px solid #33386e; background: #f6efd8; color: #33386e; font-size: 17px; cursor: pointer; }
.globe-ov .gbtn:active { transform: translateY(1px); }

.piano-scroll { overflow: hidden; max-width: 96vw; padding: 5px 3px 7px; }
.modal-piano .piano { display: inline-block; padding: 4px; background: #15110b; border-radius: 8px; }
.keys { position: relative; display: flex; height: 132px; }
.pkey.white {
    width: 14px; height: 132px; background: linear-gradient(#fffef9,#e7e1d1);
    border: 1px solid #b2ab98; border-left-width: 0; border-radius: 0 0 3px 3px;
    box-shadow: inset 0 -5px 7px rgba(0,0,0,.08);
    cursor: pointer; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4px;
}
.pkey.white:first-child { border-left-width: 1px; }
.pkey.white span { font-size: 8px; color: #b4a884; pointer-events: none; font-family: ui-monospace, monospace; }
.pkey.white.bound { background: linear-gradient(#fffdf2,#efe6cc); }
.pkey.white.bound span { color: #8c6b9a; font-weight: 700; }
.pkey.black.bound span { color: #e6c27a; font-weight: 700; }
.pkey.white.down { background: linear-gradient(#f3ead4,#d6cdb6); transform: translateY(1px); box-shadow: inset 0 -3px 7px rgba(0,0,0,.18); }
.pkey.black {
    position: absolute; top: 0; width: 9px; height: 82px;
    background: linear-gradient(#333339,#0a0a0e); border: 1px solid #000; border-radius: 0 0 3px 3px;
    box-shadow: 0 3px 5px rgba(0,0,0,.55); cursor: pointer; z-index: 2;
    display: flex; align-items: flex-end; justify-content: center; padding-bottom: 3px;
}
.pkey.black span { font-size: 7px; color: #9a9aa6; pointer-events: none; font-family: ui-monospace, monospace; }
.pkey.black.down { background: linear-gradient(#17171c,#040406); transform: translateY(1px); }

.pk { cursor: pointer; transition: fill .05s linear; }
.pk.down { fill: #ddd0b0; }
.pk.blk.down { fill: #40386a; }
.pklbl { pointer-events: none; user-select: none; }

.mute-btn {
    position: absolute; right: 14px; bottom: 60px; z-index: 34;
    width: 42px; height: 42px; border-radius: 50%;
    background: rgba(20,16,10,.82); color: #e8c878;
    border: 1px solid #6f5a2c; font-size: 18px; cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,.4);
    transition: transform .15s, color .15s, border-color .15s;
}
.mute-btn:hover { transform: scale(1.08); border-color: #c9a24a; }
.mute-btn.off { color: #7a6a4a; }

.booklet { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; }
.bk-col { flex: 1 1 240px; min-width: 220px; background: rgba(46,110,134,.12); border: 1px solid #2e6e86; border-radius: 8px; padding: 12px 14px; }
.bk-col h4 { margin: 0 0 8px; color: #7fd0e6; font-family: Georgia, serif; letter-spacing: 1px; }
.bk-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.bk-table td { padding: 5px 2px; border-bottom: 1px dashed rgba(255,255,255,.12); }
.bk-table td:last-child { text-align: right; color: #ffd98a; font-variant-numeric: tabular-nums; }
.bk-note { font-size: 12px; color: #bcae90; margin: 10px 0 0; }
.bk-offer { font-size: 13px; color: #ffd98a; margin: 10px 0 0; font-weight: 600; }

.sheet-scroll { max-height: 54vh; overflow: auto; border: 1px solid #4a3c28; border-radius: 6px; }
.ledger { width: 100%; border-collapse: collapse; font-size: 13.5px; background: #efe7d2; color: #2a2318; }
.ledger th { position: sticky; top: 0; background: #d9cdb0; color: #4a3c22; padding: 8px 10px; text-align: left; font-family: Georgia, serif; letter-spacing: .5px; border-bottom: 2px solid #b9a97f; }
.ledger td { padding: 6px 10px; border-bottom: 1px solid #d6cbae; }
.ledger tr:nth-child(even) td { background: #e6ddc4; }
.ledger .mono { font-family: ui-monospace, Menlo, Consolas, monospace; color: #3a3222; }
.ledger .num { text-align: right; font-variant-numeric: tabular-nums; }

.cell-view {
    position: absolute;
    inset: 0;
    z-index: 29;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(120% 120% at 50% 45%, rgba(233,223,196,.4) 0%, rgba(40,30,22,.72) 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity .35s ease;
}
.cell-view.show { opacity: 1; pointer-events: auto; }
.cv-wrap {
    position: relative;
    text-align: center;
    transform: scale(.22) translateY(30px);
    transition: transform .55s cubic-bezier(.2,.85,.25,1.05);
}
.cell-view.show .cv-wrap { transform: scale(1) translateY(0); }
.cell-view svg { display: block; width: min(90vw, 760px); height: auto; filter: drop-shadow(4px 8px 0 #8c6b9a); }

.cv-door { transform-box: fill-box; transform-origin: 100% 50%; transform: rotateY(2deg); }
.cell-view.show .cv-door { animation: cvDoor .9s .35s cubic-bezier(.3,.7,.2,1) both; }
@keyframes cvDoor {
    0%   { transform: perspective(900px) rotateY(0deg); }
    100% { transform: perspective(900px) rotateY(-26deg); }
}
.cell-view-cap {
    margin-top: 14px;
    color: #33386e;
    font-family: Georgia, serif;
    font-size: 1em;
    letter-spacing: .3px;
    background: #f3ecd6;
    display: inline-block;
    padding: 7px 18px;
    border: 2px solid #33386e;
    border-radius: 12px 10px 13px 9px / 10px 13px 9px 12px;
}
.cell-view-close {
    position: absolute;
    top: -6px; right: -6px;
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 2.5px solid #33386e;
    background: #f6efd8;
    color: #33386e;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 3;
    pointer-events: auto;
    transition: background .15s ease, transform .15s ease;
}
.cell-view-close:hover { background: #edc9d2; transform: rotate(8deg) scale(1.08); }

.inventory {
    position: absolute;
    right: 10px;
    top: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 10px 12px;
    border-radius: 10px;
    min-width: 92px;
    text-align: center;
    z-index: 30;
}
.inventory strong { font-size: .95em; font-weight: 600; }
#items { margin-top: 8px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
#items:empty::after {
    content: "пусто";
    color: rgba(255,255,255,.45);
    font-size: .8em;
    font-style: italic;
}

.inv-card {
    width: 92px;
    cursor: pointer;
    border-radius: 7px;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,.5));
    transition: transform .18s ease;
}
.inv-card:hover { transform: scale(1.06) rotate(-2deg); }

.urlbar {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translate(-50%, -140%);
    background: rgba(20,18,16,.92);
    border: 1px solid rgba(255,255,255,.12);
    color: #e8e2d6;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 15px;
    padding: 8px 16px 8px 12px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 9px;
    z-index: 35;
    opacity: 0;
    transition: transform .4s cubic-bezier(.2,.9,.3,1.2), opacity .4s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,.45);
    max-width: 92vw;
    white-space: nowrap;
    overflow: hidden;
}
.urlbar.show { transform: translate(-50%, 0); opacity: 1; }
.urlbar .dot { width: 9px; height: 9px; border-radius: 50%; background: #5ec26a; box-shadow: 0 0 8px #5ec26a; flex: none; }
.urlbar .uuid { color: #ffcf6e; }

.hotspot { cursor: pointer; }

.hotspot.faint { cursor: default; }

.glow-pulse { animation: glowPulse 2.4s ease-in-out infinite; }
@keyframes glowPulse {
    0%, 100% { opacity: .18; }
    50%      { opacity: .5; }
}

.shake { animation: shake .45s ease; }
@keyframes shake {
    10%,90% { transform: translateX(-2px); }
    20%,80% { transform: translateX(4px); }
    30%,50%,70% { transform: translateX(-8px); }
    40%,60% { transform: translateX(8px); }
}

.btn {
    position: absolute;
    z-index: 32;
    padding: 9px 16px;
    font-size: .95em;
    font-family: inherit;
    color: #f3ecdd;
    background: rgba(28,24,20,.82);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 999px;
    cursor: pointer;
    backdrop-filter: blur(3px);
    transition: background .15s ease, transform .15s ease;
}
.btn:hover { background: rgba(60,48,36,.92); transform: translateY(-1px); }
.btn-back { left: 18px; top: 16px; }

.fnaf-back {
    position: absolute;
    left: 18px;
    top: 16px;
    transform: rotate(-.6deg);
    z-index: 33;
    padding: 9px 22px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 14px;
    letter-spacing: 1.5px;
    color: #33386e;
    background: #f3ecd6;
    border: 2.5px solid #33386e;
    border-radius: 14px 12px 15px 11px / 12px 15px 11px 14px;
    box-shadow: 2px 3px 0 #8c6b9a;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease;
}
.fnaf-back:hover { transform: rotate(-.6deg) translateY(-2px); box-shadow: 2px 5px 0 #8c6b9a; }
.fnaf-back:active { transform: rotate(-.6deg) translateY(1px); box-shadow: 1px 2px 0 #8c6b9a; }
.fnaf-back .chev { color: #b56a5a; font-size: 1.2em; font-weight: 700; }

.dispense-card {
    position: absolute;
    z-index: 25;
    width: 220px;
    left: 50%;
    top: 58%;
    transform: translate(-50%, 40px);
    opacity: 0;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,.6));
    transition: transform .7s cubic-bezier(.2,.8,.25,1), opacity .5s ease;
    cursor: pointer;
}
.dispense-card.out { transform: translate(-50%, -10px); opacity: 1; }
.dispense-card.taken { transform: translate(50vw, -40vh) scale(.35) rotate(12deg); opacity: 0; }

.tap-hint {
    position: absolute;
    z-index: 26;
    color: #ffd98a;
    font-size: .85em;
    text-shadow: 0 1px 3px #000;
    pointer-events: none;
    animation: bob 1.4s ease-in-out infinite;
}
@keyframes bob { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-5px);} }
