/* Battle playback. Your lanes on the left, theirs mirrored on the right. */
.battle-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 8px 0 14px; margin-bottom: 14px; border-bottom: 1px solid var(--rule); }
.versus { display: flex; align-items: baseline; gap: 10px; font: 22px/1.1 var(--display); flex: 1; min-width: 0; }
.versus .vs { font: italic 16px var(--serif); color: var(--on-board-soft); }
.versus .side-b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.battle-wrap {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 10px 20px; align-items: start;
  grid-template-areas: "board bar" "board log"; grid-template-rows: auto 1fr;
}
.board-wrap { position: relative; grid-area: board; }
.battle-bar { grid-area: bar; display: flex; flex-direction: column; gap: 10px; }
.battle-log { grid-area: log; }
.board { display: flex; flex-direction: column; gap: 12px; }
.lane-row { display: grid; grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr); align-items: center; gap: 10px; }
.lane-tag {
  text-align: center; font: 15px/1 var(--display); color: var(--on-board-soft);
  writing-mode: horizontal-tb; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 6px 0;
}
.cell { min-width: 0; }
.cell .card { position: relative; }
.cell.empty {
  min-height: 110px; display: grid; place-items: center; border-radius: var(--r);
  background: rgba(0,0,0,.22); box-shadow: inset 0 2px 8px rgba(0,0,0,.45); border: 1px solid #15110d; color: var(--on-board-soft); font-family: var(--serif); font-style: italic;
}
.card.acting { box-shadow: var(--plate), 0 0 0 3px var(--gold), 0 10px 22px rgba(0,0,0,.45); }
.order-badge {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font: 700 12px/1 var(--ui);
  background: var(--board); color: var(--gold); border: 1px solid var(--gold);
}
.card.mirrored .order-badge { right: auto; left: -8px; }
.card.dead .order-badge { display: none; }

.fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.fx-line {
  position: absolute; height: 3px; transform-origin: 0 50%; border-radius: 3px;
  animation: line-draw .6s ease-out forwards;
}
.fx-line.attack { background: linear-gradient(90deg, transparent, #f2e3c4); }
.fx-line.harm { background: linear-gradient(90deg, transparent, var(--effect)); height: 2px; }
.fx-line.help { background: linear-gradient(90deg, transparent, var(--win)); height: 2px; }
@keyframes line-draw { 0% { clip-path: inset(0 100% 0 0); opacity: 1; } 50% { clip-path: inset(0 0 0 0); opacity: 1; } 100% { opacity: 0; } }

.floater {
  position: absolute; left: 50%; top: 30%; transform: translate(-50%, 0);
  font: 700 22px/1 var(--ui); pointer-events: none; white-space: nowrap;
  text-shadow: 0 1px 0 #fff, 0 0 8px rgba(255,255,255,.8);
  animation: float-up 1.05s ease-out forwards; z-index: 5;
}
.floater.harm { color: #a3261a; }
.floater.help { color: #3d6b28; }
.floater.dim { color: var(--ink-soft); font-size: 15px; }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -34px) scale(1); } }

.battle-status { font: 24px/1 var(--display); }
.battle-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.battle-controls .speed.on { background: var(--board-3); border-color: var(--gold); color: var(--gold); }
.battle-log {
  list-style: none; margin: 0; padding: 10px 12px; max-height: 420px; overflow: auto;
  background: var(--board-2); border: 1px solid var(--rule); border-radius: 12px;
  font: 15px/1.35 var(--serif); display: flex; flex-direction: column; gap: 3px;
}
.battle-log li { padding-left: 8px; border-left: 2px solid transparent; }
.battle-log li.side-0 { border-left-color: var(--gold); }
.battle-log li.side-1 { border-left-color: #6f8796; }
.battle-log li.cycle { font: 16px/1.2 var(--display); color: var(--gold); margin-top: 6px; }
.battle-log li.fire { color: #e7cf98; }
.battle-log li.dim { color: var(--on-board-soft); font-style: italic; }
.battle-log li.death { color: #e79a8b; font-weight: 600; }

.result-banner {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 8, 6, .55); animation: fade-in .3s;
}
.result-card {
  background: var(--grain), var(--paper); color: var(--ink); border-radius: 14px; padding: 26px 30px; text-align: center;
  box-shadow: inset 0 0 0 6px var(--paper), inset 0 0 0 7px rgba(107,90,69,.35), var(--shadow); max-width: 440px; width: 100%;
}
.result-card h2 { font-size: 44px; }
.result-banner.win h2 { color: #3d6b28; }
.result-banner.loss h2 { color: #8e2b1d; }
.result-card p { font: italic 18px var(--serif); margin: 6px 0 18px; color: var(--ink-soft); }
.row.center { justify-content: center; }
.result-card button.ghost { color: var(--ink); border-color: var(--paper-edge); }
.result-card button.ghost:hover:not(:disabled) { background: var(--paper-2); }
@keyframes fade-in { from { opacity: 0; } }

@media (max-width: 980px) {
  .battle-wrap { grid-template-columns: minmax(0, 1fr); grid-template-areas: "board" "bar" "log"; grid-template-rows: auto; }
  .battle-bar {
    position: sticky; bottom: 0; z-index: 20; flex-direction: row; align-items: center; flex-wrap: wrap;
    margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(28,24,19,.85), var(--board) 35%); border-top: 1px solid var(--rule);
  }
  .battle-status { font-size: 20px; flex: 1; min-width: 120px; }
  .battle-log { max-height: 260px; }
}
@container (max-width: 190px) {
  .cell .card-portrait { aspect-ratio: 2 / 1; }
}
@media (max-width: 720px) {
  .lane-row { grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr); gap: 6px; }
  .lane-tag { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 12px; padding: 0 3px; border: 0; border-left: 1px solid var(--rule); }
  .versus { font-size: 18px; }
  .floater { font-size: 18px; }
}
