:root {
  --bg: #060b16;
  --bg2: #0a1120;
  --panel: rgba(13, 18, 34, 0.74);
  --panel-strong: rgba(16, 22, 40, 0.94);
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #edf2ff;
  --muted: #8f9ab9;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --danger: #ff5d7b;
  --success: #28d17c;
  --warning: #fbbf24;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(139, 92, 246, 0.20), transparent 30%),
    radial-gradient(circle at top right, rgba(34, 211, 238, 0.16), transparent 26%),
    linear-gradient(180deg, #050815 0%, #07101f 38%, #09111d 100%);
  overflow-x: hidden;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; border: none; transition: transform .16s ease, opacity .16s ease, box-shadow .16s ease, border-color .16s ease, filter .16s ease; }
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); opacity: .96; }
button:disabled { cursor: not-allowed; opacity: .56; transform: none; }

.hidden { display: none !important; }
.wrap { flex-wrap: wrap; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.note {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: .22;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.55), rgba(0,0,0,.05));
}

.bg-orb {
  position: fixed;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(42px);
  opacity: .34;
  pointer-events: none;
}
.orb-a { left: -120px; top: -100px; background: rgba(139, 92, 246, 0.60); }
.orb-b { right: -150px; top: 160px; background: rgba(34, 211, 238, 0.44); }

body[data-page="battle"] {
  overflow: hidden;
}

.shell {
  width: min(1440px, calc(100vw - 18px));
  margin: 0 auto;
  padding: 14px 0 28px;
}

.glass {
  background: linear-gradient(180deg, rgba(20, 28, 50, 0.84), rgba(11, 16, 32, 0.70));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.panel {
  border-radius: var(--radius-xl);
  padding: 18px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}
.hero h1 {
  margin: 6px 0 10px;
  font-size: clamp(38px, 6vw, 64px);
  line-height: .95;
  letter-spacing: -0.06em;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.subtitle {
  margin: 0;
  max-width: 760px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 15px;
}
.hero-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  justify-content: flex-start;
  min-width: 170px;
}
.pill {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.04);
  white-space: nowrap;
  font-size: 13px;
}
.pill.soft { color: var(--muted); }

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  margin-bottom: 14px;
  position: sticky;
  top: 10px;
  z-index: 12;
}
.tab-btn {
  padding: 12px 15px;
  border-radius: 16px;
  background: rgba(255,255,255,.03);
  color: var(--text);
  border: 1px solid transparent;
  font-weight: 700;
}
.tab-btn.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, .92), rgba(34, 211, 238, .78));
  border-color: rgba(255,255,255,.08);
  box-shadow: 0 12px 32px rgba(34, 211, 238, .14);
}

.content-grid { display: grid; gap: 14px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.grid-2 {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 14px;
}
.panel-head.compact { margin-bottom: 10px; }
.panel h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -.02em;
}

.field { display: grid; gap: 8px; margin-bottom: 12px; }
.field span { font-size: 13px; color: var(--muted); }
input, textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 13px 14px;
  color: var(--text);
  outline: none;
  background: rgba(255,255,255,0.04);
  resize: vertical;
}
input:focus, textarea:focus {
  border-color: rgba(139, 92, 246, .72);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, .16);
}

.btn {
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 800;
  letter-spacing: .01em;
  border: 1px solid transparent;
}
.btn.primary {
  background: linear-gradient(135deg, rgba(139, 92, 246, 1), rgba(34, 211, 238, .95));
  color: white;
  box-shadow: 0 16px 40px rgba(34, 211, 238, .18);
}
.btn.secondary {
  background: rgba(255,255,255,.04);
  color: var(--text);
  border-color: var(--line);
}
.btn.danger {
  background: rgba(255, 93, 123, .11);
  color: #ffd0db;
  border-color: rgba(255, 93, 123, .24);
}
.btn.ghost {
  background: rgba(255,255,255,.04);
  color: var(--text);
  border-color: rgba(255,255,255,.12);
}

.surface, .raw-box {
  border-radius: 22px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.09);
  min-height: 260px;
  padding: 18px;
}
.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.big-action {
  width: 100%;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(139, 92, 246, .18);
  background: linear-gradient(135deg, rgba(139, 92, 246, .16), rgba(34, 211, 238, .10));
  color: var(--text);
  margin-bottom: 12px;
}
.big-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(255,255,255,.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15);
  font-size: 26px;
}
.big-title { font-weight: 900; font-size: 16px; }
.mini-stat {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  font-size: 13px;
  color: var(--muted);
}

.inventory-grid {
  display: grid;
  gap: 12px;
  max-height: 640px;
  overflow: auto;
  padding-right: 2px;
}
.inv-card {
  display: grid;
  gap: 10px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  padding: 12px;
  cursor: pointer;
}
.inv-card.selected {
  border-color: rgba(34, 211, 238, .42);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, .10);
}
.inv-card .top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}
.inv-card .title { font-weight: 900; font-size: 15px; }
.inv-card .rarity {
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.inv-card .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.inv-card .stat {
  padding: 10px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
}
.inv-card .stat span { display:block; font-size: 10px; color: var(--muted); letter-spacing:.12em; margin-bottom: 4px; }
.inv-card .stat b { font-size: 17px; }
.inv-card .moves { display: grid; gap: 8px; }

.card {
  border-radius: 24px;
  padding: 18px;
  background:
    radial-gradient(circle at top, rgba(255,255,255,.10), transparent 35%),
    linear-gradient(180deg, rgba(21, 28, 46, .96), rgba(9, 12, 24, .98));
  border: 1px solid rgba(255,255,255,.10);
}
.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}
.card-name { font-size: 20px; font-weight: 950; letter-spacing: -.04em; }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.rarity-badge {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .16em;
  white-space: nowrap;
}
.card-art {
  min-height: 120px;
  border-radius: 20px;
  margin-bottom: 14px;
  background:
    radial-gradient(circle at 28% 30%, rgba(34, 211, 238, .20), transparent 36%),
    radial-gradient(circle at 72% 60%, rgba(139, 92, 246, .26), transparent 40%),
    linear-gradient(135deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.06);
  display: grid;
  place-items: center;
  text-transform: uppercase;
  letter-spacing: .32em;
  font-size: 12px;
  color: rgba(255,255,255,.68);
}
.card-art::after { content: 'AI CREATURE'; }
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stat-chip, .status-chip, .stat-row {
  border-radius: 16px;
  padding: 10px 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
}
.stat-chip span, .status-chip span, .stat-row span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .12em;
  margin-bottom: 5px;
}
.stat-chip b, .status-chip b, .stat-row b { font-size: 18px; }
.card-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
}
.abilities {
  display: grid;
  gap: 8px;
}
.ability {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  display: grid;
  gap: 4px;
}
.ability .a-title { font-weight: 900; }
.ability .a-desc { color: var(--muted); font-size: 12px; line-height: 1.45; }

.log-list {
  display: grid;
  gap: 10px;
  max-height: 640px;
  overflow: auto;
  padding-right: 2px;
}
.log-item {
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  padding: 12px 13px;
}
.log-item .log-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}
.log-item .log-title { font-weight: 800; }
.log-item .log-time { color: var(--muted); font-size: 11px; }
.log-item .log-body { color: var(--muted); font-size: 13px; line-height: 1.45; }
.log-item.success { border-color: rgba(40, 209, 124, .24); }
.log-item.warn { border-color: rgba(251, 191, 36, .24); }
.log-item.error { border-color: rgba(255, 93, 123, .28); }
.log-item.ai { border-color: rgba(34, 211, 238, .24); }

.stats-stack { display: grid; gap: 12px; }
.stat-row { display:flex; justify-content:space-between; align-items:center; gap: 12px; }
.stat-row span { margin: 0; }
.stat-row b { font-size: 18px; }

.raw-box {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 640px;
  overflow: auto;
  color: #d7def5;
  line-height: 1.5;
}

/* BATTLE PAGE */
.battle-shell {
  height: calc(100dvh - 12px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: 10px;
}
.battle-hero {
  margin-bottom: 12px;
  flex: 0 0 auto;
}
.battle-hero h1 { margin-bottom: 8px; }
.battle-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.battle-grid-main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, .72fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.arena-panel {
  padding: 14px;
  min-height: 0;
  display: flex;
}
.arena-stack {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 54px minmax(0, 1fr);
  gap: 10px;
}
.vs-bubble {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto;
  background: linear-gradient(135deg, rgba(139, 92, 246, .92), rgba(34, 211, 238, .86));
  font-weight: 950;
  box-shadow: 0 16px 40px rgba(34, 211, 238, .16);
  flex: 0 0 auto;
}
.fighter-card {
  border-radius: 22px;
  padding: 13px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  min-height: 0;
  display: grid;
  gap: 10px;
}
.fighter-head { display:flex; justify-content:space-between; gap: 10px; align-items:start; }
.fighter-name { font-size: 19px; font-weight: 950; letter-spacing: -.03em; }
.fighter-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.fighter-badge {
  padding: 8px 11px;
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
}
.fighter-badge.accent {
  background: linear-gradient(135deg, rgba(139, 92, 246, .88), rgba(34, 211, 238, .78));
}
.hp-line {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  overflow: hidden;
}
.hp-line span {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(40,209,124,1), rgba(34,211,238,1));
}
.fighter-stats.compact {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.fighter-stats.compact div, .status-grid .status-chip {
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
}
.fighter-stats.compact span, .status-grid span { display:block; font-size: 10px; color: var(--muted); letter-spacing:.10em; margin-bottom: 4px; }
.fighter-stats.compact b, .status-grid b { font-size: 16px; }
.fighter-status {
  padding: 10px 11px;
  border-radius: 16px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.07);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  min-height: 42px;
}
.fighter-moves {
  display: grid;
  gap: 7px;
}
.move-pill {
  display:flex;
  justify-content:space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 11px;
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.07);
}
.move-pill .m-name { font-weight: 900; font-size: 13px; }
.move-pill .m-desc { color: var(--muted); font-size: 11px; line-height: 1.3; }
.moves-panel {
  padding: 14px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.battle-actions-panel { overflow: hidden; }
.round-chip {
  display: inline-flex;
  align-self: flex-start;
  margin-bottom: 10px;
  padding: 8px 11px;
  border-radius: 999px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.moves-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  flex: 1;
  min-height: 0;
}
.move-btn {
  min-height: 0;
  padding: 12px;
  border-radius: 16px;
  text-align: left;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  color: var(--text);
  display: grid;
  align-content: start;
  gap: 6px;
}
.move-btn .name { font-weight: 950; font-size: 14px; }
.move-btn .desc { color: var(--muted); font-size: 11px; line-height: 1.35; }
.move-btn.ready {
  background: linear-gradient(135deg, rgba(139, 92, 246, .18), rgba(34, 211, 238, .10));
  border-color: rgba(34, 211, 238, .20);
}
.move-btn.locked { opacity: .56; }
.turn-info.slim {
  min-height: 0;
  padding: 11px;
  margin-top: 0;
}
.history-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
}
.history-modal.hidden { display: none; }
.history-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 16, .70);
  backdrop-filter: blur(8px);
}
.history-sheet {
  position: relative;
  width: min(760px, calc(100vw - 18px));
  max-height: min(88dvh, 860px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}
.battle-log-list {
  max-height: none;
  overflow: auto;
}
@media (max-width: 1100px) {
  .grid-2, .battle-grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { width: min(100vw - 12px, 100%); padding-top: 8px; }
  .panel, .arena-panel, .moves-panel { padding: 12px; }
  .hero { flex-direction: column; }
  .hero-meta { align-items: flex-start; flex-direction: row; flex-wrap: wrap; min-width: 0; }
  .tabs {
    position: fixed;
    left: 6px;
    right: 6px;
    bottom: 6px;
    top: auto;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    border-radius: 22px;
  }
  .tab-btn { padding: 10px 6px; font-size: 10px; text-align:center; min-width: 0; }
  .content-grid { padding-bottom: 82px; }
  .grid-2 { gap: 12px; }
  .stats-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fighter-stats.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .moves-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .surface, .raw-box { min-height: 200px; }
  .inventory-grid, .log-list { max-height: none; }
  .battle-shell {
    height: calc(100dvh - 10px);
    overflow: hidden;
  }
  .battle-grid-main {
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 0;
  }
  .arena-stack {
    grid-template-rows: minmax(0, .93fr) 44px minmax(0, .93fr);
    gap: 8px;
  }
  .fighter-card {
    padding: 11px;
    gap: 8px;
  }
  .fighter-moves {
    display: none;
  }
  .fighter-name { font-size: 17px; }
  .fighter-sub { font-size: 11px; }
  .fighter-badge { font-size: 9px; padding: 7px 9px; }
  .hp-line { height: 10px; }
  .fighter-status { padding: 9px 10px; min-height: 36px; }
  .move-pill { padding: 9px 10px; }
  .move-pill .m-name { font-size: 12px; }
  .move-pill .m-desc { font-size: 10px; }
  .moves-panel { min-height: 160px; }
  .history-sheet { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); }
}

.inv-card .title, .inv-card .stat b, .inv-card .moves .a-title { color: var(--text); }
.inv-card .moves .a-desc { color: var(--muted); }

.wiki-grid { align-items: start; }
.wiki-block {
  padding: 14px 14px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.08);
  margin-bottom: 10px;
}
.wiki-block h3 {
  margin: 0 0 8px;
  font-size: 15px;
  letter-spacing: -.02em;
}
.wiki-block p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

/* ===== battle scroll/layout override ===== */
body[data-page="battle"] {
  overflow-x: hidden;
  overflow-y: auto;
  height: auto;
  min-height: 100dvh;
}

body[data-page="battle"] .battle-shell {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
  padding-bottom: 20px;
}

body[data-page="battle"] .battle-grid-main {
  overflow: visible;
  min-height: 0;
  align-items: start;
}

body[data-page="battle"] .arena-panel,
body[data-page="battle"] .battle-actions-panel {
  overflow: visible;
}

body[data-page="battle"] .battle-actions-panel {
  min-height: 0;
}

@media (max-width: 760px) {
  body[data-page="battle"] .battle-shell {
    height: auto;
    min-height: 100dvh;
    padding-bottom: 110px;
  }

  body[data-page="battle"] .battle-grid-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    overflow: visible;
  }

  body[data-page="battle"] .arena-stack {
    grid-template-rows: auto auto auto;
  }

  body[data-page="battle"] .moves-grid {
    grid-template-columns: 1fr;
  }

  body[data-page="battle"] .battle-hero-right {
    width: 100%;
  }

  body[data-page="battle"] .battle-actions {
    flex-wrap: wrap;
  }

  body[data-page="battle"] .battle-actions .btn,
  body[data-page="battle"] .pill {
    min-width: 0;
  }
}


/* ===== battle scroll/layout fix v6 ===== */
body[data-page="battle"] {
  overflow-x: hidden;
  overflow-y: auto;
  height: auto;
  min-height: 100dvh;
}

body[data-page="battle"] .battle-shell {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
  padding-bottom: 28px;
}

body[data-page="battle"] .battle-hero {
  margin-bottom: 12px;
}

body[data-page="battle"] .battle-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, .92fr);
  gap: 12px;
  align-items: start;
  overflow: visible;
}

body[data-page="battle"] .arena-panel,
body[data-page="battle"] .battle-actions-panel {
  overflow: visible;
  min-height: 0;
}

body[data-page="battle"] .arena-panel {
  display: block;
}

body[data-page="battle"] .arena-grid {
  display: grid;
  grid-template-rows: auto 54px auto;
  gap: 12px;
  min-height: 0;
  align-items: stretch;
}

body[data-page="battle"] .fighter-card.compact {
  min-height: 0;
}

body[data-page="battle"] .battle-actions-panel {
  display: flex;
  flex-direction: column;
}

body[data-page="battle"] .moves-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
}

body[data-page="battle"] .moves-note {
  margin-top: 12px;
}

body[data-page="battle"] .battle-log-list {
  max-height: min(68dvh, 760px);
  overflow: auto;
}

@media (max-width: 980px) {
  body[data-page="battle"] .battle-stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
}

@media (max-width: 760px) {
  body[data-page="battle"] .battle-shell {
    padding-bottom: 24px;
  }

  body[data-page="battle"] .battle-stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 10px;
  }

  body[data-page="battle"] .arena-grid {
    grid-template-rows: auto 44px auto;
    gap: 10px;
  }

  body[data-page="battle"] .moves-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  body[data-page="battle"] .battle-log-list {
    max-height: min(58dvh, 620px);
  }
}
