#castleLevel{position:fixed;inset:0;z-index:100000;background:radial-gradient(ellipse at center,#30243e,#080b15);display:flex;flex-direction:column;align-items:center;justify-content:center;padding:12px;color:#fff7d9;font-family:'Courier New',monospace;touch-action:none}
#castleLevel[hidden]{display:none!important}.castleFrame{width:min(100%,1100px);border:3px solid #9ca9ba;box-shadow:inset 2px 2px #fff,0 12px 50px #000;background:#111827;position:relative}.castleTitle{display:flex;justify-content:space-between;align-items:center;background:#000080;padding:8px 12px;font-weight:bold;gap:8px;font-size:clamp(11px,2vw,18px)}.castleTitle button,.castleAction{font:700 14px 'Courier New',monospace;background:#c0c0c0;border:2px outset #fff;padding:6px 10px;cursor:pointer;color:#111}.castleTitle button:active,.castleAction:active{border-style:inset}.castleHud{display:flex;justify-content:space-between;gap:5px;padding:8px;background:#162234;color:#ffdc72;font-size:clamp(10px,2vw,16px);font-weight:bold}#castleCanvas{display:block;width:100%;aspect-ratio:3/2;image-rendering:pixelated;background:#0a0d20}.castleHelp{padding:8px;font-size:clamp(10px,1.6vw,14px);text-align:center;color:#cbd5e1}.castlePad{display:flex;gap:10px;justify-content:center;padding:8px;width:100%}.castlePad button{width:64px;height:54px;border:2px solid #91a4bc;border-radius:10px;background:#1b304c;color:#fff8d9;font:bold 16px 'Courier New',monospace;touch-action:none;cursor:pointer;box-shadow:0 3px #070c16}.castlePad button:active,.castlePad button.held{background:#41637f;transform:translateY(2px)}.castlePad button:last-child{background:#8f381c;border-color:#ffb345}.castleMessage{position:absolute;left:10%;right:10%;top:35%;text-align:center;padding:22px;background:#111827ee;border:3px solid #ffcf63;box-shadow:6px 6px #000;color:#fff6db}.castleMessage[hidden]{display:none}.castleMessage h2{font-size:clamp(20px,4vw,32px);margin:0 0 12px}.castleMessage p{line-height:1.5}.castleMessage button{margin:6px}
@media(max-height:760px) and (min-width:701px){.castleFrame{width:min(100%,calc((100dvh - 120px)*1.5))}}
@media(max-width:700px){#castleLevel{padding:6px}.castlePad{gap:6px}.castlePad button{width:21%;max-width:88px}.castleMessage{left:5%;right:5%;padding:12px}}
/* Consistent retro interaction states across the original game. */
#stage button{touch-action:manipulation}#stage button:focus-visible,#xFlag:focus-visible{outline:3px solid #fff3a3;outline-offset:2px}.slotPlay{border:2px outset #fff0a0;cursor:pointer}.slotPlay:active{border-style:inset;transform:translateY(1px)}#infoPopup{border:3px outset #c8d0d8;box-shadow:8px 8px 0 #0007}#infoPopupBody{line-height:1.6}#mintPanel{border:3px outset #d8d8d8}.mobileBtn{backdrop-filter:blur(3px);border-color:#dfe9f4;background:#0a142ca8}.mobileBtn.pressed{background:#345d80d9}.tubeCastleLabel{position:absolute;right:1.8%;top:30%;font:700 clamp(5px,.85vw,13px) 'Courier New',monospace;color:#fff3a3;text-shadow:1px 1px #102410;z-index:42;pointer-events:none}

/* Match the city game's Win95 panels and its exact four-control layout. */
#castleLevel{background:#02050a url('castle-city-background.png') center/cover no-repeat;padding-bottom:110px}
.castleFrame{background:#c0c0c0;border:3px outset #eee;box-shadow:4px 4px #0008;width:min(100%,1100px,calc((100dvh - 220px)*1.5))}
.castleTitle{background:#000080;color:#fff}.castleHud{background:#c0c0c0;color:#111;border-bottom:2px inset #eee}.castleHelp{background:#c0c0c0;color:#111;font-weight:bold}.castleMessage{background:#c0c0c0;color:#111;border:3px outset #eee}.castleMessage h2{background:#000080;color:#ffe87b;padding:8px}
#castleLevel .castlePad{position:fixed;inset:0;width:100%;padding:0;display:block;pointer-events:none}
#castleLevel .castlePad button{position:absolute;width:72px;height:72px;max-width:none;border-radius:50%;border:3px solid #dfe9f4;background:#0a142ca8;color:#fff;font:bold 34px/1 monospace;display:flex;align-items:center;justify-content:center;pointer-events:auto;touch-action:none;box-shadow:0 3px 0 #0007;backdrop-filter:blur(3px);bottom:max(22px,env(safe-area-inset-bottom))}
#castleLevel .castlePad button:nth-child(1){left:max(18px,env(safe-area-inset-left))}
#castleLevel .castlePad button:nth-child(2){left:max(102px,calc(env(safe-area-inset-left) + 102px))}
#castleLevel .castlePad button:nth-child(3){right:max(102px,calc(env(safe-area-inset-right) + 102px));font-size:29px}
#castleLevel .castlePad button:nth-child(4){right:max(18px,env(safe-area-inset-right));font-size:19px}
#castleLevel .castlePad button.held,#castleLevel .castlePad button:active{transform:translateY(2px) scale(.96);background:#345d80d9}
@media(max-width:600px){#castleLevel .castlePad button{width:62px;height:62px;font-size:29px}#castleLevel .castlePad button:nth-child(2){left:max(90px,calc(env(safe-area-inset-left) + 90px))}#castleLevel .castlePad button:nth-child(3){right:max(90px,calc(env(safe-area-inset-right) + 90px))}#castleLevel .castlePad button:nth-child(4){font-size:16px}}

#mobileDown,#mobileJump{font-size:29px!important}
#castleLevel .castlePad button:nth-child(3),#castleLevel .castlePad button:nth-child(4){font-size:29px}

/* Unframed castle playfield. */
.castleFrame{border:0;box-shadow:none;background:transparent;width:min(100%,1100px,calc((100dvh - 155px)*1.5))}
.castleHelp,.castleTitle>span{display:none}.castleTitle{position:absolute;top:7px;right:7px;z-index:2;background:transparent;padding:0}.castleHud{background:#07152ddd;color:#ffe99a;border:0;padding:8px 12px}.castleTitle button{background:#172b46;color:#fff;border:1px solid #7792a9;font-size:11px}.castleMessage{background:#0c1934f0;color:#fff3d0;border:2px solid #ffcc5b}.castleMessage h2{background:transparent}
#castleWhitelist{display:flex;flex-direction:column;gap:10px;text-align:left}#castleWhitelist[hidden]{display:none}#castleWhitelist label{font-weight:bold;font-size:14px}#castleAddress{width:100%;font:14px monospace;padding:12px;border:2px solid #ffce60;background:#07162c;color:#fff}#castleAddressStatus{font-size:13px;color:#ffd477;overflow-wrap:anywhere}

@media(max-width:700px){
#castleLevel .castleMessage{left:10%;right:10%;top:24%;padding:10px;border-width:2px}
#castleLevel .castleMessage h2{font-size:15px;padding:4px;margin:0 0 6px}
#castleLevel .castleMessage p{font-size:11px;line-height:1.35;margin:5px 0 8px}
#castleWhitelist{gap:6px}#castleWhitelist label,#castleAddressStatus{font-size:10px}
#castleAddress{font-size:11px;padding:8px;min-width:0}
#castleLevel .castleMessage .castleAction{font-size:10px;padding:7px 5px;margin:3px 0}
}

/* Keep the same ground and castle baseline at every screen size. */
#castleCanvas{height:auto;aspect-ratio:900/600;object-fit:contain}

/* Black dungeon backdrop on desktop and mobile. */
#castleLevel,#castleCanvas{background:#000}
