.battle-lab-view { zoom: 1.08; }
.battle-lab-intro { margin-bottom: 22px; }
.battle-lab-root { min-width: 0; display: grid; gap: 18px; padding-bottom: 12px; }
.battle-lab-loading { min-height: 360px; display: grid; place-items: center; align-content: center; gap: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--muted); font-size: 12px; }

.battle-lab-toolbar { position: relative; min-width: 1160px; min-height: 76px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.78); box-shadow: 0 5px 24px rgba(55,64,61,.035); }
.battle-lab-side-tools { position: relative; min-width: 0; min-height: 50px; display: flex; align-items: center; gap: 10px; padding: 0 14px 0 2px; }
.battle-lab-side-tools.is-red { padding: 0 2px 0 16px; border-left: 1px solid var(--line); }
.battle-lab-side-tools > div:first-child { flex: 0 0 auto; min-width: 96px; display: grid; grid-template-columns: auto auto; align-items: baseline; justify-content: start; column-gap: 7px; }
.battle-lab-side-tools small { grid-column: 1 / -1; color: #89938d; font-family: "DM Mono",monospace; font-size: 7px; letter-spacing: .08em; }
.battle-lab-side-tools strong { margin-top: 4px; color: var(--ink); font-size: 12px; font-weight: 750; }
.battle-lab-side-tools.is-blue small { color: #708e9d; }
.battle-lab-side-tools.is-red small { color: #ad737d; }
.battle-lab-side-tools > div:first-child > span { color: #8c9590; font-size: 8px; }
.battle-lab-search { min-width: 0; flex: 1 1 auto; }
.battle-lab-search .search-field { height: 50px; }
.battle-lab-suggestions { z-index: 100; }
.battle-lab-suggestions .suggestion-usage { flex: 0 0 auto; min-width: 30px; color: var(--teal); font-family: "DM Mono",monospace; font-size: 10px; font-weight: 600; letter-spacing: .03em; text-align: right; }
.battle-lab-import { position: relative; flex: 0 0 auto; }
.battle-lab-import-btn { height: 50px; padding: 0 14px; font-size: 10px; }
.battle-lab-import-btn.is-add { border-color: var(--teal); background: var(--teal); color: #fff; }
.battle-lab-import-btn.is-add:hover { border-color: #436a4f; background: #436a4f; }
.battle-lab-team-menu-divider { height: 1px; margin: 4px 6px; background: #e7ece6; }
.battle-lab-team-menu { position: absolute; z-index: 120; top: calc(100% + 6px); right: 0; min-width: 180px; max-height: 260px; overflow-y: auto; padding: 5px; border: 1px solid #cdd9ce; border-radius: 10px; background: rgba(255,255,253,.995); box-shadow: 0 16px 38px rgba(28,41,38,.18); }
.battle-lab-team-menu[hidden] { display: none; }
.battle-lab-team-menu button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 0; border-radius: 6px; background: transparent; color: #45514d; font-size: 11px; font-weight: 650; text-align: left; cursor: pointer; }
.battle-lab-team-menu button:hover { background: #eaf2eb; color: var(--teal); }
.battle-lab-team-menu button small { flex: 0 0 auto; color: #929b97; font-family: "DM Mono",monospace; font-size: 8px; }
.battle-lab-team-menu-empty { margin: 0; padding: 10px 12px; color: #929b97; font-size: 10px; text-align: center; }

/* --- Conditions / Field panel --- */
.battle-lab-field { min-width: 1160px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.78); box-shadow: 0 5px 24px rgba(55,64,61,.035); }
.battle-lab-field-toggle { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 16px; border: 0; background: transparent; cursor: pointer; }
.battle-lab-field-toggle .field-title { flex: 0 0 auto; color: var(--ink); font-size: 12px; font-weight: 800; letter-spacing: .02em; }
.battle-lab-field-toggle .field-summary { flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--muted); font-size: 10px; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.battle-lab-field-toggle .field-chevron { width: 16px; flex: 0 0 auto; fill: none; stroke: #7a8580; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: transform .18s ease; }
.battle-lab-field.is-collapsed .field-chevron { transform: rotate(-90deg); }
.battle-lab-field-body { display: grid; gap: 12px; padding: 2px 16px 14px; }
.battle-lab-field.is-collapsed .battle-lab-field-body { display: none; }

.field-globals { display: flex; flex-wrap: wrap; gap: 9px 20px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.field-group { display: flex; align-items: center; gap: 8px; }
.field-group-label, .field-seg-label { color: #7f8985; font-family: "DM Mono",monospace; font-size: 8px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.field-seg { display: inline-flex; overflow: hidden; border: 1px solid #d6ddd7; border-radius: 8px; background: #fff; }
.field-seg .field-btn { border: 0; border-right: 1px solid #e4e9e3; border-radius: 0; }
.field-seg .field-btn:last-child { border-right: 0; }

.field-btn { padding: 5px 8px; border: 1px solid #d6ddd7; border-radius: 8px; background: #fff; color: #5c6763; font-size: 10px; font-weight: 650; line-height: 1.2; white-space: nowrap; cursor: pointer; transition: background .12s ease, color .12s ease, border-color .12s ease; }
.field-btn:hover { background: #f0f4ef; }
.field-btn.is-active { background: var(--teal); border-color: var(--teal); color: #fff; }
.field-btn.is-seg { padding: 5px 10px; }

.field-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.field-side { min-width: 0; }
.field-side.is-blue { padding-right: 18px; }
.field-side.is-red { padding-left: 18px; border-left: 1px solid var(--line); }
.field-side-head { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; color: var(--ink); font-size: 11px; font-weight: 800; }
.field-side-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; }
.field-side.is-blue .field-side-dot { background: #8daab9; }
.field-side.is-red .field-side-dot { background: #c78c96; }
.field-side-grid { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
/* Mirror the opponent side across the middle divider so it reads as a reflection of your side. */
.field-side.is-red .field-side-head { flex-direction: row-reverse; }
.field-side.is-red .field-side-grid { flex-direction: row-reverse; }
.field-side.is-blue .field-btn.is-active { background: #6d93a6; border-color: #6d93a6; color: #fff; }
.field-side.is-red .field-btn.is-active { background: #c07f8c; border-color: #c07f8c; color: #fff; }

.battle-lab-board { min-width: 1160px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: 18px; }
.battle-lab-side { min-width: 0; display: grid; align-content: start; gap: 18px; }
.battle-lab-card { overflow: visible; }
.battle-lab-card.is-blue { border-color: #b6cbd5; }
.battle-lab-card.is-red { border-color: #dbc0c5; }
.battle-lab-card.is-blue:hover { border-color: #94b5c4; }
.battle-lab-card.is-red:hover { border-color: #ca9ca4; }
/* Carry the blue outline through to the inner dividers (header underline + column split). */
.battle-lab-card.is-blue .battle-lab-card-header { border-bottom-color: #b6cbd5; }
.battle-lab-card.is-blue .battle-lab-card-columns .builder-column { border-right-color: #b6cbd5; }
/* Make the remove (X) legible instead of nearly invisible, keeping the neutral gray. */
.battle-lab-card .builder-remove { opacity: .85; }
/* [identity] [Autofill All] [ability/nature/item loadout] — loadout sized to match Team Builder's boxes.
   The middle column is a fixed width so toggling "Autofill All"/"Reset All" never resizes the loadout. */
.battle-lab-card-header { grid-template-columns: minmax(176px,.9fr) 60px minmax(258px,1.1fr); }
.battle-lab-identity-group { padding-left: 11px; }
.battle-lab-identity { min-width: 0; }
.battle-lab-name-row { display: flex; align-items: center; gap: 5px; }
.battle-lab-card-gender { flex: 0 0 auto; margin-left: 1px; font-family: "DM Mono",monospace; font-size: 14px; font-weight: 800; }
.battle-lab-card-gender.is-male { color: #668eaa; }
.battle-lab-card-gender.is-female { color: var(--accent); }
.battle-lab-identity .battle-lab-name-row > strong { display: block; min-width: 0; max-width: 132px; overflow: hidden; margin-top: 1px; color: var(--ink); font-size: 16px; font-weight: 800; line-height: 22px; letter-spacing: -.03em; text-overflow: clip; white-space: nowrap; }
.battle-lab-identity .type-list { display: flex; gap: 5px; margin-top: 6px; }
/* Right-align the button against the loadout and drop it to the ability value's line (Moxie). */
.battle-lab-autofill-slot { align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-start; padding-top: 39px; padding-right: 8px; }
.battle-lab-autofill-all { white-space: nowrap; }
.battle-lab-loadout { min-width: 0; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; padding: 0 12px 0 2px; }
.battle-lab-picker { min-width: 0; }
.battle-lab-picker .builder-picker-label { font-size: 11px; }
/* A long selected value (e.g. "Choice Scarf") should run to the box edge and hide behind the
   side line, not clip early into whitespace. Float the chevron so it stops reserving room, and
   let the control clip the overflow (no ellipsis). */
.battle-lab-picker .builder-picker-control { overflow: hidden; padding-right: 0; }
.battle-lab-picker .builder-picker-control > svg { position: absolute; right: 5px; top: 10px; }
/* When a mega stone is held, the swap button takes the chevron's spot; give it real room so the
   item name clips cleanly against it instead of whiting out under an overlapping chevron. */
.battle-lab-picker .builder-picker-control.has-mega-swap { padding-left: 4px; padding-right: 2px; gap: 2px; }
.battle-lab-picker .builder-picker-control.has-mega-swap > svg { display: none; }
.battle-lab-picker .builder-picker-control.has-mega-swap .mega-swap { margin-left: 0; }
.battle-lab-picker .builder-picker-control.has-mega-swap .builder-picker-leading img { width: 17px; height: 17px; }
/* Match .meta-lookup-btn's box exactly so "Status: …" lands in the same spot Meta Lookup did
   and lines up with "Autofill Moves" across the card. */
.battle-lab-status-condition { position: relative; flex: 0 0 auto; margin-left: auto; color: var(--teal); font-size: 10px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; cursor: pointer; }
.battle-lab-status-condition::after { content: ""; display: block; height: 1px; margin-top: 1px; background: currentColor; opacity: .45; }
.battle-lab-status-condition:hover { color: #3e684a; }
.battle-lab-status-panel { position: absolute; z-index: 90; top: calc(100% + 4px); right: 0; min-width: 150px; overflow: hidden; border: 1px solid #cdd9ce; border-radius: 9px; background: rgba(255,255,253,.995); box-shadow: 0 16px 38px rgba(28,41,38,.16); padding: 5px; }
.battle-lab-status-option { width: 100%; min-height: 30px; display: flex; align-items: center; padding: 4px 8px; border: 0; border-radius: 6px; background: transparent; color: #45514d; font-size: 10px; font-weight: 600; text-align: left; cursor: pointer; }
.battle-lab-status-option:hover, .battle-lab-status-option:focus-visible { outline: 0; background: #eaf2eb; color: var(--teal); }
.battle-lab-status-option.is-selected { background: #e6f0e7; color: var(--teal); }

.battle-lab-card-columns { grid-template-columns: minmax(305px,1.35fr) minmax(235px,1fr); }
.battle-lab-section-heading { height: 18px; }
.battle-lab-tabs { min-width: 0; height: 18px; display: flex; align-items: center; gap: 5px; }
.battle-lab-tabs > span { color: #c3c8c4; font-size: 10px; }
.battle-lab-tabs button { display: inline-flex; flex-direction: column; align-items: center; padding: 0; border: 0; background: transparent; color: #9aa29e; font-size: 11px; font-weight: 600; line-height: 18px; cursor: pointer; }
.battle-lab-tabs button::after { content: attr(data-title); height: 0; overflow: hidden; visibility: hidden; font-weight: 800; }
.battle-lab-tabs button:hover { color: #67736d; }
.battle-lab-tabs button.is-active { color: var(--ink); font-weight: 800; }
.battle-lab-stat-row { min-height: 24px; }
.battle-lab-stat-row .builder-sp-input { text-align: left; }

.battle-lab-mod-row { min-width: 0; min-height: 24px; display: grid; grid-template-columns: 31px minmax(102px,1fr) 48px minmax(58px,88px); align-items: center; gap: 6px; }
.battle-lab-stage-slots { min-width: 0; display: grid; grid-template-columns: repeat(6,minmax(14px,1fr)); gap: 2px; }
.battle-lab-stage-slots i { width: 5px; height: 5px; place-self: center; border-radius: 50%; background: #cbd1cc; }
.battle-lab-stage-slots i.is-filled { width: 11px; height: 9px; border-radius: 1px; }
.battle-lab-stage-slots.is-up i.is-filled { background: #d98a4b; clip-path: polygon(50% 0,100% 100%,0 100%); }
.battle-lab-stage-slots.is-down i.is-filled { background: #6495ae; clip-path: polygon(0 0,100% 0,50% 100%); }
.battle-lab-stage-stepper { width: 48px; height: 21px; display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; border: 1px solid #d6dfd7; border-radius: 6px; background: #fff; }
.battle-lab-stage-stepper button { min-width: 0; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: #66716c; font-size: 11px; line-height: 1; cursor: pointer; }
.battle-lab-stage-stepper button + button { border-left: 1px solid #dfe5df; }
.battle-lab-stage-stepper button:hover:not(:disabled) { background: #eff5ef; color: var(--teal); }
.battle-lab-stage-stepper button:disabled { color: #c5cac6; cursor: default; }
.battle-lab-mod-row.is-disabled .battle-lab-stage-slots { opacity: .45; }
.battle-lab-mod-row.is-disabled .battle-lab-stage-stepper { opacity: .55; }

.battle-lab-moves { position: relative; }
/* overflow:visible lets a move's dropdown escape the card instead of being clipped by its box. */
.battle-lab-moves-content { position: relative; min-height: 142px; border-radius: 7px; }
.battle-lab-move-list { display: grid; gap: 6px; }
.battle-lab-move-row { margin: 0 !important; }
.battle-lab-move-row > .builder-picker { width: 100%; }
.battle-lab-move-row .builder-picker-control { height: 31px; }
.battle-lab-move-row.has-move .builder-picker-control:hover { border-color: #a9bdaa; background: #f4f8f3; }
.battle-lab-move-row .builder-picker-selected-meta { gap: 4px; }
.battle-lab-move-row .builder-picker-selected-meta .move-pp { width: 31px; flex-basis: 31px; }
.battle-lab-move-row .builder-picker-selected-meta .matchup-type { padding: 3px 4px; font-size: 5.7px; }
.battle-lab-move-row .move-category > span { color: #fff; font-size: 7px; line-height: 1; }

.battle-lab-damage-dialog { --dialog-pointer-y: 50%; position: fixed; z-index: 180; top: 50%; width: min(660px,calc(50vw - 40px)); height: min(610px,calc(100vh - 96px)); min-height: 520px; padding: 10px; border: 1px solid #cdd8ce; border-radius: 16px; background: rgba(255,254,253,.992); box-shadow: 0 24px 68px rgba(29,42,36,.24); transform: translateY(calc(-50% - 14px)); pointer-events: none; }
.battle-lab-damage-dialog.is-blue { right: 24px; }
.battle-lab-damage-dialog.is-red { left: 24px; }
.battle-lab-dialog-grid { min-width: 0; height: 100%; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.battle-lab-dialog-column { min-width: 0; min-height: 0; display: grid; grid-template-rows: 24px minmax(0,1fr); }
.battle-lab-dialog-column.is-red { padding-left: 9px; border-left: 1px solid #e2e7e1; }
.battle-lab-dialog-column > header { min-width: 0; display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 6px; padding: 0 3px 5px; color: #7e8983; }
.battle-lab-dialog-column > header > span { width: 6px; height: 6px; border-radius: 50%; background: #8daab9; }
.battle-lab-dialog-column.is-red > header > span { background: #c78c96; }
.battle-lab-dialog-column > header strong { color: var(--ink); font-size: 12px; font-weight: 800; }
.battle-lab-dialog-column > header small { font-family: "DM Mono",monospace; font-size: 8.5px; }
.battle-lab-dialog-roster { min-height: 0; display: grid; grid-template-rows: repeat(6,minmax(0,1fr)); gap: 6px; }
.battle-lab-dialog-tile { min-width: 0; min-height: 0; display: grid; grid-template-rows: 26px minmax(0,1fr); overflow: hidden; border: 1px solid #dce4dc; border-radius: 9px; background: #fff; }
.battle-lab-dialog-tile > header { min-width: 0; display: grid; grid-template-columns: 27px minmax(0,1fr) auto; align-items: center; gap: 4px; padding: 0 6px 0 3px; border-bottom: 1px solid #e6eae5; }
.battle-lab-dialog-art { position: relative; width: 25px; height: 23px; overflow: hidden; }
.battle-lab-dialog-art img { position: absolute; width: 23px; height: 23px; inset: 50% auto auto 50%; object-fit: contain; transform: translate(-50%,-50%); }
.battle-lab-dialog-identity { min-width: 0; display: flex; align-items: center; gap: 3px; overflow: hidden; white-space: nowrap; }
.battle-lab-dialog-identity > strong { min-width: 0; overflow: hidden; flex: 0 1 auto; color: var(--ink); font-size: 10.5px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.battle-lab-dialog-gender { flex: 0 0 auto; font-family: "DM Mono",monospace; font-size: 9.5px; font-weight: 800; }
.battle-lab-dialog-gender.is-male { color: #668eaa; }
.battle-lab-dialog-gender.is-female { color: var(--accent); }
.battle-lab-dialog-types { min-width: 0; display: inline-flex; flex: 0 1 auto; gap: 2px; overflow: hidden; }
.battle-lab-dialog-types .matchup-type { flex: 0 0 auto; padding: 2px 4px; font-size: 6px; }
.battle-lab-dialog-metric { min-width: 0; overflow: hidden; color: var(--ink); font-size: 10.5px; font-weight: 800; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.battle-lab-dialog-copy { min-width: 0; min-height: 0; display: grid; align-content: center; gap: 3px; padding: 5px 7px; overflow: hidden; color: #67726d; }
.battle-lab-dialog-copy span { overflow: hidden; font-size: 9.8px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.battle-lab-dialog-copy span.battle-lab-dialog-note { color: var(--teal); font-weight: 700; white-space: normal; text-overflow: clip; }
.battle-lab-dialog-tile.is-attacker.is-blue { border-color: #9ebbc9; background: #edf3f4; }
.battle-lab-dialog-tile.is-attacker.is-red { border-color: #d3aab1; background: #faeef2; }
.battle-lab-dialog-tile.is-empty { display: grid; place-items: center; border-style: dashed; background: #fbfbf8; color: #abb2ad; font-size: 9.5px; }

.battle-lab-empty { min-height: 0; display: grid; justify-items: center; align-content: center; padding: 80px 20px; border: 1px dashed #c8d5c9; border-radius: 14px; background: transparent; text-align: center; }
.battle-lab-side.is-blue .battle-lab-empty { border-color: #b8ccd7; }
.battle-lab-side.is-red .battle-lab-empty { border-color: #d9bfc3; }
.battle-lab-empty h2 { margin: 0; font-size: 18px; }
.battle-lab-empty p { max-width: 310px; margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.battle-lab-notice { position: fixed; z-index: 170; left: 50%; bottom: 22px; max-width: min(420px,calc(100vw - 30px)); padding: 9px 14px; border: 1px solid #aec3b1; border-radius: 9px; background: #f8fcf7; box-shadow: 0 12px 30px rgba(37,52,42,.16); color: var(--teal); font-size: 9px; font-weight: 700; opacity: 0; pointer-events: none; transform: translate(-50%,8px); transition: opacity .16s ease, transform .16s ease; }
.battle-lab-notice.is-visible { opacity: 1; transform: translate(-50%,0); }
.battle-lab-notice.is-error { border-color: #ddb9c4; background: #fff8fa; color: #9c4f68; }

@media (max-width: 1180px) {
  .battle-lab-root { overflow-x: auto; padding-bottom: 16px; }
}
