.battle-page{font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
.battle-shell{max-width:1180px;width:calc(100% - 36px);margin:28px auto 0}
.battle-content-panel{margin:0 0 22px;padding:26px;border:1px solid rgba(148,163,184,.2);border-radius:22px;background:linear-gradient(135deg,rgba(16,25,44,.94),rgba(8,14,27,.96));box-shadow:0 22px 70px rgba(0,0,0,.25)}.battle-content-panel h1{margin:7px 0 10px;font-size:clamp(30px,4vw,50px);line-height:1}.battle-content-panel p{max-width:850px;margin:0;color:#aebbd0;line-height:1.7}.battle-content-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin-top:22px}.battle-info-card{border:1px solid rgba(148,163,184,.2);border-radius:20px;padding:20px;background:linear-gradient(180deg,rgba(16,25,44,.94),rgba(8,14,27,.96));box-shadow:0 18px 55px rgba(0,0,0,.2)}.battle-info-card h2{margin:0 0 10px;font-size:20px}.battle-info-card p{margin:0;color:#aebbd0;line-height:1.7}@media(max-width:900px){.battle-content-grid{grid-template-columns:1fr}}
.battle-hero{text-align:center;padding:38px 18px 26px}
.battle-kicker,.panel-eyebrow{display:inline-flex;text-transform:uppercase;letter-spacing:.14em;font-size:11px;font-weight:900;color:#7dd3fc}
.battle-hero h1{font-size:clamp(42px,6vw,72px);letter-spacing:-.06em;margin:10px 0;color:#fff}
.battle-hero p{margin:0 auto;max-width:680px;color:#aab8cd;font-size:18px;line-height:1.6}
.battle-mode-tabs{display:flex;justify-content:center;gap:10px;margin:0 auto 22px;flex-wrap:wrap}
.battle-mode-tabs button{width:auto;border:1px solid rgba(148,163,184,.22);background:#08101e;color:#dbeafe;border-radius:999px;padding:11px 18px;font-weight:1000;cursor:pointer}
.battle-mode-tabs button.active{background:linear-gradient(135deg,#7c3aed,#2563eb);color:#fff;box-shadow:0 12px 32px rgba(76,29,149,.3)}
.battle-tab-panel{display:block}
.battle-tab-panel[hidden]{display:none!important}
.battle-toolbar,.fighter-card,.simulate-panel,.result-shell{border:1px solid rgba(148,163,184,.2);background:linear-gradient(180deg,rgba(16,25,44,.94),rgba(8,14,27,.96));box-shadow:0 22px 70px rgba(0,0,0,.25)}
.battle-toolbar{border-radius:20px;padding:16px 18px;display:flex;align-items:end;justify-content:center;gap:26px;margin-bottom:22px}
.setting-group{display:grid;gap:8px;align-content:end}.setting-group>span,.pokemon-search-wrap label,.field-grid label,.field-stack label{font-size:12px;font-weight:900;text-transform:uppercase;letter-spacing:.08em;color:#a9b7cc}
.segmented{display:flex;border:1px solid rgba(148,163,184,.18);border-radius:999px;padding:4px;background:#08101e}
.segmented button{border:0;background:transparent;color:#b7c3d5;padding:10px 18px;border-radius:999px;font-weight:900;cursor:pointer}
.segmented button.active{background:linear-gradient(135deg,#7c3aed,#2563eb);color:#fff;box-shadow:0 8px 25px rgba(91,33,182,.35)}
.compact-segment button{min-width:38px;padding:10px 12px}
.strategy-segment{min-width:270px}
.strategy-segment button{white-space:nowrap}
.core-ai-bait-options{display:grid;gap:8px;width:100%;grid-column:1/-1}
.core-ai-bait-options[hidden]{display:none!important}
.core-ai-bait-options>span{font-size:12px;font-weight:900;text-transform:uppercase;letter-spacing:.08em;color:#a9b7cc}
.core-ai-bait-segment{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));min-width:0;width:100%;border-radius:14px}
.core-ai-bait-segment button{min-width:0;padding:10px 8px;white-space:normal}
.battle-toolbar .strategy-segment,.matrix-toolbar .strategy-segment,.multi-toolbar .strategy-segment{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));min-width:390px}
.team-battle-toolbar .strategy-segment{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));min-width:270px}
.hidden-select{display:none!important}
select,input{border:1px solid rgba(148,163,184,.22);background:#0a1221;color:#f8fafc;border-radius:12px;padding:12px 13px;outline:none;width:100%}
textarea{border:1px solid rgba(148,163,184,.22);background:#0a1221;color:#f8fafc;border-radius:12px;padding:12px 13px;outline:none;width:100%;resize:vertical;font:inherit;line-height:1.45}
select:focus,input:focus{border-color:#38bdf8;box-shadow:0 0 0 3px rgba(56,189,248,.12)}
textarea:focus{border-color:#38bdf8;box-shadow:0 0 0 3px rgba(56,189,248,.12)}
.shield-pair{display:flex;gap:8px}.shield-pair label{display:flex;align-items:center;gap:8px;color:#dbeafe;font-weight:900}.shield-pair select{width:72px}
.shield-segment-pair{align-items:end;gap:12px}
.shield-segment-field{display:grid;grid-template-columns:auto 1fr;align-items:center;gap:8px;color:#dbeafe;font-size:13px;font-weight:1000}
.shield-segment-field>span{min-width:18px;color:#dbeafe}
.strategy-group select{min-width:180px}
.matchup-grid{display:grid;grid-template-columns:minmax(0,1fr) 82px minmax(0,1fr);gap:14px;align-items:stretch}
.fighter-card{border-radius:24px;padding:20px;min-width:0;position:relative;overflow:visible}
.fighter-card:before{content:"";position:absolute;inset:0 0 auto;height:3px;background:linear-gradient(90deg,#8b5cf6,#38bdf8);border-radius:24px 24px 0 0}
.fighter-card[data-side="b"]:before{background:linear-gradient(90deg,#f43f5e,#fb923c)}
.fighter-heading{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:18px}
.side-pill,.engine-badge{display:inline-flex;padding:7px 10px;border-radius:999px;background:rgba(139,92,246,.14);border:1px solid rgba(167,139,250,.28);color:#c4b5fd;font-size:12px;font-weight:900}
.side-pill.opponent{background:rgba(244,63,94,.1);border-color:rgba(251,113,133,.28);color:#fda4af}
.ready-state{font-size:12px;color:#7f8da3}.ready-state.ready{color:#86efac}
.pokemon-search-wrap{position:relative;display:grid;gap:8px;z-index:5}
.search-results{position:absolute;left:0;right:0;top:74px;max-height:320px;overflow:auto;border:1px solid rgba(148,163,184,.25);border-radius:16px;background:#08101e;box-shadow:0 24px 60px rgba(0,0,0,.5);padding:8px}
.search-option{display:flex;align-items:center;gap:12px;width:100%;padding:10px;border:0;border-radius:12px;background:transparent;color:#fff;text-align:left;cursor:pointer}
.search-option:hover{background:rgba(139,92,246,.14)}
.search-option img{width:46px;height:46px;object-fit:contain;background:rgba(255,255,255,.04);border-radius:10px}
.search-option strong{display:block;font-size:14px}.search-option small{color:#8593a8}
.pokemon-stage{display:grid;grid-template-columns:128px 1fr;gap:18px;align-items:center;min-height:160px;margin:18px 0}
.art-ring{height:128px;width:128px;border-radius:50%;display:grid;place-items:center;background:radial-gradient(circle,rgba(139,92,246,.22),rgba(14,165,233,.03) 65%);border:1px solid rgba(167,139,250,.24)}
.art-ring img{width:116px;height:116px;object-fit:contain;filter:drop-shadow(0 15px 16px rgba(0,0,0,.45))}
.pokemon-stage h2{font-size:28px;letter-spacing:-.04em;margin:0 0 10px}.muted{color:#8492a7;margin:8px 0 0}
.type-row{display:flex;gap:7px;flex-wrap:wrap}.type-chip{padding:5px 9px;border-radius:999px;background:#172033;border:1px solid rgba(255,255,255,.08);font-size:11px;font-weight:900;text-transform:uppercase}
.stat-strip{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin:14px 0 18px}
.stat-strip div{padding:11px 8px;border-radius:13px;background:rgba(9,16,30,.72);border:1px solid rgba(148,163,184,.12);text-align:center}.stat-strip span{display:block;color:#7f8da3;font-size:10px;font-weight:900}.stat-strip strong{display:block;margin-top:4px;font-size:16px}
.field-grid{display:grid;gap:10px}.iv-grid{grid-template-columns:repeat(4,1fr);margin-bottom:12px}.field-grid label,.field-stack label{display:grid;gap:7px}
.field-stack{display:grid;gap:10px}
.mega-extra-move[hidden]{display:none!important}
.mega-extra-move{border:1px solid rgba(34,211,238,.28);border-radius:12px;padding:10px;background:rgba(34,211,238,.06)}
.mega-extra-move select{border-color:rgba(34,211,238,.35)}
.toggle-row{display:grid;grid-template-columns:auto 1fr;column-gap:10px;align-items:center;margin-top:14px;padding:13px;border-radius:14px;background:rgba(8,16,30,.72);border:1px solid rgba(148,163,184,.13);cursor:pointer}.toggle-row input{width:auto;grid-row:1/3}.toggle-row span{font-weight:900}.toggle-row small{color:#7f8da3}
.versus-column{display:flex;flex-direction:column;align-items:center;justify-content:center}.versus-orb{width:62px;height:62px;border-radius:50%;display:grid;place-items:center;background:linear-gradient(135deg,#7c3aed,#e11d48);font-size:20px;font-weight:1000;border:5px solid #090f1d;box-shadow:0 0 0 1px rgba(255,255,255,.15),0 0 40px rgba(139,92,246,.3)}.versus-line{width:1px;height:90px;background:linear-gradient(transparent,rgba(148,163,184,.3),transparent)}
.simulate-panel{border-radius:22px;padding:22px 24px;margin-top:20px;display:flex;align-items:center;justify-content:space-between;gap:22px}.simulate-panel h2,.result-heading h2{margin:5px 0 5px}.simulate-panel p{color:#91a0b6;margin:0;max-width:700px}.simulate-panel button{border:0;border-radius:15px;padding:16px 24px;background:linear-gradient(135deg,#7c3aed,#2563eb);color:#fff;font-weight:1000;font-size:16px;cursor:pointer;box-shadow:0 15px 35px rgba(76,29,149,.35)}.simulate-panel button:disabled{opacity:.4;cursor:not-allowed;box-shadow:none}
.result-shell{border-radius:24px;padding:24px;margin-top:20px}.result-heading{display:flex;justify-content:space-between;align-items:center}.result-grid{display:grid;grid-template-columns:1fr 1.1fr 1fr;gap:12px;margin-top:18px}.summary-card,.comparison-card{border-radius:17px;padding:18px;background:#091120;border:1px solid rgba(148,163,184,.13)}.summary-card h3{margin:0 0 12px}.summary-card ul{padding:0;margin:0;list-style:none;display:grid;gap:8px;color:#aebbd0}.comparison-card{text-align:center;display:grid;place-items:center;align-content:center}.comparison-card span{color:#8492a7}.comparison-card strong{font-size:22px;margin:8px}.comparison-card p{color:#91a0b6;line-height:1.5}
.payload-panel{margin-top:14px;border-top:1px solid rgba(148,163,184,.14);padding-top:14px}.payload-panel summary{cursor:pointer;font-weight:900;color:#bae6fd}.payload-panel pre{white-space:pre-wrap;word-break:break-word;background:#050a13;border-radius:14px;padding:16px;color:#b6c4d8;max-height:400px;overflow:auto}
@media(max-width:980px){.battle-toolbar{flex-wrap:wrap}.matchup-grid{grid-template-columns:1fr}.versus-column{height:74px}.versus-line{display:none}.result-grid{grid-template-columns:1fr}.versus-orb{width:54px;height:54px}.iv-grid{grid-template-columns:1fr 1fr}}
@media(max-width:620px){.battle-shell{width:calc(100% - 24px)}.battle-hero{padding-top:24px}.fighter-card{padding:16px}.pokemon-stage{grid-template-columns:92px 1fr}.art-ring{width:92px;height:92px}.art-ring img{width:84px;height:84px}.stat-strip{grid-template-columns:1fr 1fr}.battle-toolbar,.simulate-panel{align-items:stretch;flex-direction:column}.segmented button{padding:9px 12px}.result-heading{align-items:flex-start;gap:12px;flex-direction:column}}
.result-note{margin:6px 0 0;color:#91a0b6}
.winner-card{margin-top:18px;padding:22px;border-radius:18px;text-align:center;background:radial-gradient(circle at top,rgba(124,58,237,.25),rgba(8,16,30,.9) 65%);border:1px solid rgba(167,139,250,.25)}
.winner-label{display:block;text-transform:uppercase;letter-spacing:.16em;font-size:10px;font-weight:900;color:#93c5fd}.winner-card strong{display:block;font-size:34px;margin:7px 0;color:#fff}.winner-meta{color:#b6c4d8}
.hp-result-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:14px}.hp-result-card{padding:15px;border-radius:15px;background:#091120;border:1px solid rgba(148,163,184,.13)}.hp-result-card>div:first-child{display:flex;justify-content:space-between;gap:15px;color:#dbeafe}.hp-result-card span{color:#91a0b6}.hp-track{height:12px;margin-top:10px;border-radius:999px;overflow:hidden;background:#182235}.hp-track span{display:block;height:100%;width:0;background:linear-gradient(90deg,#22c55e,#84cc16);transition:width .45s ease}.hp-track.opponent span{background:linear-gradient(90deg,#fb7185,#f97316)}
.battle-log-panel{margin-top:16px;border-top:1px solid rgba(148,163,184,.14);padding-top:15px}.battle-log-panel summary{cursor:pointer;font-weight:900;color:#dbeafe}.battle-log-panel ol{list-style:none;padding:0;margin:14px 0 0;display:grid;gap:8px;max-height:520px;overflow:auto}.battle-log-panel li{display:grid;grid-template-columns:92px 1fr;gap:12px;padding:11px 13px;border-radius:12px;background:#07101e;border:1px solid rgba(148,163,184,.1)}.battle-log-panel li>span{font-size:11px;font-weight:900;color:#7dd3fc}.battle-log-panel p{margin:0;color:#b8c5d8;line-height:1.45}.battle-log-panel .log-charged{border-color:rgba(167,139,250,.24);background:rgba(91,33,182,.09)}.battle-log-panel .log-cmp{border-color:rgba(251,191,36,.24);background:rgba(120,53,15,.1)}
@media(max-width:620px){.hp-result-grid{grid-template-columns:1fr}.battle-log-panel li{grid-template-columns:1fr;gap:4px}}


/* Visual battle replay */
.visual-replay{margin-top:16px;padding:18px;border-radius:18px;background:linear-gradient(180deg,rgba(10,19,35,.96),rgba(5,11,22,.98));border:1px solid rgba(148,163,184,.16)}
.visual-replay-heading{display:flex;justify-content:space-between;align-items:flex-start;gap:20px;margin-bottom:14px}.visual-replay-heading h3{margin:5px 0 4px;font-size:22px}.visual-replay-heading p{margin:0;color:#8fa0b7;max-width:680px;line-height:1.5}
.replay-legend{display:flex;gap:12px;flex-wrap:wrap;justify-content:flex-end;color:#aebbd0;font-size:11px;font-weight:800}.replay-legend span{display:flex;align-items:center;gap:6px}.replay-legend i{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;font-style:normal;line-height:1}
.legend-fast{width:8px!important;height:8px!important;border-radius:1px;background:linear-gradient(135deg,#ee8130 0 25%,#6390f0 25% 50%,#7ac74c 50% 75%,#735797 75%);box-shadow:0 0 0 1px rgba(255,255,255,.28)}.legend-charge,.legend-shield,.legend-cmp,.legend-disguise{font-size:15px}
.legend-charge{width:15px!important;height:15px!important;border-radius:50%;background:linear-gradient(135deg,#6390f0,#ee8130,#7ac74c);box-shadow:0 0 0 2px #07101d,0 0 0 3px rgba(255,255,255,.28),0 0 8px rgba(125,211,252,.34)}
.legend-charge:before{display:none}
.replay-viewport{overflow-x:auto;overflow-y:hidden;border-radius:15px;border:1px solid rgba(148,163,184,.15);background:radial-gradient(circle at 50% 0,rgba(59,130,246,.08),transparent 55%),#07101d}.replay-stage{position:relative;min-width:900px;padding:18px 48px 18px 132px;cursor:ew-resize;touch-action:pan-y;user-select:none}.replay-stage.is-scrubbing .replay-cursor{transition:none}
.replay-row{position:relative;display:grid;grid-template-columns:minmax(620px,1fr) 34px;align-items:start;gap:12px;min-height:126px}.replay-row+ .replay-row{border-top:1px solid rgba(148,163,184,.12)}.replay-row>strong{position:absolute;left:-98px;width:86px;text-align:right;color:#e2e8f0;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.replay-track{position:relative;height:48px;border-top:2px dashed rgba(148,163,184,.42);margin-top:22px}.replay-charge-status{position:absolute;left:0;right:42px;bottom:9px;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.charge-meter{min-width:0;padding:7px 9px;border-radius:10px;background:rgba(8,18,34,.86);border:1px solid rgba(148,163,184,.13)}.charge-meter-head{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:10px}.charge-meter-head strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#e2e8f0}.charge-meter-head span{color:#f9a8d4;font-weight:900}.charge-slots{display:flex;gap:3px;margin-top:5px}.charge-slot{position:relative;display:block;flex:1;height:6px;overflow:hidden;border-radius:999px;background:#1e293b;border:1px solid rgba(244,114,182,.26)}.charge-slot i{display:block;height:100%;background:linear-gradient(90deg,#db2777,#f472b6);border-radius:999px;transition:width .12s linear}.charge-meter small{display:block;margin-top:4px;color:#93a4ba;font-size:9px;font-weight:800;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.replay-result{position:absolute;right:-35px;top:20px;font-size:28px;font-weight:1000}.replay-result.win{color:#4ade80}.replay-result.loss{color:#f43f5e}.replay-result.draw{color:#facc15}
.replay-event{position:absolute;top:-11px;transform:translateX(-50%);display:flex;align-items:center;justify-content:center;padding:0;border:0;background:transparent;color:#fff;font:inherit;line-height:1;text-shadow:0 2px 5px rgba(0,0,0,.65);cursor:pointer;transition:transform .15s ease,filter .15s ease,opacity .2s ease;opacity:.42}.replay-event:hover,.replay-event.is-active{transform:translateX(-50%) scale(1.28);filter:brightness(1.2);z-index:5}.replay-event.is-past{opacity:1}
.replay-event.fast{width:8px;height:8px;border-radius:1px;background:var(--event-color,#a8a77a);box-shadow:0 0 0 1px #020617,0 0 0 2px rgba(255,255,255,.2),0 3px 8px rgba(0,0,0,.4)}.replay-event.charged{width:27px;height:27px;font-size:21px}.replay-event.shield{width:28px;height:28px;font-size:21px}.replay-event.disguise{width:28px;height:28px;font-size:21px;filter:drop-shadow(0 0 6px rgba(216,133,173,.45))}.replay-event.cmp{width:27px;height:27px;font-size:20px}.replay-event.ko{width:26px;height:30px;font-size:22px;color:#ef4444;text-shadow:0 0 9px rgba(239,68,68,.55),0 2px 4px #020617}
.replay-fast-duration{position:absolute;top:-7px;height:6px;border-radius:999px;background:rgba(148,163,184,.14);box-shadow:inset 0 0 0 1px rgba(255,255,255,.08);overflow:hidden;pointer-events:none;z-index:2}.replay-fast-duration:before{content:"";display:block;width:calc(var(--progress,0) * 100%);height:100%;border-radius:inherit;background:linear-gradient(90deg,var(--event-color,#a8a77a),rgba(255,255,255,.82));box-shadow:0 0 10px var(--event-color,#a8a77a)}.replay-fast-duration.is-active{background:rgba(125,211,252,.13)}.replay-fast-duration.is-past{opacity:.58}
.replay-cursor{position:absolute;left:112px;top:13px;bottom:13px;width:2px;background:linear-gradient(#38bdf8,#a78bfa);box-shadow:0 0 13px rgba(56,189,248,.8);z-index:4;pointer-events:none;transition:left .12s linear}.replay-cursor:before{content:"";position:absolute;top:-3px;left:50%;transform:translateX(-50%);width:10px;height:10px;border-radius:50%;background:#e0f2fe}
.replay-controls{display:flex;align-items:center;justify-content:center;gap:10px;margin-top:13px;flex-wrap:wrap}.replay-controls button,.replay-controls select{border:1px solid rgba(125,211,252,.28);background:#0b1729;color:#f8fafc;border-radius:11px;padding:9px 13px;font-weight:900;width:auto}.replay-controls button{cursor:pointer}.replay-controls button:hover{border-color:#38bdf8}.replay-controls label{display:flex;align-items:center;gap:7px;color:#9fb0c7;font-size:12px;font-weight:800}.replay-controls span{min-width:90px;color:#7dd3fc;font-size:12px;font-weight:900;text-align:center}
.battle-log-panel li.replay-current{outline:2px solid rgba(56,189,248,.7);background:rgba(14,116,144,.16)}
@media(max-width:720px){.replay-charge-status{grid-template-columns:repeat(2,minmax(210px,1fr))}.visual-replay-heading{flex-direction:column}.replay-legend{justify-content:flex-start}.visual-replay{padding:14px}.replay-stage{min-width:720px}.replay-controls{justify-content:flex-start}}

/* Matrix Battle */
.matrix-toolbar,.matrix-team-panel,.matrix-generate-panel,.matrix-progress,.matrix-result-shell{border:1px solid rgba(148,163,184,.2);background:linear-gradient(180deg,rgba(16,25,44,.94),rgba(8,14,27,.96));box-shadow:0 22px 70px rgba(0,0,0,.25)}
.matrix-toolbar{border-radius:18px;padding:14px 16px;display:flex;align-items:end;justify-content:center;gap:16px;margin-bottom:14px;flex-wrap:wrap}
.matrix-toolbar .setting-group{min-width:150px}
.matrix-toolbar .strategy-group{min-width:270px}
.matrix-future-setting input{opacity:.65}
.matrix-options{margin-bottom:16px}
.matrix-toggle{max-width:460px;margin:0}
.matrix-team-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;align-items:start}
.matrix-team-panel{border-radius:18px;padding:14px;min-width:0}
.matrix-team-panel.matrix-mirrored{opacity:.58}
.matrix-team-heading{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-bottom:16px}
.matrix-team-heading h2{margin:4px 0 0}
.matrix-team-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.matrix-add-row,.matrix-import-open,.matrix-import button,.matrix-actions button{width:auto;border:0;border-radius:13px;padding:12px 15px;background:linear-gradient(135deg,#7c3aed,#2563eb);color:#fff;font-weight:1000;cursor:pointer}
.matrix-import-open{background:linear-gradient(135deg,#0891b2,#22c55e);color:#03131b}
.matrix-import{display:grid;gap:8px;margin-bottom:12px}
.matrix-import label,.matrix-row label{font-size:12px;font-weight:900;text-transform:uppercase;letter-spacing:.08em;color:#a9b7cc}
.matrix-import textarea{min-height:104px}
.matrix-errors{display:grid;gap:6px;color:#fecaca;font-size:13px;line-height:1.35}
.matrix-errors:empty{display:none}
.matrix-rows{display:grid;gap:9px;max-height:650px;overflow-y:auto;overscroll-behavior:contain;padding-right:6px;scrollbar-width:thin}
.matrix-row{position:relative;border:0;border-radius:13px;background:linear-gradient(180deg,var(--matrix-card-top,#3290d8),var(--matrix-card-bottom,#52c7ee));padding:10px 46px 10px 11px;display:grid;gap:3px;color:#04111f;box-shadow:0 6px 18px rgba(0,0,0,.16);cursor:pointer;overflow:hidden}
.matrix-row:nth-child(6n+1){--matrix-card-top:#6bb2bf;--matrix-card-bottom:#65c7c5}
.matrix-row:nth-child(6n+2){--matrix-card-top:#1f6fb8;--matrix-card-bottom:#028ad6;color:#fff}
.matrix-row:nth-child(6n+3){--matrix-card-top:#cf3470;--matrix-card-bottom:#f0444d}
.matrix-row:nth-child(6n+4){--matrix-card-top:#d13b70;--matrix-card-bottom:#f13f4c}
.matrix-row:nth-child(6n+5){--matrix-card-top:#4f96db;--matrix-card-bottom:#63c7ed}
.matrix-row:nth-child(6n+6){--matrix-card-top:#9ccc25;--matrix-card-bottom:#bad923}
.matrix-row-head{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:end}
.matrix-row-title{display:grid;gap:7px;position:relative}
.matrix-row-delete{position:absolute;right:0;top:0;width:36px;height:42px;border:0;border-radius:0 12px 0 12px;background:rgba(15,23,42,.72);color:#fff;font-weight:1000;font-size:23px;line-height:1;cursor:pointer;z-index:2}
.matrix-row-delete:hover{background:rgba(15,23,42,.9)}
.matrix-row-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}
.matrix-row-moves{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.matrix-row-toggles{display:flex;gap:12px;flex-wrap:wrap}
.matrix-row-toggles label{display:flex;align-items:center;gap:7px;margin:0;text-transform:none;letter-spacing:0;font-size:13px}
.matrix-row-toggles input{width:auto}
.matrix-row .search-results{top:72px;z-index:30}
.matrix-row-name{font-size:22px;line-height:1.04;font-weight:1000;letter-spacing:-.03em}
.matrix-row-index{font-weight:700;opacity:.72;margin-right:5px}
.matrix-row-summary{color:inherit;font-size:18px;line-height:1.18;font-weight:700}
.matrix-row-move-pill{display:inline-flex;align-items:center;justify-content:center;min-width:24px;height:24px;margin:0 2px;padding:0 6px;border-radius:999px;background:rgba(15,23,42,.34);color:#fff;font-weight:1000;font-size:15px}
.matrix-row-data{display:none}
.matrix-row.invalid{border-color:rgba(248,113,113,.55)}
.matrix-generate-panel{border-radius:22px;padding:22px 24px;margin-top:18px;display:flex;align-items:center;justify-content:space-between;gap:18px}
.matrix-generate-panel h2{margin:5px 0}
.matrix-generate-panel p,.matrix-progress p{margin:0;color:#91a0b6}
.matrix-actions{display:flex;gap:10px;flex-wrap:wrap;justify-content:flex-end}
.matrix-actions button:disabled{opacity:.45;cursor:not-allowed}
.matrix-actions #matrixCancel{background:rgba(244,63,94,.16);border:1px solid rgba(251,113,133,.28);color:#fecdd3}
.matrix-actions .swap-teams-button,.team-battle-actions .swap-teams-button{background:rgba(15,23,42,.82);border:1px solid rgba(125,211,252,.34);color:#dbeafe}
.matrix-progress{border-radius:18px;padding:18px;margin-top:16px;display:grid;gap:10px}
.matrix-progress-head{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap}
.matrix-progress-track{height:12px;border-radius:999px;background:#172033;overflow:hidden}
.matrix-progress-track span{display:block;height:100%;width:0;background:linear-gradient(90deg,#38bdf8,#22c55e);transition:width .15s linear}
.matrix-result-shell{border-radius:22px;margin-top:18px;padding:16px;overflow:hidden}
.matrix-result-actions{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-bottom:14px}
.matrix-result-actions h2{margin:4px 0 0}
.matrix-result-actions button{width:auto;border:0;border-radius:13px;padding:11px 15px;background:linear-gradient(135deg,#22c55e,#38bdf8);color:#03131b;font-weight:1000;cursor:pointer}
.matrix-result-buttons{display:flex;gap:10px;flex-wrap:wrap;justify-content:flex-end}
.matrix-table-wrap{overflow:auto;max-height:70vh;border-radius:16px;border:1px solid rgba(148,163,184,.14);background:rgba(16,25,44,.34)}
.matrix-table{border-collapse:separate;border-spacing:0;table-layout:fixed;width:max-content;min-width:100%;font-size:13px}
.matrix-name-col{width:142px}
.matrix-rating-col{width:70px}
.matrix-record-col{width:84px}
.matrix-average-col{width:56px}
.matrix-table th,.matrix-table td{border-right:1px solid rgba(148,163,184,.12);border-bottom:1px solid rgba(148,163,184,.12);padding:8px 7px;text-align:center;white-space:normal;line-height:1.12}
.matrix-table th{position:sticky;top:0;background:#10192c;color:#dbeafe;z-index:2;font-weight:1000}
.matrix-table th:first-child{left:0;z-index:3}
.matrix-name-label{display:block;max-width:100%;overflow:hidden;text-overflow:ellipsis}
.matrix-rank-prefix{display:inline-block;margin-right:4px;color:#93c5fd}
.matrix-table tbody th{position:sticky;left:0;background:#10192c;text-align:left;overflow:hidden}
.matrix-table tbody td{background:rgba(255,255,255,.035)}
.matrix-cell{background:rgba(255,255,255,.035)!important;color:#06111f;cursor:pointer;transition:background .12s ease,filter .12s ease}
.matrix-cell:hover{background:rgba(125,211,252,.08)!important;filter:brightness(1.08);z-index:1;position:relative}
.matrix-rating-chip{display:inline-flex;align-items:center;justify-content:center;width:48px;height:30px;padding:0;border:1px solid rgba(255,255,255,.18);border-radius:8px;background:linear-gradient(180deg,rgba(255,255,255,.2),rgba(255,255,255,0) 38%),var(--matrix-rating-color);box-shadow:inset 0 1px 0 rgba(255,255,255,.24),0 5px 14px rgba(0,0,0,.22);font-weight:1000;color:#06111f}
.matrix-cell.neutral .matrix-rating-chip{color:#f8fafc}
.matrix-cell:hover .matrix-rating-chip{transform:translateY(-1px);box-shadow:inset 0 1px 0 rgba(255,255,255,.3),0 8px 18px rgba(0,0,0,.3)}
.matrix-record-cell,.matrix-average-cell{background:#10192c!important;color:#dbeafe!important;font-weight:1000}
.matrix-record-cell{min-width:82px}
.matrix-average-cell{min-width:54px}
@media(max-width:980px){.matrix-team-grid{grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.matrix-toolbar{justify-content:flex-start}.matrix-generate-panel{align-items:stretch;flex-direction:column}.matrix-actions{justify-content:flex-start}.matrix-row-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.matrix-row-moves{grid-template-columns:1fr}.matrix-rows{max-height:560px}}
@media(max-width:620px){.battle-mode-tabs{justify-content:flex-start}.battle-mode-tabs button{flex:1 1 150px}.matrix-toolbar{align-items:stretch;flex-direction:column;padding:12px}.matrix-toolbar .setting-group{min-width:0;width:100%}.matrix-team-grid{grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:6px}.matrix-team-panel{padding:7px;border-radius:12px}.matrix-team-heading{align-items:flex-start;flex-direction:column;gap:7px;margin-bottom:9px}.matrix-team-heading .panel-eyebrow{font-size:10px}.matrix-team-heading h2{font-size:16px;line-height:1;margin:2px 0 0}.matrix-team-actions{width:100%;display:grid;grid-template-columns:1fr 1fr;gap:5px}.matrix-add-row,.matrix-import-open{width:100%;border-radius:9px;padding:8px 5px;font-size:11px;line-height:1.1}.matrix-import button,.matrix-actions button{width:100%}.matrix-import textarea{min-height:86px}.matrix-rows{max-height:460px;gap:6px;padding-right:2px}.matrix-row{border-radius:9px;padding:7px 27px 7px 7px;gap:2px;box-shadow:0 4px 12px rgba(0,0,0,.14)}.matrix-row-delete{width:24px;height:28px;border-radius:0 8px 0 8px;font-size:18px}.matrix-row-name{font-size:13px;line-height:1.08;letter-spacing:0}.matrix-row-index{margin-right:3px}.matrix-row-summary{font-size:11px;line-height:1.16}.matrix-row-move-pill{min-width:16px;height:16px;margin:0 1px;padding:0 4px;font-size:10px}.matrix-row-grid{grid-template-columns:1fr 1fr}.matrix-row-moves{grid-template-columns:1fr}.matrix-generate-panel{padding:16px}.matrix-result-shell{padding:8px;margin-left:-4px;margin-right:-4px}.matrix-result-actions{align-items:stretch;flex-direction:column}.matrix-result-buttons{display:grid;grid-template-columns:1fr 1fr}.matrix-result-actions button{width:100%}.matrix-table{font-size:12px}.matrix-table th,.matrix-table td{padding:6px 5px}.matrix-name-col{width:118px}.matrix-rating-col{width:58px}.matrix-record-col{width:76px}.matrix-average-col{width:50px}.matrix-rating-chip{width:42px;height:27px;border-radius:7px}}

/* Multi Battle */
.multi-toolbar,.multi-card,.multi-progress,.multi-result-shell{border:1px solid rgba(148,163,184,.2);background:linear-gradient(180deg,rgba(16,25,44,.94),rgba(8,14,27,.96));box-shadow:0 22px 70px rgba(0,0,0,.25)}
.multi-toolbar{border-radius:18px;padding:14px 16px;display:flex;align-items:end;justify-content:center;gap:16px;margin-bottom:14px;flex-wrap:wrap}
.multi-toolbar .setting-group{min-width:150px}.multi-toolbar .strategy-group{min-width:270px}
.multi-battle-grid{display:grid;grid-template-columns:minmax(0,1.08fr) minmax(320px,.92fr);gap:14px;align-items:start}
.multi-card{border-radius:22px;padding:18px;min-width:0}
.multi-card header{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:16px}
.multi-card h2{margin:4px 0 0}
.multi-stage{min-height:136px}
.multi-pool-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.multi-pool-grid label{display:grid;gap:7px;font-size:12px;font-weight:900;text-transform:uppercase;letter-spacing:.08em;color:#a9b7cc}
.multi-note{margin:14px 0 0;color:#91a0b6;line-height:1.5}
.multi-actions{margin-top:16px;justify-content:flex-start}
.multi-progress{border-radius:18px;padding:18px;margin-top:16px;display:grid;gap:10px}
.multi-result-shell{border-radius:22px;margin-top:18px;padding:16px;overflow:hidden}
.multi-result-shell .matrix-result-actions button{width:auto;border:0;border-radius:13px;padding:11px 15px;background:linear-gradient(135deg,#22c55e,#38bdf8);color:#03131b;font-weight:1000;cursor:pointer}
.multi-results{display:grid;gap:8px;max-height:70vh;overflow:auto;overscroll-behavior:contain;padding-right:6px}
.multi-result-row{display:grid;grid-template-columns:56px minmax(0,1fr) auto auto;gap:10px;align-items:center;border-left:6px solid var(--multi-color,#64748b);border-radius:12px;background:color-mix(in srgb,var(--multi-color,#64748b) 16%,#091120);padding:11px 12px;color:#f8fafc;cursor:pointer;border-top:1px solid rgba(255,255,255,.08);border-right:1px solid rgba(255,255,255,.08);border-bottom:1px solid rgba(255,255,255,.08)}
.multi-result-row:hover{filter:brightness(1.12)}
.multi-rank{font-weight:1000;color:#cbd5e1}.multi-opponent{min-width:0}.multi-opponent strong{display:block;font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.multi-opponent small{display:block;margin-top:3px;color:#aebbd0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.multi-outcome{padding:6px 8px;border-radius:999px;background:#0f172a;font-size:12px;font-weight:1000}.multi-outcome.win{color:#86efac}.multi-outcome.loss{color:#fecaca}.multi-outcome.draw{color:#fde68a}
.multi-rating{min-width:62px;text-align:center;padding:7px 9px;border-radius:9px;background:#020617;font-weight:1000;color:#fff}
@media(max-width:980px){.multi-toolbar{justify-content:flex-start}.multi-battle-grid{grid-template-columns:1fr}.multi-pool-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:620px){.multi-toolbar{align-items:stretch;flex-direction:column;padding:12px}.multi-toolbar .setting-group{min-width:0;width:100%}.multi-pool-grid{grid-template-columns:1fr}.multi-result-shell{padding:10px;margin-left:-4px;margin-right:-4px}.multi-results{max-height:68vh;padding-right:2px}.multi-result-row{grid-template-columns:38px minmax(0,1fr) 58px;gap:7px;padding:9px}.multi-outcome{grid-column:2/4;justify-self:start}.multi-rating{min-width:52px;padding:6px 7px}.multi-opponent strong{font-size:14px}.multi-opponent small{font-size:12px}}

.matrix-modal-backdrop{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;padding:18px;background:rgba(2,6,23,.72);backdrop-filter:blur(8px)}
.matrix-modal-backdrop[hidden]{display:none!important}
.matrix-modal{width:min(760px,100%);max-height:min(90vh,780px);overflow:auto;border:1px solid rgba(148,163,184,.24);border-radius:22px;background:linear-gradient(180deg,rgba(16,25,44,.98),rgba(8,14,27,.99));box-shadow:0 30px 90px rgba(0,0,0,.48)}
.matrix-modal-header{position:sticky;top:0;z-index:4;display:flex;align-items:flex-start;justify-content:space-between;gap:14px;padding:18px 20px;border-bottom:1px solid rgba(148,163,184,.16);background:rgba(10,18,32,.96)}
.matrix-modal-header h2{margin:4px 0 0}
.matrix-modal-header button{width:42px;height:42px;border:0;border-radius:12px;background:rgba(244,63,94,.14);color:#fecdd3;font-size:28px;font-weight:1000;cursor:pointer}
.matrix-modal-body{display:grid;gap:16px;padding:20px}
.matrix-modal-search{position:relative}
.matrix-modal-search .search-results{top:74px;z-index:8}
.matrix-modal-selected{min-height:54px;border:1px solid rgba(148,163,184,.16);border-radius:15px;background:rgba(7,16,30,.72);padding:14px;color:#dbeafe;font-weight:900}
.matrix-modal-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.matrix-modal-grid label,.matrix-modal-moves label{display:grid;gap:7px;font-size:12px;font-weight:900;text-transform:uppercase;letter-spacing:.08em;color:#a9b7cc}
.matrix-modal input,.matrix-modal select{min-height:46px;padding:12px 13px;line-height:1.2}
.matrix-modal select{appearance:none;background-image:linear-gradient(45deg,transparent 50%,#8aa0bd 50%),linear-gradient(135deg,#8aa0bd 50%,transparent 50%);background-position:calc(100% - 18px) 20px,calc(100% - 12px) 20px;background-size:6px 6px,6px 6px;background-repeat:no-repeat;padding-right:34px}
.matrix-modal select:disabled,.matrix-modal input:disabled{opacity:.72;color:#94a3b8}
.matrix-modal-moves{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.matrix-import-field{display:grid;gap:8px;font-size:12px;font-weight:900;text-transform:uppercase;letter-spacing:.08em;color:#a9b7cc}
.matrix-import-field textarea{min-height:300px;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;text-transform:none;letter-spacing:0;font-weight:700;line-height:1.35;font-size:16px}
.matrix-modal-actions{position:sticky;bottom:0;display:flex;justify-content:flex-end;gap:10px;padding:16px 20px;border-top:1px solid rgba(148,163,184,.16);background:rgba(10,18,32,.96)}
.matrix-modal-actions button{width:auto;min-height:44px;border:1px solid transparent;border-radius:13px;padding:12px 18px;color:#fff;font-weight:1000;cursor:pointer;box-shadow:0 10px 26px rgba(0,0,0,.22)}
#matrixModalCancel,#matrixImportCancel,#teamModalCancel{background:rgba(15,23,42,.88);border-color:rgba(148,163,184,.28);color:#cbd5e1}
#matrixModalCancel:hover,#matrixImportCancel:hover,#teamModalCancel:hover{background:rgba(30,41,59,.96);border-color:rgba(203,213,225,.38);color:#fff}
#matrixModalSave,#matrixImportSave,#teamModalSave{background:linear-gradient(135deg,#06b6d4,#2563eb 52%,#7c3aed);border-color:rgba(125,211,252,.28);color:#fff}
#matrixModalSave:hover,#matrixImportSave:hover,#teamModalSave:hover{filter:brightness(1.08)}
#matrixModalSave:disabled,#matrixImportSave:disabled,#teamModalSave:disabled{opacity:.45;cursor:not-allowed;filter:none;box-shadow:none}
.battle-busy-message{display:flex;align-items:center;gap:10px;border:1px solid rgba(56,189,248,.28);border-radius:12px;padding:10px 12px;background:rgba(14,165,233,.10);color:#dff6ff;font-weight:900}
.battle-busy-spinner{width:18px;height:18px;flex:0 0 18px;border-radius:999px;border:3px solid rgba(125,211,252,.25);border-top-color:#38bdf8;animation:battle-spin .8s linear infinite}
button.is-busy,button:disabled.is-busy{opacity:.82;cursor:wait}
@keyframes battle-spin{to{transform:rotate(360deg)}}
@media(max-width:700px){.matrix-modal-backdrop{align-items:start;padding:10px}.matrix-modal-grid,.matrix-modal-moves{grid-template-columns:1fr}.matrix-modal{width:100%;max-height:calc(100vh - 20px);border-radius:16px}.matrix-modal-header{padding:12px 14px;gap:10px}.matrix-modal-header h2{font-size:20px;line-height:1.05}.matrix-modal-header button{width:36px;height:36px;border-radius:10px;font-size:24px;flex:0 0 auto}.matrix-modal-body{padding:12px;gap:10px}.matrix-modal-selected{min-height:42px;border-radius:12px;padding:10px;font-size:13px}.matrix-modal-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.matrix-modal-grid label,.matrix-modal-moves label{gap:5px;font-size:10px;letter-spacing:.04em}.matrix-modal-moves{gap:8px}.matrix-modal input,.matrix-modal select{min-height:38px;font-size:16px}.matrix-modal-actions{padding:12px;gap:8px}.matrix-modal-actions button{flex:1;min-width:0;padding:11px 8px;font-size:13px;white-space:normal;line-height:1.1}.matrix-import-field textarea{min-height:220px;font-size:16px;line-height:1.3}}

/* Team Battle */
.team-battle-toolbar,.team-battle-card,.team-battle-runner,.team-battle-result{border:1px solid rgba(148,163,184,.2);background:linear-gradient(180deg,rgba(16,25,44,.94),rgba(8,14,27,.96));box-shadow:0 22px 70px rgba(0,0,0,.25)}
.team-battle-toolbar{border-radius:18px;padding:14px 16px;display:flex;align-items:end;justify-content:center;gap:16px;margin-bottom:14px;flex-wrap:wrap}
.team-battle-toolbar .setting-group{min-width:150px}
.team-battle-toolbar .setting-group:has(#teamShieldsA){min-width:330px}
.team-battle-toolbar .strategy-group{min-width:270px;flex:0 1 320px}
.team-battle-toolbar .shield-segment-pair{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;align-items:end}
.team-battle-toolbar .shield-segment-field{grid-template-columns:auto minmax(112px,1fr)}
.team-battle-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;align-items:start}
.team-battle-card{border-radius:18px;padding:16px;display:grid;gap:12px}
.team-battle-card header{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.team-battle-card h2{margin:4px 0 0}
.team-add-row{width:auto;border:0;border-radius:13px;padding:11px 14px;background:linear-gradient(135deg,#0891b2,#22c55e);color:#03131b;font-weight:1000;cursor:pointer}
.team-battle-rows{display:grid;gap:9px;min-height:152px;align-content:start}
.team-battle-row{height:96px;align-self:start;align-content:center}
.team-battle-row .matrix-row-name{font-size:20px;line-height:1.05;min-height:22px}
.team-battle-row .matrix-row-summary{display:-webkit-box;min-height:43px;max-height:43px;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:2}
.team-battle-runner{border-radius:22px;padding:22px 24px;margin-top:18px;display:flex;align-items:center;justify-content:space-between;gap:18px}
.team-battle-runner h2{margin:5px 0}
.team-battle-runner p{margin:0;color:#91a0b6}
.team-battle-runner button{width:auto;border:0;border-radius:13px;padding:13px 17px;background:linear-gradient(135deg,#7c3aed,#2563eb);color:#fff;font-weight:1000;cursor:pointer}
.team-battle-actions{display:flex;gap:10px;align-items:center;justify-content:flex-end;flex-wrap:wrap}
.team-battle-result{border-radius:22px;margin-top:18px;padding:20px}
.team-battle-heading{display:flex;justify-content:space-between;gap:14px;align-items:flex-start}
.team-battle-heading h2{margin:5px 0}
.team-battle-heading p{margin:0;color:#91a0b6}
.team-battle-summary{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:16px}
.team-roster-card{border:1px solid rgba(148,163,184,.14);border-radius:16px;background:#091120;padding:14px}
.team-roster-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;margin-bottom:10px}
.team-roster-card h3{margin:0}
.team-roster-shields{margin:0;color:#7dd3fc;font-weight:1000;white-space:nowrap}
.team-roster-card ul{display:grid;gap:8px;padding:0;margin:0;list-style:none;color:#b8c5d8}
.team-roster-card li{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;border:1px solid rgba(148,163,184,.1);border-radius:12px;padding:10px;background:rgba(255,255,255,.03)}
.team-roster-card strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.team-roster-card span{color:#7dd3fc;font-weight:900}
.team-timeline{margin-top:16px;border:1px solid rgba(125,211,252,.16);border-radius:18px;background:linear-gradient(180deg,rgba(6,14,28,.94),rgba(3,8,18,.98));padding:16px}
.team-timeline-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:12px}
.team-timeline-head h3{margin:4px 0 0;font-size:21px}
.team-timeline-legend{display:none}
.team-timeline-legend span{display:inline-flex;align-items:center;gap:6px}
.team-timeline-legend i{width:12px;height:12px;border-radius:50%;display:inline-block;background:#64748b}
.team-timeline-legend .fast{border-radius:2px;background:#a78bfa}
.team-timeline-legend .charged{background:#f472b6}
.team-timeline-legend .shield{background:#38bdf8}
.team-timeline-legend .switch{background:#22c55e}
.team-timeline-legend .cmp{background:#facc15}
.team-timeline-legend .faint{background:#fb7185}
.team-turn-player{border:1px solid rgba(125,211,252,.18);border-radius:16px;background:linear-gradient(180deg,rgba(15,23,42,.78),rgba(2,6,23,.82));padding:14px;margin-bottom:12px}
.team-turn-controls{display:grid;grid-template-columns:auto auto minmax(0,1fr) auto;gap:10px;align-items:center;margin-bottom:12px}
.team-turn-controls button{border:1px solid rgba(125,211,252,.3);border-radius:11px;background:#0b1728;color:#f8fafc;font-weight:1000;padding:9px 12px;cursor:pointer}
.team-turn-controls button.is-playing{border-color:rgba(34,197,94,.5);background:linear-gradient(135deg,#0891b2,#22c55e);color:#03131b}
.team-turn-control-main{display:grid;gap:7px;min-width:0}
.team-turn-control-main strong{color:#7dd3fc;font-size:14px}
.team-turn-control-main input{width:100%;accent-color:#38bdf8}
.team-turn-board{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:12px}
.team-turn-side{border:1px solid rgba(148,163,184,.14);border-radius:14px;background:rgba(8,13,25,.86);padding:12px;min-width:0}
.team-turn-side header{display:flex;justify-content:space-between;gap:10px;align-items:flex-start;margin-bottom:10px}
.team-turn-side small{display:block;color:#91a0b6;font-weight:1000;text-transform:uppercase;letter-spacing:.08em}
.team-turn-side h4{margin:2px 0 0;color:#f8fafc;font-size:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.team-turn-shields{color:#38bdf8;font-weight:1000;white-space:nowrap}
.team-turn-hp{height:8px;border-radius:999px;background:#1d2a3f;overflow:hidden;margin:8px 0}
.team-turn-hp i{display:block;height:100%;width:var(--hp);border-radius:inherit;background:linear-gradient(90deg,#22c55e,#a3e635);transition:width .18s linear}
.team-turn-meta{display:flex;justify-content:space-between;gap:10px;color:#9eb0c5;font-size:12px;font-weight:900}
.team-turn-charges{display:grid;gap:7px;margin-top:10px}
.team-turn-charge{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px;color:#cbd5e1;font-size:12px;font-weight:900}
.team-turn-charge span:first-child{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.team-turn-charge-bar{grid-column:1/-1;height:6px;border-radius:999px;background:#1d2a3f;overflow:hidden}
.team-turn-charge-bar i{display:block;width:var(--charge);height:100%;border-radius:inherit;background:linear-gradient(90deg,#f472b6,#38bdf8)}
.team-turn-roster{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin-top:10px}
.team-turn-mon{border:1px solid rgba(148,163,184,.14);border-radius:10px;background:rgba(15,23,42,.72);padding:7px;opacity:.78}
.team-turn-mon.active{border-color:rgba(56,189,248,.58);opacity:1;box-shadow:0 0 0 2px rgba(56,189,248,.12)}
.team-turn-mon.fainted{opacity:.38}
.team-turn-mon b{display:block;color:#f8fafc;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.team-turn-mon span{display:block;color:#91a0b6;font-size:10px;margin-top:2px}
.team-turn-events{border:1px solid rgba(148,163,184,.12);border-radius:14px;background:rgba(2,6,23,.46);padding:10px}
.team-turn-events h4{margin:0 0 8px;color:#f8fafc;font-size:14px}
.team-turn-events ol{margin:0;padding:0;list-style:none;display:grid;gap:7px}
.team-turn-events li{display:grid;grid-template-columns:84px minmax(0,1fr);gap:8px;align-items:start;border-radius:10px;background:rgba(15,23,42,.72);padding:8px 9px;color:#dbeafe}
.team-turn-events li.fast{border:1px solid rgba(167,139,250,.24)}
.team-turn-events li.charged{border:1px solid rgba(244,114,182,.25)}
.team-turn-events li.shield{border:1px solid rgba(56,189,248,.28)}
.team-turn-events li b{color:#7dd3fc;font-size:12px;white-space:nowrap}
.team-turn-events li span{font-size:12px;line-height:1.35}
.team-turn-events li em{grid-column:2;color:#94a3b8;font-style:normal;font-size:11px;line-height:1.35}
.team-timeline-viewport{display:block;max-width:100%;overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;scrollbar-gutter:stable}
.team-timeline-viewport::-webkit-scrollbar{height:8px}
.team-timeline-viewport::-webkit-scrollbar-track{border-radius:999px;background:rgba(148,163,184,.12)}
.team-timeline-viewport::-webkit-scrollbar-thumb{border-radius:999px;background:rgba(56,189,248,.45)}
.team-timeline-stage{position:relative;width:100%;min-width:0;padding:0}
.team-timeline-axis{position:relative;height:22px;margin-left:0;color:#7dd3fc;font-size:10px;font-weight:900}
.team-timeline-axis span{position:absolute;top:0;transform:translateX(-50%);white-space:nowrap}
.team-timeline-row{position:relative;min-height:112px;border-top:1px solid rgba(148,163,184,.12)}
.team-timeline-row:first-of-type{border-top:0}
.team-timeline-row>strong{position:absolute;left:-88px;top:43px;width:76px;text-align:right;color:#e2e8f0;font-size:12px;white-space:nowrap}
.team-timeline-track{position:absolute;left:0;right:0;top:55px;border-top:2px dashed rgba(148,163,184,.34)}
.team-timeline-marker{position:absolute;top:47px;transform:translateX(calc(-50% + var(--stack-offset,0px)));width:16px;height:16px;border:0;border-radius:50%;background:#64748b;box-shadow:0 0 0 3px #07101d,0 5px 16px rgba(0,0,0,.38);cursor:default}
.team-timeline-marker.fast{top:51px;width:8px;height:8px;border-radius:2px;background:#a78bfa}
.team-timeline-marker.charged{width:19px;height:19px;background:#f472b6}
.team-timeline-marker.charged.left{top:27px}
.team-timeline-marker.charged.right{top:74px}
.team-timeline-marker.shield{width:18px;height:18px;background:#38bdf8}
.team-timeline-marker.shield.left{top:75px}
.team-timeline-marker.shield.right{top:27px}
.team-timeline-marker.switch,.team-timeline-marker.counter-switch,.team-timeline-marker.send-in{width:18px;height:18px;background:#22c55e}
.team-timeline-marker.switch.left,.team-timeline-marker.counter-switch.left,.team-timeline-marker.send-in.left{top:21px}
.team-timeline-marker.switch.right,.team-timeline-marker.counter-switch.right,.team-timeline-marker.send-in.right{top:81px}
.team-timeline-marker.faint{width:20px;height:20px;background:#fb7185;border-radius:6px;transform:translateX(calc(-50% + var(--stack-offset,0px))) rotate(45deg)}
.team-timeline-marker.faint.left{top:22px}
.team-timeline-marker.faint.right{top:79px}
.team-timeline-marker.cmp{top:82px;width:18px;height:18px;background:#facc15}
.team-timeline-marker:hover{z-index:8;filter:brightness(1.16);box-shadow:0 0 0 3px #07101d,0 0 0 5px rgba(125,211,252,.3),0 8px 18px rgba(0,0,0,.42)}
.team-timeline-callout{position:absolute;top:6px;transform:translateX(calc(-50% + var(--stack-offset,0px)));display:inline-flex;align-items:center;justify-content:center;min-width:24px;height:24px;padding:0 7px;border:0;border-radius:999px;background:#0ea5e9;color:#03131f;font-size:12px;font-weight:1000;line-height:1;box-shadow:0 0 0 2px #07101d,0 0 0 3px rgba(125,211,252,.42),0 7px 16px rgba(0,0,0,.38);z-index:9}
.team-timeline-callout:after{content:"";position:absolute;left:50%;top:100%;height:13px;border-left:1px solid rgba(125,211,252,.38)}
.team-timeline-callout.left{top:4px}
.team-timeline-callout.right{top:auto;bottom:4px}
.team-timeline-callout.right:after{top:auto;bottom:100%}
.team-timeline-callout.shield{background:#38bdf8}
.team-timeline-callout.switch,.team-timeline-callout.counter-switch{background:#22c55e}
.team-timeline-callout.faint{background:#fb7185;color:#21060b}
.team-timeline-callout.cmp{background:#facc15}
.team-timeline-story{display:grid;grid-template-columns:1fr;gap:12px;margin-top:12px}
.team-timeline-phase{position:relative;border:1px solid rgba(125,211,252,.16);border-radius:14px;background:linear-gradient(180deg,rgba(15,23,42,.92),rgba(8,13,25,.96));padding:14px 14px 14px 18px;min-width:0}
.team-timeline-phase:before{content:"";position:absolute;left:0;top:14px;bottom:14px;width:4px;border-radius:999px;background:linear-gradient(#22c55e,#38bdf8)}
.team-timeline-opening:before{background:linear-gradient(#22c55e,#facc15)}
.team-timeline-phase header{display:grid;grid-template-columns:minmax(72px,max-content) minmax(0,1fr);gap:4px 12px;align-items:start}
.team-timeline-phase small{display:block;color:#7dd3fc;font-weight:1000}
.team-timeline-phase strong{display:block;color:#f8fafc;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.team-timeline-phase header span{grid-column:2;display:block;color:#a7b4c7;font-size:12px;line-height:1.35}
.team-timeline-events{list-style:none;margin:12px 0 0;padding:0;display:grid;gap:8px}
.team-timeline-events li{display:grid;grid-template-columns:110px minmax(0,1fr);gap:4px 10px;align-items:start;border:1px solid rgba(148,163,184,.12);border-radius:10px;background:rgba(2,6,23,.36);padding:9px 10px}
.team-timeline-events li b{color:#7dd3fc;font-size:12px;font-weight:1000;white-space:nowrap}
.team-timeline-events li span{color:#f8fafc;font-size:12px;line-height:1.35;min-width:0}
.team-timeline-events li em{grid-column:2;color:#94a3b8;font-style:normal;font-size:11px;line-height:1.35}
.team-timeline-events li.switch,.team-timeline-events li.counter-switch{border-color:rgba(34,197,94,.28)}
.team-timeline-events li.story-fast{border-color:rgba(167,139,250,.22);background:rgba(88,28,135,.12)}
.team-timeline-events li.shield{border-color:rgba(56,189,248,.28)}
.team-timeline-events li.cmp{border-color:rgba(250,204,21,.3)}
.team-timeline-events li.faint{border-color:rgba(251,113,133,.3)}
.team-timeline-highlights{display:none}
.team-timeline-card{border:1px solid rgba(148,163,184,.12);border-radius:13px;background:rgba(15,23,42,.72);padding:11px;min-width:0}
.team-timeline-card-head{display:flex;align-items:center;gap:8px;margin-bottom:5px}
.team-timeline-card b{display:inline-flex;align-items:center;justify-content:center;min-width:22px;height:22px;border-radius:999px;background:#0ea5e9;color:#03131f;font-size:11px;font-weight:1000}
.team-timeline-card small{display:block;color:#7dd3fc;font-weight:1000;margin-bottom:5px}
.team-timeline-card .team-timeline-card-head small{margin:0}
.team-timeline-card strong{display:block;color:#f8fafc;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.team-timeline-card span{display:block;margin-top:4px;color:#94a3b8;font-size:11px;line-height:1.35}
@media(max-width:820px){.team-battle-grid,.team-battle-summary{grid-template-columns:1fr}.team-battle-runner{align-items:stretch;flex-direction:column}.team-battle-actions{display:grid;grid-template-columns:1fr;width:100%}.team-battle-runner button{width:100%}.team-battle-toolbar{justify-content:flex-start}.team-battle-card header{align-items:stretch;flex-direction:column}.team-add-row{width:100%}}
@media(max-width:820px){
  .team-timeline{padding:12px}
  .team-timeline-head{flex-direction:column;gap:10px}
  .team-turn-controls{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
  .team-turn-control-main{grid-column:1/-1;grid-row:1}
  .team-turn-controls [data-team-turn-prev]{grid-column:1;grid-row:2}
  .team-turn-controls [data-team-turn-play]{grid-column:2;grid-row:2}
  .team-turn-controls [data-team-turn-next]{grid-column:3;grid-row:2}
  .team-turn-controls button{width:100%;min-width:0;padding:9px 6px}
  .team-turn-board{grid-template-columns:1fr}
  .team-turn-roster{grid-template-columns:repeat(3,minmax(0,1fr))}
  .team-turn-events li{grid-template-columns:1fr}
  .team-turn-events li em{grid-column:1}
  .team-timeline-story,.team-timeline-highlights{grid-template-columns:1fr}
}
@media(max-width:520px){
  .team-turn-player{padding:10px}
  .team-turn-side{padding:10px}
  .team-timeline-story,.team-timeline-highlights{grid-template-columns:1fr}
  .team-timeline-phase{padding:12px 10px 12px 14px}
  .team-timeline-phase header{grid-template-columns:1fr;gap:4px}
  .team-timeline-phase header span{grid-column:1}
  .team-timeline-events li{grid-template-columns:1fr;padding:8px}
  .team-timeline-events li em{grid-column:1}
}

/* Split replay timeline: one lane for Fast Moves, one lane for actions. */
.replay-stage{isolation:isolate}
.replay-axis{position:relative;height:30px;margin-left:78px;margin-right:46px;border-bottom:1px solid rgba(148,163,184,.16)}
.replay-axis span{position:absolute;top:0;transform:translateX(-50%);color:#7dd3fc;font-size:12px;font-weight:1000;white-space:nowrap}
.replay-row{min-height:196px}
.replay-row>strong{left:-116px;top:20px;width:104px;font-size:13px}
.replay-track{position:relative;height:116px;margin-top:22px;border-top:0}
.replay-lane{position:absolute;left:78px;right:46px;height:42px;border-top:2px dashed rgba(148,163,184,.36)}
.replay-lane:before{content:attr(data-lane-label);position:absolute;left:-70px;top:-10px;width:54px;text-align:right;color:#dbeafe;font-size:11px;font-weight:900}
.replay-lane-fast{top:6px}
.replay-lane-action{top:66px}
.replay-charge-status{left:78px;right:46px;bottom:9px}
.replay-event{left:0;transform:translateX(calc(-50% + var(--same-turn-offset,0px))) translateY(var(--stack-y,0px))}
.replay-event:hover,.replay-event.is-active{transform:translateX(calc(-50% + var(--same-turn-offset,0px))) translateY(var(--stack-y,0px)) scale(1.22)}
.replay-event.fast,.replay-event.lane-fast{top:-11px;z-index:7;width:9px;height:9px;border-radius:2px}
.replay-event.charged,.replay-event.lane-charged{top:-19px;z-index:5;width:30px;height:30px;border-radius:50%;background:var(--event-color,#ec4899);box-shadow:0 0 0 3px #07101d,0 0 0 5px var(--event-color,#ec4899),0 4px 14px rgba(0,0,0,.38);filter:none}
.replay-event.charged:before{display:none}
.replay-event.charged:after{content:"";position:absolute;inset:7px;border-radius:50%;background:rgba(7,16,29,.18);box-shadow:inset 0 0 0 2px rgba(2,6,23,.72)}
.replay-charge-ring{position:absolute;top:-10px;transform:translateX(calc(-50% + var(--same-turn-offset,0px))) translateY(var(--stack-y,0px));width:var(--ring-size,10px);height:var(--ring-size,10px);border:3px solid var(--event-color,#ec4899);border-radius:50%;background:transparent;opacity:var(--ring-opacity,.5);box-shadow:0 0 0 2px rgba(7,16,29,.88);pointer-events:none;z-index:4}
.replay-event.shield,.replay-event.lane-shield{top:-18px;z-index:6;width:28px;height:26px;background:#db2777;clip-path:polygon(25% 0,75% 0,100% 50%,75% 100%,25% 100%,0 50%);box-shadow:0 0 0 3px #07101d,0 0 0 5px rgba(244,114,182,.7),0 4px 14px rgba(0,0,0,.38);filter:drop-shadow(0 0 8px rgba(219,39,119,.45))}
.replay-event.disguise,.replay-event.lane-disguise{top:-17px;z-index:6}
.replay-event.ko{top:-20px;z-index:7}
.replay-event.buff,.replay-event.lane-buff{top:-17px;z-index:6;width:26px;height:26px;border-radius:50%;background:#facc15;color:#1f1600;font-size:15px;font-weight:1000;box-shadow:0 0 0 3px #07101d,0 0 0 5px rgba(250,204,21,.45),0 4px 14px rgba(0,0,0,.38);text-shadow:none}
.replay-cmp-layer{position:absolute;left:210px;right:94px;top:50%;height:0;z-index:8;pointer-events:none}
.replay-cmp-layer .replay-event{pointer-events:auto}
.replay-cmp-layer .replay-event.cmp{top:-12px;width:24px;height:24px;background:transparent;border:0;font-size:18px;font-weight:1000;color:#cbd5e1;text-shadow:0 2px 5px rgba(0,0,0,.65);box-shadow:none}
.replay-cmp-layer .replay-event.cmp:hover,.replay-cmp-layer .replay-event.cmp.is-active{transform:translateX(-50%) scale(1.28)}
@media(max-width:720px){.replay-cmp-layer{left:112px;right:48px}}

/* Responsive polish v1 */
*{box-sizing:border-box}
html,body{max-width:100%;overflow-x:hidden}
img,svg{max-width:100%}

.battle-toolbar,.matrix-toolbar,.multi-toolbar,.team-battle-toolbar{
  width:100%;
}

.battle-toolbar .setting-group,.matrix-toolbar .setting-group,.multi-toolbar .setting-group,.team-battle-toolbar .setting-group{
  min-width:150px;
}

@media(max-width:900px){
  .battle-shell{width:min(100% - 24px,760px);margin-top:18px}
  .battle-hero{padding:26px 12px 20px}
  .battle-hero h1{font-size:clamp(36px,9vw,54px)}
  .battle-hero p{font-size:16px}
  .battle-toolbar,.matrix-toolbar,.multi-toolbar,.team-battle-toolbar{justify-content:flex-start;align-items:stretch;gap:14px}
  .battle-toolbar .setting-group,.matrix-toolbar .setting-group,.multi-toolbar .setting-group,.team-battle-toolbar .setting-group{flex:1 1 220px}
  .strategy-group select{min-width:0}
  .strategy-segment{min-width:0}
  .battle-toolbar .strategy-segment,.matrix-toolbar .strategy-segment,.multi-toolbar .strategy-segment,.team-battle-toolbar .strategy-segment{min-width:0}
  .matchup-grid{gap:12px}
  .fighter-card{width:100%}
  .simulate-panel{gap:14px}
  .result-shell{padding-left:16px;padding-right:16px}
  .visual-replay{margin-left:-2px;margin-right:-2px}
}

@media(max-width:720px){
  .battle-shell{width:calc(100% - 16px);margin-top:12px}
  .battle-hero{padding:18px 8px 16px}
  .battle-hero h1{font-size:clamp(32px,11vw,46px);line-height:1.02}
  .battle-hero p{font-size:15px;line-height:1.5}
  .battle-toolbar,.matrix-toolbar,.multi-toolbar,.team-battle-toolbar{padding:14px;border-radius:16px;gap:12px;flex-direction:column;align-items:stretch}
  .battle-toolbar .setting-group,.matrix-toolbar .setting-group,.multi-toolbar .setting-group,.team-battle-toolbar .setting-group{flex-basis:auto;width:100%;min-width:0}
  .segmented{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;border-radius:14px}
  .segmented button{width:100%;padding:10px 8px;border-radius:10px;font-size:13px}
  .compact-segment{grid-template-columns:repeat(3,minmax(0,1fr))}
  .strategy-segment{grid-template-columns:repeat(3,minmax(0,1fr))}
  .team-battle-toolbar .strategy-segment{grid-template-columns:repeat(2,minmax(0,1fr))}
  .shield-pair{display:grid;grid-template-columns:1fr 1fr;width:100%}
  .shield-pair label{justify-content:space-between;min-width:0}
  .shield-segment-field{grid-template-columns:1fr;gap:6px}
  .shield-pair select{width:76px}
  .fighter-card{padding:14px;border-radius:18px}
  .fighter-heading{margin-bottom:14px}
  .pokemon-stage{grid-template-columns:76px minmax(0,1fr);gap:12px}
  .art-ring{width:76px;height:76px}
  .art-ring img{width:68px;height:68px}
  .stat-strip{gap:7px}
  .stat-strip>*{min-width:0}
  .field-grid,.iv-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
  .toggle-row{gap:8px;flex-wrap:wrap}
  .simulate-panel{padding:16px;border-radius:18px}
  .simulate-panel button{width:100%;min-height:48px}
  .result-shell{padding:16px 12px;border-radius:18px}
  .winner-card{padding:18px 12px}
  .winner-card strong{font-size:28px}
  .summary-card{min-width:0}
  .hp-result-card{padding:13px}
  .hp-result-card>div:first-child{align-items:center;gap:8px;font-size:13px}

  .visual-replay{padding:12px;border-radius:15px;overflow:hidden}
  .visual-replay-heading{gap:10px;margin-bottom:12px}
  .visual-replay-heading h3{font-size:19px}
  .visual-replay-heading p{font-size:13px}
  .replay-legend{gap:9px;font-size:10px}
  .replay-viewport{width:100%;max-width:100%;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;overscroll-behavior-inline:contain;scrollbar-width:thin}
  .replay-stage{min-width:680px;padding:16px 38px 16px 88px}
  .replay-row{grid-template-columns:minmax(540px,1fr) 28px;min-height:138px}
  .replay-row>strong{left:-78px;width:68px;font-size:11px}
  .replay-charge-status{right:34px;gap:6px}
  .charge-meter{padding:6px 7px}
  .charge-meter-head{font-size:9px}
  .charge-meter small{font-size:8px}
  .replay-result{right:-27px;font-size:23px}
  .replay-cursor{left:88px}
  .replay-cmp-layer{left:88px;right:38px}
  .replay-controls{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;justify-content:stretch}
  .replay-controls button,.replay-controls select{width:100%;min-height:42px;padding:9px 10px}
  .replay-controls label{grid-column:1/-1;display:grid;grid-template-columns:auto 1fr;gap:8px}
  .replay-controls span{grid-column:1/-1;width:100%;min-width:0;text-align:center;padding:4px}
  .battle-log-panel ol{max-height:430px}
  .battle-log-panel li{padding:10px}
  .payload-panel pre{font-size:11px;padding:12px}
}

@media(max-width:480px){
  .battle-shell{width:calc(100% - 10px)}
  .battle-hero{padding-left:4px;padding-right:4px}
  .battle-kicker,.panel-eyebrow{font-size:9px}
  .battle-toolbar,.fighter-card,.simulate-panel,.result-shell{border-radius:14px}
  .pokemon-stage{grid-template-columns:64px minmax(0,1fr)}
  .art-ring{width:64px;height:64px}
  .art-ring img{width:58px;height:58px}
  .pokemon-stage h2,.pokemon-stage h3{font-size:18px}
  .field-grid,.iv-grid{grid-template-columns:1fr 1fr}
  .field-grid label,.field-stack label{font-size:10px}
  select,input{padding:11px 10px;font-size:16px}
  .stat-strip{grid-template-columns:1fr 1fr}
  .visual-replay{padding:10px}
  .replay-legend span:nth-child(n+4){display:none}
  .replay-stage{min-width:620px;padding-left:76px;padding-right:32px}
  .replay-row{grid-template-columns:minmax(500px,1fr) 24px}
  .replay-row>strong{left:-68px;width:60px;font-size:10px}
  .replay-cursor{left:76px}
  .replay-cmp-layer{left:76px;right:32px}
  .replay-event.fast{width:8px;height:8px}
  .replay-event.charged{top:-18px;width:24px;height:24px}
  .replay-event.charged:before{display:none}
  .replay-charge-ring{top:-10px;border-width:2px;box-shadow:0 0 0 2px rgba(7,16,29,.88)}
  .replay-event.shield{top:-17px;width:24px;height:22px}
  .replay-event.disguise{width:24px;height:24px}
  .charge-meter-head strong{max-width:82px}
  .replay-controls{grid-template-columns:1fr 1fr}
  .replay-controls button{font-size:12px}
  .battle-log-panel li{font-size:12px}
}

@media(max-width:360px){
  .battle-shell{width:calc(100% - 6px)}
  .battle-hero h1{font-size:30px}
  .fighter-card{padding:11px}
  .pokemon-stage{grid-template-columns:56px minmax(0,1fr)}
  .art-ring{width:56px;height:56px}
  .art-ring img{width:50px;height:50px}
  .field-grid,.iv-grid{grid-template-columns:1fr}
  .shield-pair{grid-template-columns:1fr}
  .replay-stage{min-width:580px}
}


/* Mobile search results stay inside the visible area above the software keyboard. */
@media(max-width:620px){
  .search-results{
    max-height:220px;
    overflow-y:auto;
    overscroll-behavior:contain;
    -webkit-overflow-scrolling:touch;
    z-index:1000;
  }
}

@media(max-width:700px){
  #teamModal.matrix-modal-backdrop{
    align-items:stretch;
    height:100dvh;
    min-height:100dvh;
    overflow:hidden;
    padding:8px;
    padding-bottom:calc(8px + env(safe-area-inset-bottom));
  }
  #teamModal .team-modal{
    display:flex;
    flex-direction:column;
    width:100%;
    max-height:calc(100dvh - 16px - env(safe-area-inset-bottom));
    overflow:hidden;
  }
  #teamModal .matrix-modal-header{
    flex:0 0 auto;
  }
  #teamModal .matrix-modal-body{
    flex:1 1 auto;
    min-height:0;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
    padding-bottom:10px;
  }
  #teamModal .matrix-modal-actions{
    position:relative;
    flex:0 0 auto;
    display:grid;
    grid-template-columns:1fr 1fr;
    padding:10px;
    padding-bottom:calc(10px + env(safe-area-inset-bottom));
    background:linear-gradient(180deg,rgba(10,18,32,.98),rgba(8,14,27,1));
    box-shadow:0 -14px 28px rgba(0,0,0,.28);
  }
  #teamModal .matrix-modal-actions button{
    min-height:44px;
    font-size:14px;
  }
}

@media(max-width:420px){
  #teamModal .matrix-modal-header{
    padding:10px 12px;
  }
  #teamModal .matrix-modal-header h2{
    font-size:18px;
  }
  #teamModal .matrix-modal-header button{
    width:34px;
    height:34px;
  }
  #teamModal .matrix-modal-body{
    padding:10px;
    gap:8px;
  }
  #teamModal .matrix-modal-grid{
    gap:7px;
  }
  #teamModal .matrix-modal-moves{
    gap:7px;
  }
  #teamModal .matrix-modal-selected{
    min-height:40px;
    padding:9px 10px;
  }
}

/* Final split-timeline responsive overrides */
@media(max-width:720px){
  .replay-row{min-height:190px}
  .replay-row>strong{top:18px}
  .replay-track{height:112px;margin-top:22px;border-top:0}
  .replay-lane{height:40px}
  .replay-lane:before{left:-62px;width:54px;font-size:10px}
  .replay-lane-fast{top:6px}
  .replay-lane-action{top:64px}
  .replay-charge-status{bottom:8px}
}

@media(max-width:480px){
  .replay-row{min-height:186px}
  .replay-track{height:108px}
  .replay-lane-action{top:62px}
  .replay-event.charged,.replay-event.lane-charged{width:24px;height:24px}
  .replay-event.charged:after{inset:6px}
  .replay-event.shield,.replay-event.lane-shield{width:24px;height:22px}
}

/* Mockup-aligned replay layout */
.replay-stage{--replay-lane-gutter:78px;--replay-lane-right:46px;min-width:900px;padding:18px 48px 18px 132px}
.replay-axis{margin-left:var(--replay-lane-gutter);margin-right:var(--replay-lane-right)}
.replay-row{grid-template-columns:minmax(700px,1fr) 34px;min-height:196px}
.replay-row>strong{left:-116px;top:20px;width:104px;font-size:13px}
.replay-track{height:116px;margin-top:22px;border-top:0}
.replay-lane{left:var(--replay-lane-gutter);right:var(--replay-lane-right)}
.replay-lane:before{left:-70px;width:54px}
.replay-charge-status{left:var(--replay-lane-gutter);right:var(--replay-lane-right);bottom:9px}
.replay-cmp-layer{left:210px;right:94px}

@media(max-width:720px){
  .replay-stage{--replay-lane-gutter:66px;--replay-lane-right:34px;min-width:760px;padding:16px 38px 16px 120px}
  .replay-axis{margin-left:var(--replay-lane-gutter);margin-right:var(--replay-lane-right)}
  .replay-row{grid-template-columns:minmax(560px,1fr) 28px;min-height:190px}
  .replay-row>strong{left:-104px;width:92px;font-size:11px}
  .replay-lane:before{left:-60px;width:48px;font-size:10px}
  .replay-cmp-layer{left:186px;right:72px}
}

@media(max-width:480px){
  .replay-stage{--replay-lane-gutter:60px;--replay-lane-right:30px;min-width:700px;padding-left:108px;padding-right:32px}
  .replay-row{grid-template-columns:minmax(520px,1fr) 24px;min-height:186px}
  .replay-row>strong{left:-94px;width:84px;font-size:10px}
  .replay-lane:before{left:-54px;width:44px}
  .replay-cmp-layer{left:168px;right:62px}
}

.replay-legend{gap:10px}
.replay-legend span{white-space:nowrap}
.replay-legend i{position:relative;flex:0 0 auto}
.legend-fast{width:9px!important;height:9px!important;border-radius:2px;background:#a8a77a;box-shadow:0 0 0 1px #020617,0 0 0 2px rgba(255,255,255,.2),0 3px 8px rgba(0,0,0,.4)}
.legend-charge{width:18px!important;height:18px!important;border-radius:50%;background:#ec4899;box-shadow:0 0 0 2px #07101d,0 0 0 4px #ec4899,0 4px 12px rgba(0,0,0,.32)}
.legend-charge:after{content:"";position:absolute;inset:5px;border-radius:50%;background:rgba(7,16,29,.18);box-shadow:inset 0 0 0 1px rgba(2,6,23,.72)}
.legend-shield{width:20px!important;height:18px!important;background:#db2777;clip-path:polygon(25% 0,75% 0,100% 50%,75% 100%,25% 100%,0 50%);box-shadow:0 0 0 2px #07101d,0 0 0 4px rgba(244,114,182,.7),0 4px 12px rgba(0,0,0,.32)}
.legend-buff{width:18px!important;height:18px!important;border-radius:50%;background:#facc15;color:#1f1600;font-size:11px!important;font-weight:1000;text-shadow:none;box-shadow:0 0 0 2px #07101d,0 0 0 4px rgba(250,204,21,.45),0 4px 12px rgba(0,0,0,.32)}
.legend-disguise,.legend-cmp,.legend-ko{font-size:16px!important;text-shadow:0 2px 5px rgba(0,0,0,.65)}
.legend-ko{color:#ef4444;text-shadow:0 0 9px rgba(239,68,68,.55),0 2px 4px #020617}
.replay-tooltip{position:fixed;left:0;top:0;z-index:9999;max-width:min(360px,calc(100vw - 24px));padding:9px 11px;border:1px solid rgba(125,211,252,.34);border-radius:10px;background:rgba(3,8,18,.96);box-shadow:0 14px 40px rgba(0,0,0,.45),0 0 0 1px rgba(255,255,255,.04);color:#e2e8f0;font-size:12px;font-weight:800;line-height:1.35;pointer-events:none;opacity:0;transform:translate(-50%,-100%) translateY(-10px);transition:none;white-space:pre-line}
.replay-tooltip.is-visible{opacity:1}

/* Multi Battle overall histogram */
.multi-overall{margin:2px 0 18px}.multi-overall[hidden]{display:none!important}
.multi-overall>header{margin:0 0 12px}.multi-overall>header h3{margin:0 0 4px;font-size:22px;color:#f8fafc}.multi-overall>header p{margin:0;color:#91a0b6;line-height:1.45}
.multi-chart-card{width:min(620px,100%);margin:0 auto;border:1px solid rgba(148,163,184,.18);border-radius:18px;background:rgba(3,9,20,.58);padding:18px}
.multi-chart-title{text-align:center;margin-bottom:10px}.multi-chart-title strong{display:block;font-size:26px;line-height:1.08;color:#f8fafc}.multi-chart-title span{display:block;margin-top:5px;color:#cbd5e1;font-size:14px;line-height:1.35}
.multi-histogram{position:relative;height:250px;margin:0 18px 0 42px;border-left:2px solid rgba(125,211,252,.7);border-bottom:2px solid rgba(125,211,252,.7)}
.multi-axis-label{position:absolute;left:-52px;top:50%;transform:translateY(-50%) rotate(-90deg);font-size:14px;font-weight:900;color:#cbd5e1}
.multi-midline{position:absolute;left:50%;top:0;bottom:0;border-left:1px dashed rgba(226,232,240,.65);pointer-events:none}
.multi-bars{position:absolute;inset:0;display:flex;align-items:flex-end;padding:0 5%}
.multi-histogram-bar{display:block;flex:1 1 0;height:var(--bar-height);min-width:2px;background:hsl(calc(320 - (var(--bar-rating) / 1000 * 125)) 72% 48%);opacity:.95}.multi-histogram-bar:hover{filter:brightness(1.22)}
.multi-axis-values{position:absolute;left:0;right:0;bottom:-24px;display:flex;justify-content:space-between;color:#cbd5e1;font-size:13px;font-weight:800}
.multi-rating-banner{margin:34px auto 0;border-radius:12px;background:rgba(148,163,184,.34);padding:9px 14px;text-align:center;color:#f8fafc;font-size:20px;font-weight:1000}
.multi-record-summary{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-top:14px}.multi-record-summary span{text-align:center}.multi-record-summary strong,.multi-record-summary small{display:block}.multi-record-summary strong{font-size:15px;color:#f8fafc}.multi-record-summary small{margin-top:3px;color:#aebbd0;font-size:13px}
@media(max-width:620px){.multi-chart-card{padding:14px 10px}.multi-chart-title strong{font-size:21px}.multi-chart-title span{font-size:12px}.multi-histogram{height:190px;margin-left:34px;margin-right:8px}.multi-axis-label{left:-46px;font-size:12px}.multi-rating-banner{font-size:16px}.multi-record-summary{gap:6px}.multi-record-summary strong{font-size:13px}.multi-record-summary small{font-size:12px}}

/* Make unavailable ranking controls visually obvious in All League Defaults mode. */
#multiRankingListField:has(#multiRankingList:disabled),
.multi-pool-grid label:has(#multiRankingScope:disabled){
  opacity:.42;
  transition:opacity .18s ease;
}
#multiRankingList:disabled,
#multiRankingScope:disabled{
  cursor:not-allowed;
}


/* Matrix Target Pool loader */
.matrix-options{display:grid;grid-template-columns:minmax(250px,460px) minmax(0,1fr);gap:14px;align-items:stretch;margin-bottom:14px}
.matrix-options .matrix-toggle{max-width:none;margin:0}
.matrix-pool-loader{min-width:0;border:1px solid rgba(148,163,184,.2);border-radius:18px;padding:13px 14px;background:linear-gradient(180deg,rgba(16,25,44,.94),rgba(8,14,27,.96))}
.matrix-pool-loader-head{display:flex;align-items:end;justify-content:space-between;gap:12px;margin-bottom:10px}
.matrix-pool-loader-head strong{display:block;margin-top:3px;color:#f8fafc;font-size:15px}
.matrix-pool-loader-head small{max-width:330px;text-align:right;color:#91a0b6;line-height:1.3}
.matrix-pool-loader-controls{display:grid;grid-template-columns:minmax(130px,.8fr) minmax(170px,1.35fr) minmax(150px,1fr) auto;gap:8px;align-items:end}
.matrix-pool-loader-controls label{min-width:0;color:#91a0b6;font-size:11px;font-weight:900;text-transform:uppercase;letter-spacing:.04em}
.matrix-pool-loader-controls select{width:100%;margin-top:5px}
.matrix-pool-loader-controls label.is-disabled{opacity:.42}
.matrix-pool-side-actions{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.matrix-pool-side-actions button{white-space:nowrap;border:0;border-radius:11px;padding:10px 11px;background:linear-gradient(135deg,#7c3aed,#2563eb);color:#fff;font-weight:900;cursor:pointer}
.matrix-pool-side-actions button:disabled{opacity:.4;cursor:not-allowed}
@media(max-width:1100px){
  .matrix-options{grid-template-columns:1fr}
  .matrix-pool-loader-controls{grid-template-columns:repeat(3,minmax(0,1fr))}
  .matrix-pool-side-actions{grid-column:1/-1}
}
@media(max-width:620px){
  .matrix-options{gap:8px}
  .matrix-pool-loader{padding:10px;border-radius:12px}
  .matrix-pool-loader-head{align-items:flex-start;flex-direction:column;gap:4px}
  .matrix-pool-loader-head small{text-align:left;max-width:none;font-size:11px}
  .matrix-pool-loader-controls{grid-template-columns:1fr 1fr;gap:6px}
  .matrix-pool-loader-controls label:first-child{grid-column:1/-1}
  .matrix-pool-side-actions{grid-column:1/-1}
  .matrix-pool-side-actions button{padding:9px 6px;font-size:11px}
}

/* Battle page final responsive guard */
.battle-page :where(.battle-content-panel,.battle-toolbar,.fighter-card,.simulate-panel,.result-shell,.visual-replay,.matrix-toolbar,.matrix-team-panel,.matrix-generate-panel,.matrix-progress,.matrix-result-shell,.multi-toolbar,.multi-card,.multi-progress,.multi-result-shell,.team-battle-toolbar,.team-battle-card,.team-battle-runner,.team-battle-result,.team-timeline,.matrix-modal){
  max-width:100%;
}
.battle-page :where(.setting-group,.fighter-card,.summary-card,.comparison-card,.matrix-team-panel,.matrix-row,.multi-card,.team-battle-card,.team-roster-card,.team-turn-side,.team-turn-events,.charge-meter){
  min-width:0;
}
.battle-page :where(.segmented,.shield-pair,.matrix-team-actions,.matrix-actions,.matrix-result-buttons,.team-battle-card header,.team-battle-heading,.team-roster-card-head,.team-turn-side header,.team-turn-meta){
  min-width:0;
}
.battle-page :where(.matrix-table-wrap,.multi-results,.battle-log-panel ol,.payload-panel pre){
  -webkit-overflow-scrolling:touch;
}

@media(max-width:1100px){
  .battle-shell{width:calc(100% - 24px)}
  .battle-toolbar,.matrix-toolbar,.multi-toolbar,.team-battle-toolbar{justify-content:flex-start}
  .battle-toolbar .setting-group,.matrix-toolbar .setting-group,.multi-toolbar .setting-group,.team-battle-toolbar .setting-group{flex:1 1 190px;min-width:0}
  .strategy-segment,.matrix-toolbar .strategy-group,.multi-toolbar .strategy-group{min-width:0}
  .team-battle-toolbar{display:grid;grid-template-columns:minmax(220px,.75fr) minmax(330px,1.15fr);align-items:end}
  .team-battle-toolbar .strategy-group{grid-column:1/-1;min-width:0}
  .team-battle-toolbar .setting-group:has(#teamShieldsA){min-width:0}
  .team-battle-toolbar .strategy-segment{min-width:0}
  .battle-mode-tabs{padding-inline:2px}
  .matchup-grid{grid-template-columns:minmax(0,1fr) 58px minmax(0,1fr)}
  .versus-orb{width:54px;height:54px}
  .result-grid{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
  .comparison-card{grid-column:1/-1}
  .matrix-team-grid,.team-battle-grid{gap:10px}
  .matrix-team-heading,.multi-card header,.team-battle-card header{gap:10px}
  .multi-battle-grid{grid-template-columns:minmax(0,1fr)}
}

@media(max-width:860px){
  .battle-content-panel{padding:18px;border-radius:18px}
  .battle-toolbar,.matrix-toolbar,.multi-toolbar,.team-battle-toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));align-items:stretch;gap:12px}
  .battle-toolbar .strategy-group,.matrix-toolbar .strategy-group,.multi-toolbar .strategy-group,.team-battle-toolbar .strategy-group{grid-column:1/-1}
  .team-battle-toolbar .setting-group:has(#teamShieldsA){grid-column:1/-1}
  .team-battle-toolbar .shield-segment-pair{grid-template-columns:repeat(2,minmax(0,1fr))}
  .team-battle-toolbar .shield-segment-field{grid-template-columns:auto minmax(0,1fr)}
  .matchup-grid{grid-template-columns:1fr}
  .versus-column{height:56px}
  .versus-line{display:none}
  .simulate-panel,.matrix-generate-panel,.team-battle-runner{align-items:stretch;flex-direction:column}
  .simulate-panel button,.matrix-actions button,.team-battle-runner button{width:100%}
  .result-grid,.team-battle-summary{grid-template-columns:1fr}
  .matrix-team-grid{grid-template-columns:1fr 1fr}
  .matrix-team-heading,.team-battle-heading{align-items:stretch;flex-direction:column}
  .matrix-result-actions{align-items:stretch;flex-direction:column}
  .matrix-result-buttons{display:grid;grid-template-columns:1fr 1fr}
  .multi-result-row{grid-template-columns:46px minmax(0,1fr) auto}
  .multi-outcome{grid-column:2/3;justify-self:start}
  .multi-rating{grid-column:3;grid-row:1/3}
  .team-turn-board{grid-template-columns:1fr}
}

@media(max-width:640px){
  .battle-shell{width:calc(100% - 12px);margin-top:10px}
  .battle-hero{padding:16px 4px 14px}
  .battle-hero h1{font-size:clamp(30px,10vw,42px);letter-spacing:0;line-height:1.04}
  .battle-hero p{font-size:14px}
  .battle-mode-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin-bottom:14px}
  .battle-mode-tabs button{min-width:0;padding:10px 6px;font-size:12px;line-height:1.1;white-space:normal}
  .battle-toolbar,.matrix-toolbar,.multi-toolbar,.team-battle-toolbar{grid-template-columns:1fr;padding:12px;border-radius:14px;gap:10px}
  .segmented{display:grid;width:100%;border-radius:14px}
  .segmented button{min-width:0;padding:10px 6px;font-size:12px;line-height:1.12;white-space:normal}
  .compact-segment{grid-template-columns:repeat(3,minmax(0,1fr))}
  .strategy-segment{grid-template-columns:repeat(3,minmax(0,1fr))}
  .team-battle-toolbar .strategy-segment{grid-template-columns:repeat(2,minmax(0,1fr))}
  .shield-segment-pair,.shield-pair{display:grid;grid-template-columns:1fr 1fr;gap:8px}
  .shield-segment-field{grid-template-columns:1fr}
  .team-battle-toolbar .shield-segment-pair{grid-template-columns:1fr 1fr}
  .team-battle-toolbar .shield-segment-field{grid-template-columns:1fr;gap:6px}
  .fighter-card,.matrix-team-panel,.multi-card,.team-battle-card{padding:12px;border-radius:14px}
  .fighter-heading,.matrix-team-heading,.multi-card header,.team-battle-card header{align-items:stretch;flex-direction:column}
  .pokemon-stage{grid-template-columns:64px minmax(0,1fr);min-height:104px;margin:12px 0}
  .pokemon-stage h2{font-size:20px;line-height:1.08}
  .stat-strip{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
  .iv-grid,.field-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .field-grid label,.field-stack label,.matrix-import label,.matrix-row label,.multi-pool-grid label{font-size:10px;letter-spacing:.04em}
  .toggle-row{padding:10px;border-radius:12px}
  .simulate-panel,.result-shell,.matrix-generate-panel,.matrix-progress,.matrix-result-shell,.multi-progress,.multi-result-shell,.team-battle-runner,.team-battle-result{padding:12px;border-radius:16px}
  .result-heading,.team-battle-heading{align-items:stretch;flex-direction:column}
  .hp-result-grid,.multi-pool-grid{grid-template-columns:1fr}

  .matrix-options{grid-template-columns:1fr}
  .matrix-team-grid{grid-template-columns:1fr 1fr;gap:6px}
  .matrix-team-panel{padding:8px}
  .matrix-team-heading{gap:6px;margin-bottom:8px}
  .matrix-team-heading h2{font-size:15px;line-height:1.05}
  .matrix-team-actions{display:grid;grid-template-columns:1fr 1fr;width:100%;gap:5px}
  .matrix-add-row,.matrix-import-open{width:100%;padding:8px 4px;border-radius:9px;font-size:11px;line-height:1.08}
  .matrix-rows{max-height:430px;gap:6px;padding-right:2px}
  .matrix-row{padding:7px 27px 7px 7px;border-radius:9px}
  .matrix-row-name{font-size:13px;line-height:1.08;letter-spacing:0}
  .matrix-row-summary{font-size:11px;line-height:1.15}
  .matrix-row-move-pill{min-width:16px;height:16px;font-size:10px}
  .matrix-result-buttons{grid-template-columns:1fr 1fr}
  .matrix-table-wrap{max-height:64vh}
  .matrix-table{font-size:11px}
  .matrix-table th,.matrix-table td{padding:7px 6px}

  .multi-result-row{grid-template-columns:34px minmax(0,1fr) 54px;gap:7px;padding:9px}
  .multi-outcome{grid-column:2/4;grid-row:auto}
  .multi-rating{grid-column:3;grid-row:1}
  .multi-record-summary{grid-template-columns:repeat(3,minmax(0,1fr))}

  .team-battle-grid,.team-battle-summary{grid-template-columns:1fr}
  .team-battle-card h2{font-size:26px}
  .team-roster-card-head{align-items:flex-start;flex-direction:column;gap:4px}
  .team-roster-card li{grid-template-columns:1fr;gap:5px}
  .team-turn-roster{grid-template-columns:repeat(3,minmax(0,1fr))}
  .team-turn-side h4{font-size:16px}
  .team-turn-events li{grid-template-columns:1fr}
  .team-turn-events li em{grid-column:1}

  .visual-replay,.team-timeline{overflow:hidden}
  .replay-viewport{overflow-x:auto;overflow-y:hidden}
  .replay-stage{--replay-lane-gutter:54px;--replay-lane-right:30px;min-width:640px;padding:14px 32px 14px 100px}
  .replay-axis{margin-left:var(--replay-lane-gutter);margin-right:var(--replay-lane-right)}
  .replay-row{grid-template-columns:minmax(490px,1fr) 24px;min-height:178px}
  .replay-row>strong{left:-88px;width:78px;font-size:10px}
  .replay-lane:before{left:-48px;width:42px;font-size:9px}
  .replay-charge-status{left:var(--replay-lane-gutter);right:var(--replay-lane-right);grid-template-columns:repeat(2,minmax(170px,1fr))}
  .charge-meter-head{font-size:9px}
  .charge-meter small{font-size:8px}
  .replay-cmp-layer{left:154px;right:62px}
  .replay-controls{display:grid;grid-template-columns:1fr 1fr;gap:8px}
  .replay-controls label,.replay-controls span{grid-column:1/-1}

  .matrix-modal-backdrop{padding:8px;align-items:stretch}
  .matrix-modal{width:100%;max-height:calc(100dvh - 16px);display:flex;flex-direction:column;overflow:hidden;border-radius:16px}
  .matrix-modal-header{flex:0 0 auto;padding:12px}
  .matrix-modal-body{flex:1 1 auto;min-height:0;overflow:auto;padding:12px}
  .matrix-modal-actions{position:relative;flex:0 0 auto;display:grid;grid-template-columns:1fr 1fr;padding:10px;padding-bottom:calc(10px + env(safe-area-inset-bottom))}
  .matrix-modal-actions button{width:100%;min-width:0}
}

@media(max-width:430px){
  .battle-shell{width:calc(100% - 8px)}
  .battle-mode-tabs{grid-template-columns:1fr}
  .battle-mode-tabs button{min-height:40px}
  .shield-segment-pair,.shield-pair{grid-template-columns:1fr}
  .iv-grid,.field-grid{grid-template-columns:1fr 1fr}
  .matrix-team-grid{grid-template-columns:1fr 1fr;gap:5px}
  .matrix-team-panel{padding:6px;border-radius:11px}
  .matrix-team-actions{grid-template-columns:1fr}
  .matrix-add-row,.matrix-import-open{min-height:36px}
  .matrix-row-name{font-size:12px}
  .matrix-row-summary{font-size:10px}
  .matrix-result-buttons{grid-template-columns:1fr}
  .team-turn-roster{grid-template-columns:1fr}
  .team-turn-meta{display:grid;grid-template-columns:1fr}
  .team-battle-card h2{font-size:24px}
  .team-add-row{width:100%}
  .multi-result-row{grid-template-columns:30px minmax(0,1fr);gap:6px}
  .multi-rating{grid-column:2;grid-row:auto;justify-self:start}
  .multi-outcome{grid-column:2;justify-self:start}
  .replay-stage{min-width:600px;padding-left:86px}
  .replay-row{grid-template-columns:minmax(470px,1fr) 22px}
  .replay-row>strong{left:-76px;width:68px}
  .replay-cmp-layer{left:140px;right:58px}
  .matrix-modal-grid,.matrix-modal-moves{grid-template-columns:1fr}
}

/* Battleboard layout: keep opposing sides visible together on phone screens. */
@media(max-width:640px){
  .battle-mode-tabs{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
  .battle-mode-tabs button{min-height:42px;padding:8px 6px}

  .matchup-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;align-items:stretch}
  .matchup-grid>.versus-column{display:none}
  .fighter-card{padding:9px;border-radius:14px}
  .fighter-heading{align-items:flex-start;gap:7px;margin-bottom:10px}
  .side-pill{padding:5px 7px;font-size:10px}
  .ready-state{font-size:10px}
  .pokemon-search-wrap{gap:6px}
  .pokemon-search-wrap label{font-size:10px;letter-spacing:.04em}
  .pokemon-search-wrap input{min-height:42px;padding:9px 8px;font-size:16px}
  .pokemon-stage{grid-template-columns:52px minmax(0,1fr);gap:7px;min-height:78px;margin:10px 0}
  .art-ring{width:52px;height:52px}
  .art-ring img{width:46px;height:46px}
  .pokemon-stage h2{font-size:16px;line-height:1.05;overflow-wrap:anywhere}
  .pokemon-stage .muted{font-size:10px;line-height:1.2}
  .type-row{gap:4px}
  .type-chip{padding:4px 6px;font-size:9px}
  .stat-strip{grid-template-columns:repeat(2,minmax(0,1fr));gap:4px;margin:9px 0}
  .stat-strip div{padding:6px 3px;border-radius:9px}
  .stat-strip strong{font-size:13px}
  .iv-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin-bottom:8px}
  .field-grid label,.field-stack label{font-size:9px;letter-spacing:.03em}
  .field-grid input,.field-stack select{min-height:40px;padding:8px 7px;font-size:16px}
  .field-stack{gap:7px}
  .toggle-row{grid-template-columns:auto 1fr;gap:6px;margin-top:9px;padding:8px;font-size:11px}
  .toggle-row small{grid-column:2;font-size:9px;line-height:1.2}

  .matrix-team-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
  .matrix-team-panel{padding:7px;min-width:0}
  .matrix-team-heading{align-items:stretch;flex-direction:column;gap:7px;margin-bottom:8px}
  .matrix-team-heading h2{font-size:15px;line-height:1.05}
  .matrix-team-actions{display:grid;grid-template-columns:1fr 1fr;gap:5px;width:100%}
  .matrix-add-row,.matrix-import-open{width:100%;min-width:0;padding:8px 4px;font-size:10px;line-height:1.1}
  .matrix-rows{gap:6px;padding-right:2px}
  .matrix-row{padding:7px 27px 7px 7px;border-radius:9px}
  .matrix-row-delete{width:23px;height:27px;border-radius:0 8px 0 8px;font-size:17px}
  .matrix-row-name{font-size:13px;line-height:1.08;letter-spacing:0}
  .matrix-row-summary{font-size:10px;line-height:1.15}
  .matrix-row-move-pill{min-width:16px;height:16px;margin:0 1px;padding:0 4px;font-size:10px}
  .matrix-table{font-size:12px}
  .matrix-table th,.matrix-table td{padding:6px 5px}
  .matrix-rating-chip{width:42px;height:27px;border-radius:7px}

  .team-battle-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
  .team-battle-card{min-width:0;padding:8px;border-radius:13px;gap:8px}
  .team-battle-card header{align-items:stretch;flex-direction:column;gap:7px}
  .team-battle-card h2{font-size:16px;line-height:1.05}
  .team-add-row{width:100%;min-width:0;padding:8px 5px;border-radius:9px;font-size:10px}
  .team-battle-rows{min-height:0;gap:6px}
  .team-battle-row{height:auto;min-height:82px;padding:7px 26px 7px 7px;border-radius:9px}
  .team-battle-row .matrix-row-name{font-size:13px;line-height:1.08}
  .team-battle-row .matrix-row-summary{min-height:0;max-height:34px;font-size:10px;line-height:1.15}
}
@media(max-width:360px){
  .battle-mode-tabs{grid-template-columns:repeat(2,minmax(0,1fr))}
  .battle-mode-tabs button{font-size:11px}
  .fighter-card{padding:7px}
  .pokemon-stage{grid-template-columns:46px minmax(0,1fr);gap:5px}
  .art-ring{width:46px;height:46px}
  .art-ring img{width:41px;height:41px}
  .team-battle-card{padding:6px}
  .team-battle-row{padding-right:23px}
  .matrix-team-actions{grid-template-columns:1fr}
}

/* Keep all battle mode tabs visually consistent. */
.battle-mode-tabs{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  width:min(720px,100%);
  align-items:stretch;
}
.battle-mode-tabs button{
  display:flex;
  align-items:center;
  justify-content:center;
  min-width:0;
  min-height:46px;
  padding:0 14px;
  line-height:1.1;
  text-align:center;
  white-space:normal;
}
.battle-mode-tabs button.active{
  border-color:rgba(125,211,252,.22);
}
@media(max-width:640px){
  .battle-mode-tabs{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:360px){
  .battle-mode-tabs{grid-template-columns:1fr}
}

/* Shared settings toolbar sizing across Single, Matrix, Multi, and Team Battle. */
.battle-toolbar,
.matrix-toolbar,
.multi-toolbar,
.team-battle-toolbar{
  display:grid;
  grid-template-columns:minmax(220px,.75fr) minmax(330px,1fr) minmax(340px,1fr);
  align-items:end;
  gap:16px;
  padding:14px 16px;
  border-radius:18px;
}
.battle-toolbar .setting-group,
.matrix-toolbar .setting-group,
.multi-toolbar .setting-group,
.team-battle-toolbar .setting-group{
  min-width:0;
  width:100%;
}
.battle-toolbar .setting-group:has(#shieldsA),
.matrix-toolbar .setting-group:has(#matrixShieldsA),
.multi-toolbar .setting-group:has(#multiShieldsA),
.team-battle-toolbar .setting-group:has(#teamShieldsA){
  min-width:0;
}
.battle-toolbar .strategy-group,
.matrix-toolbar .strategy-group,
.multi-toolbar .strategy-group,
.team-battle-toolbar .strategy-group{
  min-width:0;
  flex:auto;
}
.battle-toolbar .shield-segment-pair,
.matrix-toolbar .shield-segment-pair,
.multi-toolbar .shield-segment-pair,
.team-battle-toolbar .shield-segment-pair{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
  align-items:end;
}
.battle-toolbar .shield-segment-field,
.matrix-toolbar .shield-segment-field,
.multi-toolbar .shield-segment-field,
.team-battle-toolbar .shield-segment-field{
  grid-template-columns:auto minmax(0,1fr);
  gap:8px;
}
.battle-toolbar .segmented,
.matrix-toolbar .segmented,
.multi-toolbar .segmented,
.team-battle-toolbar .segmented{
  width:100%;
}
.battle-toolbar .segmented button,
.matrix-toolbar .segmented button,
.multi-toolbar .segmented button,
.team-battle-toolbar .segmented button{
  min-width:0;
  padding:10px 10px;
  line-height:1.1;
}
@media(max-width:1040px){
  .battle-toolbar,
  .matrix-toolbar,
  .multi-toolbar,
  .team-battle-toolbar{
    grid-template-columns:minmax(220px,.75fr) minmax(330px,1.1fr);
  }
  .battle-toolbar .strategy-group,
  .matrix-toolbar .strategy-group,
  .multi-toolbar .strategy-group,
  .team-battle-toolbar .strategy-group{
    grid-column:1/-1;
  }
}
@media(max-width:700px){
  .battle-toolbar,
  .matrix-toolbar,
  .multi-toolbar,
  .team-battle-toolbar{
    grid-template-columns:1fr;
    gap:10px;
    padding:12px;
    border-radius:14px;
  }
  .battle-toolbar .shield-segment-field,
  .matrix-toolbar .shield-segment-field,
  .multi-toolbar .shield-segment-field,
  .team-battle-toolbar .shield-segment-field{
    grid-template-columns:1fr;
    gap:6px;
  }
}
@media(max-width:430px){
  .battle-toolbar .shield-segment-pair,
  .matrix-toolbar .shield-segment-pair,
  .multi-toolbar .shield-segment-pair,
  .team-battle-toolbar .shield-segment-pair{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:6px;
  }
  .battle-toolbar .compact-segment button,
  .matrix-toolbar .compact-segment button,
  .multi-toolbar .compact-segment button,
  .team-battle-toolbar .compact-segment button{
    padding:9px 4px;
  }
}
