:root{--bg:#050a14;--card:#0b1426;--card2:#0f1b33;--line:#1a2a4a;--line2:#27407a;--tx:#eaf0fc;--mu:#9db0d0;--blue:#2d86ff;--blue2:#1b6fe8;--green:#38e070;--red:#ff5757;--amber:#ffc641;--purple:#7b3fe0;--r:10px}
*{box-sizing:border-box}
html,body{margin:0;height:100%;background:var(--bg);color:var(--tx);font:13px/1.35 Inter,"Segoe UI",system-ui,sans-serif;overflow:hidden}
button,input,select{font:inherit;color:inherit}
button{cursor:pointer}
:focus-visible{outline:2px solid #6db2ff;outline-offset:2px}
#app{display:grid;height:100vh;height:100dvh;grid-template-columns:minmax(232px,19vw) 1fr;grid-template-rows:auto minmax(0,1fr) clamp(146px,20vh,200px) clamp(104px,14vh,142px);grid-template-areas:"top top" "left stage" "left charts" "strip strip";gap:7px;padding:7px;background:radial-gradient(1200px 500px at 10% -10%,#0d2147 0,transparent 60%),var(--bg)}
.card{background:linear-gradient(180deg,rgba(14,24,44,.96),rgba(9,16,32,.96));border:1px solid var(--line);border-radius:var(--r);padding:8px 10px;min-width:0}
.glass{background:rgba(8,14,28,.82);backdrop-filter:blur(6px);border:1px solid var(--line2);border-radius:var(--r)}
h1,h2,h3{margin:0;font-weight:600}
h2{font-size:15px}h3{font-size:13.5px}
small{color:var(--mu)}
.pos{color:var(--green)}.neg{color:var(--red)}
/* header */
#top{grid-area:top;display:flex;align-items:center;gap:14px;min-width:0}
.brand{display:flex;align-items:center;gap:12px;flex:1 1 520px;min-width:0}
.sky{width:clamp(70px,8vw,118px);height:auto;flex:none;filter:drop-shadow(0 0 10px #2a7fff66)}
.ttl h1{font-size:clamp(22px,2.9vw,40px);line-height:1.05;font-weight:800;letter-spacing:-.4px}
.ttl h1 span{color:#1e90ff;text-shadow:0 0 16px #1e90ff66}
.ttl p{margin:3px 0 0;color:#dbe5f8;font-size:clamp(11px,1vw,13.5px);max-width:560px}
#tabs{display:flex;gap:7px;flex:0 1 auto;flex-wrap:nowrap}
.tab{width:clamp(66px,7.4vw,112px);height:clamp(62px,8.6vh,86px);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;border:1px solid var(--line);border-radius:10px;background:linear-gradient(180deg,#0d1730,#080f20);color:#e5ecfb;font-size:clamp(11px,1vw,13.5px);transition:.15s}
.tab svg{width:clamp(22px,2.2vw,32px);height:clamp(22px,2.2vw,32px)}
.tab:hover{border-color:var(--line2);background:#0f1e3d}
.tab[aria-selected=true]{border-color:#3b8cff;box-shadow:0 0 0 1px #3b8cff,0 0 18px #2d86ff88;background:linear-gradient(180deg,#123068,#0b1d44)}
/* left */
#left{grid-area:left;display:flex;flex-direction:column;gap:7px;overflow-y:auto;overflow-x:hidden;min-height:0;scrollbar-width:thin;scrollbar-color:#243a68 transparent}
.chead{display:flex;justify-content:space-between;align-items:center;margin-bottom:3px}
.ibtn{width:30px;height:28px;border-radius:7px;border:1px solid var(--line2);background:#0d1830;display:grid;place-items:center;padding:0}
.ibtn svg{width:17px;height:17px}
.row{display:flex;align-items:center;gap:8px;padding:5px 0;border-top:1px solid #14223f}
.row:first-of-type{border-top:0}
.row label,.row .k{flex:0 0 76px;color:#e4ecff;font-size:12.5px}
.row input{flex:1;min-width:0;background:#142240;border:1px solid #1f3566;border-radius:6px;padding:6px 9px;color:var(--tx)}
.kv .ic{flex:none;width:30px;height:30px;display:grid;place-items:center}
.kv .ic svg{width:26px;height:26px}
.ic.money{font-size:24px;font-weight:600;color:#c6d4ee;font-family:Georgia,serif}
.kv .v{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.kv .v b{font-size:15.5px;font-weight:600}
.kv .v small{font-size:11.5px}
.bar{height:7px;background:#16233f;border-radius:5px;overflow:hidden}
.bar i{display:block;height:100%;background:linear-gradient(90deg,#27c75a,#52f08a);border-radius:5px;transition:width .5s}
.timeRow{display:flex;align-items:center;gap:8px;padding:4px 0}
.timeRow .ic svg{width:34px;height:34px}
.clock{display:flex;flex-direction:column;flex:1;font-size:12.5px;line-height:1.25}
.speed{display:flex;border:1px solid var(--line2);border-radius:7px;overflow:hidden;background:#0c1730}
.speed button{width:28px;height:26px;border:0;background:transparent;display:grid;place-items:center;padding:0;border-right:1px solid #17284c}
.speed button:last-child{border-right:0}
.speed button svg{width:14px;height:14px}
.speed button[aria-pressed=true]{background:#1e56b8}
.wx{display:flex;gap:6px;padding-top:4px}
.wcell{flex:1;display:flex;align-items:center;gap:7px;min-width:0}
.wcell .ic svg{width:38px;height:38px}
.wcell b{display:block;font-size:15px;font-weight:600}
.wcell small{font-size:11.5px}
.zgrid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px;margin-top:5px}
.ztool{grid-column:span 2;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;border-radius:8px;border:1px solid transparent;color:#fff;font-size:11.5px;min-height:56px;padding:4px 2px}
.ztool .ic svg{width:26px;height:26px}
.ztool.wide{grid-column:span 6;flex-direction:row;gap:8px;min-height:44px;font-size:13px}
.ztool.zRd,.ztool.zPk{grid-column:span 3;min-height:62px}
.zR{background:linear-gradient(180deg,#2f9a45,#1f7a33);border-color:#46c764}
.zC{background:linear-gradient(180deg,#2467c4,#184f9c);border-color:#4b8ee8}
.zI{background:linear-gradient(180deg,#c9962a,#a67318);border-color:#e8bd52}
.zP{background:linear-gradient(180deg,#5b2db0,#43208a);border-color:#8f62e6}
.zRd{background:linear-gradient(180deg,#2a3346,#1a2233);border-color:#41506d}
.zPk{background:linear-gradient(180deg,#2f9a45,#1f7a33);border-color:#46c764}
.ztool.on{outline:2px solid #fff;outline-offset:1px;box-shadow:0 0 16px #ffffff55}
/* stage */
#stage{grid-area:stage;position:relative;border-radius:var(--r);overflow:hidden;border:1px solid var(--line2);background:#0a1426;min-height:180px}
#c{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none;outline:none}
#labels{position:absolute;inset:0;pointer-events:none;overflow:hidden}
.pin{position:absolute;left:0;top:0;will-change:transform;pointer-events:none}
.pin .box{position:absolute;left:0;bottom:var(--stem,30px);transform:translateX(-50%);display:flex;align-items:center;gap:7px;padding:5px 9px 5px 7px;white-space:nowrap;background:rgba(6,12,24,.88);border:1px solid #31507f;border-radius:7px;font-size:11.5px;line-height:1.25;box-shadow:0 4px 14px #0008}
.pin .box svg{width:24px;height:24px;flex:none}
.pin .box b{display:block;font-weight:600;font-size:12px}
.pin .box span{display:block;color:#c8d6ee}
.pin .stem{position:absolute;left:-.5px;bottom:0;width:1px;height:var(--stem,30px);background:linear-gradient(#9fe0ff,#5dffa0)}
.pin .dot{position:absolute;left:-4px;bottom:-4px;width:8px;height:8px;border-radius:50%;background:#50ff8a;box-shadow:0 0 8px #50ff8a}
.pin .g{color:#53f58a}
#maptools{position:absolute;left:8px;bottom:8px;display:flex;gap:5px;align-items:center;flex-wrap:wrap;max-width:calc(100% - 16px);z-index:4}
.mt,#mtOv{height:30px;border-radius:8px;border:1px solid var(--line2);background:rgba(8,14,28,.86);padding:0 9px;display:inline-flex;align-items:center;gap:5px;font-size:12px}
.mt em{font-style:normal}
.mt svg{width:15px;height:15px}
.mt.sq{width:30px;padding:0;justify-content:center;font-size:17px}
.mt.on,.mt[aria-pressed=true]{background:#1b4fa8;border-color:#5aa0ff}
#mtOv{padding:0 6px;max-width:150px}
.sep{width:1px;height:22px;background:var(--line2);margin:0 2px}
#drawer{position:absolute;right:8px;top:8px;width:min(310px,calc(100% - 16px));max-height:calc(100% - 56px);overflow:auto;padding:10px 11px;z-index:5;font-size:12.5px;scrollbar-width:thin}
#drawer h4{margin:0 0 6px;font-size:13.5px;display:flex;justify-content:space-between;align-items:center}
#drawer h5{margin:9px 0 4px;font-size:12px;color:#bcd0f4;text-transform:uppercase;letter-spacing:.5px}
#drawer .x{border:0;background:transparent;color:var(--mu);font-size:18px;line-height:1;padding:0 4px}
#drawer p{margin:4px 0;color:#c9d7ef}
.mrow{display:flex;justify-content:space-between;gap:8px;padding:2px 0}
.mrow b{font-weight:600}
.meter{height:8px;background:#16233f;border-radius:5px;overflow:hidden;margin:2px 0 5px}
.meter i{display:block;height:100%;border-radius:5px;transition:width .4s}
.sl{display:grid;grid-template-columns:1fr auto;gap:2px 8px;align-items:center;margin:5px 0}
.sl label{color:#dbe6fb}
.sl output{font-variant-numeric:tabular-nums;font-weight:600}
.sl input[type=range]{grid-column:1/-1;width:100%;accent-color:#3b8cff}
.btn{display:inline-flex;align-items:center;gap:6px;border:1px solid #3a63b4;border-radius:7px;background:#14306a;padding:5px 10px;margin:2px 3px 2px 0}
.btn:hover{background:#1b3f86}
.btn.on{background:#2a67d6;border-color:#8cbcff}
.btn[disabled]{opacity:.45;cursor:not-allowed}
.tgl{display:flex;justify-content:space-between;align-items:flex-start;gap:8px;padding:5px 0;border-top:1px solid #14223f}
.tgl small{display:block}
.tgl input{margin-top:3px;accent-color:#3b8cff;width:16px;height:16px}
table.t{width:100%;border-collapse:collapse}
table.t td,table.t th{padding:2px 4px;text-align:right;font-weight:400;font-variant-numeric:tabular-nums}
table.t td:first-child,table.t th:first-child{text-align:left}
table.t tr.sum td{border-top:1px solid #2a4170;font-weight:600}
.pf{display:inline-block;min-width:36px;padding:0 6px;border-radius:5px;font-size:11px;text-align:center}
.pf.ok{background:#14532d;color:#8bf0b0}.pf.bad{background:#6b1d1d;color:#ffb0b0}
#hint{position:absolute;left:8px;top:8px;max-width:min(360px,calc(100% - 340px));padding:6px 10px;font-size:12px;color:#dbe6fb;z-index:3;pointer-events:none}
#hint:empty{display:none}
#toasts{position:absolute;left:50%;bottom:48px;transform:translateX(-50%);display:flex;flex-direction:column;gap:5px;align-items:center;pointer-events:none;z-index:6;width:min(420px,90%)}
.toast{padding:7px 12px;border-radius:8px;background:rgba(8,14,28,.94);border:1px solid #31507f;font-size:12.5px;animation:tin .25s,tout .4s 3.8s forwards;text-align:center}
.toast.good{border-color:#2fbf64;color:#b4ffd0}.toast.warn{border-color:#ffb02e;color:#ffe0a8}.toast.bad{border-color:#ff5757;color:#ffc2c2}
@keyframes tin{from{opacity:0;transform:translateY(8px)}}
@keyframes tout{to{opacity:0}}
#loading{position:absolute;inset:0;display:grid;place-content:center;justify-items:center;gap:10px;background:#071022;z-index:20;transition:opacity .4s}
#loading.hide{opacity:0;pointer-events:none}
.spin{width:34px;height:34px;border-radius:50%;border:3px solid #234;border-top-color:#4aa0ff;animation:sp 1s linear infinite}
@keyframes sp{to{transform:rotate(360deg)}}
.pop{position:absolute;left:8px;top:8px;width:min(300px,calc(100% - 16px));padding:11px;z-index:9;max-height:calc(100% - 16px);overflow:auto}
.pop[hidden]{display:none}
/* charts */
#charts{grid-area:charts;display:grid;grid-template-columns:1.2fr 1.05fr 1.1fr 1fr;gap:7px;min-height:0;min-width:0}
.ch{display:flex;flex-direction:column;min-height:0;min-width:0;padding:7px 9px}
.ch canvas{flex:1;width:100%;min-height:0;display:block}
.chhead{display:flex;justify-content:space-between;align-items:baseline}
.chhead .big{text-align:right}.chhead .big b{font-size:16px;font-weight:600;display:block;line-height:1.1}
.eco{display:flex;gap:10px;margin:2px 0 1px;font-size:11px}
.eco small{display:block;font-size:11px}.eco b{font-size:14.5px;font-weight:600}
.inc{color:var(--green)}.exp{color:var(--red)}
.donutwrap{display:flex;flex:1;min-height:0;align-items:center;gap:8px}
.donutwrap canvas{flex:0 0 auto;height:100%;aspect-ratio:1;width:auto;cursor:pointer}
.legend{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px;font-size:12px}
.legend small{font-size:10.5px;line-height:1.2}
.legend div{display:flex;align-items:center;gap:7px}
.legend i{width:11px;height:11px;border-radius:3px;flex:none}
.legend span{flex:1}.legend b{font-weight:500;font-variant-numeric:tabular-nums}
.envrows{display:flex;flex-direction:column;gap:5px;margin:3px 0 4px}
.erow{display:grid;grid-template-columns:22px 1fr 1.2fr auto;align-items:center;gap:6px;font-size:12px}
.erow svg{width:19px;height:19px}
.erow .bar{height:9px}
#cvMini{height:34%;flex:none;border-radius:7px;border:1px solid var(--line)}
/* strip */
#strip{grid-area:strip;display:flex;flex-direction:column;min-height:0;padding:7px 9px}
#shop{display:grid;grid-template-columns:repeat(10,minmax(0,1fr));gap:7px;flex:1;min-height:0;margin-top:4px}
.shopi{position:relative;display:flex;flex-direction:column;padding:0;border:1px solid var(--line);border-radius:8px;background:#0a1224;overflow:hidden;text-align:left;min-height:0}
.shopi .im{flex:1;min-height:0;background:#1b2f48 center/cover no-repeat}
.shopi .nm{padding:3px 7px 0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.shopi .pr{padding:0 7px 4px;font-size:12px;color:#dbe6fb}
.shopi:hover{border-color:#4b7fd0}
.shopi.on{border-color:#5ea6ff;box-shadow:0 0 0 1px #5ea6ff,0 0 14px #2d86ff88}
.shopi.lock .im{filter:grayscale(.85) brightness(.55)}
.shopi.lock::after{content:attr(data-lock);position:absolute;left:0;right:0;top:34%;text-align:center;font-size:12px;font-weight:600;color:#ffe0a0;text-shadow:0 1px 4px #000}
.shopi.poor .pr{color:#ff9a9a}
/* science modal */
.modal{position:fixed;inset:0;background:#000a;z-index:50;display:grid;place-items:center;padding:12px}
.modal[hidden]{display:none}
.mbox{position:relative;width:min(760px,100%);max-height:100%;overflow:auto;padding:16px 18px;font-size:13px}
.mbox h3{font-size:16px;margin:12px 0 4px}.mbox h3:first-child{margin-top:0}
.mbox code{background:#122244;border-radius:4px;padding:1px 5px;font-family:"JetBrains Mono",Consolas,monospace;font-size:12px;color:#c5dcff}
.mbox p,.mbox li{color:#d3dff4}
.mclose{position:absolute;right:8px;top:6px;border:0;background:transparent;font-size:24px;color:var(--mu)}
/* ---- compact desktop heights ---- */
@media (max-height:760px) and (min-width:861px){
  .ttl p{display:none}.card{padding:6px 8px}.row{padding:3px 0}.ztool{min-height:44px}.ztool .ic svg{width:20px;height:20px}.tab{height:56px}
}
@media (max-width:1180px) and (min-width:861px){.ttl p{display:none}#tabs{gap:5px}.tab{width:clamp(58px,6.9vw,80px)}}
/* ---- phones / narrow ---- */
@media (max-width:860px){
  html,body{overflow:auto}
  #app{display:flex;flex-direction:column;height:auto;min-height:100dvh;padding:6px;gap:6px}
  #app>*{flex:none}
  #charts{grid-auto-rows:200px}
  #strip{height:178px}
  #left{min-height:max-content}
  #top{flex-direction:column;align-items:stretch;gap:6px}
  .brand{flex:none}.ttl p{font-size:11px}
  #tabs{overflow-x:auto;scrollbar-width:none;padding-bottom:2px}
  .tab{flex:0 0 74px;height:62px}
  #stage{order:2;height:62vh;height:62dvh;min-height:300px;flex:none}
  #left{order:3;overflow:visible}
  #charts{order:4;grid-template-columns:1fr 1fr}
  .ch{height:200px}
  #strip{order:5}
  #shop{display:flex;overflow-x:auto;gap:7px;padding-bottom:4px}
  .shopi{flex:0 0 118px;height:118px}
  body.embed-mode,body.embed-mode #app{height:auto;min-height:100dvh}
  body.embed-mode{overflow:auto}
  #drawer{left:6px;right:6px;top:auto;bottom:46px;width:auto;max-height:50%}
  #hint{display:none}
  .pin .box{font-size:10.5px;padding:3px 6px}.pin .box svg{width:18px;height:18px}
  #maptools{bottom:6px;gap:4px}.mt em{display:none}.mt{padding:0 8px}
  #mtOv{max-width:104px}
}
@media (max-width:520px){#charts{grid-template-columns:1fr}.ch{height:190px}.pin .box span{display:none}}
@media (prefers-reduced-motion:reduce){.toast{animation:none}.spin{animation-duration:3s}}

@media (max-height:900px) and (min-width:861px){
  .card{padding:6px 8px}h2{font-size:14px}.row{padding:3px 0}.row input{padding:4px 8px}.kv .ic{width:26px;height:26px}.kv .ic svg{width:22px;height:22px}.kv .v b{font-size:14.5px}
  .timeRow{padding:2px 0}.timeRow .ic svg{width:28px;height:28px}.wcell .ic svg{width:30px;height:30px}.wcell b{font-size:14px}
  .ztool{min-height:40px}.ztool .ic svg{width:20px;height:20px}.ztool.wide{min-height:34px}.ztool.zRd,.ztool.zPk{min-height:44px}.zgrid{gap:4px;margin-top:3px}#left{gap:6px}
}
