/* ===== Build phase ===== */
#scr-build .build-grid { position: absolute; inset: 0; display: grid; gap: 1cqmin; padding: 1cqmin; }
.landscape #scr-build .build-grid {
    grid-template-columns: minmax(0, 1fr) clamp(84px, 12cqw, 200px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
}
.portrait #scr-build .build-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) clamp(42px, 6.5cqh, 90px) minmax(0, 1fr);
}
#scr-build .panel.p1 { order: 1; --team: var(--t1); --team-d: var(--t1-d); }
#scr-build .center { order: 2; }
#scr-build .panel.p2 { order: 3; --team: var(--t2); --team-d: var(--t2-d); }
.portrait #scr-build .panel.p2 { order: 1; }
.portrait #scr-build .panel.p1 { order: 3; }
.tabletop #scr-build .panel.p2 {   /* portrait: P2 on top; landscape: P2 on the right; either way they sit opposite */ transform: rotate(180deg); }

.panel {
    position: relative; min-width: 0; min-height: 0;
    container-type: size; container-name: panel;
    border: .35cqmin solid var(--ink);
    border-radius: 2.4cqmin;
    background: linear-gradient(180deg, rgba(58, 29, 99, .88), rgba(28, 14, 52, .92));
    box-shadow: 0 .6cqmin 0 var(--ink), 0 1.2cqmin 2.4cqmin rgba(0, 0, 0, .45), inset 0 .25cqmin 0 rgba(255, 255, 255, .12), inset 0 0 0 .3cqmin color-mix(in srgb, var(--team) 40%, transparent);
    overflow: hidden;
    transition: box-shadow .3s;
}
.p-in {
    --k: max(.8px, min(.2778cqw, .3333cqh));
    position: absolute; inset: 0;
    font-size: calc(var(--k) * 10);
    padding: .45em .6em .55em;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    gap: .32em;
}
.short .p-in { padding: .5em .6em .6em; gap: .3em; }

/* header */
.p-head { display: flex; align-items: center; gap: .6em; min-height: 2.3em; }
.p-name { flex: 1 1 0; min-width: 0; font-family: var(--font-display); font-size: 1.55em; text-transform: uppercase; color: var(--team);
    text-shadow: 0 .08em 0 var(--ink), .06em 0 0 var(--ink), -.06em 0 0 var(--ink), 0 -.06em 0 var(--ink); letter-spacing: .02em; line-height: 1.1; }
.p-wins { display: flex; gap: .1em; flex: none; }
.trophy { display: inline-block; width: 1.5em; height: 1.5em; filter: grayscale(1) brightness(.5); opacity: .55; transition: filter .3s, opacity .3s, transform .3s var(--ease-spring); }
.trophy svg { width: 100%; height: 100%; display: block; }
.trophy.got { filter: none; opacity: 1; }
.trophy.fresh { animation: trophyPop .8s var(--ease-spring); }
@keyframes trophyPop { 0% { transform: scale(2.4) rotate(-20deg); } 60% { transform: scale(.85); } 100% { transform: none; } }
.p-scrap { flex: none; display: flex; align-items: center; gap: .25em; padding: .1em .7em .1em .25em; border-radius: 1em; background: var(--ink); border: .15em solid var(--yellow-d); }
.p-scrap .ico { width: 1.9em; height: 1.9em; display: block; }
.p-scrap .ico svg { width: 100%; height: 100%; display: block; }
.scrap-num { font-family: var(--font-display); font-size: 1.8em; color: var(--yellow); min-width: 1.1em; text-align: right; line-height: 1; }
.p-scrap.bad { animation: shake .4s; }
.p-scrap.bad .scrap-num { color: var(--red); }

/* preview + stats */
.p-main { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: .6em; min-height: 0; }
.p-preview { position: relative; min-height: 0; border-radius: 1em; overflow: hidden;
    background:
        radial-gradient(ellipse 70% 40% at 50% 92%, color-mix(in srgb, var(--team) 45%, transparent), transparent 75%),
        linear-gradient(180deg, rgba(12, 6, 26, .55), rgba(40, 20, 70, .55));
    border: .15em solid rgba(20, 12, 34, .9);
    box-shadow: inset 0 .2em .6em rgba(0, 0, 0, .4); }
.p-preview::after { content: ''; position: absolute; left: 0; right: 0; bottom: 6%; height: .15em; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .18), transparent); }
.bot-canvas { width: 100%; height: 100%; }
.p-brands { position: absolute; left: 0; top: 0; z-index: 3; display: flex; flex-direction: column; gap: .3em; padding: .4em; min-width: 44px; min-height: 44px; border: 0; background: none; cursor: pointer; align-items: flex-start; color: #fff; }
.p-brands.empty { pointer-events: none; }
.bpill { display: inline-flex; align-items: center; gap: .25em; padding: 0 .55em 0 .3em; height: 1.9em; border-radius: 1em; font-size: 1em; font-weight: 800; line-height: 1;
    background: rgba(20, 12, 34, .82); border: .14em solid var(--bc); color: #fff; width: fit-content; opacity: .9; pointer-events: none; transition: box-shadow .2s, background .2s; }
.bpill .bico { width: 1.25em; height: 1.25em; display: block; color: var(--bc); flex: none; filter: drop-shadow(0 .06em 0 var(--ink)); }
.bpill .bico svg, .br-row .bico svg { width: 100%; height: 100%; display: block; }
.bpill b { font-family: var(--font-display); font-weight: 400; font-size: 1.05em; }
.bpill small { font-size: .78em; opacity: .65; margin-left: -.15em; }
.bpill.active { opacity: 1; box-shadow: 0 0 .9em var(--bc), inset 0 0 .6em color-mix(in srgb, var(--bc) 55%, transparent); background: color-mix(in srgb, var(--bc) 38%, #140c22); animation: setGlow 1.6s ease-in-out infinite; }
.bpill.active.t3 { box-shadow: 0 0 1.3em var(--bc), 0 0 .3em #fff, inset 0 0 .8em color-mix(in srgb, var(--bc) 70%, transparent); }
.bpill.active .bico { color: #fff; }
@keyframes setGlow { 50% { box-shadow: 0 0 1.5em var(--bc), inset 0 0 .6em color-mix(in srgb, var(--bc) 55%, transparent); } }
.br-list { display: flex; flex-direction: column; gap: .3em; flex: 1; min-height: 0; overflow: hidden; justify-content: flex-start; grid-area: desc; }
.br-list.many { display: grid; grid-template-columns: 1fr 1fr; align-content: start; }
.pop.brands .pi-q { font-size: 1em; justify-content: flex-start; padding: 0 2.4em 0 .2em; flex: none; }
.br-row { display: flex; align-items: center; gap: .45em; padding: .15em .3em; border-radius: .7em; border: .12em solid color-mix(in srgb, var(--bc) 55%, transparent); background: rgba(0, 0, 0, .3); min-width: 0; opacity: .8; }
.br-row.on { opacity: 1; border-color: var(--bc); background: color-mix(in srgb, var(--bc) 25%, #140c22); box-shadow: 0 0 .6em color-mix(in srgb, var(--bc) 60%, transparent); }
.br-row .bico { width: 1.7em; height: 1.7em; flex: none; color: var(--bc); display: block; }
.br-txt { min-width: 0; flex: 1; } .br-name { font-weight: 800; font-size: 1.05em; color: var(--bc); line-height: 1.1; }
.br-row.on .br-name { color: #fff; } .br-bonus { font-size: .95em; line-height: 1.1; color: var(--text); font-weight: 600; max-height: 2.3em; }
.p-hint { position: absolute; left: 50%; bottom: .5em; z-index: 2; transform: translate(-50%, 0); max-width: 94%; padding: .25em .8em; border-radius: 1em; display: none; pointer-events: none;
    background: rgba(20, 12, 34, .88); border: .14em solid var(--yellow); color: var(--yellow); font-weight: 800; font-size: 1.05em; text-align: center; animation: hintBob 1.2s ease-in-out infinite; }
.p-hint.show { display: block; }
.p-hint::after { content: '\25BC'; margin-left: .4em; font-size: .8em; }
@keyframes hintBob { 50% { transform: translate(-50%, .25em); } }
.panel.ready .p-hint { display: none; }
.ready-stamp { position: absolute; left: 50%; top: 42%; z-index: 4; transform: translate(-50%, -50%) rotate(-10deg) scale(0); opacity: 0;
    font-size: 2.4em; padding: .05em .4em; border: .14em solid var(--green); color: var(--green); border-radius: .3em; background: rgba(20, 12, 34, .8);
    text-shadow: 0 0 .5em var(--green); pointer-events: none; transition: transform .35s var(--ease-spring), opacity .2s; white-space: nowrap; }
.panel.ready .ready-stamp { transform: translate(-50%, -50%) rotate(-10deg) scale(1); opacity: 1; }
.ready-glow { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; opacity: 0; transition: opacity .3s;
    box-shadow: inset 0 0 0 .5cqmin var(--green), inset 0 0 6cqmin rgba(91, 227, 125, .35); }
.panel.ready .ready-glow { opacity: 1; animation: readyPulse 1.4s ease-in-out infinite; }
@keyframes readyPulse { 50% { opacity: .55; } }

.p-stats { display: flex; flex-direction: column; justify-content: space-evenly; gap: .2em; min-width: 0; padding: .2em 0; }
.stat { display: grid; grid-template-columns: 3.5em minmax(0, 1fr) 2.4em; align-items: center; gap: .35em; }
.s-lbl { font-size: 1.05em; font-weight: 800; color: var(--text-dim); letter-spacing: .02em; }
.s-track { position: relative; height: 1.35em; border-radius: .7em; background: #0e0720; border: .15em solid var(--ink); overflow: hidden; box-shadow: inset 0 .15em .2em rgba(0, 0, 0, .5); }
.s-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: .6em; background: linear-gradient(180deg, color-mix(in srgb, var(--sc) 60%, #fff), var(--sc)); }
.stat.hp { --sc: #5BE37D; } .stat.dmg { --sc: #ff7a3d; } .stat.speed { --sc: #2EC4F1; } .stat.armor { --sc: #9fb2d0; }
.s-delta { position: absolute; top: 0; bottom: 0; width: 0; }
.s-delta.up { background: repeating-linear-gradient(-45deg, #b9ff6a 0 .35em, #5BE37D .35em .7em); box-shadow: 0 0 .6em #b9ff6a; animation: deltaPulse 0.9s ease-in-out infinite; }
.s-delta.down { background: repeating-linear-gradient(-45deg, #ff6a6a 0 .35em, #b81f43 .35em .7em); animation: deltaPulse 0.9s ease-in-out infinite; }
@keyframes deltaPulse { 50% { opacity: .6; } }
.s-val { font-size: 1.05em; font-weight: 800; text-align: left; min-width: 0; white-space: nowrap; }
.s-val.up { color: #8dff9d; } .s-val.down { color: #ff7d7d; }

/* chips */
.p-chips { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .4em; }
.chip { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: space-between; min-height: max(44px, 3.4em); padding: .2em .1em .2em; border-radius: .8em; cursor: pointer;
    background: linear-gradient(180deg, rgba(12, 6, 26, .6), rgba(40, 20, 70, .7)); border: .15em solid var(--ink);
    border-bottom: .3em solid var(--bc, transparent); box-shadow: inset 0 .15em .3em rgba(0, 0, 0, .35); transition: transform .12s var(--ease-spring), filter .12s; color: var(--text-dim); }
.chip:hover { transform: translateY(-.15em); filter: brightness(1.15); }
.chip.pressed { transform: scale(.94); }
.chip .chip-ico { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.chip .chip-ico canvas, .chip .chip-ico svg { height: 100%; max-height: 2.9em; width: auto; max-width: 100%; aspect-ratio: 1; }
.chip .chip-ico canvas.fit-icon { contain: size; contain-intrinsic-size: 80px 80px; object-fit: contain; }
.chip:not(.filled) .chip-ico svg { height: 1.7em; opacity: .4; }
.chip .chip-lbl { font-size: max(.72em, 8.5px); line-height: 1; max-width: 100%; opacity: .0; position: absolute; bottom: .2em; }
.chip:not(.filled) .chip-lbl { opacity: .6; }
.chip:not(.filled) .pips { display: none; }
.pips { display: flex; gap: .15em; height: .5em; align-items: center; }
.pips i { width: .45em; height: .45em; border-radius: 50%; background: rgba(255, 255, 255, .2); border: .08em solid var(--ink); }
.pips i.on { background: var(--yellow); box-shadow: 0 0 .3em var(--yellow); }
.chip.attach { animation: chipAttach .6s var(--ease-spring); }
@keyframes chipAttach { 0% { transform: scale(.5) rotate(-12deg); filter: brightness(2.2); } 60% { transform: scale(1.12); } 100% { transform: none; } }

/* shop cards */
.p-shop { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .45em; padding-top: .4em; }
.card { --bc: #888; position: relative; min-height: max(44px, 5.5em); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: .1em;
    padding: 1.1em .15em .3em; border: .22em solid var(--bc); border-radius: .9em; cursor: pointer; color: #fff;
    background: linear-gradient(180deg, color-mix(in srgb, var(--bc) 28%, #34195c), #1b0e34);
    box-shadow: 0 .3em 0 var(--ink), 0 .5em .7em rgba(0, 0, 0, .35), inset 0 .15em 0 rgba(255, 255, 255, .15);
    transition: transform .15s var(--ease-spring), box-shadow .15s, filter .2s; font-weight: 800; }
.card:hover:not(.sold) { transform: translateY(-.25em) scale(1.04); }
.card.pressed { transform: translateY(.2em) scale(.94); box-shadow: 0 .05em 0 var(--ink); }
.card.sel { transform: translateY(-.3em) scale(1.05); z-index: 2; box-shadow: 0 .3em 0 var(--ink), 0 0 0 .22em var(--team), 0 0 1.3em var(--team); }
.card.kfocus { z-index: 3; box-shadow: 0 .3em 0 var(--ink), 0 0 0 .2em #fff, 0 0 0 .45em var(--team), 0 0 1.6em .3em var(--team); animation: kfocus 1s ease-in-out infinite; }
@keyframes kfocus { 50% { transform: translateY(-.2em) scale(1.03); } }
.card .c-icon { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.card .c-icon canvas { height: 100%; width: auto; max-width: 100%; aspect-ratio: 1; }
/* DPR-sharp part art (botView.js createPartIcon `fit`): the square backing store is re-rendered at the shown size x DPR and drawn
   uniformly (object-fit: contain), so it is never stretched nor CSS-upscaled. Size containment keeps the layout of the old fixed
   96px icon (2 PLAYERS cards look exactly as before), whatever resolution the bitmap has. */
.card .c-icon canvas.fit-icon { contain: size; contain-intrinsic-size: 96px 96px; object-fit: contain; }
.card .c-name { font-size: 1.02em; line-height: 1.1; max-width: 100%; text-align: center; padding: 0 .1em; text-shadow: 0 .08em 0 var(--ink); }
.c-cost { position: absolute; top: -.55em; left: -.45em; z-index: 2; display: flex; align-items: center; gap: .1em; padding: 0 .45em 0 .2em; height: 1.7em;
    background: var(--yellow); color: var(--ink); border: .15em solid var(--ink); border-radius: 1em; font-family: var(--font-display); font-size: 1.1em; box-shadow: 0 .15em 0 var(--ink); }
.c-cost .ico { width: 1.15em; height: 1.15em; display: block; }
.c-cost .ico svg { width: 100%; height: 100%; display: block; }
.c-gems { position: absolute; top: .35em; right: .35em; display: flex; gap: .15em; }
.c-gems i { width: .6em; height: .6em; transform: rotate(45deg); background: #3a2a60; border: .08em solid var(--ink); }
.c-gems i.on { background: var(--bc); box-shadow: 0 0 .4em var(--bc); }
.c-ribbon { display: none; position: absolute; left: -.4em; top: 1.5em; z-index: 2; padding: .05em .6em .05em .4em; background: var(--green); color: var(--ink); font-family: var(--font-display);
    font-size: .78em; transform: rotate(-9deg); border: .14em solid var(--ink); border-radius: .3em; max-width: 120%; box-shadow: 0 .12em 0 var(--ink); text-transform: uppercase; }
.card.upg .c-ribbon { display: block; animation: ribbonPop .8s var(--ease-spring) both; }
@keyframes ribbonPop { from { transform: rotate(-9deg) scale(0); } }
.c-set { display: none; position: absolute; right: -.35em; bottom: -.35em; z-index: 2; width: 1.5em; height: 1.5em; border-radius: 50%; background: var(--yellow); color: var(--ink); text-align: center; line-height: 1.35em; font-size: 1em; border: .14em solid var(--ink); }
.card.setb { animation: setb 1.2s ease-in-out infinite; }
.card.setb .c-set { display: block; }
@keyframes setb { 50% { box-shadow: 0 .3em 0 var(--ink), 0 0 1.2em var(--yellow), 0 0 0 .15em var(--yellow); } }
.card.cant { filter: saturate(.45) brightness(.72); }
.card.cant .c-cost { background: #b9acd6; }
.card.sold { opacity: .28; filter: grayscale(1); pointer-events: none; transform: scale(.92); }
.card.sold > * { visibility: hidden; }
.card.empty { visibility: hidden; }
.card.deal { animation: dealIn .45s var(--ease-spring) both; animation-delay: var(--d, 0ms); }
@keyframes dealIn { from { transform: translateY(-1.4em) rotate(-8deg) scale(.5); opacity: 0; } to { transform: none; opacity: 1; } }
.card.bought { animation: bought .45s var(--ease-spring); }
@keyframes bought { 0% { transform: scale(1.2); filter: brightness(2); } 100% { transform: none; } }

/* actions */
.p-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: .6em; min-height: 44px; }
.btn.act { font-size: 1.5em; min-height: 0; padding: .2em .5em; gap: .3em; border-radius: .7em; }
.btn.act .ico { width: 1.3em; height: 1.3em; display: block; }
.btn.act .ico svg { width: 100%; height: 100%; display: block; }
.btn.act .lbl { min-width: 0; max-width: 100%; }
.btn.act.reroll .cost-chip { font-size: .8em; padding: .05em .4em; background: var(--ink); color: var(--yellow); border-radius: 1em; display: inline-flex; align-items: center; gap: .15em; }
.btn.act .cost-chip .ico { width: .95em; height: .95em; }
.btn.act.kfocus { outline: .15em solid #fff; outline-offset: .12em; box-shadow: 0 .32em 0 var(--ink), 0 0 0 .45em var(--team), 0 0 1.4em .3em var(--team); }
.arm-choice.kfocus { outline: .2em solid #fff; outline-offset: .1em; box-shadow: 0 0 1em var(--team); }
.btn.act.on { box-shadow: 0 .32em 0 var(--ink), 0 0 1.2em var(--yellow); }
.btn.act.ready:not(.on) { animation: readyBtn 1.6s ease-in-out infinite; }
@keyframes readyBtn { 50% { filter: brightness(1.15); transform: scale(1.03); } }

/* CPU panel */
.p-cover { display: none; grid-row: 4 / 6; grid-column: 1; z-index: 3; border-radius: 1em; align-items: center; justify-content: center; gap: .8em;
    background: repeating-linear-gradient(-45deg, rgba(20, 12, 34, .75) 0 .8em, rgba(40, 20, 70, .75) .8em 1.6em); border: .15em dashed rgba(255, 255, 255, .2); padding: 0 1em; }
.is-cpu .p-cover { display: flex; }
.is-cpu .p-shop, .is-cpu .p-actions { visibility: hidden; }
.cover-gear { width: 3em; height: 3em; flex: none; background: url('gear.svg') center / contain no-repeat; filter: brightness(1.8); animation: spin 3s linear infinite; }
.cover-txt { font-size: 1.4em; color: var(--text-dim); min-width: 0; }

/* popover (lives inside .p-main, which is a size container) */
.p-main { position: relative; z-index: 6; container-type: size; container-name: pmain; }
.pop-host { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.pop { position: absolute; left: 0; top: 0; bottom: 0; width: calc((100% - .6em) * .535); pointer-events: auto; display: flex; flex-direction: column; gap: .3em; padding: .4em .45em .45em;
    background: linear-gradient(180deg, rgba(40, 20, 70, .98), rgba(20, 10, 40, .98)); border: .18em solid var(--team); border-radius: .9em; box-shadow: 0 0 1.2em rgba(0, 0, 0, .6);
    animation: popUp .22s var(--ease-spring) both; overflow: hidden; }
.pop.out { animation: popOut .15s ease-in both; pointer-events: none; }
@keyframes popUp { from { transform: scale(.85) translateY(.6em); opacity: 0; } }
@keyframes popOut { to { transform: scale(.92); opacity: 0; } }
.pop-x { position: absolute; top: .25em; right: .25em; width: 2.3em !important; height: 2.3em !important; min-width: 0 !important; min-height: 0 !important; font-size: 1em; z-index: 3; padding: 0; }
.pop-x svg { width: 1.1em !important; height: 1.1em !important; }
.pi-head { display: flex; gap: .5em; align-items: center; padding-right: 2.2em; min-width: 0; grid-area: head; }
.pi-ico { flex: none; width: 3em; height: 3em; border-radius: .7em; background: color-mix(in srgb, var(--bc) 30%, #1b0e34); border: .14em solid var(--bc); display: flex; align-items: center; justify-content: center; }
.pi-ico canvas { width: 100%; height: 100%; object-fit: contain; }
.pi-titles { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: .05em; }
.pi-name { font-size: 1.2em; color: var(--yellow); line-height: 1.1; }
.pi-brand { font-size: .82em; font-weight: 800; }
.pi-lv { font-size: .82em; color: #9fe0ff; font-weight: 800; }
.pi-desc { flex: 1; min-height: 0; font-size: .95em; line-height: 1.2; color: var(--text); font-weight: 600; overflow: hidden; grid-area: desc; }
.pi-deltas { display: flex; flex-wrap: wrap; gap: .25em; grid-area: deltas; min-height: 0; }
.pi-deltas:empty { display: none; }
.dchip { font-size: .8em; font-weight: 800; padding: .05em .45em; border-radius: 1em; background: rgba(0, 0, 0, .4); white-space: nowrap; }
.dchip.up { color: #8dff9d; } .dchip.down { color: #ff7d7d; }
.pi-set { font-size: .82em; color: var(--yellow); font-weight: 800; line-height: 1.15; grid-area: set; }
.pi-empty { margin: auto; text-align: center; color: var(--text-dim); font-size: 1.15em; padding: 0 1.5em; }
.pi-q { font-size: 1.1em; text-align: center; padding: 0 2em 0 .2em; display: flex; align-items: center; justify-content: center; grid-area: head; }
.pop .btn { font-size: 1.1em; min-height: 0; padding: .3em .6em; border-radius: .7em; }
.pop-buy, .pop-sell { height: max(44px, 2.4em); min-height: 44px !important; flex: none; grid-area: buy; }
.pop-sell { grid-area: sell; margin-top: auto; gap: .5em; }
.pop-sell .lbl { flex: 0 1 auto; min-width: 0; }
.pop-x::after { content: ''; position: absolute; inset: -50%; }
.pop-buy .cost-chip { display: inline-flex; align-items: center; gap: .1em; background: var(--ink); color: var(--yellow); border-radius: 1em; padding: 0 .4em; font-size: .85em; }
.pop-buy .cost-chip .ico { width: 1em; height: 1em; display: block; }
.choice-row { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: .5em; min-height: 0; grid-area: desc; }
.arm-choice { flex-direction: column; font-size: .95em !important; gap: .1em; padding: .2em !important; min-height: 44px !important; white-space: normal; }
.arm-choice canvas { height: 55%; width: auto; aspect-ratio: 1; }
.arm-choice .lv-badge { font-size: .8em; color: var(--yellow); }
/* compact: main area is short -> popover spans the full width in a horizontal layout */
@container pmain (max-height: 150px) {
    .pop { width: 100%; bottom: -4.3em; display: grid; grid-template-columns: minmax(0, 1fr) 7.5em; grid-template-areas: "head buy" "desc buy" "info buy" "deltas deltas" "set set"; grid-template-rows: auto minmax(0, 1fr) auto auto auto; column-gap: .5em; row-gap: .2em; }
    .pop-buy, .pop-sell { grid-row: 1 / 4; height: auto; align-self: stretch; margin-top: 2.3em; flex-direction: column; }
    .pi-desc { font-size: .9em; }
    .pop.choice { grid-template-areas: "head head" "desc desc"; }
    .pop-buy, .pop-sell { grid-row: 1 / 5; }
    .pop.chip { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "desc" "info" "sell"; grid-template-rows: auto minmax(0, 1fr) auto auto; }
    .pop.chip .pop-sell { grid-row: auto; margin-top: 0; height: max(44px, 2.4em); align-self: end; flex-direction: row; }
    .pop.brands { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "desc"; grid-template-rows: auto minmax(0, 1fr); }
}
@container pmain (min-height: 150px) and (max-width: 330px) {
    .pop { width: 100%; }
}

.float-host { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: visible; }
.float-text { position: absolute; left: 50%; top: 35%; transform: translateX(-50%); white-space: nowrap; font-size: 1.9em; color: var(--yellow);
    -webkit-text-stroke: .1em var(--ink); paint-order: stroke fill; animation: floatUp 1.2s ease-out both; }
.float-text.refund { color: var(--green); } .float-text.err { color: #ff7d7d; font-size: 1.4em; }
@keyframes floatUp { 0% { transform: translate(-50%, 1em) scale(.4); opacity: 0; } 15% { transform: translate(-50%, 0) scale(1.15); opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(-50%, -2.8em) scale(1); opacity: 0; } }

/* center column */
.center { position: relative; display: flex; align-items: center; justify-content: space-between; font-size: clamp(11px, 2.1cqmin, 22px); padding: .4em; min-width: 0; min-height: 0; }
.landscape .center { flex-direction: column; padding: 1.2em .2em; }
.portrait .center { flex-direction: row; padding: 0 1em; }
.center .pause-btn { font-size: 1em; width: 2.9em; height: 2.9em; padding: 0; }
.c-round { font-size: 1.15em; color: var(--yellow); text-align: center; max-width: 100%; line-height: 1; text-shadow: 0 .1em 0 var(--ink); transform: rotate(-3deg); }
.c-round .fit { display: block; }
.c-timer { position: relative; width: 5.4em; height: 5.4em; flex: none; }
.portrait .c-timer { width: 4.2em; height: 4.2em; }
.short.landscape .c-timer { width: 4em; height: 4em; }
.ring { width: 100%; height: 100%; filter: drop-shadow(0 .15em 0 var(--ink)); }
.ring-bg { stroke: #0e0720; } .ring-fg { stroke: var(--yellow); transition: stroke .3s; }
.time-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.9em; color: #fff; text-shadow: 0 .08em 0 var(--ink); }
.portrait .time-num { font-size: 1.5em; }
.center.urgent .ring-fg { stroke: var(--red); }
.center.urgent .c-timer { animation: urgent 1s ease-in-out infinite; }
.center.urgent .time-num { color: #ff8f8f; }
@keyframes urgent { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.14); } }
#scr-build.urgent::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 20; box-shadow: inset 0 0 8cqmin rgba(255, 40, 60, .55); animation: urgentVig 1s ease-in-out infinite; }
@keyframes urgentVig { 0%, 100% { opacity: .25; } 15% { opacity: 1; } }
.c-scores { display: flex; align-items: center; gap: .35em; font-size: 1.3em; }
.landscape .c-scores { flex-direction: column; gap: 0; }
.landscape .cdash { display: none; }
.cscore { display: flex; align-items: center; gap: .15em; font-size: 1.1em; }
.cscore .ico { width: 1.3em; height: 1.3em; display: block; } .cscore .ico svg { width: 100%; height: 100%; display: block; }
.cscore.p1 b { color: var(--t1); text-shadow: 0 .08em 0 var(--ink); } .cscore.p2 b { color: var(--t2); text-shadow: 0 .08em 0 var(--ink); }
.cdash { color: var(--text-dim); }

.is-cpu .ready-stamp, .is-cpu .ready-glow { display: none; }
.is-cpu { box-shadow: 0 .6cqmin 0 var(--ink), 0 1.2cqmin 2.4cqmin rgba(0, 0, 0, .45); }
.p-in > .p-head { grid-row: 1; } .p-in > .p-main { grid-row: 2; } .p-in > .p-chips { grid-row: 3; } .p-in > .p-shop { grid-row: 4; } .p-in > .p-actions { grid-row: 5; }
.p-in > * { grid-column: 1; }

/* the first-round hint would cover the whole bot on very small previews */
@container pmain (max-height: 110px) { .p-hint { display: none !important; } }

/* ===== readability pass: roles, counters, sell preview ===== */
:root { --warn: #ffa13d; }
.card .c-role { position: absolute; left: .15em; bottom: 1.45em; z-index: 2; width: 1.35em; height: 1.35em; padding: .2em; border-radius: 50%; background: rgba(12, 6, 26, .78); color: #d8ccf0; pointer-events: none; }
.card .c-role svg { width: 100%; height: 100%; display: block; }
.c-vs { display: none; }
.c-vs.good, .c-vs.bad { position: absolute; right: .1em; bottom: 1.4em; z-index: 3; display: flex; align-items: center; gap: .05em; height: 1.75em; padding: 0 .2em 0 .3em; border-radius: 1em; pointer-events: none;
    border: .13em solid var(--ink); box-shadow: 0 .1em 0 var(--ink); animation: vsPop .5s var(--ease-spring) both; }
.c-vs.good { background: var(--green); color: var(--ink); } .c-vs.bad { background: var(--warn); color: var(--ink); }
.c-vs b { font-size: .8em; line-height: 1; font-family: var(--font-display); }
.c-vs .mini-part { width: 1.4em; height: 1.4em; margin: 0; background: rgba(12, 6, 26, .85); }
@keyframes vsPop { from { transform: scale(0); } }
.mini-part { display: inline-flex; width: 1.9em; height: 1.9em; flex: none; border-radius: 50%; background: rgba(0, 0, 0, .35); align-items: center; justify-content: center; }
.mini-part canvas { width: 100%; height: 100%; display: block; }
.mini-part.hit { box-shadow: 0 0 0 .14em var(--green), 0 0 .5em var(--green); }
.vs-row.weak .mini-part.hit { box-shadow: 0 0 0 .14em var(--warn), 0 0 .5em var(--warn); }
.role-tag { display: inline-flex; align-items: center; gap: .25em; align-self: flex-start; max-width: 100%; padding: .02em .5em .02em .3em; border-radius: 1em; background: rgba(255, 255, 255, .12); color: #e9defc; font-size: .78em; font-weight: 800; line-height: 1.25; }
.role-tag i { width: 1.05em; height: 1.05em; flex: none; display: block; } .role-tag i svg { width: 100%; height: 100%; display: block; }
.role-tag b { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-info { grid-area: info; display: flex; flex-direction: column; gap: .2em; min-height: 0; min-width: 0; }
.pi-info:empty { display: none; }
.pi-vs { display: grid; grid-template-columns: repeat(auto-fit, minmax(9em, 1fr)); gap: .15em .6em; }
.vs-row { display: flex; align-items: center; gap: .3em; min-width: 0; font-size: .88em; font-weight: 800; }
.vs-lbl { flex: none; } .vs-row.strong .vs-lbl { color: #8dff9d; } .vs-row.weak .vs-lbl { color: var(--warn); }
.vs-ico { display: flex; gap: .2em; flex-wrap: wrap; min-width: 0; }
.pi-verdict { display: flex; align-items: center; gap: .3em; font-size: .92em; font-weight: 800; line-height: 1.1; min-width: 0; }
.pi-verdict b { flex: none; width: 1.4em; height: 1.4em; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--ink); font-size: .8em; }
.pi-verdict.good { color: #8dff9d; } .pi-verdict.good b { background: var(--green); }
.pi-verdict.bad { color: var(--warn); } .pi-verdict.bad b { background: var(--warn); }
.pi-verdict .mini-part { width: 1.7em; height: 1.7em; }
.pi-verdict .fit-box { min-width: 0; flex: 1; }
.pi-note { font-size: .88em; font-weight: 800; color: var(--yellow); line-height: 1.15; min-width: 0; }
.pi-note.locked { color: var(--text-dim); font-weight: 700; }
.pop-sell .cost-chip { display: inline-flex; align-items: center; gap: .1em; background: var(--ink); color: var(--yellow); border-radius: 1em; padding: 0 .4em; font-size: .85em; }
.pop-sell .cost-chip .ico { width: 1em; height: 1em; display: block; }
.pi-role { margin-top: .05em; }
.chip.kfocus { z-index: 3; box-shadow: 0 0 0 .2em #fff, 0 0 0 .4em var(--team), 0 0 1.2em .2em var(--team); }

/* guided first match: "Two players? Skip" pill (hidden outside the tutorial). Landscape: in the centre column under the pause button.
   Portrait: the centre strip is full, so the pill hangs just above it, over the corner of the opponent's panel. */
#scr-build .tut-skip { z-index: 35; font-size: clamp(10px, 1.7cqmin, 16px); padding: .4em .8em; min-height: 2.2em; line-height: 1.15; opacity: .92; flex: none; }
#scr-build .tut-skip[hidden] { display: none; }
.landscape #scr-build .tut-skip { position: relative; max-width: 96%; white-space: normal; text-align: center; font-size: clamp(11px, 1.75cqmin, 16px); }
.portrait #scr-build .tut-skip { position: absolute; left: 1.2cqmin; bottom: calc(100% + .3cqmin); white-space: nowrap; max-width: 60%; }
