@font-face {
  font-family: Paperlogy;
  src: url("brand/Paperlogy-4Regular.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: Paperlogy;
  src: url("brand/Paperlogy-7Bold.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: Paperlogy;
  src: url("brand/Paperlogy-9Black.woff") format("woff");
  font-weight: 900;
  font-display: swap;
}

@font-face {
  font-family: Cafe24ProUp;
  src: url("brand/Cafe24PROUP.woff") format("woff");
  font-display: swap;
}

:root {
  color-scheme: light;
  --canvas: #158ea0;
  --paper: #fffdf5;
  --paper-soft: #f8edce;
  --paper-deep: #ead9a8;
  --ink: #33291f;
  --muted: #766a5e;
  --brown: #5a1e00;
  --brown-light: #8a4b20;
  --black: #17130f;
  --gold: #fbd317;
  --orange: #ff9000;
  --red: #d84637;
  --green: #168b58;
  --blue: #296fb6;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235a1e00' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  font-family: Paperlogy, "Apple SD Gothic Neo", system-ui, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:not(:disabled),
select:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  min-height: 82px;
  display: flex;
  align-items: center;
  padding: 8px max(24px, calc((100vw - 1380px) / 2));
  color: white;
  background: var(--black);
}

.app-title {
  display: flex;
  align-items: center;
  gap: 18px;
}

.app-title img {
  width: 112px;
  height: 62px;
  object-fit: contain;
}

.app-title h1 {
  margin: 0;
  padding-left: 18px;
  border-left: 1px solid rgb(255 255 255 / 30%);
  font-family: Cafe24ProUp, Paperlogy, sans-serif;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.page-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 24px auto 64px;
}

.page-tabs {
  display: flex;
  align-items: end;
  gap: 6px;
  padding-left: 14px;
}

.page-tab {
  min-width: 150px;
  padding: 13px 20px 11px;
  border: 2px solid var(--brown);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  color: #f6dfbd;
  background: #71401f;
  font-size: 16px;
  font-weight: 900;
}

.page-tab.is-active {
  position: relative;
  z-index: 1;
  color: var(--brown);
  background: var(--paper);
}

.app-view {
  min-width: 0;
}

.simulation-setup,
.batch-setup {
  display: grid;
  align-items: center;
  gap: 18px;
  min-height: 96px;
  padding: 16px;
  border: 2px solid var(--brown);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 5px 0 var(--brown);
}

.simulation-setup {
  grid-template-columns: auto minmax(220px, .8fr) minmax(300px, 1.1fr) 180px 160px;
}

.batch-setup {
  grid-template-columns: minmax(360px, 1fr) 150px 180px;
}

.batch-setup.is-arena {
  grid-template-columns: 150px minmax(0, 1fr) 180px;
}

.simulation-setup > .launch-button {
  grid-column: -2 / -1;
  width: 160px;
  justify-self: end;
}

.batch-actions {
  grid-column: -2 / -1;
  width: 180px;
  display: flex;
  align-items: stretch;
  justify-self: end;
  gap: 8px;
}

.batch-actions .launch-button {
  min-width: 0;
  flex: 1 1 auto;
  padding-inline: 10px;
}

.segmented {
  display: flex;
  padding: 3px;
  border: 2px solid var(--brown);
  border-radius: 999px;
  background: var(--paper-deep);
}

.segmented__button {
  min-width: 88px;
  padding: 9px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 14px;
  font-weight: 900;
}

.segmented__button.is-active {
  color: var(--brown);
  background: var(--gold);
}

.match-fields {
  min-width: 0;
  display: flex;
  align-items: end;
  gap: 10px;
}

.match-fields .select-field {
  min-width: 0;
  flex: 1;
}

.versus-label {
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--brown);
  font-size: 17px;
  font-weight: 900;
}

.versus-label[hidden] {
  display: none;
}

.select-field,
.boss-select-field,
.deck-name-field,
.seed-field,
.batch-runs-field {
  display: grid;
  gap: 5px;
}

.select-field > span,
.boss-select-field > span,
.deck-name-field > span,
.seed-field > span,
.batch-runs-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.deck-name-field input,
.roster-search input {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border: 2px solid #b89c69;
  border-radius: 8px;
  color: var(--ink);
  background: white;
  font-size: 14px;
  font-weight: 700;
}

.select-field select,
.boss-select-field select {
  width: 100%;
  min-height: 38px;
  padding: 3px 30px 3px 2px;
  border: 0;
  border-bottom: 2px solid #a98c5a;
  border-radius: 0;
  color: var(--ink);
  background-color: transparent;
  font-size: 15px;
  font-weight: 900;
}

.roster-search select {
  width: 100%;
  min-height: 42px;
  padding-right: 30px;
  border: 0;
  border-bottom: 2px solid #a98c5a;
  border-radius: 0;
  color: var(--ink);
  background-color: transparent;
  font-size: 13px;
  font-weight: 900;
}

.boss-control {
  min-width: 0;
  display: block;
}

.seed-control {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 7px;
}

.seed-field input,
.batch-runs-field input {
  width: 100%;
  height: 42px;
  padding: 6px 9px;
  border: 0;
  border-bottom: 2px solid #a98c5a;
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
}

.seed-field input::-webkit-inner-spin-button,
.seed-field input::-webkit-outer-spin-button,
.batch-runs-field input::-webkit-inner-spin-button,
.batch-runs-field input::-webkit-outer-spin-button {
  appearance: none;
}

.random-seed-button {
  height: 42px;
  padding: 0 11px;
  border: 2px solid var(--brown);
  border-radius: 8px;
  color: var(--brown);
  background: var(--paper-soft);
  font-size: 12px;
  font-weight: 900;
}

.random-seed-button:not(:disabled):hover {
  background: var(--gold);
}

.launch-button {
  min-height: 52px;
  padding: 10px 20px 8px;
  border: 2px solid var(--brown);
  border-radius: 10px;
  color: var(--brown);
  background: var(--gold);
  box-shadow: 0 4px 0 var(--brown);
  font-size: 17px;
  font-weight: 900;
}

.launch-button:not(:disabled):hover {
  background: #ffe95b;
  transform: translateY(1px);
  box-shadow: 0 3px 0 var(--brown);
}

.launch-button:disabled {
  color: #857b70;
  background: #d8d1c5;
  box-shadow: 0 2px 0 #857b70;
  opacity: .8;
}

.batch-stop-button {
  min-height: 52px;
  flex: 0 0 58px;
  padding: 8px;
  border: 2px solid var(--brown);
  border-radius: 10px;
  color: white;
  background: var(--red);
  box-shadow: 0 4px 0 var(--brown);
  font-size: 14px;
  font-weight: 900;
}

.batch-stop-button:not(:disabled):hover {
  transform: translateY(1px);
  box-shadow: 0 3px 0 var(--brown);
}

.batch-stop-button:disabled {
  color: #e3d8d0;
  background: #8f665b;
  box-shadow: 0 2px 0 var(--brown);
}

.battle-view-shell,
.results-shell,
.deck-library,
.deck-editor,
.roster-panel,
.batch-deck-panel,
.batch-results {
  min-width: 0;
  border: 2px solid var(--brown);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 5px 0 var(--brown);
}

.batch-deck-panel,
.batch-results {
  margin-top: 18px;
  overflow: hidden;
}

.batch-deck-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  padding: 12px;
}

.batch-deck-option {
  min-width: 0;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 2px solid #c8af76;
  border-radius: 8px;
  background: white;
  cursor: pointer;
}

.batch-deck-option:has(input:checked) {
  border-color: var(--brown);
  background: #fff7b5;
}

.batch-deck-option.is-empty {
  color: #918575;
  background: #eee8dc;
  cursor: default;
}

.batch-deck-option:has(input:disabled) {
  cursor: default;
}

.batch-deck-option input {
  width: 18px;
  height: 18px;
  flex: none;
  margin: 0;
  accent-color: var(--brown);
  cursor: pointer;
}

.batch-deck-option input:disabled {
  cursor: default;
}

.batch-deck-option > span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.batch-deck-option strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
}

.batch-deck-option small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.batch-result-head {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--brown);
  background: var(--paper-deep);
}

.batch-result-head h2,
.batch-result-head span {
  margin: 0;
}

.batch-result-head h2 {
  color: var(--brown);
  font-size: 19px;
}

.batch-result-head span {
  color: var(--muted);
  font-weight: 700;
}

.batch-progress {
  width: min(240px, 45%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px 12px;
  font-variant-numeric: tabular-nums;
}

.batch-progress span,
.batch-progress strong {
  font-size: 12px;
  white-space: nowrap;
}

.batch-progress strong {
  color: var(--brown);
  text-align: right;
}

.batch-progress > i {
  grid-column: 1 / -1;
  height: 5px;
  display: block;
  overflow: hidden;
  background: #c8af76;
}

.batch-progress > i > b {
  height: 100%;
  display: block;
  background: var(--brown);
}

.batch-table-wrap {
  overflow-x: auto;
}

.batch-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.arena-evaluation-table {
  min-width: 1160px;
}

.batch-table > thead > tr > th,
.batch-table > tbody > tr > th,
.batch-table > tbody > tr > td {
  height: 58px;
  padding: 9px 13px;
  border-bottom: 1px solid #d8c89b;
  text-align: right;
  white-space: nowrap;
}

.batch-table > thead > tr > th {
  height: 42px;
  color: var(--muted);
  background: var(--paper-soft);
  font-size: 12px;
  font-weight: 900;
}

.batch-table > thead > tr > th:nth-child(2),
.batch-table > tbody > tr > th {
  min-width: 170px;
  text-align: left;
}

.batch-table > tbody > tr > th {
  overflow: hidden;
  max-width: 260px;
  text-overflow: ellipsis;
  font-size: 14px;
}

.batch-table > tbody > tr[data-batch-detail-id] {
  cursor: pointer;
}

.batch-table > tbody > tr[data-batch-detail-id]:hover {
  background: #fffaf0;
}

.batch-table > tbody > tr[data-batch-detail-id]:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

.batch-table > tbody > tr.is-selected {
  background: #fff7b5;
}

.batch-table > tbody > tr.is-running {
  box-shadow: inset 4px 0 0 var(--orange);
}

.batch-table > tbody > tr.is-running:not(.is-selected) {
  background: #fffaf0;
}

.batch-detail-row {
  background: white;
}

.batch-detail-cell {
  height: auto !important;
  padding: 0 !important;
  border-bottom: 2px solid var(--brown) !important;
  text-align: left !important;
  white-space: normal !important;
}

.batch-deck-detail-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-table > tbody > tr > th small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.batch-table > tbody > tr > td {
  font-weight: 700;
}

.batch-table > tbody > tr > td small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.batch-rank {
  width: 64px;
  color: var(--brown);
  font-size: 20px;
  font-weight: 900 !important;
  text-align: center !important;
}

.batch-detail {
  min-width: 0;
}

.batch-detail-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 14px;
  border-bottom: 1px solid #d8c89b;
  background: white;
}

.batch-detail-head > div:first-child {
  min-width: 0;
}

.batch-detail-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.batch-detail-tabs {
  display: flex;
  align-items: center;
  padding: 2px;
  border: 1px solid #b89c69;
  border-radius: 7px;
  background: var(--paper-soft);
}

.batch-detail-tab {
  min-height: 30px;
  padding: 5px 10px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 900;
}

.batch-detail-tab.is-active {
  color: var(--brown);
  background: var(--gold);
}

.batch-chart {
  min-width: 0;
  padding: 10px 14px 12px;
}

.batch-chart-head {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-left: 48px;
}

.batch-chart-head strong {
  font-size: 14px;
}

.batch-chart-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.batch-chart-grid {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 8px;
}

.batch-chart-scale {
  height: 156px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3px 0 24px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.batch-chart-scroll {
  min-width: 0;
  overflow-x: auto;
}

.batch-run-bars {
  min-width: max(100%, calc(var(--run-count) * 36px));
  height: 156px;
  display: grid;
  grid-template-columns: repeat(var(--run-count), 32px);
  align-items: end;
  justify-content: center;
  gap: 4px;
}

.batch-run-bar {
  min-width: 0;
  display: grid;
  grid-template-rows: 130px 22px;
  gap: 2px;
  padding: 0 2px;
  border: 0;
  border-radius: 5px;
  background: transparent;
}

.batch-run-bar:hover {
  background: var(--paper-soft);
}

.batch-run-bar > span {
  min-width: 0;
  height: 130px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-bottom: 1px solid #b9aa8d;
}

.batch-run-bar i {
  width: min(28px, 100%);
  height: max(3px, var(--bar-height));
  display: block;
  border-radius: 3px 3px 0 0;
  background: var(--red);
}

.batch-run-bar[data-outcome="victory"] i {
  background: var(--green);
}

.batch-run-bar[data-outcome="draw"] i {
  background: #b18a2c;
}

.batch-run-bar small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
}

.batch-score-rule {
  margin: 0;
  padding: 10px 14px;
  color: var(--muted);
  background: var(--paper-soft);
  font-size: 12px;
}

.arena-evaluation-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  border-bottom: 1px solid #d8c89b;
  background: var(--paper-soft);
}

.arena-evaluation-summary span {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid #d8c89b;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.arena-evaluation-summary span:last-child {
  border-right: 0;
}

.arena-evaluation-summary strong {
  display: block;
  margin-top: 2px;
  color: var(--brown);
  font-size: 14px;
}

.arena-matchup-wrap {
  overflow-x: auto;
  border-top: 1px solid #d8c89b;
}

.arena-matchup-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.arena-matchup-table th,
.arena-matchup-table td {
  height: 42px;
  padding: 8px 14px;
  border-bottom: 1px solid #e2d5b4;
  text-align: right;
  white-space: nowrap;
}

.arena-matchup-table thead th {
  color: var(--muted);
  background: var(--paper-soft);
  font-size: 11px;
}

.arena-matchup-table th:first-child {
  text-align: left;
}

.battle-view-shell {
  min-height: 620px;
  margin-top: 18px;
  overflow: hidden;
  background: #0e0e10;
}

.battle-view-shell iframe {
  width: 100%;
  height: 680px;
  display: block;
  border: 0;
  background: #0e0e10;
}

.battle-empty {
  min-height: 616px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  color: #d7d2cb;
}

.battle-empty h2,
.battle-empty p {
  margin: 0;
}

.battle-empty h2 {
  color: white;
  font-size: 22px;
}

.battle-empty p {
  color: #96918b;
  font-size: 14px;
}

.deck-manager {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 420px;
  align-items: start;
  gap: 14px;
  padding: 16px;
  border: 2px solid var(--brown);
  border-radius: 12px;
  background: var(--paper-soft);
  box-shadow: 0 5px 0 var(--brown);
}

.deck-library,
.deck-editor,
.roster-panel {
  overflow: hidden;
  box-shadow: none;
}

.panel-head {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 2px solid var(--brown);
  background: var(--paper-deep);
}

.panel-head h2 {
  margin: 0;
  color: var(--brown);
  font-size: 17px;
  font-weight: 900;
}

.small-button,
.delete-button {
  min-height: 34px;
  padding: 6px 11px;
  border: 2px solid var(--brown);
  border-radius: 7px;
  background: var(--paper);
  font-size: 12px;
  font-weight: 900;
}

.small-button:hover {
  background: var(--gold);
}

.deck-list-actions {
  display: flex;
  gap: 6px;
}

.deck-list {
  display: grid;
  gap: 7px;
  max-height: 690px;
  padding: 10px;
  overflow: auto;
}

.deck-list__item {
  min-width: 0;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 2px solid #c8af76;
  border-radius: 8px;
  background: white;
  text-align: left;
}

.deck-list__item strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
}

.deck-list__item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.deck-list__item.is-active {
  border-color: var(--brown);
  background: var(--gold);
}

.deck-editor__head {
  min-height: 78px;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding: 12px;
  border-bottom: 2px solid var(--brown);
  background: var(--paper-deep);
}

.delete-button {
  min-height: 42px;
  color: #8a211a;
  border-color: #a84037;
  background: #fff5ee;
}

.delete-button:disabled {
  opacity: .45;
  cursor: default;
}

.deck-editor__slots {
  display: grid;
  grid-template-columns: repeat(6, minmax(78px, 1fr));
  gap: 8px;
  padding: 14px;
  overflow-x: auto;
}

.editor-slot {
  position: relative;
  min-width: 72px;
  min-height: 138px;
  display: grid;
  grid-template-rows: 78px minmax(34px, auto);
  align-content: start;
  gap: 4px;
  padding: 6px;
  border: 2px solid #b89c69;
  border-radius: 10px;
  background: var(--paper-soft);
  overflow: hidden;
}

.editor-slot.is-selected {
  border-color: var(--brown);
  background: #fff7b5;
  box-shadow: inset 0 0 0 2px var(--gold);
}

.editor-slot.is-captain {
  border-color: #a95d16;
  background: #fff1b8;
  box-shadow: inset 0 0 0 2px #eaa62e;
}

.editor-slot.is-selected.is-captain {
  border-color: var(--brown);
  box-shadow: inset 0 0 0 3px #e99a1e;
}

.editor-slot__captain {
  position: absolute;
  top: 5px;
  right: 5px;
  padding: 3px 5px;
  color: white;
  background: #8e4912;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.editor-slot__portrait {
  position: relative;
  min-width: 0;
  height: 78px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.editor-slot__portrait img,
.cookie-pick__portrait img,
.meter-row__portrait img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: block;
  object-fit: contain;
  object-position: center bottom;
}

.editor-slot__name {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
}

.editor-slot--empty {
  place-items: center;
  align-content: center;
  color: #937956;
  background: #f5ecd4;
}

.editor-slot--empty > span {
  font-size: 30px;
  line-height: 1;
}

.editor-slot--empty > small {
  font-size: 11px;
  font-weight: 700;
}

.unit-inspector {
  min-height: 76px;
  margin: 0 14px 14px;
  border-block: 2px solid #c8af76;
}

.unit-inspector > .empty-copy {
  margin: 0;
  padding: 24px 4px;
}

.inspector-unit {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 72px;
  padding: 9px 4px;
}

.inspector-unit__name {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.inspector-unit__name strong {
  overflow: hidden;
  font-size: 17px;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.inspector-unit__name span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.inspector-actions {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 12px;
}

.select-field select,
.boss-select-field select,
.roster-search select {
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px 8px;
}

.select-field select:hover,
.boss-select-field select:hover,
.roster-search select:hover {
  border-color: var(--brown);
}

select option {
  color: var(--ink);
  background: var(--paper);
}

.captain-field {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.captain-field input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--orange);
  cursor: pointer;
}

.captain-field.is-active {
  color: #9a4b00;
}

.captain-field:hover {
  color: var(--brown-light);
}

.remove-unit {
  min-height: 0;
  padding: 4px 0;
  border: 0;
  border-radius: 0;
  color: #8a211a;
  background: transparent;
  font-size: 12px;
  font-weight: 900;
}

.remove-unit:hover {
  text-decoration: underline;
}

.roster-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid #d8c89b;
}

.cookie-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  max-height: 590px;
  padding: 10px;
  overflow-y: auto;
  align-content: start;
  align-items: start;
}

.cookie-pick {
  min-width: 0;
  display: grid;
  grid-template-rows: 94px auto;
  align-content: start;
  gap: 4px;
  padding: 6px;
  border: 2px solid #c8af76;
  border-radius: 10px;
  background: white;
  overflow: hidden;
}

.cookie-pick:hover {
  border-color: var(--brown-light);
  background: #fff9dc;
}

.cookie-pick.is-in-deck {
  border-color: #53906f;
}

.cookie-pick.is-active {
  border-color: var(--brown);
  background: var(--gold);
  box-shadow: inset 0 0 0 2px #fff2a1;
}

.cookie-pick__portrait {
  position: relative;
  min-width: 0;
  width: 100%;
  height: 94px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.cookie-pick__name {
  min-width: 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.4;
  text-align: center;
  overflow-wrap: anywhere;
}

.portrait-fallback {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 2px solid var(--brown);
  border-radius: 50%;
  color: var(--brown);
  background: var(--gold);
  font-size: 24px;
  font-weight: 900;
}

.empty-copy {
  grid-column: 1 / -1;
  margin: 0;
  padding: 24px 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.results-shell {
  margin-top: 18px;
  overflow: hidden;
}

.report-head {
  min-height: 104px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  border-bottom: 2px solid var(--brown);
  background: var(--paper-deep);
}

.outcome-plate {
  display: grid;
  place-content: center;
  gap: 2px;
  padding: 16px;
  color: white;
  background: var(--green);
  text-align: center;
}

.outcome-plate[data-outcome="defeat"],
.outcome-plate[data-outcome="timeout"] {
  background: var(--red);
}

.outcome-plate[data-outcome="draw"],
.outcome-plate[data-outcome="incomplete"] {
  background: var(--brown-light);
}

.outcome-plate strong {
  font-family: Cafe24ProUp, Paperlogy, sans-serif;
  font-size: 31px;
  font-weight: 400;
  line-height: 1;
}

.outcome-plate span {
  font-size: 12px;
  font-weight: 700;
}

.report-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  align-items: stretch;
}

.report-fact {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 15px 18px;
  border-left: 1px solid #c6ad71;
}

.report-fact span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.report-fact strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.report-body {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(420px, .75fr);
  align-items: stretch;
}

.meter-section {
  min-width: 0;
  border-right: 2px solid var(--brown);
}

.report-side {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.report-section-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #d8c89b;
}

.report-section-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
}

.meter-head-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-tabs {
  display: flex;
  padding: 2px;
  border: 1px solid #b89c69;
  border-radius: 7px;
  background: var(--paper-soft);
}

.metric-tab {
  padding: 6px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  font-size: 11px;
  font-weight: 900;
}

.metric-tab.is-active {
  color: var(--brown);
  background: var(--gold);
}

.meter-list {
  display: grid;
}

.meter-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 48px 150px minmax(150px, 1fr) 112px;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid #e1d7ba;
  background: white;
  text-align: left;
}

.meter-row:hover,
.meter-row.is-selected {
  background: #fff8d2;
}

.meter-row.is-selected {
  box-shadow: inset 5px 0 0 var(--gold);
}

.meter-row__portrait {
  position: relative;
  width: 48px;
  height: 52px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.meter-row__identity,
.meter-value {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.meter-row__identity strong,
.meter-row__identity span,
.meter-value strong,
.meter-value span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.meter-row__identity strong {
  font-size: 13px;
}

.meter-row__identity span,
.meter-value span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.meter-track {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.meter-track__rail {
  height: 12px;
  overflow: hidden;
  border: 1px solid #a99471;
  border-radius: 999px;
  background: #e8e1cf;
}

.meter-track__fill {
  width: var(--meter-width);
  height: 100%;
  display: block;
  background: var(--blue);
}

.meter-row[data-side="enemy"] .meter-track__fill {
  background: var(--red);
}

.meter-track__sub {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 3px 9px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

.meter-value {
  text-align: right;
}

.meter-value strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.timeline-section,
.log-section {
  min-width: 0;
}

.log-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.timeline-section {
  border-bottom: 2px solid var(--brown);
}

.timeline-legend {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.timeline-legend span::before {
  width: 9px;
  height: 9px;
  display: inline-block;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--blue);
  content: "";
}

.timeline-legend span:last-child::before {
  background: var(--red);
}

.timeline-chart {
  width: 100%;
  height: 208px;
  display: block;
  padding: 12px;
  background: #fffef9;
}

.timeline-chart text {
  fill: var(--muted);
  font: 10px Paperlogy, sans-serif;
}

.timeline-chart path {
  fill: none;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}

.timeline-chart .player-line {
  stroke: var(--blue);
}

.timeline-chart .enemy-line {
  stroke: var(--red);
}

.grid-line {
  stroke: #ddd2b5;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.log-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.log-list {
  min-height: 240px;
  overflow-y: auto;
  contain: size;
}

.log-row {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 82px;
  align-items: center;
  gap: 8px;
  min-height: 39px;
  padding: 7px 12px;
  border: 0;
  border-bottom: 1px solid #ece4d0;
  background: white;
  text-align: left;
}

.log-row:hover {
  background: #fff8d2;
}

.log-row__time,
.log-row__amount {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.log-row__time {
  color: var(--muted);
}

.log-row__event {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11px;
}

.log-row__amount {
  color: var(--red);
  font-weight: 900;
  text-align: right;
}

.log-row[data-kind="heal"] .log-row__amount {
  color: var(--green);
}

.log-row[data-kind="buff"] .log-row__amount {
  color: var(--blue);
}

.log-row[data-kind="synergy"] .log-row__amount {
  color: var(--orange);
}

.log-pagination {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 10px;
  border-top: 1px solid #d8c8a1;
  background: var(--paper-soft);
}

.log-pagination button {
  min-width: 58px;
  height: 28px;
  border: 1px solid var(--brown);
  border-radius: 5px;
  color: var(--brown);
  background: var(--paper);
  font-size: 11px;
  font-weight: 700;
}

.log-pagination button:not(:disabled):hover {
  background: var(--gold);
}

.log-pagination button:disabled {
  border-color: #b9aa8d;
  color: #9b907e;
  cursor: default;
}

.log-pagination span {
  min-width: 54px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.log-head-controls {
  display: flex;
  align-items: center;
  gap: 9px;
}

.deck-support h3 {
  margin: 0;
  color: var(--brown);
  font-size: 18px;
  font-weight: 900;
}

.deck-support h3 {
  font-size: 14px;
}

.deck-support {
  border-top: 2px solid var(--brown);
  background: var(--paper);
}

.deck-support > section {
  padding: 12px 14px;
}

.deck-support > section + section {
  border-top: 1px solid #d8c89b;
}

.deck-support h3,
.deck-support-title {
  margin-bottom: 9px;
}

.deck-support-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.deck-support-title h3 {
  margin-bottom: 0;
}

.deck-support-title span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.deck-pet-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid #cdbb8d;
}

.deck-pet-slot {
  min-width: 0;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-right: 1px solid #d8c89b;
}

.deck-pet-slot > span {
  color: #665b4c;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.deck-pet-slot:last-child {
  border-right: 0;
}

.deck-pet-slot:not(.is-equipped) .deck-pet-select {
  grid-column: 2 / -1;
}

.deck-pet-select,
.deck-pet-grade {
  min-width: 0;
  height: 36px;
  border: 1px solid #aa8e5c;
  border-radius: 4px;
  background: #fffdf6;
}

.deck-pet-select {
  width: 100%;
  padding: 4px 28px 4px 8px;
  color: var(--ink);
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px 8px;
  appearance: none;
  font-size: 12px;
  font-weight: 800;
}

.deck-pet-grade {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.deck-pet-grade input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 4px 2px 4px 7px;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.deck-pet-grade span {
  padding-right: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.deck-pet-select:hover,
.deck-pet-select:focus-visible,
.deck-pet-grade:focus-within {
  border-color: var(--brown);
}

.deck-perks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.deck-perk {
  min-width: 0;
  min-height: 54px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid #c8af76;
  background: var(--paper-soft);
  cursor: pointer;
}

.deck-perk.is-active {
  border-color: var(--brown);
  background: #fff1a5;
}

.deck-perk:has(input:disabled) {
  opacity: .55;
  cursor: default;
}

.deck-perk input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--orange);
  cursor: inherit;
}

.deck-perk > span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.deck-perk strong,
.deck-perk small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.deck-perk strong {
  font-size: 12px;
}

.deck-perk small {
  color: var(--muted);
  font-size: 10px;
}

.report-footnote {
  padding: 10px 14px;
  border-top: 2px solid var(--brown);
  color: var(--muted);
  background: var(--paper-soft);
  font-size: 11px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(440px, calc(100vw - 44px));
  padding: 12px 16px;
  border: 2px solid var(--brown);
  border-radius: 9px;
  color: white;
  background: var(--black);
  box-shadow: 0 4px 0 var(--brown);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .arena-evaluation-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .simulation-setup {
    grid-template-columns: auto minmax(240px, 1fr) minmax(310px, 1fr);
  }

  .simulation-setup .seed-control {
    grid-column: 2;
  }

  .simulation-setup .launch-button {
    grid-column: 3;
    justify-self: end;
    width: 190px;
  }

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

  .deck-manager {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .roster-panel {
    grid-column: 1 / -1;
  }

  .cookie-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    max-height: 500px;
  }

  .report-body {
    grid-template-columns: 1fr;
  }

  .report-side,
.log-section {
    display: block;
  }

  .log-list {
    max-height: min(70vh, 720px);
    contain: none;
  }

  .meter-section {
    border-right: 0;
    border-bottom: 2px solid var(--brown);
  }
}

@media (max-width: 820px) {
  .app-header {
    min-height: 68px;
  }

  .app-title img {
    width: 88px;
    height: 50px;
  }

  .app-title h1 {
    font-size: 18px;
  }

  .page-shell {
    width: min(100% - 20px, 1380px);
    margin-top: 18px;
  }

  .page-tabs {
    padding-left: 8px;
  }

  .page-tab {
    min-width: 120px;
    padding: 11px 14px 9px;
    font-size: 14px;
  }

  .simulation-setup,
.batch-setup {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .batch-setup.is-arena {
    grid-template-columns: 1fr;
  }

  .simulation-setup .seed-control {
    grid-column: auto;
  }

  .segmented {
    justify-self: start;
  }

  .simulation-setup > .launch-button,
.batch-actions {
    grid-column: auto;
    justify-self: end;
    width: 190px;
  }

  .batch-deck-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .battle-view-shell {
    min-height: 500px;
  }

  .battle-view-shell iframe {
    height: 540px;
  }

  .battle-empty {
    min-height: 496px;
  }

  .deck-manager {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .deck-list {
    max-height: 240px;
  }

  .deck-editor__head {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .deck-editor__slots {
    grid-template-columns: repeat(6, 86px);
  }

  .inspector-unit {
    grid-template-columns: minmax(140px, 1fr) auto;
  }

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

  .report-head {
    grid-template-columns: 160px minmax(0, 1fr);
  }

  .report-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .meter-row {
    grid-template-columns: 46px 130px minmax(130px, 1fr) 100px;
    gap: 7px;
    padding-inline: 8px;
  }
}

@media (max-width: 560px) {
  .arena-evaluation-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body {
    font-size: 13px;
  }

  .app-header {
    padding-inline: 14px;
  }

  .app-title {
    gap: 10px;
  }

  .app-title h1 {
    padding-left: 10px;
    font-size: 16px;
  }

  .page-tab {
    flex: 1;
    min-width: 0;
  }

  .batch-deck-list {
    grid-template-columns: 1fr;
  }

  .batch-detail-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .batch-detail-tabs {
    width: 100%;
  }

  .batch-detail-tab {
    min-width: 0;
    flex: 1;
  }

  .batch-chart {
    padding-inline: 10px;
  }

  .battle-view-shell {
    min-height: 400px;
  }

  .battle-view-shell iframe {
    height: 440px;
  }

  .battle-empty {
    min-height: 396px;
    padding: 20px;
    text-align: center;
  }

  .deck-editor__head {
    grid-template-columns: 1fr auto;
  }

  .inspector-actions {
    justify-content: start;
  }

  .inspector-unit {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .roster-search {
    grid-template-columns: 1fr;
  }

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

  .cookie-pick {
    grid-template-rows: 84px auto;
  }

  .cookie-pick__portrait {
    height: 84px;
  }

  .report-head {
    grid-template-columns: 1fr;
  }

  .outcome-plate {
    min-height: 82px;
  }

  .report-fact {
    border-top: 1px solid #c6ad71;
  }

  .report-section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .meter-list {
    overflow-x: auto;
  }

  .meter-row {
    min-width: 660px;
  }

  .timeline-chart {
    height: 180px;
  }

  .deck-pet-slots,
.deck-perks {
    grid-template-columns: 1fr;
  }

  .deck-pet-slot {
    border-right: 0;
    border-bottom: 1px solid #d8c89b;
  }

  .deck-pet-slot:last-child {
    border-bottom: 0;
  }

  .log-head-controls {
    width: 100%;
    justify-content: space-between;
  }
}
