:root{color-scheme:dark;--ink:#f4ead1;--gold:#d8b376;--dim:#9ca8ab;--rule:#455351}*{box-sizing:border-box}html,body{margin:0;min-height:100%;background:#111820;color:var(--ink);font-family:system-ui,Arial,sans-serif}body{min-height:100svh;display:grid;align-items:center;justify-items:center;padding:max(8px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));background:radial-gradient(ellipse at 50% 15%,#293738 0,#151e25 50%,#101519 100%)}#cabinet{width:min(100%,1020px)}header{display:flex;align-items:center;gap:13px;padding:5px 0 12px}.crest{color:#e8c183;background:#242b29;border:1px solid #75694f;border-radius:4px;padding:2px 7px;font:29px Georgia}.title{min-width:0;flex:1}.title small,#zonebar,#status,#end small,#ad small,footer{font:600 10px/1.4 ui-monospace,Consolas,monospace;letter-spacing:.11em}.title small{color:var(--gold);font:600 9px/1.5 ui-monospace,Consolas,monospace;letter-spacing:.21em}.title h1{margin:0;line-height:1.04;font:600 clamp(19px,3vw,34px)/1.05 Georgia,serif}.title h1 span{color:#cebc9e;font-style:italic;font-weight:400;margin-left:.25em}button{color:var(--ink);border:1px solid #827457;background:#29312f;border-radius:4px;cursor:pointer;touch-action:none;user-select:none;-webkit-user-select:none}button:focus-visible{outline:2px solid #f4cb80;outline-offset:2px}button:active,button.held{background:#846c45;color:#fff}#sound{width:34px;height:34px;font-size:20px}#shell{aspect-ratio:1.8;position:relative;background:#26323a;overflow:hidden;border:1px solid #726952;box-shadow:0 12px 45px #0005;isolation:isolate}#viewport,#viewport canvas,#ad,#end{position:absolute;inset:0;width:100%;height:100%}#viewport canvas{display:block;image-rendering:pixelated;touch-action:none}#zonebar{position:absolute;top:0;left:0;right:0;display:flex;justify-content:space-between;align-items:start;padding:2.5% 3% 4%;background:linear-gradient(#12191cb0,transparent);pointer-events:none;color:#feefd0;text-shadow:1px 2px #1c2229}#hearts{color:#ff956c;font-size:15px}#dialog{position:absolute;left:50%;transform:translateX(-50%);bottom:23%;min-width:min(75%,420px);max-width:92%;text-align:center;pointer-events:none;font:600 clamp(11px,1.65vw,19px)/1.3 Georgia,serif;color:#fff7df;text-shadow:0 1px 2px #080d13,1px 1px 1px black;padding:6px 12px;background:linear-gradient(90deg,#1118 0%,#111d 25%,#111d 75%,#1118);border-radius:2px}#dialog:empty{display:none}#actionWrap{position:absolute;left:0;right:0;bottom:6%;text-align:center;pointer-events:none}#action{pointer-events:auto;min-height:36px;padding:7px 17px;background:#172225ed;color:#ffdc98;font:bold clamp(12px,1.6vw,18px)/1.2 ui-monospace,monospace;border:1px solid #b69358;box-shadow:0 2px 0 #080e12}#action:empty{display:none}#status{display:flex;justify-content:space-between;gap:1em;padding:10px 2px;color:#d5c8a8;letter-spacing:.025em;text-wrap:balance}#score{white-space:nowrap;color:var(--gold)}#controls{display:none;justify-content:space-between;gap:8px;padding:8px 0}#controls div{display:flex;gap:8px}#controls button{min-width:60px;min-height:50px;font-size:19px;line-height:1}#controls b{font:700 11px system-ui;letter-spacing:.08em}#controls>button{padding:0 19px;border-color:#a18c65}footer{display:flex;justify-content:space-between;color:var(--dim);border-top:1px solid var(--rule);padding:9px 2px;letter-spacing:.01em}footer i{color:#9b927c;font-style:normal}#end,#ad{z-index:4;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center;background:#121b24ee}#end[hidden],#ad[hidden]{display:none}#end small{color:#b9a17c}#end h2{font:700 clamp(18px,4.4vw,56px)/1.03 Georgia,serif;margin:12px 0 4px}#end strong{color:#edc080;font:700 clamp(16px,3vw,36px)/1.05 Georgia,serif}#end p{font:500 clamp(10px,1.6vw,16px)/1.3 ui-monospace,monospace;max-width:94%;margin:12px}#restart{font:700 12px ui-monospace,monospace;padding:10px 14px}#ad{background:#100e2c}#ad img{width:100%;height:100%;object-fit:contain}#ad img:not([src]){display:none}#ad small{position:absolute;bottom:0;left:0;color:white;background:#131023b8;font-size:8px}#adFallback{background:linear-gradient(120deg,#3828ec,#9a49eb,#289fe1);color:white;border:3px solid #d7a4ff;padding:3%;font:900 clamp(13px,3vw,28px)/1.1 system-ui}#adFallback strong{display:block;font-size:4em}#adPicture[src]+#adFallback{display:none}
@media(pointer:coarse),(max-width:760px){#controls{display:flex}footer{font-size:8px}footer span{visibility:hidden}#cabinet{max-width:800px}.title h1 span{white-space:nowrap}}@media(max-width:500px) and (orientation:portrait){body{align-items:center}header{gap:9px}.title h1 span{display:block;margin:2px 0 0;font-size:16px}.title small{font-size:8px}#shell{aspect-ratio:1.65}#dialog{bottom:24%;min-width:80%}#status{font-size:10px}#zonebar{font-size:9px}#action{min-height:34px}#controls{padding-top:4px}#end h2{margin-top:5px}}@media(orientation:landscape) and (max-height:540px){body{padding:0 5px}#cabinet{width:min(100vw,calc((100svh - 72px)*1.8))}header,footer{display:none}#status{padding:1px 0;font-size:9px}#controls{padding:2px 0}#controls button{min-height:39px}#dialog{font-size:12px}#action{min-height:28px}}

#dialog{bottom:auto;top:16%}

/* Actor captions are anchored to the shared 504×280 game coordinates. */
#dialog[data-mode="speech"]{z-index:2;min-width:0;width:max-content;max-width:39%;left:var(--speech-x,50%);top:var(--speech-y,40%);bottom:auto;transform:translate(-50%,-100%);background:#142333f5;border:1px solid #7899b8;border-radius:4px;padding:.52em .78em;box-shadow:0 2px 0 #111b26,0 6px 16px #0f17267a;font:750 clamp(10px,1.48vw,17px)/1.22 system-ui,Arial,sans-serif;color:#f6ead5;text-wrap:pretty;letter-spacing:.01em}
#dialog[data-mode="speech"]:not(:empty)::after,#dialog[data-mode="speech"]:not(:empty)::before{content:"";position:absolute;left:var(--speech-tail,50%);top:100%;width:0;height:0;border-left:.38em solid transparent;border-right:.38em solid transparent;border-top:.54em solid #7899b8;transform:translateX(-50%);pointer-events:none}
#dialog[data-mode="speech"]:not(:empty)::after{margin-top:-1px;border-top-color:#142333;border-left-width:.29em;border-right-width:.29em;border-top-width:.43em}
#dialog[data-speaker="malborn"]{border-color:#d29570;background:#32201af5}
#dialog[data-speaker="malborn"]:not(:empty)::before{border-top-color:#d29570}
#dialog[data-speaker="malborn"]:not(:empty)::after{border-top-color:#32201a}
#dialog[data-mode="scroll"]{z-index:3;top:21%;bottom:auto;width:min(78%,510px);min-width:0;padding:1.55em 1em;color:#392310;background:linear-gradient(90deg,#ae8957,#e6ca8e 8%,#f0d7a1 48%,#debf84 92%,#926941);text-shadow:none;border:2px solid #534028;border-radius:5px;box-shadow:0 8px 0 #16110ea0,0 12px 32px #000b;font-weight:800}
#dialog[data-mode="scroll"]:not(:empty)::before{display:block;content:"✦  Д Р Е В Н И Й  С В И Т О К  ✦";color:#6b461e;border-bottom:1px solid #9a743f;margin:0 auto .65em;padding-bottom:.42em;font:800 .63em ui-monospace,monospace;letter-spacing:.08em}
@media(max-width:500px){#dialog[data-mode="speech"]{font-size:10px;max-width:48%}}
#dialog[data-mode="scroll"][data-reveal="waiting"]{opacity:0}
#dialog[data-mode="scroll"][data-reveal="shown"]{animation:unfurl-scroll .26s ease-out both}
@keyframes unfurl-scroll{from{opacity:0;transform:translate(-50%,-6px) scale(.96)}to{opacity:1;transform:translate(-50%,0) scale(1)}}
@media(prefers-reduced-motion:reduce){#dialog[data-mode="scroll"][data-reveal="shown"]{animation:none}}
#dialog[data-speaker="hero"]{border-color:#d6af72;background:#2c241af7}
#dialog[data-speaker="hero"]:not(:empty)::before{border-top-color:#d6af72}
#dialog[data-speaker="hero"]:not(:empty)::after{border-top-color:#2c241a}


/* The game retains its 504:280 proportions when filling the display. */
#fullscreen{
 display:grid;place-items:center;flex:none;width:36px;height:36px;padding:0;
 color:var(--gold);background:#262d29
}
#fullscreen svg{width:20px;height:20px;pointer-events:none}
#fullscreen .collapse-icon,#fullscreen[aria-pressed="true"] .expand-icon{display:none}
#fullscreen[aria-pressed="true"] .collapse-icon{display:block}
#sound{flex:none}
#cabinet:focus{outline:none}
@media(pointer:coarse){#sound,#fullscreen{width:42px;height:42px}}
@media(orientation:landscape) and (max-height:540px){
 #cabinet:not([data-expanded]){position:relative}
 #cabinet:not([data-expanded]) header{
   display:flex;position:absolute;z-index:5;gap:4px;padding:0;top:3px;right:4px
 }
 #cabinet:not([data-expanded]) header :is(.crest,.title){display:none}
 #cabinet:not([data-expanded]) header button{width:34px;height:34px}
 #cabinet:not([data-expanded]) #zonebar{padding-right:79px}
}
html.game-expanded{overflow:hidden}
#cabinet[data-expanded]{
 position:fixed;inset:0;z-index:10;
 width:100%;max-width:none;height:100vh;height:100dvh;
 display:flex;flex-direction:column;justify-content:center;align-items:center;
 padding:max(4px,env(safe-area-inset-top)) max(5px,env(safe-area-inset-right)) max(4px,env(safe-area-inset-bottom)) max(5px,env(safe-area-inset-left));
 background:#111820;
}
#cabinet[data-expanded] header{
 display:flex;align-items:center;align-self:stretch;gap:6px;min-height:35px;padding:0 0 4px
}
#cabinet[data-expanded] header .crest,#cabinet[data-expanded] header .title small,
#cabinet[data-expanded] header .title h1 span,#cabinet[data-expanded] footer{display:none}
#cabinet[data-expanded] header .title h1{font-size:clamp(14px,2.4vw,20px)}
#cabinet[data-expanded] #play-area{
 display:grid;place-items:center;flex:1;align-self:stretch;min-height:0;
 container-type:size
}
#cabinet[data-expanded] #shell{
 width:min(100%,calc((100dvh - 100px)*1.8));aspect-ratio:504/280;
 box-shadow:none
}
@supports(width:1cqh){
 #cabinet[data-expanded] #shell{width:min(100cqw,180cqh)}
}
#cabinet[data-expanded] #status{
 align-self:center;width:100%;max-width:1500px;gap:4px 12px;padding:5px 2px 3px;
 flex-wrap:wrap;
}
#cabinet[data-expanded] #mission{flex:1 1 11rem}
#cabinet[data-expanded] #score{white-space:normal;text-align:right}
#cabinet[data-expanded] #controls{width:min(100%,1500px);padding:3px 0 0}
#cabinet[data-expanded] #controls button{min-height:46px}
@media(orientation:landscape) and (max-height:540px){
 #cabinet[data-expanded] header{position:absolute;z-index:5;right:max(8px,env(safe-area-inset-right));top:max(8px,env(safe-area-inset-top));min-height:0;padding:0}
 #cabinet[data-expanded] header .title{display:none}
 #cabinet[data-expanded] header button{width:34px;height:34px}
 #cabinet[data-expanded] #zonebar{padding-right:84px}
 #cabinet[data-expanded] #status{padding:2px 0 1px}
 #cabinet[data-expanded] #controls button{min-height:39px}
}

/* Deadpan chapter title, in the same visual language as the mission HUD. */
#dialog[data-title="true"]{
 z-index:3;top:15%;bottom:auto;left:50%;width:max-content;max-width:84%;min-width:0;
 transform:translateX(-50%);padding:.9em 1.65em .8em;border:1px solid #bc9759;
 background:linear-gradient(90deg,#141b26f0,#252321fa 50%,#141b26f0);
 box-shadow:0 3px 0 #121621a0,0 8px 27px #090c15bd,inset 0 0 0 2px #332b22;
 color:#f4d893;letter-spacing:.085em;text-transform:uppercase;
 font:700 clamp(11px,2.1vw,25px)/1.17 Georgia,serif;text-shadow:0 1px 2px #0e1018;
 animation:reception-title .26s ease-out both;
}
#dialog[data-title="true"]::before{display:block;position:static;width:auto;height:auto;transform:none;border:0;content:"✦";color:#c1a06a;font-size:.75em;margin-bottom:.3em}
#dialog[data-title="true"]::after{display:block;position:static;width:auto;height:auto;transform:none;border:0;content:"Задача: незаметно отвлечь гостей";color:#e4cba3;font:500 .68em/1.3 Georgia,serif;text-transform:none;letter-spacing:.05em;margin-top:.58em}
@keyframes reception-title{from{opacity:0;transform:translate(-50%,-10px)}to{opacity:1;transform:translate(-50%,0)}}
#shell[data-phase="cut"]::after{content:"";position:absolute;inset:0;z-index:8;pointer-events:none;background:#111119;box-shadow:inset 0 1px #b1c8cc}
#end:not([hidden]){background:radial-gradient(ellipse at center,#25282d,#111824 78%);gap:.38em}
#end #summary{
 position:relative;white-space:pre-line;text-align:left;width:max-content;max-width:94%;
 padding:.95em 1.2em;margin:.27em 0 .44em;background:#efe1be;color:#352b25;
 border-top:2px dashed #9a7957;border-bottom:2px dashed #9a7957;
 font:700 clamp(9px,1.42vw,15px)/1.35 ui-monospace,monospace;
 letter-spacing:0;box-shadow:0 6px 24px #090e17af;text-shadow:none;
}
#end h2{margin:.1em 0;font-size:clamp(15px,3vw,34px)}
#end strong{font-size:clamp(12px,2.1vw,24px)}
@media(max-height:500px) and (orientation:landscape){#end #summary{font-size:9px;padding:.5em 1em}#end small{font-size:8px}#end h2{font-size:16px}#end strong{font-size:12px}#end #restart{padding:5px 12px}}
@media(prefers-reduced-motion:reduce){#dialog[data-title="true"]{animation:none}}

#shell{container-type:inline-size}
#dialog[data-mode="speech"][data-speaker="hero"][data-scene="basement"]{
  max-width:54%;font-size:clamp(14px,2.38cqw,26px);font-weight:820;line-height:1.24;
  padding:.42em .68em;color:#fff5e3;background:#241c15;border-color:#e1b779;
}
#dialog[data-mode="speech"][data-speaker="hero"][data-scene="basement"]::before{border-top-color:#e1b779}
#dialog[data-mode="speech"][data-speaker="hero"][data-scene="basement"]::after{border-top-color:#241c15}

/* Anton is visibly furious, but the jolt settles before the words need reading. */
#dialog[data-mode="speech"][data-speaker="anton"][data-anger]{
  color:#fff1df;background:#31191ff7;border-color:#ee8d80;box-shadow:0 2px 0 #200e16,0 5px 16px #250a158c;
}
#dialog[data-mode="speech"][data-speaker="anton"][data-anger]::before{border-top-color:#ee8d80}
#dialog[data-mode="speech"][data-speaker="anton"][data-anger]::after{border-top-color:#31191f}
#dialog[data-anger="peak"] .anton-accent{color:#ffae98;font-weight:900}

/* Text and the dialogue blips use the same reveal timetable. */
.dialog-word{white-space:nowrap}
.dialog-letter{animation:dialog-letter-show 1ms step-end both}
@keyframes dialog-letter-show{from{opacity:0}to{opacity:1}}
@media(prefers-reduced-motion:reduce){.dialog-letter{animation:none!important}}
