/* Phase-2 UI components (layout + new widgets). Shell/sidebar/topbar come from styles.css. */
main.main{padding-bottom:40px}
.panels{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;align-items:start}
.panel{background:#fff;border:1px solid #e8ece8;border-radius:12px;box-shadow:var(--shadow);padding:16px 18px}
.panel.wide{grid-column:1/-1}
.panel h2{margin:0 0 12px;font:700 15px Manrope,sans-serif;display:flex;align-items:center;gap:10px}
.panel h3{margin:14px 0 8px;font:700 12px Manrope,sans-serif;color:#40594a}
.panel .n{width:22px;height:22px;border-radius:7px;background:var(--green-pale);color:var(--green);display:grid;place-items:center;font-size:11px}
.panel .src{font-weight:500;font-size:11px;color:#a06a1c}
.row{display:flex;gap:12px;margin-bottom:10px;align-items:flex-end;flex-wrap:wrap}
.row.three{display:grid;grid-template-columns:repeat(3,minmax(0,1fr))}
.fld{display:flex;flex-direction:column;gap:4px;font-size:11px;font-weight:600;color:#5d6d63;flex:1;min-width:120px}
.fld input,.fld select,.erow input,.sel input,.manual input,.trow select,#tech-search{height:32px;border:1px solid #dfe7e0;border-radius:6px;padding:0 8px;font:600 12px 'DM Sans',sans-serif;color:#284a34;background:#fff;outline:0;width:100%}
.fld input:focus,.fld select:focus{border-color:#7aa486}
.fld input[readonly]{background:#f6f8f6;color:#5c7a64}
.hint{font-size:11px;color:#8a958e;line-height:1.5;margin:6px 0 0}
.adv{margin-top:10px;border:1px dashed #d8e0d9;border-radius:8px;padding:8px 10px}
.adv summary{cursor:pointer;font-weight:600;font-size:12px;color:#40594a}
.erow{display:grid;grid-template-columns:minmax(0,1fr) 130px;gap:14px;align-items:center;padding:8px 0;border-bottom:1px solid #f0f2f0;font-size:12px}
.erow small{color:#8a958e}
.enemy-unit{display:grid;grid-template-columns:46px minmax(0,1fr);gap:10px;align-items:center;min-width:0}
.erow .enemy-unit .nm{display:flex;flex-direction:column;align-items:flex-start;gap:2px;min-width:0}
.enemy-unit .nm b{font:700 12px 'DM Sans',sans-serif;color:#3d2b1a;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.enemy-unit .nm small{display:block;font-size:10px;font-weight:400;color:#8a7150;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.enemy-actions{display:flex;justify-content:flex-end;margin:0 0 4px}
.restore-btn{border:1px solid #c9a76b;border-radius:999px;background:#f7ead0;color:#6b4a2a;font:600 10px 'DM Sans',sans-serif;padding:6px 11px;cursor:pointer;display:inline-flex;align-items:center;gap:6px;transition:background .15s,border-color .15s}
.restore-btn:hover{background:#f2dfba;border-color:#b98a46}
.restore-btn:focus-visible{outline:2px solid #b98a46;outline-offset:2px}
.category-tabs{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:10px}
.category-tab2{border:1px solid #e0e6e0;border-radius:7px;background:#fff;padding:7px 11px;font:600 12px 'DM Sans',sans-serif;color:#667569;cursor:pointer;display:flex;gap:7px;align-items:center}
.category-tab2 span{font-size:10px;color:#9aa59d}
.category-tab2.active{background:var(--green);border-color:var(--green);color:#fff}.category-tab2.active span{color:#cfe5d6}
.catalog-tools2{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-bottom:6px}
.search2{flex:1;min-width:200px}.search2 input{width:100%;height:32px;border:1px solid #dfe7e0;border-radius:6px;padding:0 10px;font:500 12px 'DM Sans'}
.chips{display:flex;gap:4px;flex-wrap:wrap}
.chip{height:26px;border:1px solid #e0e6e0;border-radius:6px;background:#fff;font:600 11px 'DM Sans';color:#7a867e;cursor:pointer;padding:0 8px}
.chip.active{background:#eaf4ed;border-color:#8db79a;color:var(--green-dark)}
.catalog-meta2{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:6px 12px;font-size:11px;color:#8a958e;margin-bottom:8px}
.catalog-meta2 .chk{margin-bottom:0}
.catalog-meta2 .btns{display:flex;gap:12px}
.text-button{font-size:11px}
.two-col{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);gap:18px}
.troop-list2,.selected-list,.tech-list2{max-height:340px;overflow:auto;border:1px solid #edf0ed;border-radius:8px}
.trp{display:grid;grid-template-columns:20px 1fr 40px 150px;gap:8px;align-items:center;padding:7px 9px;border-bottom:1px solid #f0f2f0;cursor:pointer;font-size:12px}
.trp:hover{background:#f7faf7}
.trp small,.sel small,.trow small{display:block;color:#8a958e;font-size:10px;font-weight:400}
.trp .st{text-align:right;font-weight:600;color:#40594a}
.tag{font-size:10px;font-weight:700;background:#f1efe6;color:#8a6a2c;border-radius:4px;padding:2px 5px;white-space:nowrap}
.sub-h{font:700 12px Manrope,sans-serif;margin-bottom:8px;color:#40594a}
.sel{display:grid;grid-template-columns:1fr 120px 24px;gap:8px;align-items:center;padding:7px 9px;border-bottom:1px solid #f0f2f0;font-size:12px}
.sel .x{border:0;background:none;font-size:16px;color:#a0a9a2;cursor:pointer}
.warn-inline{font-size:10px;color:#b4581d;background:#fbeee3;border-radius:4px;padding:1px 5px}
.empty-list{padding:18px;color:#8a958e;font-size:12px;text-align:center}
.manual{border-collapse:collapse;width:100%;font-size:12px}.manual th{font-size:10px;color:#8a958e;text-align:left;padding:2px 4px}.manual td{padding:3px 4px}.manual td:first-child{font-weight:600;color:#40594a}
.progression-tools{display:flex;gap:8px;align-items:center;margin-bottom:8px;flex-wrap:wrap}
.progress-tabs{display:flex;gap:4px}
.progress-tab{border:1px solid #e0e6e0;background:#fff;border-radius:6px;height:28px;padding:0 9px;font:600 11px 'DM Sans';color:#7a867e;cursor:pointer}
.progress-tab.active{background:#eaf4ed;color:var(--green-dark);border-color:#8db79a}
#tech-search{flex:1;min-width:140px}
.trow{display:grid;grid-template-columns:1fr 84px;gap:8px;align-items:center;padding:7px 9px;border-bottom:1px solid #f0f2f0;font-size:12px}
.actionbar{display:flex;align-items:center;gap:16px;margin:18px 0}
.primary-button.big{width:auto;height:44px;padding:0 28px;font-size:14px}
.primary-button:disabled{opacity:.6;cursor:progress}
body.busy .primary-button.big{background:#c9c4b4}
.status{font-size:12px;color:#5d6d63}
.results{display:grid;grid-template-columns:minmax(0,1fr);gap:16px} /* minmax(0,1fr): wide tables scroll inside .table-wrap instead of widening the page */
.score-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:10px;margin-bottom:12px}
.score{background:#f7f9f7;border:1px solid #e8ece8;border-radius:9px;padding:9px 12px}
.score span{display:block;font-size:10px;letter-spacing:.4px;color:#8a958e;text-transform:uppercase}
.score b{font:800 20px Manrope,sans-serif;color:#1f3b2a}.score b.sm{font-size:12px}
.score.is-metric{background:#eaf4ed;border-color:#b9d6c2}
.warn{background:#fff6e8;border:1px solid #f0d9a8;color:#8a5a12;border-radius:8px;padding:7px 10px;font-size:12px;margin-bottom:8px}
.table-wrap{overflow:auto}
table.grid{width:100%;border-collapse:collapse;font-size:12px}
table.grid th{text-align:left;font-size:10px;letter-spacing:.3px;text-transform:uppercase;color:#8a958e;padding:6px 8px;border-bottom:1px solid #e4e9e4;white-space:nowrap}
table.grid td{padding:7px 8px;border-bottom:1px solid #f0f2f0;white-space:nowrap}
.r{text-align:right !important}
tr.self td{background:#f4faf5}
.up{color:#1f7a45;font-weight:700}.down{color:#b4401d;font-weight:600}
.bars{margin-top:14px;display:grid;gap:7px}
.bar{display:grid;grid-template-columns:90px 1fr 170px;gap:10px;align-items:center;font-size:12px}
.bar .track{height:9px;background:#edf1ed;border-radius:5px;overflow:hidden}.bar i{display:block;height:100%;background:var(--green)}
.bar b{text-align:right;font-weight:600}
.btn-row{margin-top:12px}
.secondary-button{border:1px solid #cfd9d1;background:#fff;border-radius:7px;height:32px;padding:0 14px;font:600 12px 'DM Sans';cursor:pointer;color:#40594a}
.tabs{display:flex;gap:4px}.tab{border:1px solid #e0e6e0;background:#fff;border-radius:7px;height:32px;padding:0 12px;font:600 12px 'DM Sans';color:#7a867e;cursor:pointer}
.tab.active{background:var(--green);color:#fff;border-color:var(--green)}
.log{max-height:420px;overflow:auto;border:1px solid #edf0ed;border-radius:8px;margin:10px 0}
.log details{border-bottom:1px solid #f0f2f0;padding:4px 10px}.log summary{cursor:pointer;font-weight:700;font-size:12px;padding:4px 0}.log summary small{font-weight:400;color:#8a958e}
.log ol{margin:4px 0 8px;padding-left:26px;font-size:12px;line-height:1.7}
.log li.enemy{color:#9b3d2a}.log li.player{color:#24583a}
/* Battle log: one entry per strike (the game calls these rounds), with the simulator cycle in the gutter. */
.log-scores{display:grid;grid-template-columns:minmax(220px,2fr) minmax(90px,1fr) minmax(200px,2fr);gap:10px;margin-bottom:12px}
.log .rounds{margin:2px 0;padding-left:38px;font-size:12px;line-height:1.8}
.log .rnd{display:inline-block;min-width:28px;margin-left:-38px;margin-right:10px;font:700 9px Manrope,sans-serif;color:#9aa79d;letter-spacing:.3px}
.log .phase-sep{list-style:none;display:flex;align-items:center;gap:10px;margin:11px 0 8px -38px;padding:0;font:700 9px Manrope,sans-serif;letter-spacing:1.35px;text-transform:uppercase;color:#9b7a3c}
.log .phase-sep::before,.log .phase-sep::after{content:'';height:1px;background:#e6d7b9;flex:1}
.log .phase-sep span{padding:0 4px}
tr.enemy td{color:#9b3d2a}
.dialog-body{font-size:13px;line-height:1.55;max-height:60vh;overflow:auto;padding-right:6px}.dialog-body li{margin-bottom:8px}
dialog{max-width:700px}
@media(max-width:1000px){.panels{grid-template-columns:minmax(0,1fr)}.two-col{grid-template-columns:1fr}.row.three{grid-template-columns:1fr}.sidebar{display:none}main.main{width:100%;padding:0 16px}}
.chk{display:flex;gap:6px;align-items:center;font-size:12px;font-weight:600;color:#40594a;margin-bottom:8px}
.cmd-row{display:flex;gap:10px;align-items:flex-end;margin-bottom:8px;flex-wrap:wrap}
.fld.inline{min-width:90px;flex:0 1 auto}
.cmd-actions{display:flex;gap:14px;align-items:center;margin:6px 0 10px;flex-wrap:wrap}
#captain-slots .x{border:0;background:none;font-size:18px;color:#a0a9a2;cursor:pointer;height:32px}
.cmd-row.inactive{opacity:.45}
.drop{border:2px dashed #b9c8bd;border-radius:10px;padding:16px;text-align:center;font-size:13px;color:#40594a;background:#f6f9f6}
/* Live feed strip (Chrome extension -> local server -> this page). */
.live-strip{display:flex;align-items:center;gap:9px;flex-wrap:wrap;padding:8px 11px;margin:0 0 10px;border:1px solid #e2ebe4;background:#f7faf8;border-radius:8px;font-size:11px;color:#5f7267}
.live-strip #live-text{flex:1;min-width:240px;line-height:1.45}
.live-strip .chk{margin:0;font-size:11px}
.live-strip .text-button{margin:0;font-size:11px}
.live-lamp{width:7px;height:7px;border-radius:50%;background:#c4cec7;flex:0 0 7px}
.live-lamp.on{background:#3f9a63;box-shadow:0 0 0 3px #e1f1e5;animation:livepulse 2s ease-in-out infinite}
.live-lamp.paused{background:#c99a4a;box-shadow:0 0 0 3px #f6eddd}
.live-lamp.err{background:#c1543f;box-shadow:0 0 0 3px #f7e7e3}
@keyframes livepulse{50%{opacity:.4}}
.drop.over,.drop:focus{border-color:#2f7d52;background:#e9f4ec;outline:none}
.drop .pick{color:#2f7d52;text-decoration:underline;cursor:pointer}
.imp-table{border-collapse:collapse;font-size:12px;margin-top:6px}
.imp-table td,.imp-table th{padding:2px 10px 2px 0;text-align:left}
.imp-table tr.march td{font-weight:700;color:#2f7d52}
.locked{opacity:.45;pointer-events:none}
.imp-err{color:#a3361f}
.imp-status{margin-top:8px}
.imp-grp{margin:4px 0;border-left:3px solid #d8e0d9;padding-left:8px}
.imp-grp summary{cursor:pointer;font-size:12px;font-weight:600}
.imp-grp ul{margin:4px 0;padding-left:16px;font-size:12px;line-height:1.5}
.imp-grp.off,.imp-grp li.off{opacity:.5}
.imp-grp li.off em{color:#a3361f;font-style:normal}
.imp-grp ul.cols{columns:3;font-size:11px}
.imp-warn{padding-left:16px}
.imp-lv{font-weight:700;color:#2f7d52;font-size:12px;white-space:nowrap}
.trp{grid-template-columns:20px 48px 1fr 40px 150px}
.sel{grid-template-columns:40px 1fr 120px 24px}
.erow .nm{display:flex;align-items:center;gap:10px}
.tcell{position:relative;display:inline-block;flex:0 0 auto;width:var(--cell,46px);aspect-ratio:158/153;vertical-align:middle}
.tcell img{position:absolute;display:block}
.tcell-back{left:50%;top:50%;width:79.1%;height:auto;transform:translate(-50%,-50%)}
.tcell-frame{inset:0;width:100%;height:100%}
.tcell-icon{left:50%;top:50%;width:79.1%;height:auto;transform:translate(-50%,-50%)}
.tcell-badge{left:0;top:0;width:28.5%;height:auto}

/* ---------------------------------------------------------------- player-facing polish
   Documentation and debug output are hidden unless the app is opened with ?dev=1 (remembered).
   Operational feedback (import status, warnings, computed results) uses .note and always stays. */
body:not(.dev) .hint,
body:not(.dev) .doc,
body:not(.dev) #model-info,
body:not(.dev) #info-dialog,
body:not(.dev) #metric-table,
body:not(.dev) #commander-bonuses,
body:not(.dev) #capacity-breakdown{display:none !important}
.troop-head .btns{display:flex;gap:12px;margin-left:auto}
.note{font-size:12px;color:#7c8880;line-height:1.5;margin:6px 0 0}
.dev-badge{display:none;font-size:10px;font-weight:700;letter-spacing:.5px;color:#a06a1c;background:#fdf3e0;border:1px solid #f0d9a8;border-radius:5px;padding:2px 7px}
body.dev .dev-badge{display:inline-block}

/* --- commander strip (hero + captains), modelled on the in-game selector --- */
.cmd-strip{display:flex;gap:22px;flex-wrap:wrap;align-items:flex-start;margin:14px 0 6px;min-height:110px}
.ccell{position:relative;width:92px;cursor:pointer;border-radius:10px;padding:0;border:0;background:none}
.ccell.hero-cell{width:108px}
.ccell .art,.cpick .art{display:block;position:relative}
.ccell .art{width:100%;aspect-ratio:1;border-radius:10px;overflow:hidden;border:2px solid #d9c9a4;background:linear-gradient(160deg,#4a5a68,#2c3a44);box-shadow:0 2px 6px rgba(20,40,30,.18)}
.ccell.hero-cell .art{border-color:#e0b45c;box-shadow:0 0 0 2px #f4e2b4 inset,0 2px 8px rgba(20,40,30,.25)}
.ccell .art img{width:100%;height:100%;object-fit:cover;display:block}
.ccell .lvl{position:absolute;top:-7px;right:-7px;min-width:30px;height:24px;padding:0 6px;display:grid;place-items:center;font:800 12px Manrope,sans-serif;color:#fff;background:linear-gradient(180deg,#5d7f9c,#37536b);border:2px solid #dceaf5;border-radius:7px;box-shadow:0 1px 3px rgba(0,0,0,.3)}
.ccell.hero-cell .lvl{background:linear-gradient(180deg,#c8a24a,#8d6a20);border-color:#f2e0b0}
.ccell .stars{position:absolute;bottom:3px;left:0;right:0;text-align:center;font-size:11px;letter-spacing:1px;color:#ffd45e;text-shadow:0 1px 2px rgba(0,0,0,.75);pointer-events:none}
.ccell .off{position:absolute;inset:0;display:grid;place-items:center;font:700 10px 'DM Sans';letter-spacing:.5px;color:#c8d2cb;background:rgba(16,23,19,.55);text-transform:uppercase}
.ccell .nm{display:block;margin-top:5px;font:600 10px 'DM Sans',sans-serif;color:#5d6d63;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ccell .rm{position:absolute;top:-7px;left:-7px;width:20px;height:20px;border-radius:50%;border:1px solid #e0c9c9;background:#fff;color:#b4581d;font-size:12px;line-height:1;cursor:pointer;display:grid;place-items:center;padding:0}
.ccell.empty .art{border-style:dashed;border-color:#cfd9d1;background:#f7faf7;display:grid;place-items:center;font-size:26px;color:#9aa79d}
.ccell.inactive{opacity:.55}
.cmd-picker{margin-top:10px;border:1px solid #e8ece8;border-radius:10px;padding:12px;background:#fbfcfb}
.cmd-picker h4{margin:0 0 8px;font:700 12px Manrope,sans-serif;color:#40594a}
.cmd-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(64px,1fr));gap:8px;max-height:260px;overflow:auto}
.cpick{border:2px solid transparent;border-radius:9px;padding:0;background:none;cursor:pointer;position:relative}
.cpick .art{width:100%;aspect-ratio:1;border-radius:8px;overflow:hidden;border:1px solid #dbe2dc;background:#3a4a55}
.cpick .art img{width:100%;height:100%;object-fit:cover;display:block}
.cpick.active{border-color:var(--green)}
.cpick .nm{display:block;font-size:9px;color:#6b7a70;text-align:center;margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* --- troops: one list, count input inline --- */
.troop-head{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:10px}
.trp{grid-template-columns:22px 48px minmax(0,1fr) 118px}
.trp .ct{width:100%;height:30px;border:1px solid #dfe7e0;border-radius:6px;padding:0 8px;font:600 12px 'DM Sans';color:#284a34;background:#fff}
.trp .ct:disabled{background:#f4f7f4;color:#93a29a}
.trp.on{background:#f2f9f4;box-shadow:inset 3px 0 0 var(--green)}

/* --- results: outcome cells + clean lineup --- */
.outcome{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;margin-bottom:14px}
.ocell{border-radius:11px;padding:12px 14px;border:1px solid #e4e9e4;background:#f7f9f7}
.ocell span{display:block;font-size:10px;letter-spacing:.5px;text-transform:uppercase;color:#8a958e;margin-bottom:2px}
.ocell b{font:800 25px Manrope,sans-serif;color:#1f3b2a;line-height:1.1}
.ocell i{display:block;font-style:normal;font-size:11px;color:#7c8880;margin-top:3px}
.ocell.win{background:#eef8f0;border-color:#b6dcc2}.ocell.win b{color:#1f7a45}
.ocell.loss{background:#fdf0ec;border-color:#efc9bb}.ocell.loss b{color:#b4401d}
.ocell.draw{background:#fdf7e8;border-color:#efdfae}.ocell.draw b{color:#946a12}
.ocell.race{background:#eef3fa;border-color:#c3d4ea}.ocell.race b{color:#2c5286}
.ocell .ic{font-style:normal;margin-left:7px;opacity:.6}
.ocell .ic svg{width:13px;height:13px;vertical-align:-2px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.linup{display:grid;gap:6px;margin-bottom:14px}
.lrow{display:grid;grid-template-columns:46px minmax(0,1fr) auto 34px;gap:10px;align-items:center;border:1px solid #edf0ed;border-radius:9px;padding:6px 10px}
.lrow .nm{font:600 13px 'DM Sans';color:#284a34}
.lrow .cnt{font:800 15px Manrope,sans-serif;color:#1f3b2a;text-align:right;white-space:nowrap}
.lrow .cnt small{display:block;font:500 10px 'DM Sans';color:#8a958e}
.cpbtn{width:30px;height:30px;border:1px solid #dbe2dc;border-radius:7px;background:#fff;cursor:pointer;display:grid;place-items:center;color:#4b7a5c;padding:0}
.cpbtn:hover{background:#f1f7f2}
.cpbtn.done{background:#e8f5ec;border-color:#a8d0b4;color:#1f7a45}
.copybar{display:flex;gap:8px;align-items:center;margin-bottom:10px;font-size:12px;color:#7c8880}
.copybar .text-button{margin-left:0}


/* ---- side-panel mode (?embed=sidepanel): no packet chrome, single column, sticky Optimize ---- */
body.embed .sidebar,
body.embed .topbar,
body.embed .page-head,
body.embed .footer,
body.embed #panel-import { display: none }
body.embed .app-shell { display: block; min-height: auto }
body.embed .main { width: 100%; max-width: none; padding: 10px 12px 0 }
body.embed .panels { grid-template-columns: minmax(0, 1fr); gap: 10px }
body.embed .panel.wide { grid-column: auto }
body.embed .panel { padding: 12px 13px; border-radius: 10px }
body.embed .two-col { grid-template-columns: 1fr }
body.embed .row.three { grid-template-columns: 1fr }
body.embed .actionbar { position: sticky; bottom: 0; z-index: 6; margin: 10px 0 0; padding: 8px 0 10px; background: var(--canvas) }
body.embed .actionbar .primary-button.big { height: 38px }
body.embed .results { margin-top: 10px }
body.embed .results .panel { margin-bottom: 10px }
body.embed #panel-budget .cmd-strip { gap: 18px }
/* Battle-log summary: the 3-column min widths (220+90+200) forced a 530px content box.
   Below ~720px (and always in the side panel) stack the score card above Rounds / End. */
@media (max-width: 720px) {
  .log-scores { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) }
  .log-scores .score.is-metric { grid-column: 1 / -1 }
}
body.embed .log-scores { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) }
body.embed .log-scores .score.is-metric { grid-column: 1 / -1 }
/* Narrow panels: drop secondary table columns instead of hiding them behind a horizontal scroll. */
@media (max-width: 640px) {
  #baseline-table th:nth-child(2), #baseline-table td:nth-child(2),
  #baseline-table th:nth-child(5), #baseline-table td:nth-child(5),
  #log-stacks th:nth-child(5), #log-stacks td:nth-child(5),
  #log-stacks th:nth-child(6), #log-stacks td:nth-child(6) { display: none }
}
body.embed #baseline-table th:nth-child(2), body.embed #baseline-table td:nth-child(2),
body.embed #baseline-table th:nth-child(5), body.embed #baseline-table td:nth-child(5),
body.embed #log-stacks th:nth-child(5), body.embed #log-stacks td:nth-child(5),
body.embed #log-stacks th:nth-child(6), body.embed #log-stacks td:nth-child(6) { display: none }

/* ---- access tiers: anonymous (browser) / free account / premium ---- */
.plan-badge{margin-left:auto;font:700 9px 'DM Sans';letter-spacing:.5px;text-transform:uppercase;color:#5b7663;background:#f1f5f2;border:1px solid #dfe8e1;border-radius:5px;padding:3px 6px}
.plan-line{margin:0 0 10px;padding:8px 11px;border:1px solid #e6ece7;border-radius:8px;background:#f8faf8;font-size:11px;line-height:1.45;color:#5f7267}
.plan-line.premium{background:#eef6f0;border-color:#cfe3d5}
.plan-line.free{background:#f8f9f4;border-color:#e7e9dc}
.plan-line span{color:#8a958e}
.live-strip[hidden]{display:none}
.dragon-block{margin:0 0 14px;padding:10px 11px;border:1px solid #e8eee9;border-radius:9px;background:#f8faf8}
.dragon-block[hidden]{display:none}
.dragon-block .row{margin-bottom:0}
body:not(.dev) #drop-zone{display:none}

/* ---- layout: no sidebar, full-width workspace, brand in the page head -------------------------- */
.app-shell{display:block}
.main{width:100%;max-width:1500px;padding:0 40px;margin:0 auto}
.topbar{justify-content:flex-end}
.page-head{display:grid;grid-template-columns:320px minmax(0,1fr);gap:32px;align-items:center;padding:30px 0 26px}
.page-head .brand{margin:0;align-self:center;gap:14px;font-size:3rem;letter-spacing:-1.5px}
.page-head .brand-mark{width:46px;height:46px;border-radius:13px;font-size:26px}
/* styles.css zeroes the sidebar brand text on narrow screens; the page brand needs it back. */
.page-head .brand > span:last-child{font-size:3rem}
.page-intro{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;min-width:0}
.page-intro > div:first-child{min-width:0}
.lang-switch{display:inline-flex;gap:2px;padding:3px;border:1px solid rgba(196,154,79,.55);border-radius:999px;background:rgba(24,13,11,.32);flex:0 0 auto}
.lang-toggle{appearance:none;-webkit-appearance:none;font:inherit;color:inherit;cursor:pointer;min-height:32px;align-items:center}
.lang-sep{color:#8d7a5c;font:600 10px 'DM Sans',sans-serif;align-self:center}
.lang-btn{border:0;background:transparent;color:#c3ad8d;font:700 10px 'DM Sans',sans-serif;letter-spacing:.5px;padding:5px 9px;border-radius:999px;cursor:pointer;line-height:1}
.lang-btn:hover{color:#f6e8cb}
.lang-btn.active{background:#c49a4f;color:#22120e}
.lang-btn:focus-visible{outline:2px solid #e3c078;outline-offset:2px}
@media(max-width:560px){.page-intro{flex-wrap:wrap}.lang-switch{order:-1;margin-left:auto}}
.embed-lang{display:none}
body.embed .actionbar .embed-lang{display:inline-flex;margin-left:8px;align-self:flex-end}
@media(max-width:900px){
  .page-head{grid-template-columns:1fr;gap:14px;align-items:start}
  .page-head .brand{align-self:start}
}
@media(max-width:1000px){.main{padding:0 16px}}

/* ---- the fancy target selector now lives in the Target panel ---------------------------------- */
#panel-target #target-pill{width:100%;max-width:none;min-width:0;height:auto;margin:0 0 12px;padding:9px 11px;gap:10px;cursor:pointer;position:relative}
#panel-target .target-icon{width:42px;height:42px;flex:0 0 42px}
#panel-target .target-pick{display:flex;flex-direction:column;justify-content:center;gap:1px;min-width:0;flex:1}
#panel-target .target-pick .target-label{display:block;max-width:100%;font:700 12px 'DM Sans',sans-serif;line-height:1.3;color:#3d2b1a;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* Safari cannot open a native select from a synthetic click / showPicker(). Stretch the real select
   across the whole pill so every click lands on the control itself; the text above is the visual copy. */
#panel-target #target-pill-select{position:absolute;inset:0;width:100%;height:100%;opacity:0;z-index:2;cursor:pointer}
#panel-target #target-pill:focus-within{outline:2px solid #c49a4f;outline-offset:2px}
#panel-target .target-pick select{max-width:none}
#panel-target .target-pill .chev{flex:0 0 auto}

/* ---- troops: search immediately above the troop list ---------------------------------------- */
.troop-search2{display:block;margin:8px 0 10px;min-width:0}
.troop-search2 input{width:100%}

/* ---- collapsible Bonuses summary ------------------------------------------------------------- */
#panel-bonuses{padding:16px 18px}
#panel-bonuses > summary{list-style:none;cursor:pointer;display:block}
#panel-bonuses > summary::-webkit-details-marker{display:none}
#panel-bonuses > summary::marker{content:''}
#panel-bonuses > summary h2{margin:0;padding-bottom:0;border-bottom:0}
#panel-bonuses[open] > summary h2{padding-bottom:8px;border-bottom:1px solid rgba(185,138,70,.32);margin-bottom:12px}
.bonus-summary{margin-left:auto;min-width:0;max-width:55%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-left:12px;font:600 11px 'DM Sans',sans-serif;color:#6b5538}
.bonus-chev{display:inline-block;flex:0 0 auto;margin-left:8px;color:#8a7150;font-size:12px;transition:transform .15s}
#panel-bonuses[open] .bonus-chev{transform:rotate(90deg)}

/* ---- sticky Optimize bar; the generation options live here ---------------------------------- */
.actionbar{
  position:sticky;bottom:0;z-index:40;display:flex;align-items:center;gap:16px;flex-wrap:wrap;
  margin:18px 0 0;padding:10px 0 12px;
  background:linear-gradient(180deg,rgba(24,13,11,.72),#180d0b 45%);
  border-top:1px solid rgba(185,138,70,.45);
  box-shadow:0 -10px 24px rgba(0,0,0,.3);
}
.optimize-options{display:flex;align-items:center;gap:14px;flex-wrap:wrap;flex:1;min-width:0}
.optimize-options .chk{margin:0;color:#fff;gap:9px;font-size:11px;line-height:1.35}
.optimize-options .chk input{
  appearance:none;-webkit-appearance:none;width:38px;height:20px;flex:0 0 38px;margin:0;
  border:1px solid rgba(196,150,80,.6);border-radius:10px;position:relative;cursor:pointer;
  background:linear-gradient(90deg,#1e0d04,#2e1508);box-shadow:inset 0 1px 3px rgba(0,0,0,.5);
  transition:background .22s,border-color .22s,box-shadow .22s;
}
.optimize-options .chk input::after{
  content:'';position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;
  background:radial-gradient(circle at 35% 32%,#c8b080,#907040,#5a4020);border:1px solid #402808;
  box-shadow:0 1px 3px rgba(0,0,0,.7);transition:left .22s,background .22s,box-shadow .22s;
}
.optimize-options .chk input:checked{
  border-color:rgba(220,170,70,.8);background:linear-gradient(90deg,#7a3e08,#b87820);
  box-shadow:inset 0 1px 3px rgba(0,0,0,.4),0 0 6px rgba(180,120,30,.3);
}
.optimize-options .chk input:checked::after{
  left:19px;background:radial-gradient(circle at 35% 32%,#f0d880,#d4a030,#9a6c10);border-color:#7a5008;
  box-shadow:0 1px 3px rgba(0,0,0,.6),0 0 4px rgba(220,160,40,.4);
}
.optimize-options .chk input:focus-visible{outline:2px solid #d8b16a;outline-offset:2px}
.optimize-options .hint{flex-basis:100%;margin:0;font-size:10px}
.actionbar .status{margin-left:auto;flex:0 1 auto}
@media(max-width:700px){
  .actionbar{flex-direction:column;align-items:stretch;gap:8px}
  .optimize-options{flex-direction:column;align-items:flex-start;gap:6px;width:100%}
  .actionbar .primary-button{width:100%}
  .actionbar .status{margin-left:0;flex-basis:auto}
}

/* `.results` sets display:grid, which would override the UA [hidden] rule. */
.results[hidden]{display:none}

@media(max-width:560px){
  .erow{grid-template-columns:minmax(0,1fr) 100px;gap:8px}
  .enemy-unit{grid-template-columns:46px minmax(0,1fr);gap:8px}
  .page-head .brand{font-size:clamp(2.4rem,10vw,3rem)}
  .page-head .brand-mark{width:40px;height:40px;font-size:22px}
}

.ccell .tg.disabled{opacity:.4;cursor:not-allowed}
#optimize-btn.has-updates{box-shadow:0 0 0 2px rgba(216,177,106,.65),0 0 18px rgba(216,177,106,.28)}

/* ---- hosted / mobile polish ---------------------------------------------------------------- */
/* Flex/grid rules below must not resurrect elements carrying the hidden attribute. */
[hidden]{display:none!important}
html{-webkit-text-size-adjust:100%}
body{overscroll-behavior-y:none}
.page-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.ghost-chip{border:1px solid rgba(196,154,79,.55);background:rgba(24,13,11,.32);color:#e7cf9f;border-radius:999px;padding:6px 11px;font:700 10px 'DM Sans',sans-serif;letter-spacing:.3px;cursor:pointer;white-space:nowrap}
.ghost-chip:hover{background:rgba(196,154,79,.18);color:#f6e8cb}
.local-actions{display:flex;flex-wrap:wrap;align-items:center;gap:6px 16px;margin:6px 0 2px}
.local-actions .text-button{margin:0;padding:4px 0}
.local-actions .hint{flex-basis:100%;margin:0}
/* Without the extension there is no packet import: keep the card useful, not misleading. */
.local-only .live-strip,.local-only .drop,.local-only #import-summary,.local-only #import-status{display:none!important}
#setup-input{width:100%;border:1px solid #dfe7e0;border-radius:8px;padding:9px;font:12px/1.45 ui-monospace,Menlo,monospace;color:#284a34;background:#fff;resize:vertical}
#setup-dialog .primary-button{margin-top:10px}

@media(max-width:700px){
  .main{padding-left:max(12px,env(safe-area-inset-left));padding-right:max(12px,env(safe-area-inset-right))}
  .page-actions{width:100%;justify-content:flex-start}
  .local-actions{gap:8px 14px}
  /* iOS zooms the viewport when a focused input is below 16px. */
  input,select,textarea{font-size:16px!important}
  .fld input,.fld select,.erow input,.sel input,.manual input,.trow select,#tech-search{height:42px}
  .manual td{padding:5px 4px}
  .manual th{font-size:11px}
  .troop-row{min-height:52px}
  .troop-check{height:20px;width:20px}
  .tier-chip{height:32px;min-width:30px;font-size:11px}
  .category-tab{min-height:36px;font-size:11px}
  .text-button{min-height:32px}
  .actionbar{padding-bottom:calc(12px + env(safe-area-inset-bottom))}
  .panel{border-radius:12px}
  .page-head h1{line-height:1.12}
  .ccell{min-height:64px}
  .ccell .tg{min-width:28px;min-height:28px}
}
@media(max-width:400px){
  .page-head .brand > span:last-child{font-size:clamp(1.9rem,9vw,2.4rem)}
  .page-intro{gap:10px}
}

/* ---- manual gear -------------------------------------------------------------------------- */
.gear-block{border-top:1px solid rgba(185,138,70,.28);margin-top:12px;padding-top:12px}
.gear-block .row{margin-bottom:8px}
.gear-slots{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:4px}
.gear-slots .fld{min-width:0}
.gear-block.is-imported{opacity:.55}
.gear-block select{overflow:hidden;text-overflow:ellipsis}
@media(max-width:560px){.gear-slots{grid-template-columns:1fr}}

/* ---- small-screen layout fixes ------------------------------------------------------------ */
@media(max-width:700px){
  /* iOS Safari with viewport-fit=cover: keep the brand out of the status bar / notch. */
  body{padding-top:max(env(safe-area-inset-top,0px),8px)}
  /* Commander portraits stay on one row; scroll sideways instead of wrapping. */
  #panel-budget .cmd-strip{flex-wrap:nowrap;overflow-x:auto;overflow-y:visible;padding-bottom:2px;scrollbar-width:none}
  #panel-budget .cmd-strip::-webkit-scrollbar{display:none}
  #panel-budget .ccell{flex:0 0 auto}
  /* Leadership / Dominance / Authority on one row. */
  #panel-budget .row.three{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
  #panel-budget .row.three .fld{min-width:0}
  #panel-budget .row.three .fld input{width:100%;min-width:0;padding:0 6px}
}
.lang-btn{display:inline-block}

/* ---- commander row: compact portraits, no scrolling --------------------------------------- */
.ccell.disabled{opacity:.45;cursor:not-allowed}
.cmd-picker .cmd-stats{flex-wrap:nowrap;gap:8px}
.cmd-picker .cmd-stats .fld{flex:1 1 0;min-width:0}
@media(max-width:700px){
  #panel-budget .cmd-strip{flex-wrap:nowrap;overflow:visible;gap:4px;min-height:84px}
  #panel-budget .ccell{width:auto;flex:1 1 0;min-width:0}
  #panel-budget .ccell.hero-cell{flex:1.12 1 0}
  #panel-budget .ccell .art{border-width:1px;border-radius:8px}
  #panel-budget .ccell .lvl{min-width:20px;height:18px;padding:0 3px;font-size:9px;top:-5px;right:-5px;border-width:1px}
  #panel-budget .ccell .tg{min-width:20px;min-height:20px;font-size:9px}
  #panel-budget .ccell .nm{font-size:7px;margin-top:3px}
  #panel-budget .ccell .stars{font-size:8px;letter-spacing:0}
  .cmd-grid{grid-template-columns:repeat(auto-fill,minmax(52px,1fr));gap:6px;max-height:230px}
  .cpick .nm{font-size:8px}
}

/* ---- gear cards, picker dialog and tier colours ------------------------------------------- */
.gear-slots{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:4px}
.gear-card{display:flex;align-items:center;gap:8px;min-width:0;padding:6px;border:1px solid rgba(185,138,70,.35);border-radius:9px;background:rgba(255,255,255,.45);cursor:pointer;text-align:left}
.gear-card:hover{background:rgba(255,255,255,.75)}
.gear-card:disabled{opacity:.55;cursor:not-allowed}
.gear-card .gc-icon{width:40px;height:40px;flex:0 0 40px;border-radius:7px;border:1px solid rgba(185,138,70,.3);background:linear-gradient(160deg,#f7ecd8,#e9d6b1);overflow:hidden;display:grid;place-items:center}
.gear-card .gc-icon img{width:100%;height:100%;object-fit:contain;display:block}
.gear-card .gc-body{min-width:0;display:flex;flex-direction:column;gap:2px;flex:1}
.gear-card .gc-body b{font-size:10px;color:#5b4930;font-weight:700}
.gear-card .gc-body small{font-size:9px;color:#7d6a4b;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.gear-card .gt{margin-left:auto;flex:0 0 auto}
.gt{display:inline-grid;place-items:center;min-width:26px;height:20px;padding:0 5px;border-radius:5px;font:800 9px 'DM Sans',sans-serif;color:#fff;border:1px solid rgba(0,0,0,.18);text-shadow:0 1px 1px rgba(0,0,0,.35)}
.gt0{background:#8b8b8b}.gt1{background:#8d8d8d}.gt2{background:#4f9b57}.gt3{background:#3e79b5}.gt4{background:#8a5ab8}.gt5{background:#d1842f}.gt6{background:#c04a3a}.gt7{background:#c49a4f}.gt8{background:#3aa6a0}.gt9{background:#9c6d3a}
.gear-artifact-preview{display:flex;align-items:center;gap:8px;margin:2px 0 6px;font-size:11px;color:#5b4930}
.gear-artifact-preview img{width:34px;height:34px;object-fit:contain;border-radius:7px;border:1px solid rgba(185,138,70,.35);background:rgba(255,255,255,.5)}
#gear-dialog{max-width:560px}
.gear-dialog-tools{display:flex;flex-direction:column;gap:8px;margin-bottom:8px}
.gear-dialog-tools input{width:100%;height:38px;border:1px solid #dfe7e0;border-radius:8px;padding:0 10px;font-size:16px;background:#fff;color:#284a34}
.gear-tiers{display:flex;gap:5px;flex-wrap:wrap}
.gear-tier{width:34px;height:29px;border:1px solid rgba(0,0,0,.18);border-radius:6px;cursor:pointer;font:800 10px 'DM Sans',sans-serif;color:#fff;text-shadow:0 1px 1px rgba(0,0,0,.35)}
.gear-tier.active{outline:2px solid #c49a4f;outline-offset:2px}
.gear-list{max-height:52vh;overflow:auto;border-top:1px solid #e8e0d1}
.gear-item{display:flex;align-items:center;gap:9px;width:100%;padding:7px 5px;border:0;border-bottom:1px solid #f0eadf;background:none;text-align:left;cursor:pointer;color:#3f3424}
.gear-item:hover,.gear-item.active{background:rgba(196,154,79,.13)}
.gear-item img{width:38px;height:38px;flex:0 0 38px;object-fit:contain;border-radius:7px;background:rgba(255,255,255,.55)}
.gear-item .gi-main{flex:1;min-width:0}
.gear-item b{display:block;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.gear-item small{display:block;font-size:9px;color:#8a7656;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.gear-item .gt{margin-left:auto;flex:0 0 auto}
@media(max-width:560px){
  .gear-slots{grid-template-columns:repeat(2,minmax(0,1fr))}
  .gear-card .gc-icon{width:44px;height:44px;flex-basis:44px}
  .gear-card .gc-body b{font-size:11px}
  .gear-card .gc-body small{font-size:10px}
  #gear-dialog{width:calc(100% - 16px);max-height:92vh;padding:16px}
  .gear-list{max-height:58vh}
  .gear-tier{width:38px;height:34px;font-size:11px}
}

@media(max-width:360px){.gear-slots{grid-template-columns:1fr}}
