:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #657087;
  --line: #dfe4ec;
  --panel: #ffffff;
  --page: #f4f6f9;
  --blue: #1d63d8;
  --blue-dark: #174faa;
  --red: #d94452;
}

* { box-sizing: border-box; }

/* Manual battles are a text-first working surface, without sprite placeholders. */
.turn-toolbar, .turn-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.turn-actions { margin: 18px 0 10px; }
.turn-switch-actions { display: contents; }
.turn-action-button { min-height: 48px; padding-inline: 18px; }
.turn-action-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.turn-action-button:disabled { cursor: not-allowed; opacity: .48; }
.turn-clock { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 16px 0; font-variant-numeric: tabular-nums; }
.turn-clock strong { font-size: 24px; }
.turn-combatants, .turn-team { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.turn-combatants section, .turn-team section { padding: 14px; border: 1px solid var(--line); border-radius: 8px; }
.turn-combatants h3, .turn-team h3 { margin: 0 0 6px; }
.turn-combatant-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.turn-combatant-heading h3 { margin-right: 3px; }
.turn-combatants p, .turn-team p { margin: 4px 0 8px; }
.turn-meter-label { display: block; margin-top: 6px; font-size: 14px; color: var(--muted); }
.turn-combatants .energy-track, .turn-team .energy-track { margin-top: 0; height: 9px; }
.turn-numeric { font-variant-numeric: tabular-nums; font-size: 14px; }
.turn-hide-numbers .turn-numeric { display: none; }
.turn-help { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.turn-log { max-height: 280px; min-height: 90px; overflow: auto; white-space: pre-wrap; font-size: 14px; background: #f4f6f9; padding: 12px; }
#turn-status { margin: 12px 0; }
#turn-status.error { color: var(--red); }
.turn-team { margin-top: 12px; }
@media (max-width: 640px) {
  .turn-combatants, .turn-team { grid-template-columns: 1fr; }
  .view-tab { padding-inline: 8px; }
}

/* Raid playback: a compact arena rather than a dashboard of entity cards. */
.panel.playback-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 16px);
  padding: 14px 18px;
  overflow: visible;
  scroll-margin-top: 8px;
}
.playback-panel[hidden] { display: none; }
.playback-topline { display: flex; align-items: flex-start; flex-shrink: 0; }
.playback-topline h2 { margin: 4px 0 0; }
.battle-clock {
  position: relative;
  justify-self: center;
  display: grid;
  place-content: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #ee9518;
  box-shadow: 0 3px 12px rgb(130 73 0 / 25%);
  color: white;
  text-align: center;
}
.battle-clock strong { font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.playback-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 6px; }
.playback-controls label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.playback-controls select { width: auto; min-width: 80px; }
#playback-elapsed { margin-left: auto; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--muted); }
.playback-seek-label { font-size: 14px; }
#playback-seek { width: 100%; accent-color: var(--blue); padding: 0; min-height: 26px; cursor: pointer; }
.playback-outcome { text-align: center; min-height: 20px; margin: 2px 0 4px; font-weight: bold; }
.battle-stage {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(min-content, 1fr) auto;
  gap: 8px;
  flex: 1;
  min-height: 570px;
  padding: 10px 16px 12px;
  overflow: hidden;
  border: 1px solid #c9d8ed;
  border-radius: 14px;
  background: linear-gradient(to bottom, #dff3ff, #eef7ff);
}
.battle-boss { display: flex; align-items: center; justify-content: center; min-height: 0; }
.battle-boss .combatant-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(82%, 520px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.battle-boss .combatant-caption { display: none; }
.battle-boss .combatant-heading { order: 1; }
.battle-boss .combatant-action { order: 2; min-height: 18px; margin: 2px 0; }
.battle-boss .health-track { order: 3; width: min(100%, 460px); }
.battle-boss .combatant-hp { order: 4; margin-top: 2px; line-height: 1.2; }
.battle-boss .energy-track { order: 5; width: min(58%, 260px); margin-top: 4px; }
.battle-boss .combatant-energy { order: 6; margin-top: 2px; line-height: 1.2; }
.battle-boss .combatant-party-power { order: 7; }
.battle-boss .combatant-state { order: 8; min-height: 0; margin: 2px 0; }
.battle-boss .combatant-state:empty { display: none; }
.battle-boss .sprite-area { order: 9; padding-top: 24px; }
.battle-boss .replay-team { order: 10; }
.battle-players {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 200px));
  align-items: end;
  justify-content: center;
  gap: 10px;
  min-height: 0;
  margin: 0;
}
.combatant-card { min-width: 0; text-align: center; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.combatant-caption { font-size: 14px; color: var(--muted); margin-bottom: 0; }
.sprite-area { position: relative; padding-top: 38px; display: flex; justify-content: center; }
.pokemon-circle { display: grid; place-items: center; width: 86px; height: 86px; border: 3px solid #a0b8dc; background: #edf3fd; border-radius: 50%; color: #45628d; font-size: 44px; font-weight: bold; transition: transform .2s, opacity .2s; }
.battle-boss .pokemon-circle { width: 86px; height: 86px; font-size: 44px; }
.battle-players .combatant-card { padding: 8px 10px; background: rgb(255 255 255 / 82%); }
.battle-players .sprite-area { padding-top: 24px; }
.battle-players .pokemon-circle { width: 58px; height: 58px; font-size: 31px; }
.battle-players .combatant-heading { margin-top: 6px; }
.battle-players .combatant-name { font-size: 15px; }
.battle-players .combatant-action { min-height: 18px; margin-bottom: 5px; font-size: 12px; }
.battle-players .health-track { width: min(100%, 150px); margin-inline: auto; }
.battle-players .energy-track { width: min(78%, 112px); margin-inline: auto; }
.battle-players .combatant-state { min-height: 17px; margin: 5px 0; font-size: 12px; }
.battle-players .replay-team { gap: 5px; }
.battle-players .replay-team-slot { width: 23px; height: 23px; font-size: 11px; }
.pokemon-circle.acting { transform: translateY(-5px) scale(1.04); }
.off-field .pokemon-circle, .fainted .pokemon-circle { opacity: 0; }
.pokemon-circle.sprite-entering { animation: sprite-enter .42s ease-out both; }
.pokemon-circle.sprite-leaving { animation: sprite-leave .36s ease-in both; }
.pokemon-circle.sprite-swapping { animation: sprite-swap .65s ease-in-out both; }
@keyframes sprite-enter {
  from { opacity: 0; transform: scale(.72); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes sprite-leave {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(.72); }
}
@keyframes sprite-swap {
  0% { opacity: 1; transform: scale(1); }
  48% { opacity: 0; transform: scale(.72); }
  52% { opacity: 0; transform: scale(.72); }
  100% { opacity: 1; transform: scale(1); }
}
.effectiveness-message { position: absolute; top: 9px; left: 0; width: 100%; white-space: nowrap; font-size: 14px; font-weight: bold; pointer-events: none; }
.effectiveness-message[data-kind="super"] { color: #147447; }
.effectiveness-message[data-kind="resisted"] { color: #805600; }
.combatant-name { font-size: 18px; line-height: 1.3; margin: 12px 0 4px; overflow-wrap: anywhere; }
.combatant-heading { display: grid; justify-items: center; gap: 3px; margin: 12px 0 4px; }
.combatant-heading .combatant-name { margin: 0; }
.combatant-types { display: flex; min-height: 28px; gap: 4px; }
.type-icon {
  display: inline-block;
  width: 28px;
  height: 28px;
  overflow: hidden;
  flex: 0 0 28px;
  border-radius: 50%;
  background-image: url("assets/pokemon-go-type-icons.png");
  background-repeat: no-repeat;
  background-size: 217.212px 108.606px;
}
.type-bug { background-position: 0 -22.061px; }
.type-ghost { background-position: -28px -22.061px; }
.type-normal { background-position: -56px -22.061px; }
.type-ice { background-position: -84px -22.061px; }
.type-dragon { background-position: 0 -50.061px; }
.type-flying { background-position: -28px -50.061px; }
.type-ground { background-position: -56px -50.061px; }
.type-grass { background-position: -84px -50.061px; }
.type-fairy { background-position: -112px -50.061px; }
.type-electric { background-position: -140px -50.061px; }
.type-poison { background-position: -168px -50.061px; }
.type-steel { background-position: 0 -78.061px; }
.type-psychic { background-position: -28px -78.061px; }
.type-water { background-position: -56px -78.061px; }
.type-dark { background-position: -84px -78.061px; }
.type-rock { background-position: -112px -78.061px; }
.type-fighting { background-position: -140px -78.061px; }
.type-fire { background-position: -168px -78.061px; }
.combatant-action { min-height: 22px; margin: 0 0 10px; color: var(--blue); font-size: 14px; }
.health-track, .energy-track { overflow: hidden; border-radius: 7px; background: #e5e9f0; }
.health-track { height: 13px; }
.energy-track { height: 7px; margin-top: 9px; }
.health-fill, .energy-fill { height: 100%; }
.health-fill[data-colour="green"] { background: #24a66b; }
.health-fill[data-colour="yellow"] { background: #e6b527; }
.health-fill[data-colour="red"] { background: #dd4855; }
.energy-fill { background: #4184e5; }
.combatant-hp, .combatant-energy { font-size: 14px; font-variant-numeric: tabular-nums; margin: 4px 0 0; }
.combatant-energy, .combatant-state { color: var(--muted); }
.combatant-party-power { min-height: 18px; margin: 3px 0 0; color: #7b4dc7; font-size: 13px; font-weight: 700; }
.combatant-party-power:empty { display: none; }
.playback-panel.numbers-hidden .combatant-hp,
.playback-panel.numbers-hidden .combatant-energy { display: none; }
.combatant-state { font-size: 14px; min-height: 21px; margin: 10px 0; }
.replay-team { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.replay-team-slot { display: grid; place-items: center; position: relative; width: 30px; height: 30px; border: 2px solid var(--line); border-radius: 50%; font-weight: bold; background: #f6f8fc; }
.replay-team-slot.active { outline: 2px solid var(--blue); outline-offset: 2px; }
.replay-team-slot[data-colour="green"] { border-color: #24a66b; }
.replay-team-slot[data-colour="yellow"] { border-color: #e6b527; }
.replay-team-slot[data-colour="red"] { border-color: #dd4855; }
.replay-team-slot.fainted { opacity: .3; }
.replay-slot-number { position: absolute; bottom: -7px; right: -5px; padding: 0 3px; background: white; font-size: 12px; border-radius: 4px; }
@media (max-width: 540px) {
  .panel.playback-panel { min-height: calc(100dvh - 8px); padding: 10px; }
  .battle-clock { width: 64px; height: 64px; }
  .battle-stage { min-height: 620px; padding: 8px; }
  .combatant-card { padding: 12px; }
  #playback-elapsed { width: 100%; margin: 0; }
  .battle-clock strong { font-size: 21px; }
  .battle-players { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); }
}
@media (max-height: 650px) and (min-width: 541px) {
  .panel.playback-panel { min-height: 480px; }
  .battle-stage { min-height: 480px; gap: 4px; padding-block: 6px; }
  .battle-clock { width: 60px; height: 60px; }
  .battle-clock strong { font-size: 20px; }
  .battle-boss .pokemon-circle { width: 64px; height: 64px; font-size: 34px; }
  .battle-players .pokemon-circle { width: 46px; height: 46px; font-size: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  .pokemon-circle { transition: none; }
  .pokemon-circle.acting { transform: none; }
  .pokemon-circle.sprite-entering,
  .pokemon-circle.sprite-leaving,
  .pokemon-circle.sprite-swapping { animation: none; }
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 Arial, Helvetica, sans-serif;
}

header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  padding: 28px max(24px, calc((100vw - 1180px) / 2));
  background: #172033;
  color: white;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(26px, 4vw, 38px); }
h2 { margin-bottom: 18px; font-size: 20px; }

.eyebrow {
  margin-bottom: 4px;
  color: #8fb7ff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.header-note { max-width: 420px; margin-bottom: 4px; color: #cbd4e5; }
main { width: min(1180px, calc(100% - 32px)); margin: 28px auto 60px; }
form { display: grid; gap: 18px; }

.view-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

.view-tab {
  flex: 1;
  padding: 0 18px;
  background: transparent;
  color: var(--muted);
}

.view-tab:hover { background: #f2f6fd; color: var(--blue-dark); }
.view-tab.active { background: var(--blue); color: white; }
.app-view[hidden] { display: none; }

.panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 2px 8px rgb(28 42 66 / 5%);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.settings-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.setting-checkbox {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding-top: 20px;
  gap: 8px;
}

.setting-checkbox input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

label {
  display: grid;
  gap: 7px;
  color: #465169;
  font-size: 13px;
  font-weight: 700;
}

select, input {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid #cbd2de;
  border-radius: 7px;
  background: white;
  color: var(--ink);
  font: inherit;
}

select:focus, input:focus, textarea:focus, button:focus-visible {
  outline: 3px solid rgb(29 99 216 / 20%);
  border-color: var(--blue);
}

.pokemon-search {
  position: relative;
  display: block;
}

.pokemon-matches {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid #cbd2de;
  border-radius: 8px;
  background: white;
  box-shadow: 0 10px 24px rgb(28 42 66 / 18%);
}

.pokemon-matches[hidden] { display: none; }

.pokemon-match {
  display: block;
  width: 100%;
  min-height: 36px;
  padding: 8px 9px;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font-weight: 400;
  text-align: left;
}

.pokemon-match:hover,
.pokemon-match.highlighted {
  background: #edf3ff;
  color: var(--blue-dark);
}

.pokemon-match-empty {
  display: block;
  padding: 8px 9px;
  color: var(--muted);
  font-weight: 400;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2 { margin-bottom: 2px; }
.section-heading p { margin-bottom: 0; color: var(--muted); }
.team { display: grid; gap: 10px; margin-top: 20px; }

.pokemon-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fafbfc;
}

/* Hidden optional controls must not shift IVs into a narrower column. */
.pokemon-row > label { flex: 1 1 160px; min-width: 0; }
.pokemon-row > .pokemon-field { flex: 2 1 220px; }
.pokemon-row > .level-field { flex: 0 0 76px; }
.pokemon-row > .mega-level-field { flex: 0 0 110px; }
.pokemon-row > .catch-tank-field { flex: 0 0 auto; }
.pokemon-row > .slot-number { flex: 0 0 24px; }
.pokemon-row > .remove { flex: 0 0 38px; }

.mega-level-field[hidden] { display: none; }

.ivs-field {
  flex: 0 0 11.5rem;
  min-width: 11.5rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.ivs-field legend {
  margin-bottom: 7px;
  color: #465169;
  font-size: 13px;
  font-weight: 700;
}

.iv-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(3.5rem, 1fr));
  gap: 5px;
}

.iv-inputs input {
  padding-inline: 5px;
  text-align: center;
}

.catch-tank-field {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 8px;
}

.catch-tank-field[hidden] { display: none; }
.catch-tank { width: 18px; min-height: 18px; margin: 0; }
.setting-note { margin: 14px 0 0; color: var(--muted); }

.pokemon-code-actions {
  display: flex;
  flex: 1 0 100%;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.shadow-field {
  display: flex;
  align-items: center;
  min-height: 34px;
  margin-right: auto;
  gap: 7px;
}

.shadow-field span {
  color: var(--muted);
  font-weight: 400;
}

.shadow {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.slot-number {
  align-self: center;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.primary {
  justify-self: start;
  padding: 0 28px;
  background: var(--blue);
  color: white;
}
.primary:hover { background: var(--blue-dark); }
.primary:disabled { cursor: wait; opacity: .65; }

.secondary {
  padding: 0 16px;
  border: 1px solid #b9c6dc;
  background: #f2f6fd;
  color: var(--blue-dark);
}

.small-button {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid #b9c6dc;
  background: white;
  color: var(--blue-dark);
}

.small-button:hover { background: #edf3ff; }

.remove {
  width: 38px;
  padding: 0;
  background: #fcecee;
  color: var(--red);
  font-size: 20px;
}

.result { margin-top: 24px; border-top: 5px solid var(--blue); }
.result.loss { border-top-color: var(--red); }
.result-heading { display: flex; align-items: baseline; justify-content: space-between; }
.result-heading h2 { margin: 0; font-size: 32px; }
.result-heading span { color: var(--muted); font-size: 18px; }
.result-meta { display: grid; justify-items: end; gap: 2px; }
.result-meta #result-seed { font-size: 12px; font-family: Consolas, "Courier New", monospace; }
.result-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 24px 0; }
.result-stats div { display: grid; gap: 2px; padding: 16px; background: #f5f7fa; border-radius: 8px; }
.result-stats strong { font-size: 24px; }
.result-stats span { color: var(--muted); font-size: 12px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.batch-overview { grid-template-columns: repeat(4, 1fr); }
.batch-table-wrap { margin: 0 0 20px; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.batch-table { width: 100%; border-collapse: collapse; background: white; font-variant-numeric: tabular-nums; }
.batch-table th, .batch-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.batch-table th:first-child, .batch-table td:first-child,
.batch-table th:nth-child(2), .batch-table td:nth-child(2) { text-align: left; }
.batch-table tbody tr:last-child td { border-bottom: 0; }
.batch-table th { background: #f5f7fa; color: var(--muted); font-size: 12px; }
details { border-top: 1px solid var(--line); padding-top: 16px; }
summary { cursor: pointer; font-weight: 700; }
pre { max-height: 460px; overflow: auto; padding: 16px; border-radius: 8px; background: #111827; color: #dce6f5; font-size: 12px; white-space: pre-wrap; }

.replay-import { margin-top: 0; }
.replay-heading { align-items: start; }
.replay-heading .eyebrow { margin-bottom: 4px; }
.replay-heading h2 { margin-bottom: 4px; }
.replay-heading p:not(.eyebrow) { max-width: 720px; }

.file-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  cursor: pointer;
}

.file-button input { display: none; }

.replay-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 18px;
  margin-top: 22px;
}

.replay-text-field { min-width: 0; }

#replay-text {
  width: 100%;
  min-height: 410px;
  resize: vertical;
  padding: 13px;
  border: 1px solid #cbd2de;
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--ink);
  font: 13px/1.5 Consolas, "Courier New", monospace;
  tab-size: 2;
}

.replay-guide {
  align-self: stretch;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7f9fc;
}

.replay-guide h3 { margin: 0 0 13px; font-size: 16px; }
.replay-guide dl { display: grid; gap: 12px; margin: 0; }
.replay-guide dl div { display: grid; gap: 3px; }
.replay-guide dt { font-weight: 700; }
.replay-guide dd { margin: 0; color: var(--muted); font-size: 13px; }
.replay-guide p { margin: 18px 0 0; color: var(--muted); font-size: 13px; }

code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #e9eef7;
  color: #23304a;
  font: 12px/1.4 Consolas, "Courier New", monospace;
}

.replay-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.replay-status { margin: 0 0 0 6px; color: var(--blue-dark); }
.replay-status.error { color: var(--red); }

.replay-preview {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.replay-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.replay-summary div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 13px;
  border-radius: 8px;
  background: #f5f7fa;
}

.replay-summary strong { overflow-wrap: anywhere; font-size: 17px; }
.replay-summary span { color: var(--muted); font-size: 12px; }

.replay-warnings {
  margin-top: 14px;
  padding: 13px 16px;
  border: 1px solid #e7ca8d;
  border-radius: 8px;
  background: #fff8e8;
  color: #6d4b09;
}

.replay-warnings ul { margin: 7px 0 0; padding-left: 20px; }
.replay-table-wrap { max-height: 430px; overflow: auto; margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; }
.replay-table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.replay-table-wrap th,
.replay-table-wrap td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.replay-table-wrap th { position: sticky; top: 0; background: #f0f3f8; color: #465169; }
.replay-table-wrap tr:last-child td { border-bottom: 0; }

dialog {
  width: min(620px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  box-shadow: 0 22px 60px rgb(23 32 51 / 28%);
}

dialog::backdrop { background: rgb(23 32 51 / 55%); }

.dialog-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-heading h2 { margin-bottom: 0; }
.dialog-help { margin: 16px 0 10px; color: var(--muted); }

#pokemon-code {
  width: 100%;
  resize: vertical;
  padding: 11px;
  border: 1px solid #cbd2de;
  border-radius: 7px;
  color: var(--ink);
  font: 13px/1.45 Consolas, "Courier New", monospace;
  overflow-wrap: anywhere;
}

.code-status {
  min-height: 21px;
  margin: 8px 0 0;
  color: var(--blue-dark);
  font-size: 13px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.dialog-actions button { padding-inline: 18px; }

.icon-button {
  width: 38px;
  min-height: 38px;
  background: #f2f4f7;
  color: var(--muted);
  font-size: 20px;
}

@media (max-width: 850px) {
  header { align-items: start; flex-direction: column; }
  .field-grid, .settings-grid { grid-template-columns: 1fr 1fr; }
  .replay-editor-grid { grid-template-columns: 1fr; }
  .replay-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  main { width: min(100% - 20px, 1180px); }
  .panel { padding: 18px; }
  .field-grid, .settings-grid, .result-stats { grid-template-columns: 1fr; }
  .pokemon-row > .pokemon-field, .pokemon-row > .move-field { flex-basis: 100%; }
  .slot-number { display: none; }
  .pokemon-code-actions { justify-content: stretch; }
  .pokemon-code-actions .shadow-field { flex-basis: 100%; flex-wrap: wrap; }
  .pokemon-code-actions button { flex: 1; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .replay-actions { align-items: stretch; flex-direction: column; }
  .replay-actions .primary { justify-self: auto; }
  .replay-status { margin-left: 0; }
  .replay-summary { grid-template-columns: 1fr 1fr; }
  .result-actions { align-items: stretch; flex-direction: column; }
}
