:root{--safe-top:env(safe-area-inset-top,0px);--safe-bottom:env(safe-area-inset-bottom,0px);--safe-left:env(safe-area-inset-left,0px);--safe-right:env(safe-area-inset-right,0px)}
html,body{width:100%;height:100%;overscroll-behavior:none}body{background:#101c2c}canvas{position:absolute;width:auto;height:auto;touch-action:none}
.mobile-ui{display:none}.screen-layer[hidden]{display:none!important}.screen-layer{position:fixed;inset:0;z-index:140;display:flex;align-items:center;justify-content:center;background:#102433ed;text-align:center;padding:25px;box-sizing:border-box}.screen-card{max-width:420px;color:#edf0df}.screen-card button{padding:14px 32px;border:0;border-radius:12px;background:#d7d9a1;color:#233d40;font-size:17px;cursor:pointer}.screen-card p{line-height:1.8}
#debug-panel{position:absolute;right:16px;top:16px;z-index:120;background:#18333eea;padding:12px;border-radius:10px;color:#eef0db;font:13px system-ui;max-width:230px}
#shop{box-sizing:border-box}#shop .shop-grid button{min-width:0}#shop button{touch-action:manipulation}
@media(pointer:coarse),(any-pointer:coarse){
 body{user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;touch-action:none}button,select,summary{touch-action:manipulation;-webkit-tap-highlight-color:transparent}footer,.hud{display:none}
 .mobile-ui{display:block}#mobile-header{position:absolute;z-index:30;top:calc(7px + var(--safe-top));left:calc(14px + var(--safe-left));right:calc(14px + var(--safe-right));display:flex;justify-content:space-between;align-items:flex-start;pointer-events:none;font-size:12px;color:#e4ebd4}#mobile-header .vitals{display:flex;gap:12px;font-weight:700;font-size:15px}#mobile-location{margin-top:3px;color:#becdc6}#mobile-gear{margin-top:3px;color:#e2cc94}.mobile-toolbar{display:flex;gap:8px;pointer-events:auto}.mobile-toolbar button{border:1px solid #9ab5a4;background:#1d383deb;color:#f2eacb;padding:9px 13px;border-radius:12px;font-weight:bold;min-height:44px}
 #mobile-controls{position:absolute;inset:0;z-index:40;pointer-events:none}#mobile-controls.controls-blocked{visibility:hidden}#dpad{position:absolute;left:calc(16px + var(--safe-left));bottom:calc(12px + var(--safe-bottom));display:grid;grid-template-columns:repeat(3,48px);grid-template-rows:repeat(3,43px);gap:3px;pointer-events:none}.control{pointer-events:auto;touch-action:none;border:1px solid #91afa4aa;background:#1c383dc9;color:#eaf0d8;box-shadow:0 3px 8px #0004;border-radius:13px;font-size:17px;font-weight:700;user-select:none}.control.pressed{background:#d4d7a7;color:#213e3d;transform:scale(.96)}#dpad .up{grid-area:1/2}#dpad .left{grid-area:2/1}#dpad .right{grid-area:2/3}#dpad .down{grid-area:3/2}#dpad .center{grid-area:2/2;display:flex;align-items:center;justify-content:center;font-size:10px;color:#a9bdb3}
 #actions{position:absolute;bottom:calc(15px + var(--safe-bottom));right:calc(18px + var(--safe-right));display:grid;grid-template-columns:52px 58px 68px;grid-template-rows:46px 58px;gap:7px;pointer-events:none}#actions .control{font-size:12px}#primary-attack{grid-area:2/3;font-size:16px!important;background:#506858e8;border-color:#d6d8a0}#throw-knife{grid-area:2/2}#interact{grid-area:1/3}#switch-weapon{grid-area:1/2}#change-ammo{grid-area:1/1}
 #notice{bottom:calc(155px + var(--safe-bottom))!important;max-width:48vw!important;padding:8px 12px!important;font-size:12px;z-index:65!important;pointer-events:none}
 #shop{width:min(790px,calc(100vw - var(--safe-left) - var(--safe-right) - 24px))!important;padding:10px 14px!important;max-height:none;font-size:12px}#shop h2{font-size:17px;margin:0 0 3px}#shop p{font-size:11px;margin:3px 0}#shop .shop-tabs{margin:5px 0;gap:5px}#shop .shop-tabs button{padding:6px 3px;font-size:12px;min-height:32px}#shop .shop-grid{gap:5px}#shop .shop-grid button{min-height:49px;padding:5px;gap:2px;font-size:11px}#shop .shop-grid span{font-size:10px}#shop .shop-grid strong{font-size:11px}#shop>button{min-height:32px;padding:5px 16px;border-radius:7px;border:0;background:#d3dcb8;color:#243e43}#receipt{min-height:13px;line-height:1.15}#debug-panel{top:calc(62px + var(--safe-top));right:calc(12px + var(--safe-right));padding:7px;font-size:10px;max-width:210px}#chapterEnd h1{font-size:24px}
}
@media(pointer:coarse) and (max-height:360px){#shop .shop-grid button{min-height:42px}#shop .shop-grid{gap:3px}#shop>p:nth-of-type(1){display:none}#dpad{grid-template-columns:repeat(3,43px);grid-template-rows:repeat(3,38px)}#notice{bottom:140px!important}}

#dpad .up-left{grid-area:1/1;font-size:15px;background:#203d4299}#dpad .up-right{grid-area:1/3;font-size:15px;background:#203d4299}

html{overflow:hidden}body{position:fixed;inset:0;height:100dvh;overflow:hidden}@media(pointer:coarse),(any-pointer:coarse){#mobile-hint{max-width:55vw;color:#d7dfcf;font-size:11px;line-height:1.4;margin-top:3px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}}

body.portrait-blocked canvas,body.portrait-blocked #mobile-header,body.portrait-blocked #shop,body.portrait-blocked #chapterEnd,body.portrait-blocked #notice{visibility:hidden!important}#rotate-layer{z-index:200}#orientation-status{font-size:13px;color:#c7d3c3;max-width:320px;margin:18px auto}#start-landscape:disabled{opacity:.6}

#mobile-boss{margin-top:4px;color:#f3cd83;font-weight:bold;font-size:13px}

@media(pointer:coarse) and (max-height:360px){#mobile-hint{-webkit-line-clamp:1}#mobile-gear{font-size:11px}#mobile-boss{font-size:12px}}
@media(pointer:coarse),(any-pointer:coarse){#notice{bottom:calc(10px + var(--safe-bottom))!important;max-width:calc(100vw - 420px)!important;max-height:66px;overflow:hidden;padding:7px 10px!important;font-size:12px;line-height:1.4;box-sizing:border-box}}
/* Small, optional feedback panels. */
#desktop-feedback{position:absolute;right:16px;top:16px;z-index:125;display:flex;gap:8px}#desktop-feedback button,[data-rescue-open],[data-sound-toggle]{min-height:40px;border:1px solid #9bb7a9;background:#25454b;color:#e8e6c7;border-radius:10px;padding:8px 12px;cursor:pointer}#debug-panel{top:68px}
#friends-layer{z-index:155}.friends-card{width:min(620px,92vw);box-sizing:border-box;padding:20px;border:1px solid #b5c2a6;background:#2c4a4f;border-radius:18px;text-align:left}.friends-card h2{font-size:22px;margin:0 0 8px}.friends-card>p{font-size:14px;margin:6px 0 14px}#friend-cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-bottom:14px}.friend-card{display:flex;align-items:center;gap:8px;background:#d5ddc4;color:#29454b;border-radius:12px;padding:10px;min-width:0}.friend-card h3{font-size:15px;margin:0 0 6px}.friend-card p{font-size:13px;line-height:1.5;margin:0;color:#355357}.friend-avatar{position:static!important;display:block;width:64px!important;height:72px!important;flex:0 0 64px}#close-friends{min-height:44px}
#party-canvas{position:static!important;display:block;width:min(450px,100%)!important;height:88px!important;margin:0 auto;pointer-events:none}.end-card{box-sizing:border-box;position:relative;width:min(600px,calc(100vw - 30px));padding:18px!important;overflow:hidden}.end-card h1{font-size:25px;margin:0 0 8px}.end-card p{font-size:14px;margin:6px 0;line-height:1.5}.end-card #endFriends{font-size:14px;margin:5px 0 12px;color:#d9d7a0}.end-card #finishChapter{position:relative;z-index:2;min-height:44px;font-size:18px!important;padding:10px 35px!important}#confetti{position:absolute;inset:0;pointer-events:none;overflow:hidden}#confetti i{position:absolute;left:var(--left);top:-12px;width:6px;height:10px;border-radius:2px;animation:boat-confetti 2.6s var(--delay) ease-in forwards}@keyframes boat-confetti{to{transform:translateY(330px) rotate(var(--turn));opacity:0}}
@media(pointer:coarse),(any-pointer:coarse){#desktop-feedback{display:none}.mobile-toolbar{gap:5px}.mobile-toolbar button{font-size:12px;padding:8px 9px;min-height:44px}#debug-panel{top:calc(62px + var(--safe-top))}.friends-card{padding:14px;max-width:590px}.friends-card h2{font-size:19px}.friends-card>p{font-size:12px}.friend-card{padding:8px}.friend-card p{font-size:12px}.end-card h1{font-size:22px}}
@media(max-height:360px){#party-canvas{height:70px!important}.end-card{padding:12px!important}.end-card h1{font-size:20px}.friends-card{padding:12px}}
@media(prefers-reduced-motion:reduce){#confetti i{animation:none;display:none}}
#close-friends{border:0;border-radius:10px;padding:10px 22px;font-size:14px;font-weight:bold;background:#d7dcad;color:#29454b;cursor:pointer}
.route-mini{display:inline-flex;align-items:center;gap:3px;vertical-align:middle;flex:0 0 auto;height:12px}.route-step{display:block;width:8px;height:8px;border-radius:50%;background:#66858180;border:1px solid #8aa598;box-sizing:border-box}.route-step.done{background:#bad3a2;border-color:#bad3a2}.route-step.current{background:#e9c57d;border-color:#fff0b6;box-shadow:0 0 0 2px #e9c57d33}.book-tabs{display:flex;gap:7px;margin:9px 0}.book-tabs button{flex:1;min-height:36px;border:1px solid #92aaa0;background:#35565b;color:#edf0d9;border-radius:9px;cursor:pointer}.book-tabs button[aria-selected="true"]{background:#d7dcad;color:#29454b}#book-friends>p,#book-finds>p{font-size:13px;line-height:1.5;margin:7px 0 10px}#find-cards{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:7px;margin-bottom:13px}.find-card{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-height:59px;padding:5px 2px;border-radius:9px;background:#3a5a5e;color:#b9ccc0;font-size:10px;text-align:center;box-sizing:border-box}.find-card.found{background:#d5ddc4;color:#29454b}.find-mark{font-size:21px;line-height:1.15}.friends-card{max-height:calc(100dvh - 24px)}
@media(pointer:coarse),(any-pointer:coarse){#mobile-header>div:first-child{min-width:0}.mobile-toolbar{flex-shrink:0}#mobile-header .vitals{flex-wrap:wrap;column-gap:10px;row-gap:2px}.vitals .route-mini{margin-top:3px}.route-step{width:7px;height:7px}.route-mini{gap:3px}.book-tabs{margin:7px 0}.friends-card{padding:12px 14px}.friends-card h2{margin-bottom:3px}.book-tabs button{font-size:12px}.find-card{min-height:56px}#book-friends>p,#book-finds>p{font-size:12px}}
@media(pointer:coarse),(any-pointer:coarse){
 #dpad{display:block;width:156px;height:156px;left:calc(16px + var(--safe-left));bottom:calc(12px + var(--safe-bottom));border:1px solid #a4beb177;border-radius:50%;box-sizing:border-box;background:radial-gradient(circle,#41656988 0%,#203e4488 65%,#17343d99 100%);box-shadow:inset 0 0 0 13px #92b4a015,0 3px 12px #10263344;pointer-events:auto;touch-action:none}
 #dpad.active{border-color:#d2d9aeaa}#stick-knob{position:absolute;left:50%;top:50%;margin:-24px 0 0 -24px;width:48px;height:48px;border:1px solid #adc3b5;background:#71918bc9;border-radius:50%;box-sizing:border-box;box-shadow:0 3px 8px #10263355;pointer-events:none}
 #dpad .stick-direction{position:absolute;width:36px;height:36px;display:flex;align-items:center;justify-content:center;border:0;border-radius:50%;background:transparent;color:#d5e1c4;font-size:16px;padding:0;touch-action:none;user-select:none;grid-area:auto}
 #dpad .up{top:3px;left:calc(50% - 18px)}#dpad .down{bottom:3px;left:calc(50% - 18px)}#dpad .left{left:3px;top:calc(50% - 18px)}#dpad .right{right:3px;top:calc(50% - 18px)}#dpad .pressed{color:#f7e5a6;background:#b4c39b22}
 #actions{grid-template-columns:64px 64px;grid-template-rows:64px 64px;gap:10px;right:calc(18px + var(--safe-right));bottom:calc(18px + var(--safe-bottom))}#actions .control{border-radius:50%;font-size:12px;min-width:0;padding:3px}#interact{grid-area:1/2}#switch-weapon{grid-area:1/1}#throw-knife{grid-area:2/1}#primary-attack{grid-area:2/2;font-size:16px!important}#interact:disabled{opacity:.55;border-style:dashed;color:#c3d2c7}
}

#actions .control:disabled{opacity:.42;border-style:dashed;filter:saturate(.35);cursor:default;box-shadow:none}#actions .control:disabled.pressed{transform:none;background:#1c383dc9;color:#c3d2c7}
#chest-reveal{z-index:148;background:#10243188;padding:12px}.loot-card{position:relative;isolation:isolate;width:min(370px,calc(100vw - 28px));padding:16px 20px;text-align:center;box-sizing:border-box;border:1px solid #e9cf83;background:linear-gradient(145deg,#3d5a54,#29474b);border-radius:22px;box-shadow:0 0 60px #e4bb4938;overflow:hidden;animation:loot-open .35s ease-out}.loot-card h2{font-size:22px;margin:3px 0 10px;color:#fff0bc}.loot-glow{position:absolute;width:290px;height:250px;left:50%;top:-32px;transform:translateX(-50%);z-index:-1;background:radial-gradient(ellipse,#ffdc736b 0%,#eac96333 35%,transparent 72%);animation:loot-light .6s ease-out}.loot-chest{position:relative;width:104px;height:80px;margin:0 auto 4px}.loot-base{position:absolute;left:9px;top:37px;width:86px;height:40px;border:3px solid #e5c373;border-radius:3px 3px 12px 12px;box-sizing:border-box;background:linear-gradient(90deg,#a07149,#b78c54,#8e6748)}.loot-base:before,.loot-base:after{content:'';position:absolute;top:0;bottom:0;width:6px;background:#d1b16c}.loot-base:before{left:13px}.loot-base:after{right:13px}.loot-base b{position:absolute;width:15px;height:17px;left:32px;top:4px;background:#efd58a;border-radius:4px;border:1px solid #856c43}.loot-base b:after{content:'';display:block;width:3px;height:8px;background:#7a6749;margin:4px auto}.loot-lid{position:absolute;left:6px;top:15px;width:92px;height:28px;border:3px solid #e6c877;border-radius:14px 14px 4px 4px;box-sizing:border-box;background:linear-gradient(#b58c53,#936b46);transform-origin:50% 100%;transform:translateY(-7px) rotate(-15deg);animation:loot-lid .55s ease-out}.loot-stars{position:absolute;inset:0;pointer-events:none}.loot-stars i{position:absolute;font-style:normal;color:#f7df91;font-size:18px;animation:loot-sparkle .9s ease-out forwards}.loot-stars i:nth-child(1){left:20%;top:25px}.loot-stars i:nth-child(2){right:20%;top:40px;animation-delay:.08s}.loot-stars i:nth-child(3){left:11%;top:90px;animation-delay:.14s}.loot-stars i:nth-child(4){right:13%;top:100px;animation-delay:.18s}.loot-stars i:nth-child(5){left:34%;top:8px;animation-delay:.2s}.loot-stars i:nth-child(6){right:32%;top:10px;animation-delay:.25s}#loot-rewards{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:8px}.loot-item{display:flex;align-items:center;justify-content:center;gap:12px;border:1px solid #e2c77e88;background:#f2e4b8;border-radius:13px;padding:9px;color:#4f533e}.loot-icon{width:48px;height:48px;display:block;flex:0 0 48px}.loot-icon svg{width:100%;height:100%;display:block}.loot-name{display:block;font-size:16px;font-weight:bold}.loot-quantity{display:block;font-size:25px;line-height:1.2;margin-top:2px;color:#82602d}#loot-message{font-size:14px;line-height:1.5;margin:9px 0;color:#e7e6c9}#close-loot{border:0;background:#ecd38d;color:#3f5146;border-radius:12px;padding:10px 28px;font-size:16px;font-weight:bold;min-height:42px;cursor:pointer}
@keyframes loot-open{from{transform:scale(.9);opacity:.4}to{transform:scale(1);opacity:1}}@keyframes loot-lid{from{transform:translateY(0) rotate(0)}to{transform:translateY(-7px) rotate(-15deg)}}@keyframes loot-light{from{opacity:0}to{opacity:1}}@keyframes loot-sparkle{0%{opacity:0;transform:translateY(8px) scale(.6)}25%{opacity:1}100%{opacity:0;transform:translateY(-14px) scale(1.1)}}
@media(max-height:360px){.loot-card{padding:10px 16px}.loot-chest{height:72px;transform:scale(.9);margin-top:-5px}.loot-card h2{font-size:20px;margin-bottom:7px}.loot-item{padding:6px}.loot-icon{width:42px;height:42px;flex-basis:42px}#loot-message{font-size:13px;margin:7px 0}}
@media(prefers-reduced-motion:reduce){.loot-card,.loot-lid,.loot-glow,.loot-stars i{animation:none!important}.loot-stars{display:none}}

#close-loot:focus-visible{outline:2px solid #fff0b6;outline-offset:3px}

/* Game currency: embossed gold coin, independent of platform emoji fonts. */
.coin-icon, #mobile-money::before {
  display:inline-flex; align-items:center; justify-content:center;
  width:1em; height:1em; margin-right:.25em; flex-shrink:0;
  border:2px solid #e3a52c; border-radius:50%;
  background:linear-gradient(135deg,#fff0a0,#f5c348 58%,#df9b24);
  box-shadow:inset 0 0 0 1px #ffe8a0,0 1px 1px #17293466;
  color:#9b6415; font-size:1em; line-height:1; vertical-align:-.12em;
  text-shadow:0 1px #ffeaa4;
}
#mobile-money::before {content:"★";}
.sr-only {position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;}

#mobile-shop.shop-guide {position:relative;outline:2px solid #f8d768;overflow:visible;}
#mobile-shop.shop-guide::after {content:'⬆';position:absolute;top:100%;left:50%;transform:translateX(-50%);font-size:30px;line-height:1.2;color:#ffe28a;text-shadow:0 2px 3px #132b38;pointer-events:none;animation:shop-guide-pulse 1.2s ease-in-out infinite;}
@keyframes shop-guide-pulse {0%,100%{opacity:1;transform:translate(-50%,3px)}50%{opacity:.4;transform:translate(-50%,9px)}}
@media(prefers-reduced-motion:reduce){#mobile-shop.shop-guide::after{animation:none;}}

#shop #receipt.purchase-message{box-sizing:border-box;padding:8px 12px;margin:5px 0;border-radius:8px;font-size:14px;font-weight:700;line-height:1.35;border:2px solid #eac767;background:#fff1ba;color:#31433c;}
#shop #receipt.purchase-message.warning{background:#ffe1bb;border-color:#e5a56a;color:#654025;}
@media(pointer:coarse){#shop #receipt.purchase-message{font-size:12px;padding:5px 8px;}}


#shop #shop-close{position:absolute;right:10px;top:8px;width:36px;height:36px;padding:0;border:0;border-radius:50%;font-size:27px;line-height:1;background:#d3dcb8;color:#243e43;}
#shop h2{padding-right:40px;}
#shop #balance{font-weight:700;color:#ffe29a;}

#shop{max-height:calc(100dvh - 16px);overflow-y:auto;}
#shop #shop-close{z-index:2;}

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

.loot-card{display:flex;flex-direction:column;max-height:calc(100dvh - 24px);}
.loot-card .loot-chest,.loot-card h2,.loot-card #loot-rewards,.loot-card #close-loot{flex-shrink:0;}
.loot-card #loot-message{min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;flex:1 1 auto;line-height:1.55;padding:0 5px;}
.loot-card #close-loot{align-self:center;}
