/* Original battle visual system; only five-slot rule capacity and full prints. */
.loan-op-match .field,.battle-v05.loan-op-match .r7-arena .field{display:flex;justify-content:flex-start;align-items:center;overflow-x:auto;overflow-y:visible;gap:8px;padding:4px;scrollbar-width:thin}
.loan-op-match .field>.unit-wrap,.loan-op-match .field>.slot{flex:0 0 var(--board-card);width:var(--board-card)}
.loan-op-match .loan-printed-face{padding:0;border:0;border-radius:0;background:transparent;box-shadow:none}
.loan-op-match .loan-printed-face>.runtime-surface{background:transparent!important}
.loan-op-match .leader-wrap>.playing-card{width:100%}
.loan-op-match .current-state{pointer-events:none}
.loan-op-match .showcase{display:flex;gap:12px;flex-wrap:wrap;justify-content:center}
.loan-op-match .showcase .playing-card{width:130px}
.loan-op-match .zoom-actions{display:flex;gap:10px;flex-wrap:wrap}
.loan-op-match .zoom-actions button{min-height:44px}
.loan-op-match .side-rail .status-line{max-height:100%;overflow-y:auto}

/* Original-source citations only: retain the normal readable color in every link state. */
.loan-op-match #battle-modal .card-extra a[href^="https://"]:link,
.loan-op-match #battle-modal .card-extra a[href^="http://"]:link,
.loan-op-match #battle-modal .card-extra a[href^="https://"]:visited,
.loan-op-match #battle-modal .card-extra a[href^="http://"]:visited,
.loan-op-match #battle-modal .card-extra a[href^="https://"]:focus-visible,
.loan-op-match #battle-modal .card-extra a[href^="http://"]:focus-visible{color:#d8f2e5}

/* Pending attacks in loan, owned CPU and guided practice. */
.loan-op-match .loan-attack-vector {
  position:absolute;
  inset:0;
  display:block;
  width:100%;
  height:100%;
  visibility:hidden;
  pointer-events:none;
}
/* Cross the center tray with a thin, noninteractive core above its opaque fill. */
.loan-op-match .r7-arena > .game-fx:has(.loan-attack-vector) {z-index:10}
.loan-op-match .loan-attack-bolt,
.loan-op-match .loan-attack-sparks {
  fill:none;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.loan-op-match .loan-attack-bolt {
  stroke:#fff1c5;
  stroke-width:2.5;
  filter:drop-shadow(0 0 2px #f9a44e) drop-shadow(0 0 5px #ffc65eb3);
}
.loan-op-match .loan-attack-sparks {stroke:#ffc66a;stroke-width:1.4;opacity:.72}
.loan-op-match .loan-attack-tip {fill:#fff1c5;filter:drop-shadow(0 0 3px #ffac53)}
.loan-op-match .playing-card[data-attack-role="source"] {outline:3px solid #ffe1a0;outline-offset:-3px}
.loan-op-match .playing-card[data-attack-role="target"] {outline:3px dashed #ffac86;outline-offset:-3px}
.loan-op-match .loan-attack-arrival .loan-attack-bolt {animation:loan-attack-travel .28s ease-out both}
.loan-op-match .loan-attack-arrival .loan-attack-sparks {animation:loan-attack-sparks-in .28s ease-out both}
.loan-op-match .loan-attack-arrival .loan-attack-tip {animation:loan-attack-tip-in .28s ease-out both}
@keyframes loan-attack-travel {
  from {stroke-dasharray:1;stroke-dashoffset:1}
  to {stroke-dasharray:1;stroke-dashoffset:0}
}
@keyframes loan-attack-sparks-in {
  0%,60% {opacity:0}
  100% {opacity:.72}
}
@keyframes loan-attack-tip-in {
  0%,65% {opacity:0}
  100% {opacity:1}
}
@media(prefers-reduced-motion:reduce) {
  .loan-op-match .loan-attack-arrival :is(.loan-attack-bolt,.loan-attack-sparks,.loan-attack-tip) {animation:none}
}
.reduced .loan-op-match .loan-attack-arrival :is(.loan-attack-bolt,.loan-attack-sparks,.loan-attack-tip),
.reduced.loan-op-match .loan-attack-arrival :is(.loan-attack-bolt,.loan-attack-sparks,.loan-attack-tip) {animation:none}

/* Compact battle keeps all five character slots visible while the hand can scroll. */
@media (max-width: 799px) {
  body:has(> #borrowed-editor:not([hidden])) > .prototype-state-badge,
  body:has(> #free-battle-root.loan-op-match:not([hidden])) > .prototype-state-badge {
    position: static;
    display: table;
    margin: 4px 8px 4px auto;
    max-width: calc(100% - 16px);
  }

  .loan-op-match .r7-arena {
    --leader-card: clamp(54px, 16vw, 88px);
  }
  .loan-op-match .r7-arena > .battle-side {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    gap: 4px;
  }
  .loan-op-match .side-rail .status-line {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 4px 8px !important;
    max-height: none;
    overflow: visible;
  }
  .loan-op-match .side-rail .status-line > button {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .loan-op-match .side-rail .barrier {
    padding-inline: 6px;
  }

  .loan-op-match .r7-arena .duel-row {
    min-height: 0;
    gap: 6px;
    align-items: start;
  }
  .battle-v05.loan-op-match .r7-arena .field {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: start;
    gap: 4px;
    padding: 2px;
    box-sizing: border-box;
    overflow: visible;
  }
  .loan-op-match .r7-arena .field > :is(.unit-wrap, .slot),
  .loan-op-match .r7-arena .field .unit-card {
    width: 100%;
    max-width: none;
  }
  .loan-op-match .r7-arena :is(.unit-card, .leader-card) > .current-state {
    display: block;
    width: 100%;
    min-height: 0;
    padding: 2px;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .loan-op-match .r7-arena :is(.unit-card, .leader-card) > .current-state > span {
    display: block;
  }
}

/* Hand types occupy a separate row under the complete card image. */
.loan-op-match .r7-arena .hand > .loan-hand-card {
  display:grid;
  grid-template-rows:minmax(0,1fr) auto;
}
.loan-op-match .loan-hand-card > .loan-printed-face {
  height:100%;
  min-height:0;
  aspect-ratio:auto;
}
.loan-op-match .loan-hand-type {
  color:#fff4d6;
  background:#102d31;
  font:700 11px/16px system-ui,sans-serif;
  text-align:center;
}
.loan-op-match .card-type-usage {
  padding:6px 9px;
  border-inline-start:2px solid #d5b86b;
  line-height:1.55;
}

/* Keep status labels readable on short, wide screens with a narrow side rail. */
@media (min-width: 800px) and (max-width: 1024px) and (max-height: 500px) and (orientation: landscape) {
  .loan-op-match .side-rail .status-line {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .loan-op-match .side-rail .status-line > :is(.barriers, .zone-count:nth-child(3), .zone-count:last-child) {
    grid-column: 1 / -1;
  }
  .loan-op-match .side-rail .status-line > .zone-count {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* Show the same attack route when a compact viewport cuts off a card. */
.loan-op-match .loan-attack-route[hidden] {display:none}
@media (max-width: 600px) and (orientation: portrait), (max-width: 1024px) and (max-height: 500px) and (orientation: landscape) {
  .loan-op-match .loan-attack-route {
    position:fixed;
    z-index:11;
    top:8px;
    left:50%;
    transform:translateX(-50%);
    display:flex;
    align-items:center;
    gap:8px;
    width:max-content;
    max-width:calc(100% - 32px);
    padding:5px 10px 6px;
    border:1px solid #d5b86b;
    border-radius:8px;
    color:#fff1c5;
    background:#0b2128;
    box-shadow:0 2px 8px #000a;
    font:700 13px/1.24 system-ui,sans-serif;
    pointer-events:none;
  }
  .loan-op-match .loan-attack-route > span {min-width:0;overflow-wrap:anywhere}
  .loan-op-match .loan-attack-route small {display:block;color:#e9d7b0;font-size:11px}
  .loan-op-match .loan-attack-route svg {width:32px;height:17px;flex:none;overflow:visible}
  .loan-op-match .loan-attack-route svg path {fill:none;stroke:#fff1c5;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
  .loan-op-match .loan-attack-route svg .loan-attack-route-tip {fill:#fff1c5;stroke:none}
}

/* Keep the existing legal actions and their confirmation flow. */
.loan-op-match .modal-head{flex-wrap:wrap;gap:6px}
.loan-op-match .modal-head-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:6px}
.loan-op-match .modal-head-actions button,.loan-op-match .center-line .end-turn-action,.loan-op-match .action-tray :is(.reaction-choices,.reaction-pass,.cancel-target-button){min-height:44px;font-weight:750}
.loan-op-match .center-line .end-turn-action,.loan-op-match .action-tray .reaction-choices{background:#f0d592;color:#162825;border:2px solid #f7e3ad;padding-inline:10px}
.loan-op-match .action-tray .reaction-pass,.loan-op-match .cancel-target-button{background:#273e49;color:#fff5dd;border:1px solid #d9c58e}
.loan-op-match .arena .playing-card[data-reaction-label]::after,.loan-op-match .showcase .playing-card[data-reaction-label]::after{content:attr(data-reaction-label);position:absolute;top:3px;right:3px;z-index:3;padding:2px 5px;border-radius:4px;background:#f0d592;color:#162825;font:800 12px/1.2 system-ui,sans-serif;pointer-events:none}
.loan-op-match .arena .playing-card[data-reaction-label],.loan-op-match .showcase .playing-card[data-reaction-label]{position:relative}
