:root{font-family:"Noto Sans Arabic","Noto Sans",Tahoma,Arial,sans-serif;color:#f9f6dc;background:#69943a;font-synthesis:none;--gold:#edc258;--ink:#173d2b}
*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden;overscroll-behavior:none}body{background:#69943a}button,a{-webkit-tap-highlight-color:transparent}button{font:inherit;cursor:pointer;touch-action:manipulation;border:0}button:focus-visible,a:focus-visible{outline:3px solid #ffe7a0;outline-offset:5px}button:disabled{cursor:default}button svg{fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
#game{position:fixed;inset:0;width:100vw;height:100dvh;overflow:hidden;isolation:isolate;background:#69943a}#canvas-wrap{position:absolute;inset:0;touch-action:none}canvas{display:block;width:100%;height:100%;outline:none}
/* Game surfaces are controls, not selectable document text. Keep editable fields native. */
#game,#game *{-webkit-user-select:none;user-select:none}
#game :is(input,textarea,[contenteditable="true"],[contenteditable="plaintext-only"]),#game :is([contenteditable="true"],[contenteditable="plaintext-only"]) *{-webkit-user-select:text;user-select:text}
/* Floating game HUD; the world remains visible behind every edge. */
.hud-top{position:absolute;top:0;right:0;width:min(100%,440px);padding:max(15px,env(safe-area-inset-top)) 20px 23px;pointer-events:none;background:linear-gradient(#153828a8,#15382835 78%,transparent);color:#fffbe1;text-shadow:0 2px 3px #173a29}
.heading{display:flex;align-items:center;justify-content:space-between}.heading h1{font-size:23px;line-height:1.4;margin:0;font-weight:800;letter-spacing:-.5px}.heading p{font-size:11px;margin:2px 0 0;color:#f5f8e7da}.wallet{display:flex;align-items:center;gap:7px;background:#203e2bd9;border:1px solid #b6bf7e65;border-radius:7px;padding:5px 9px;font:700 18px/1.5 Arial;color:#fff3c1;min-width:77px;justify-content:center;box-shadow:inset 0 1px #ffffff1f,0 2px 0 #18332266}.wallet svg{width:24px;fill:#efbe45;stroke:#a87925;stroke-width:1.4}
.base-health{margin-top:12px;display:grid;grid-template-columns:1fr 1fr;gap:4px 12px}.base-row{display:flex;align-items:center;justify-content:space-between;font-size:10px;font-weight:700;grid-column:1;grid-row:1}.base-row.enemy{grid-column:2}.health-track{height:7px;grid-row:2;background:#142d24b0;border:1px solid #d9dbad70;border-radius:3px;overflow:hidden;box-shadow:0 1px 3px #16301a77}.health-track.enemy{grid-column:2}.health-track i{display:block;width:100%;height:100%;background:linear-gradient(90deg,#267fc9,#61ccf1);transition:width .2s}.health-track.enemy i{background:linear-gradient(90deg,#de684a,#f9a16a)}
.view-tools{position:absolute;left:max(16px,env(safe-area-inset-left));top:max(20px,env(safe-area-inset-top));display:flex;flex-direction:column;gap:10px}.icon-button{width:42px;height:42px;display:grid;place-items:center;background:linear-gradient(145deg,#416c47f2,#23482ff2);color:#f1df9c;border-radius:10px;text-decoration:none;box-shadow:inset 0 1px #bdd49977,0 3px 0 #183b29aa,0 5px 10px #17392233;border:1px solid #8da16ba6}.icon-button svg{width:20px;height:20px}.icon-button:active{transform:translateY(2px);box-shadow:inset 0 1px #bdd49944}.icon-button:disabled{opacity:.45}.icon-button.muted{color:#b4bf94}
.hud-bottom{position:absolute;bottom:0;left:50%;transform:translateX(-50%);width:min(100%,430px);padding:22px 12px max(13px,env(safe-area-inset-bottom));color:#fff9db;pointer-events:none;background:radial-gradient(ellipse at 50% 110%,#183e2ee8,transparent 78%)}
.battle-info{display:flex;justify-content:space-between;align-items:center;font-size:10px;padding:0 22px 4px;color:#fff9d8;text-shadow:0 2px 3px #143822;font-weight:600}.battle-info b{font-size:12px}.team-dot{display:inline-block;background:#6acffa;width:6px;height:6px;border-radius:50%;vertical-align:middle;box-shadow:0 0 5px #62c9ff77}
.actions{display:flex;justify-content:center;gap:12px;align-items:flex-end;pointer-events:auto}.upgrade-button,.deploy-button{position:relative;isolation:isolate;display:flex;align-items:center;flex-direction:column;justify-content:flex-end;flex:0 1 110px;min-width:0;height:111px;padding:0 0 4px;background:none;border:0;color:#fff5cc;text-shadow:0 2px 2px #113328,0 0 6px #173b29;font-size:12px;font-weight:800;user-select:none;transition:transform .12s,filter .12s;touch-action:manipulation}
.upgrade-button::before,.deploy-button::before{content:"";position:absolute;z-index:-1;top:32px;left:17%;right:17%;height:44px;background:linear-gradient(160deg,#557b48d9,#21472ce6);border:1px solid #a6b66e99;border-radius:9px;transform:perspective(100px) rotateX(28deg);box-shadow:0 4px 0 #143b27a8,inset 0 1px #e5de9e55}
.action-art{width:75px;height:75px;object-fit:contain;display:block;pointer-events:none;user-select:none;filter:drop-shadow(0 3px 2px #14362080)}.upgrade-button span,.deploy-button span{position:relative;display:flex;flex-direction:column;align-items:center;line-height:1.6;white-space:nowrap}.upgrade-button small{font:800 12px/1.5 Arial;color:#ffe28c;display:flex;align-items:center;justify-content:center;gap:4px;text-shadow:0 2px 2px #233c24}.coin-dot{background:#e7bb4e;width:10px;height:10px;border-radius:50%;border:1px solid #a77c24;box-shadow:inset 0 1px #ffe9a8;display:inline-block}.upgrade-button:disabled{filter:saturate(.35) brightness(.76)}.upgrade-button:active:not(:disabled),.deploy-button:active:not(:disabled),.deploy-button.holding{transform:translateY(3px) scale(.96)}
.deploy-button{height:123px;flex-basis:126px;font-size:14px;touch-action:none;color:#fffdf0}.deploy-button .action-art{width:94px;height:88px}.deploy-button::before{top:35px;left:14%;right:14%;height:53px;background:linear-gradient(160deg,#4aa5cbd9,#1e628cdb);border-color:#9fdbdcc9;box-shadow:0 4px 0 #123d51ba,inset 0 1px #c5f0ff9c}.deploy-button small{font-size:9px;font-weight:600;color:#dbf4e9}.deploy-button:disabled{filter:saturate(.35) brightness(.78)}.deploy-button.holding::before{box-shadow:0 0 18px #68cdf377,inset 0 1px #e3faff}
.energy-row{display:flex;gap:8px;align-items:center;font-size:9px;font-weight:600;color:#eff3c9;margin:8px 25px 0;text-shadow:0 1px 2px #123823}.energy-row>span:last-child{min-width:22px;text-align:left;font-family:Arial}.energy-track{height:5px;background:#17382b;border:1px solid #658451b3;border-radius:3px;overflow:hidden;flex:1}.energy-track i{height:100%;width:100%;display:block;background:linear-gradient(90deg,#b8c761,#e2de8e);border-radius:3px;transition:width .12s}
.overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:125px 24px 155px;pointer-events:none;background:#1f3b2308}.overlay[hidden]{display:none}.dialog{pointer-events:auto;text-align:center;width:min(100%,330px);padding:23px 23px 18px;border-radius:15px;background:linear-gradient(155deg,#f4efcfef,#e3dfbaee);box-shadow:0 6px 0 #25442d70,0 12px 40px #13352250,inset 0 0 0 3px #fff8d24f;border:2px solid #9a9d5f;color:#2b4630;backdrop-filter:blur(8px)}.dialog-icon{margin:0 auto 9px;width:48px;height:48px;display:grid;place-items:center;color:#597747}.dialog-icon svg{width:40px;fill:#7e9a5c33;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}#dialog-kicker{font-size:10px;color:#7f8046;margin:0 0 5px;font-weight:700}.dialog h2{font-size:22px;line-height:1.5;margin:0 0 9px;font-weight:800;letter-spacing:-.5px}.dialog>p#dialog-copy{font-size:12px;line-height:1.9;color:#5d6b4d;margin:0 0 16px}.primary-button{width:100%;padding:12px 15px;color:#fff8da;background:linear-gradient(#4d97b4,#27627e);border-radius:8px;box-shadow:0 4px 0 #234a55,inset 0 1px #b8e2dc88;border:1px solid #8ab8bb;font-size:15px;font-weight:800;display:flex;justify-content:center;gap:20px;align-items:center;text-shadow:0 1px 2px #1d4d5d}.primary-button:active{transform:translateY(2px);box-shadow:0 2px 0 #234a55}.secondary-button{padding:12px 10px 2px;color:#60714b;background:none;font-size:12px}.gesture-hint{font-size:9px;color:#7b835e;margin:14px 0 0;line-height:1.7}
#toast{position:absolute;top:135px;left:50%;transform:translate(-50%,-8px);opacity:0;transition:.2s;pointer-events:none;white-space:nowrap;background:#284a31ee;border:1px solid #a7b57d;border-radius:7px;color:#fff4c3;padding:8px 15px;font-size:12px;font-weight:700;box-shadow:0 4px 12px #15302150}#toast.visible{opacity:1;transform:translate(-50%,0)}#loading{position:absolute;inset:0;background:#385639;display:flex;align-items:center;justify-content:center;flex-direction:column;color:#f4f2df;font-size:13px;z-index:10;transition:opacity .4s}#loading.done{opacity:0;pointer-events:none}.loading-orbit{width:40px;height:40px;border:2px solid #cee0a533;border-top-color:#d8d990;border-radius:50%;animation:spin 1s linear infinite}#fatal{position:absolute;inset:100px 20px;z-index:20;padding:25px;background:#f4efcf;border-radius:15px;text-align:center;font-size:15px;color:#23402d}#fatal[hidden]{display:none}@keyframes spin{to{transform:rotate(360deg)}}
@media(max-width:540px){.view-tools{top:145px;left:13px;gap:9px}.icon-button{width:38px;height:38px}.hud-top{padding-left:18px;padding-right:18px}.hud-bottom{padding-bottom:max(12px,env(safe-area-inset-bottom))}.actions{gap:9px}.upgrade-button{flex-basis:100px;font-size:11px}.deploy-button{flex-basis:116px;font-size:13px}}
@media(max-height:620px){.heading h1{font-size:19px}.heading p{font-size:10px}.hud-top{padding-top:10px;max-width:360px}.base-health{margin-top:7px}.hud-bottom{padding-top:10px;padding-bottom:8px}.battle-info{font-size:9px}.upgrade-button{height:92px}.action-art{height:61px;width:64px}.deploy-button{height:102px}.deploy-button .action-art{height:71px;width:80px}.energy-row{margin-top:4px}.overlay{padding:90px 24px 125px}.dialog{padding:15px 21px;max-width:325px}.dialog-icon{display:none}.dialog h2{font-size:19px}.dialog>p#dialog-copy{font-size:11px;margin-bottom:10px}.gesture-hint{margin-top:10px}.primary-button{padding:9px 15px}.view-tools{top:14px;flex-direction:row;gap:8px}.icon-button{width:37px;height:37px}}
@media(prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
@media(max-width:540px) and (max-height:620px){.view-tools{top:120px;left:12px;flex-direction:column;gap:8px}.icon-button{width:35px;height:35px}}
/* Combat readability and traceable round economy. */
.heading{align-items:flex-start}.mission-meta{text-align:right;line-height:1.5}.mission-meta #stage-label{font-size:13px;font-weight:800;color:#fff4cb}.mission-meta>span{font-size:10px;color:#e4efc5}.wallet{pointer-events:auto;position:relative;padding-bottom:18px;min-width:87px;cursor:pointer}.wallet small{position:absolute;bottom:2px;left:0;right:0;font:700 8px/1.4 Tahoma;color:#eadfb1}.coin-notice{font-size:9px;color:#f5df8e;margin:5px 1px 0;min-height:13px;text-align:left}.wallet.reward{animation:wallet-pop .35s ease-out}.hud-top{padding-bottom:19px}.base-health{margin-top:4px}.view-tools{gap:8px}.battle-info{gap:9px;font-size:9px;padding-bottom:1px}.battle-info b{font-size:11px}.hud-bottom{padding-top:15px}.deploy-button small{font-size:8px;max-width:130px;white-space:normal;line-height:1.35}.castle-energy{position:absolute;display:flex;align-items:center;gap:5px;width:137px;padding:5px 7px;background:#163e31e6;border:1px solid #92b8a0;border-radius:7px;pointer-events:none;box-shadow:0 2px 7px #17352355;z-index:2;transform:translate(-50%,-50%);font-size:8px;font-weight:800;color:#dcf6df;white-space:nowrap}.castle-energy .energy-track{flex:1;height:6px;border-color:#98bea1}.castle-energy .energy-track i{background:linear-gradient(90deg,#43bfd0,#a7edc9)}.castle-energy b{font:800 10px Arial}.castle-energy small{position:absolute;top:100%;left:0;right:0;text-align:center;color:#ffe080;font-size:8px;text-shadow:0 1px 3px #20361d}
#feedback-layer,#structure-labels{position:absolute;inset:0;pointer-events:none;overflow:hidden;z-index:3}.combat-label{position:absolute;top:0;left:0;font:900 15px/1.2 Tahoma,Arial;white-space:nowrap;text-shadow:0 2px 2px #27341c,1px 0 2px #27341c;will-change:transform,opacity}.coin-fly{position:absolute;top:0;left:0;font-size:18px;line-height:1;color:#ffdd58;text-shadow:0 1px #aa7721,0 0 6px #fff4a977;will-change:transform,opacity}.structure-hp{position:absolute;top:0;left:0;width:60px;text-align:center;transform:translate(-50%,-50%);font:700 8px/1.4 Tahoma;color:#fff6dc;text-shadow:0 1px 2px #183423}.structure-hp>div{height:5px;background:#1c3629ce;border:1px solid #d5e7bd88;border-radius:3px;overflow:hidden}.structure-hp i{display:block;height:100%;background:#76cbe4}.structure-hp.enemy i{background:#e78c64}.structure-hp small{font-size:7px}
.game-panel{position:absolute;z-index:14;width:min(350px,calc(100% - 32px));max-height:calc(100dvh - 90px);overflow:auto;background:linear-gradient(145deg,#edf0d8f7,#d9dfbdf5);color:#324d35;border:2px solid #a0ad76;border-radius:13px;box-shadow:0 5px 0 #21482e77,0 15px 40px #15392366;padding:21px 20px 17px;pointer-events:auto;touch-action:pan-y}.game-panel[hidden],.reward-overlay[hidden]{display:none}.game-panel h2{font-size:18px;margin:0 0 13px;padding-left:22px}.game-panel h3{font-size:12px;margin:16px 0 8px}.game-panel p{font-size:10px;line-height:1.9;margin:8px 0 0;color:#687853}.panel-close{position:absolute;top:9px;left:10px;display:grid;place-items:center;width:27px;height:27px;background:#71845d26;border:1px solid #8c9c6b66;border-radius:6px;font-size:20px;color:#526a43}.ledger-panel{top:95px;right:18px}.ledger-panel dl{margin:0}.ledger-panel dl>div{display:flex;justify-content:space-between;gap:14px;font-size:11px;margin:9px 0}.ledger-panel dd{font:800 13px Arial;margin:0;direction:ltr}.ledger-total{border-top:1px solid #93a47177;padding-top:10px;font-weight:800}.settings-panel,.arsenal-panel,.building-panel{top:65px;left:18px}.setting-row{display:flex;justify-content:space-between;align-items:center;font-size:12px;margin:10px 0}.settings-panel label[for=audio-volume]{display:flex;justify-content:space-between;font-size:10px}.settings-panel input[type=range]{width:100%;accent-color:#3c838c;margin-top:11px}.settings-panel input[type=checkbox]{accent-color:#3c838c;width:18px;height:18px}.build-version{font-size:9px!important;text-align:center}.stage-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}.stage-grid button{font-size:10px;line-height:1.6;padding:8px 4px;background:#d1dabc;border:1px solid #98ac7f;border-radius:6px;color:#3f5b36}.stage-grid button:disabled{opacity:.4}.stage-grid button.current{background:#387b82;color:#fff6d6}.arsenal-panel{width:min(420px,calc(100% - 32px))}.weapon-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin-top:12px}.weapon-choice{background:#c9d6b8;border:1px solid #9ab285;border-radius:7px;color:#355231;padding:8px 3px;font-size:9px;line-height:1.5}.weapon-choice b{display:block;font-size:17px;color:var(--weapon,#4e8c99);text-shadow:0 1px 1px #436550}.weapon-choice small{display:block;font:700 8px Arial;color:#788461;margin-top:3px}.weapon-choice.selected{background:#3e7880;color:#fff3c8;border-color:#b1d3c0}.weapon-choice.selected small{color:#d4e7d0}.panel-link{display:block;text-align:center;color:#3b7882;margin-top:13px;font-size:11px;font-weight:700}.building-upgrade{display:flex;flex-direction:column;gap:4px;width:100%;text-align:right;padding:12px;margin:8px 0;background:#c7d4b4;border:1px solid #99ad7e;border-radius:8px;color:#3b5631}.building-upgrade b{font-size:13px}.building-upgrade span{font-size:10px}.building-upgrade small{font-size:11px;color:#826e31;font-weight:800}.building-upgrade:disabled{opacity:.5}.reward-button{width:100%;margin-top:12px;padding:10px;color:#fff7d5;border-radius:7px;border:1px solid #c8ba75;background:#6d8452;font-size:12px;font-weight:800}.reward-button small{display:block;font-size:9px;margin-top:4px;font-weight:500}.reward-overlay{position:absolute;inset:0;z-index:25;display:grid;place-items:center;background:#16362899;padding:20px}.reward-overlay .dialog{position:relative}.reward-overlay p{font-size:11px;line-height:1.8}.reward-overlay select{width:100%;padding:9px;background:#fff4d7;border:1px solid #a6ad7f;border-radius:5px;font:11px Tahoma;color:#3a5533}.reward-progress{height:7px;margin-top:17px;background:#b5c39e;border-radius:5px;overflow:hidden}.reward-progress i{display:block;height:100%;width:0;background:#469a95}.intro-hints{display:flex;justify-content:center;gap:6px;flex-wrap:wrap;margin:0 0 13px}.intro-hints span{font-size:8px;padding:3px 6px;border-radius:4px;background:#cbd4ae;color:#5c713f}.intro-hints[hidden]{display:none}.result-economy{font-size:10px;line-height:1.9;background:#d7dfbd;border:1px solid #b9c794;border-radius:6px;padding:8px;color:#5a6d40}.result-economy[hidden]{display:none}
@keyframes wallet-pop{50%{transform:scale(1.1);box-shadow:0 0 20px #f2dc6177}}@media(max-width:540px){.view-tools{top:132px;gap:7px}.view-tools .icon-button{width:33px;height:33px}.settings-panel,.arsenal-panel,.building-panel{top:130px;left:12px;max-height:calc(100dvh - 150px)}.hud-top{padding-top:12px}.wallet{font-size:16px}.coin-notice{font-size:8px}.castle-energy{width:123px;padding:4px;font-size:7px}.combat-label{font-size:12px}.battle-info{padding-left:18px;padding-right:18px}.dialog{padding:16px 19px}.dialog-icon{display:none}.dialog h2{font-size:20px}.dialog>p#dialog-copy{font-size:11px;margin-bottom:11px}.gesture-hint{margin-top:10px;font-size:8px}}@media(max-height:620px) and (min-width:541px){.view-tools{flex-direction:row;top:12px}.settings-panel,.arsenal-panel,.building-panel{top:62px;max-height:calc(100dvh - 75px)}.hud-top{max-width:340px}.dialog h2{font-size:18px}.intro-hints{margin-bottom:10px}}@media(max-width:540px) and (max-height:620px){.view-tools{top:118px;gap:6px}.view-tools .icon-button{width:30px;height:30px}.game-panel{max-height:calc(100dvh - 135px);top:122px}.dialog h2{font-size:18px}.dialog .gesture-hint{font-size:7px}.intro-hints{gap:4px;margin-bottom:10px}.intro-hints span{font-size:7px;padding:2px 4px}}
.weapon-choice img{display:block;width:76px;height:68px;max-width:100%;object-fit:contain;margin:auto;filter:drop-shadow(0 2px 2px #42684644)}.weapon-choice>span{display:block;font-size:9px;font-weight:800}.arsenal-panel{max-height:calc(100dvh - 85px)}.weapon-grid{gap:5px}.weapon-choice{padding:3px 2px 7px}.hud-top .mission-meta #stage-label{font-size:12px}.castle-energy .energy-track{min-width:25px}.castle-energy[hidden]{display:none}
.hud-top,.hud-bottom{z-index:6}.view-tools{z-index:6}.overlay{z-index:10}#toast{z-index:16}
.mission-meta>small{display:block;font-size:8px;color:#e5edbe;margin-top:3px}.weapon-choice img{pointer-events:none}
