/* Simulator (simulator.html, sim.js): mini party bar on top, then one row per unit and one per enemy */
.sim-h { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 8px; font-family: var(--font-head); font-size: 13px; font-weight: 700; letter-spacing: .1em; color: var(--gold); text-transform: uppercase; }
.sim-h small { font-family: var(--font); letter-spacing: 0; text-transform: none; font-weight: 400; color: var(--text-muted); font-size: 12.5px; }
.btn.small { height: 26px; padding: 0 9px; font-size: 12.5px; }
.sim .x { background: none; border: 0; color: var(--text-faint); cursor: pointer; font-size: 14px; padding: 2px 4px; }
.sim .x:hover { color: var(--red-text); }
.sim select, .sim input[type="number"], .sim input[type="search"] {
  height: 26px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 12.5px; padding: 0 5px; }
.sim input[type="number"] { width: 64px; }
.sim small { color: var(--text-muted); }
.sim .small { font-size: 12.5px; }
.sim h3 { font-size: 13px; margin: 0 0 6px; color: var(--text); }
.sim h3 small { font-weight: 400; font-size: 11.5px; margin-left: 6px; }
.sim h3 + * { margin-top: 0; }
.sim-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin: 6px 0; border: 1px solid var(--gold); background: var(--gold-soft); border-radius: var(--radius); font-size: 13.5px; }
.sim-notice[hidden] { display: none; }
.sim-notice .x { margin-left: auto; }

/* mini party bar */
.sim-mini { padding: 4px 0 8px; display: grid; gap: 6px; }
.mini-units { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.mini { display: grid; grid-template-columns: auto 40px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 8px; min-height: 54px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
button.mini:hover { border-color: var(--gold); }
.mini.empty { grid-template-columns: auto minmax(0, 1fr); border-style: dashed; cursor: default; }
.mini-num { width: 20px; height: 20px; flex: none; border-radius: 50%; background: var(--surface-3); color: var(--text-muted); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; }
.mini-unit { width: 40px; height: 40px; border-radius: 7px; }
.mini-nm { display: grid; min-width: 0; line-height: 1.25; }
.mini-nm b, .mini-nm small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-nm small { font-size: 11.5px; color: var(--gold); }
.mini-eq { display: flex; gap: 3px; align-items: center; }
.mini-eq img, .mini-eq .eq-empty { width: 28px; height: 28px; border-radius: 6px; }
.mini-eq img + img, .mini-eq .eq-empty ~ img, .mini-eq img ~ .eq-empty, .mini-eq .eq-empty ~ .eq-empty { width: 24px; height: 24px; }
.mini-eq .eq-empty { display: inline-block; border: 1px dashed var(--border); }
.mini-enemies { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mini-enemy { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; }
.mini-enemy:hover { border-color: var(--gold); }
.mini-enemy small { font-size: 11.5px; display: inline-flex; align-items: center; gap: 3px; }
.mini-enemy .gi { width: 15px; height: 15px; }

/* pickers */
.picker { position: relative; min-width: 0; }
.picker input { width: 100%; }
.picker .search-results { display: block; max-height: 380px; overflow-y: auto; min-width: 280px; }
.picker .search-results[hidden] { display: none; }
.picker .po { display: grid; grid-template-columns: 32px 1fr; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 6px; color: var(--text);
  width: 100%; text-align: left; background: none; border: 0; font: inherit; cursor: pointer; }
.picker .po:hover, .picker .po.on { background: var(--surface-2); }
.picker .po img { width: 32px; height: 32px; border-radius: 6px; }
.picker .po span { display: grid; min-width: 0; }
.picker .po b, .picker .po small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker .po small { color: var(--text-muted); font-size: 12px; }
.picker .po.none { color: var(--text-muted); cursor: default; display: block; font-size: 12px; }

/* turn order */
.sim-order { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ord { display: grid; grid-template-columns: auto auto 1fr; gap: 0 6px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 9px; font-size: 13px; }
.ord img { width: 24px; height: 24px; border-radius: 5px; }
.ord small { grid-column: 1 / -1; font-size: 11.5px; display: flex; gap: 8px; }
.ord.swap { border-color: #ebbe5c80; border-style: dashed; }
.sim-order .arrow { color: var(--text-faint); }
.party-total { margin: 8px 0 4px; font-size: 14px; }
.party-total b { color: var(--gold); font-variant-numeric: tabular-nums; }
.party-total small { margin-left: 8px; }

/* unit and enemy rows: setup | buffs & caps | damage */
.urow, .erow { display: grid; grid-template-columns: 270px minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; align-items: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin: 10px 0 14px; scroll-margin-top: 140px; }
.usetup, .enemy { display: flex; flex-direction: column; gap: 7px; min-width: 0; font-size: 13px; }
.pslot-head { display: flex; gap: 8px; align-items: flex-start; }
.pslot-head > img { width: 52px; height: 52px; border-radius: 8px; }
.pslot-head .nm { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.pslot-head .nm small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 3px; }
.pslot-head .gi { width: 16px; height: 16px; }
.pslot-set, .pslot-plan { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; color: var(--text-muted); font-size: 12.5px; }
.pslot-plan { border-top: 1px solid var(--border); padding-top: 7px; }
.pslot-stats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); }
.pslot-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.pslot-stats small { font-size: 11px; color: var(--t-heal); }
.pslot-row { display: grid; grid-template-columns: 50px 1fr; gap: 6px; align-items: start; }
.pslot-row .lbl { color: var(--text-muted); font-size: 12px; padding-top: 4px; }
.picked { display: flex; gap: 6px; align-items: flex-start; min-width: 0; }
.picked > img { width: 32px; height: 32px; border-radius: 6px; flex: none; }
.picked > div { flex: 1; min-width: 0; display: grid; gap: 2px; }
.picked small { font-size: 11.5px; line-height: 1.35; }
.picked .fx { color: var(--text); opacity: .85; }
.picked .stars { margin-left: 2px; vertical-align: 0; font-size: 11px; }
.picked select { height: 22px; font-size: 12px; }
.ubuffs, .sdmg { min-width: 0; }
.sdmg h3 ~ h3 { margin-top: 12px; }

/* enemy setup */
.enemy { color: var(--text-muted); font-size: 12.5px; }
.enemy-head { display: flex; justify-content: space-between; color: var(--text); font-size: 14px; }
.enemy-grid { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.enemy-grid input[type="number"] { width: 62px; }
.enemy-grid.atk { border-top: 1px solid var(--border); padding-top: 7px; }
.enemy-grid .lbl { color: var(--text); }
.enemy-res { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.enemy-res label { display: inline-flex; align-items: center; gap: 2px; }
.enemy-res .gi { width: 18px; height: 18px; }
.enemy-res input[type="number"] { width: 48px; padding: 0 3px; }
.enemy-res label.weak input { color: var(--red-text); border-color: #ff6f6188; }
.enemy-res label.resist input { color: var(--t-heal); }

/* tables */
.sim-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.sim-table th { text-align: right; color: var(--text-muted); font-weight: 600; font-size: 11.5px; padding: 4px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.sim-table th:first-child { text-align: left; }
.sim-table th small { font-weight: 400; margin-left: 4px; }
.sim-table td { padding: 3px 6px; border-bottom: 1px solid #322a4466; vertical-align: middle; }
.sim-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.sim-table td.num small { display: block; font-size: 11px; font-weight: 400; }
.sim-table td img { width: 22px; height: 22px; border-radius: 5px; vertical-align: middle; }
.sim-table .tot { color: var(--gold); }
.sim-table tr.mv { cursor: pointer; }
.sim-table tr.mv:hover td { background: #ffffff08; }
.sim-table tr.mv.chosen td { background: var(--gold-soft); }
.sim-table tr.mv label { cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.sim-table tr.mv input { accent-color: var(--gold); margin: 0; }
.sim-table tr.mv .gi { width: 15px; height: 15px; vertical-align: -3px; }
.sim-table .skn { display: block; font-size: 11px; margin-left: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.sim-table tr.how td { background: var(--surface-2); font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.how-row + .how-row { margin-top: 4px; }
.how-row b { color: var(--text); }
.sim-table tr.sum td { border-top: 2px solid var(--border); font-weight: 600; }

/* buffs */
.sim-buffs { width: 100%; border-collapse: collapse; font-size: 12px; }
.sim-buffs th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 11px; padding: 3px 5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.sim-buffs td { padding: 3px 5px; border-bottom: 1px solid #322a4466; vertical-align: middle; }
.sim-buffs td small { display: block; font-size: 10.5px; }
.sim-buffs tr.zero td:first-child { color: var(--text-muted); }
.sim-buffs td.num { white-space: nowrap; font-weight: 600; min-width: 92px; }
.sim-buffs td.num small { display: inline; font-weight: 400; }
.sim-buffs .wasted { display: block !important; color: var(--red-text); }
.sim-buffs input[type="number"] { width: 54px; height: 24px; }
.sim-buffs .gi { width: 15px; height: 15px; vertical-align: -3px; margin-right: 3px; }
.srcs { display: flex; flex-wrap: wrap; gap: 3px; }
.src { display: inline-block; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11px; white-space: nowrap; }
.src.own, .k.own { border-color: var(--gold); color: var(--gold); }
.src.ally, .k.ally { border-color: #b9a6ff88; color: #c9bbff; }
.src.field, .k.field { border-color: #4b97f788; color: #8ec0ff; }
.k { display: inline-block; padding: 0 5px; border: 1px solid; border-radius: 5px; font-size: 10.5px; }
.bar { width: 100%; max-width: 110px; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; background: var(--t-advantage); }
.bar.full i { background: var(--gold); }
.bar.over i { background: var(--red-text); }
.bar.none { opacity: .3; }

/* survivability */
.ehp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; font-size: 12.5px; color: var(--text-muted); }
.ehp-grid b { color: var(--text); font-variant-numeric: tabular-nums; }
.ehp-grid .tot b { color: var(--gold); }
.ehp-grid small { font-size: 11px; }

.sim-how { margin: 26px 0 40px; font-size: 13px; color: var(--text-muted); }
.sim-how summary { cursor: pointer; color: var(--gold); }

@media (max-width: 1100px) {
  .urow, .erow { grid-template-columns: 280px minmax(0, 1fr); }
  .urow .sdmg, .erow .sdmg { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .mini-units { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .urow, .erow { grid-template-columns: 1fr; }
  .ubuffs, .sdmg { overflow-x: auto; }
}
@media (max-width: 480px) {
  .mini-units { grid-template-columns: 1fr; }
}

/* enemy cards + wave loader in the top bar */
.mini-enemies { display: grid; }
.mini-e { border-color: #c3030055; }
.mini-num.e { width: auto; padding: 0 5px; border-radius: 10px; background: #c3030033; color: var(--red-text); font-size: 10.5px; }
.mini-unit.ph { display: grid; place-items: center; background: var(--surface-2); color: var(--text-faint); }
.mini-unit.ph .gi { width: 26px; height: 26px; }
.mini-tags { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; }
.mini-tags .gi { width: 14px; height: 14px; }
.mini-add { grid-template-columns: 1fr; justify-items: center; color: var(--text-muted); border-style: dashed; }
.wave-load { grid-template-columns: 1fr; border-style: dashed; cursor: default; }
.wave-panel { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; background: var(--surface); border: 1px solid var(--gold); border-radius: var(--radius); font-size: 12.5px; }
.wave-panel .x { margin-left: auto; }
.wave-panel .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sim small.warn { color: #ff9b6a; }
.ph { position: relative; overflow: hidden; }
.ph > img { position: absolute; inset: 0; width: 100%; height: 100%; }
.eicon { width: 52px; height: 52px; border-radius: 8px; flex: none; display: grid; place-items: center; background: var(--surface-2); }
.eicon .gi { width: 30px; height: 30px; }
.pslot-plan .reach { flex-basis: 100%; font-size: 11.5px; }
.sim .warn { color: #ff9b6a; }
.ord.forced { border-color: var(--gold); }
.sim-buffs + .linkbtn { font-size: 11.5px; margin-top: 4px; }

/* multi-turn plan */
.plan-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 8px; color: var(--text-muted); font-size: 12.5px; }
.sim-table.plan td, .sim-table.plan th { text-align: left; vertical-align: top; }
.sim-table.plan td.num, .sim-table.plan th:last-child { text-align: right; }
.sim-table.plan th.on, .sim-table.plan td.on { background: #ebbe5c12; }
.sim-table.plan select { max-width: 120px; }
.sim-table.plan td small { display: block; font-size: 11px; }
.sim-table.plan td small.num { color: var(--gold); font-weight: 600; font-size: 12px; }
.sim-table.plan tr.hp td { color: var(--text-muted); }
.sim-table.plan td.dead { color: var(--t-heal); font-weight: 600; }
.turn-view { margin: 14px 0 6px; }

/* enemy HP */
.hpbar { position: relative; display: flex; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 4px; min-width: 60px; }
.hpbar i { display: block; height: 100%; }
.hpbar .left { background: #e2385c; }
.hpbar .cut { background: #ebbe5c; }
.hpbar.none { opacity: .35; }
.mini-nm .hpbar { margin-top: 3px; }
.sim-table small.pct, .sim-table td small.pct { display: block; color: #ff8a7a; font-weight: 400; font-size: 11px; }
.sim-table.plan tr.edmg td { color: var(--text); }
.hpline { margin: 8px 0 0; font-size: 12.5px; color: var(--text-muted); }
.hpline b { color: var(--text); }

.leader-note { font-size: 11.5px; color: var(--gold); }
.src.ach { border-color: #6fdc9b88; color: #8be8b0; }
