:root {
  --accent: #ffe2a0;
  --ink: #101d19;
  --panel: #192b24;
  --inset: #13231d;
  --edge: #3d5342;
  --text: #f0e9cb;
  --muted: #afbea2;
  --moss: #a8d495;
  --amber: #f3c36e;
  --body: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --title: "Songti SC", "Noto Serif CJK SC", "SimSun", Georgia, serif;
  --screen-margin: clamp(10px, 2.8dvh, 26px);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  font: 15px/1.5 var(--body);
  background: radial-gradient(ellipse at 45% 0, #2e4938 0, var(--ink) 62%);
  display: grid;
  place-items: center;
  height: 100dvh;
  padding: max(var(--screen-margin), env(safe-area-inset-top))
    max(var(--screen-margin), env(safe-area-inset-right))
    max(var(--screen-margin), env(safe-area-inset-bottom))
    max(var(--screen-margin), env(safe-area-inset-left));
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 17px; font-weight: 730; line-height: 1.32; }
.game-screen {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(100%, 1170px);
  height: 100%;
  max-height: 870px;
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid #678066;
  border-radius: 12px;
  box-shadow: 0 18px 54px #08130e99, 0 0 0 4px #283e33;
}
.game-screen .cache-update { position: absolute; bottom: 68px; }

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 8px 15px;
  border-bottom: 1px solid #617058;
  background: #1a2d25;
}
.branding { display: flex; align-items: center; gap: 12px; min-width: 0; }
.branding h1 {
  color: #f6eccb;
  font: 900 clamp(22px, 3.2vw, 33px)/1.08 var(--title);
  letter-spacing: .055em;
  text-shadow: 0 3px #22362a;
  white-space: nowrap;
}
.back {
  color: #f5e5b7;
  text-decoration: none;
  background: #233b2e;
  border: 1px solid #516751;
  box-shadow: 0 2px 0 #101e17;
  border-radius: 7px;
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 21px;
}
.utility, .market-actions, .dialog-actions { display: flex; align-items: center; gap: 8px; }
.quiet, .battle-actions button {
  border: 1px solid #526951;
  border-radius: 6px;
  background: #253d30;
  min-height: 36px;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.back:hover, .quiet:hover:not(:disabled), .battle-actions button:hover { background: #365440; }
.quiet:disabled { opacity: .55; }
.primary {
  background: #efbf72;
  color: #302817;
  min-height: 40px;
  padding: 8px 18px;
  border: 1px solid #f0c77e;
  border-radius: 6px;
  box-shadow: inset 0 -3px #c18443;
  font-weight: 840;
  white-space: nowrap;
}
.primary:hover:not(:disabled) { background: #ffcf83; }
.primary:disabled { background: #424b34; color: #d2c7a3; border-color: #5d6246; box-shadow: none; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}
.section-head p, .orders p, .scout p { color: var(--muted); font-size: 12px; }
.section-head p { margin-top: 3px; }
.minor { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* The controls share one arena with the Phaser playfield. */
.arena {
  --hud-gap: clamp(8px, 1.5vw, 17px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #22372d;
}
.battlefield {
  position: relative;
  min-height: 0;
  container-type: size;
  background-color: #405847;
  background-size: cover;
  background-position: center 68%;
  image-rendering: pixelated;
}
.arena-canvas {
  position: absolute;
  inset: auto 0 max(0px, calc((100cqh - 43.75cqw) * .19));
  height: min(100%, 43.75cqw);
  container-type: size;
  overflow: hidden;
  pointer-events: none;
}
.arena-canvas canvas {
  position: absolute;
  left: 50%;
  /* 裁切较宽的战场时，保持交锋位置在画框内。 */
  bottom: clamp(min(0px, calc(100cqh - 43.75cqw)), calc(20cqh - 10.8cqw), 0px);
  transform: translateX(-50%);
  display: block;
  image-rendering: pixelated;
}
.stage-ribbon {
  display: flex;
  justify-content: space-between;
  align-items: start;
  position: absolute;
  top: var(--hud-gap);
  right: var(--hud-gap);
  left: var(--hud-gap);
  pointer-events: none;
}
.stage-name {
  background: #1d3029;
  color: #fff0c8;
  border: 1px solid #7b8763;
  border-left: 3px solid #e2b873;
  border-radius: 3px;
  padding: 5px 11px 6px;
  box-shadow: 3px 3px #18271f5c;
}
.stage-name span { color: #ded7b4; font-size: 11px; font-weight: 700; }
.stage-name h2 { font: 850 clamp(18px, 2.1vw, 29px)/1.18 var(--title); letter-spacing: .09em; }
.route-trigger {
  position: absolute; top: calc(var(--hud-gap) + 73px); left: var(--hud-gap);
  z-index: 3; min-height: 30px; padding: 3px 8px;
  color: #ffedb8; background: #3c4830; border-color: #b79d61;
}
.route-trigger[aria-expanded="true"] { color: #221c11; background: #f0c77a; }
.stage-status { display: flex; gap: 6px; align-items: center; }
.stage-phase, .stage-wins {
  padding: 4px 12px;
  border: 1px solid #8a9f71;
  border-radius: 4px;
  color: #e5f1c5;
  background: #233c2d;
  font-size: 12px;
  font-weight: 700;
}
.stage-wins { background: #24342b; color: #ffe3a1; border-color: #a59464; font-variant-numeric: tabular-nums; }
.stage-phase[data-phase="play"], .stage-phase[data-phase="draw"] { background: #534228; color: #ffdf9d; border-color: #d1a964; }
.stage-phase[data-phase="win"] { background: #365942; color: #e3ffc9; border-color: #c0dc92; }
.stage-phase[data-phase="loss"] { background: #583733; color: #ffcec0; border-color: #dd9386; }
.stage-phase[data-phase="review"] { background: #293e53; color: #d8edff; border-color: #8db9d1; }
.battle-sides {
  pointer-events: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4.5%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  text-align: center;
  color: #e7f8ce;
  font-size: clamp(10px, 1.1vw, 13px);
  font-weight: 780;
  letter-spacing: .12em;
  text-shadow: 0 2px #172920, 1px 0 #172920, -1px 0 #172920;
}
.battle-sides span:last-child { color: #ffe3cf; }
.field-tools {
  position: absolute; z-index: 3; top: calc(var(--hud-gap) + 34px); right: var(--hud-gap);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 5px;
  max-width: calc(100% - 2 * var(--hud-gap));
}
.field-tools .quiet, .battle-actions button { background: #21372e; border-color: #9c946d; min-height: 32px; }
.field-tools [aria-expanded="true"] { color: #ffe8a8; border-color: #edc673; background: #525035; }
.battle-actions { display: flex; align-items: center; gap: 5px; }
.battle-actions button { padding: 2px 7px; }
.battle-progress {
  position: absolute; z-index: 3; bottom: 0; left: 0; width: 100%; height: 4px;
  border: 0; appearance: none; accent-color: #f4c872; background: #20362c;
}
.battle-progress::-webkit-progress-bar { background: #20362c; }
.battle-progress::-webkit-progress-value { background: #f4c872; }
.field-overlay {
  position: absolute; z-index: 4; top: calc(var(--hud-gap) + 76px); right: var(--hud-gap);
  width: min(560px, calc(100% - 2 * var(--hud-gap))); max-height: calc(100% - var(--hud-gap) - 82px);
  overflow: auto; overscroll-behavior: contain; scrollbar-color: #758469 #27392f;
  padding: 0 12px 12px; color: var(--text); background: #172d24fa;
  border: 1px solid #81966f; border-radius: 7px; box-shadow: 0 9px 22px #14251a99;
}
.overlay-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  position: sticky; top: 0; z-index: 2; background: #172d24;
  padding-block: 6px; margin-bottom: 8px; border-bottom: 1px solid #435e4a;
}
.overlay-head h2 { font-size: 14px; }
.overlay-head .quiet { min-height: 27px; padding: 2px 7px; font-size: 11px; }
.battle-caption {
  position: absolute;
  bottom: 3.5%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 94%;
  padding: 3px 10px;
  background: #26372feb;
  border: 1px solid #b4ac73;
  border-radius: 4px;
  color: #fff2ca;
  text-align: center;
  font-size: clamp(10px, 1.2vw, 13px);
  pointer-events: none;
}
.arena:has(.battle-caption:not([hidden])) .battle-sides { visibility: hidden; }
.battlefield:has(.review-bar:not([hidden])) .battle-sides { visibility: hidden; }
.battle-result {
  --result-ink: #ffebb1;
  --result-edge: #ac935e;
  position: absolute; z-index: 3; left: 50%; top: max(94px, 19%); translate: -50% 0;
  width: min(434px, calc(100% - 24px)); padding: 12px 16px;
  display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: start; gap: 11px;
  color: var(--result-ink); border: 1px solid var(--result-edge); border-top: 3px solid var(--result-edge);
  border-radius: 7px; background: #183028f7; box-shadow: 0 12px 26px #091b16b5;
}
.battle-result[data-outcome="win"] { --result-edge: #e4c173; background: linear-gradient(115deg, #263e2c, #192e24 72%); }
.battle-result[data-outcome="loss"] { --result-edge: #be806e; --result-ink: #ffdfce; }
.result-medal {
  position: relative; display: grid; place-items: center; min-height: 54px;
  background: #3a4933; color: var(--result-ink); border: 1px solid var(--result-edge);
  font: 700 32px/1 var(--title); border-radius: 6px; box-shadow: inset 0 0 0 3px #242f23;
}
.result-body > p { color: #d5e0bf; font-size: 12px; margin: 0; }
.result-body h2 { margin: 1px 0 5px; font: 900 clamp(26px, 4.5vw, 42px)/1.1 var(--title); letter-spacing: .08em; }
.result-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 0; margin: 8px 0 0; }
.result-metrics div { border: 1px solid #59704f; background: #1b3228; border-radius: 4px; padding: 4px 6px; }
.result-metrics dt { font-size: 10px; color: #d1dbbb; }
.result-metrics dd { margin: 0; font-size: 17px; font-weight: 800; }
.result-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.result-actions .quiet { min-height: 30px; padding: 3px 6px; font-size: 11px; }
.battle-result.is-celebrating { animation: result-arrive 440ms ease-out both; }
.battle-result.is-celebrating .result-medal { animation: medal-glow 740ms ease-out both; }
.battle-result.is-celebrating .result-medal::after {
  content: ''; pointer-events: none; position: absolute; left: calc(50% - 2px); top: calc(50% - 2px);
  width: 4px; height: 4px;
  box-shadow: -25px -15px #e5c170, 13px -29px #e5c170, 24px -2px #f8e7ad,
    -21px 18px #a9ce8b, 15px 22px #a9ce8b, 32px 12px #e5c170;
  animation: victory-sparks 740ms ease-out both;
}
@keyframes result-arrive {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes medal-glow {
  0% { transform: scale(.8); }
  45% { transform: scale(1.1); box-shadow: 0 0 20px #f0c768a6, inset 0 0 0 3px #242f23; }
  100% { transform: scale(1); }
}
@keyframes victory-sparks {
  from { opacity: 1; transform: scale(.65); }
  to { opacity: 0; transform: translateY(-8px) scale(1.65); }
}
.review-bar {
  position: absolute; bottom: 8px; left: 50%; translate: -50% 0; z-index: 3;
  width: min(590px, calc(100% - 16px)); display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 5px 8px; color: #e0f0ff; background: #203744f5; border: 1px solid #7ea9b9; border-radius: 5px;
}
.review-context { min-width: 0; }
.review-context strong { color: #a8dafa; font-size: 10px; }
.review-context p { margin: 0; font-size: 12px; line-height: 1.35; }
.review-actions { display: flex; gap: 3px; }
.review-actions .quiet { min-height: 30px; padding: 3px 5px; }
.battle-failure {
  position: absolute; z-index: 1; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--panel); padding: 8px 12px; width: max-content; max-width: 80%; font-size: 13px;
}

[data-drag-grip] { touch-action: none; -webkit-user-select: none; user-select: none; }
.field-slot[data-drag-kind]:not(:disabled), .offer-art[data-drag-kind] { cursor: grab; }
.offer-art[data-drag-kind]::after {
  content: '⋮⋮'; position: absolute; left: 7px; bottom: 3px; color: #cde0c0; line-height: 1; font-size: 15px;
}
.pet-dragging { cursor: grabbing; -webkit-user-select: none; user-select: none; }
.pet-dragging .drag-origin { cursor: grabbing; opacity: .45; }
.pet-dragging .battle-sides { visibility: hidden; }
.battle-sides b { margin-left: 4px; font-size: 10px; letter-spacing: 0; color: #f4e7bc; }
.field-slots { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
button.field-slot {
  display: grid; place-items: center;
  position: absolute; translate: -50% -50%; box-sizing: border-box; pointer-events: auto;
  min-height: 0; padding: 0; color: #e5f8d6; background: transparent; border: 1px solid transparent; border-radius: 5px;
}
.field-slot.filled:hover, .field-slot[aria-pressed="true"] { border-color: #e9d18e; background: #e7c87912; }
.field-slot.guided-slot { border-color: #c0e7a4; box-shadow: 0 0 0 2px #a7d680a0; }
.field-slot-label {
  position: absolute; bottom: 0; translate: 0 45%; padding: 0 4px;
  font: 700 10px/1.2 var(--body); background: #192e26e0; border-radius: 2px; color: #e6edc8;
}
.field-leader .field-slot-label { color: #142519; background: #cbe8a8; white-space: nowrap; font-size: 9px; }
.field-slot-empty { align-self: end; margin-bottom: 5px; font-size: clamp(14px, 2vw, 24px); line-height: 1; color: #d7ecad; text-shadow: 1px 2px #213427; }
.field-slot[data-drop-action] { border-style: dashed; border-color: #b7d69b; background: #84ae5c29; }
.field-slot[data-drop-action="upgrade"] { border-color: #f0c173; background: #dfaa5433; }
.field-slot[data-drop-action="replace"] { border-color: #efac84; background: #ce825025; }
.field-slot[data-drop-action][data-drop-hover] { border-style: solid; outline: 2px solid #fff0af; }
.field-slot[data-drop-hover]:not([data-drop-action]) { border-color: #da988a; }
.drop-instruction {
  pointer-events: none; position: absolute; z-index: 3; bottom: 7px; left: 50%; translate: -50% 0;
  background: #223a30f5; border: 1px solid #91ac7d; border-radius: 4px; padding: 4px 9px;
  color: #fff1bc; font-size: 12px; font-weight: 750; white-space: nowrap;
}
.drag-preview {
  pointer-events: none;
  position: absolute;
  z-index: 8;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px 2px 3px;
  border: 1px solid #d2c086;
  border-radius: 4px;
  background: #243b2e;
  color: #fff0c4;
  box-shadow: 0 3px 8px #0c1713a6;
  white-space: nowrap;
  font-size: 11px;
}
.drag-preview .pet-avatar { width: 32px; }

.shop-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.pet-avatar { display: block; aspect-ratio: 1; object-fit: contain; image-rendering: pixelated; }
.pet-stats {
  display: flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 11px; font-weight: 740;
  font-variant-numeric: tabular-nums;
}
.attack-stat { color: #fbc289; }
.health-stat { color: #c0e4a7; }
.field-controls {
  min-width: 0; background: linear-gradient(180deg, #293a2c 0, #192d24 48%);
  border-top: 1px solid #7d8158;
}
.market { max-width: 950px; margin-inline: auto; padding: 8px 14px; }
.market-label { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; }
.market-label p { margin: 0; }
.market-head { margin-bottom: 6px; }
#refresh[data-free="true"]:not(:disabled) { color: #ffe8ad; border-color: #b59456; background: #49472d; }
.wallet {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #ffdc92;
  min-height: 34px;
  padding: 2px 10px 2px 8px;
  border: 1px solid #826d44;
  border-radius: 5px;
  background: #343826;
  font-variant-numeric: tabular-nums;
}
.coin, .cost::before {
  width: 11px; height: 11px; display: inline-block;
  background: #f5c679; box-shadow: inset -2px -2px #b8753a;
  clip-path: polygon(27% 0,73% 0,73% 9%,91% 9%,91% 27%,100% 27%,100% 73%,91% 73%,91% 91%,73% 91%,73% 100%,27% 100%,27% 91%,9% 91%,9% 73%,0 73%,0 27%,9% 27%,9% 9%,27% 9%);
}
.offer {
  --path: #9fc8a3;
  position: relative;
  background: #20352b;
  border: 1px solid #4f6450;
  border-radius: 7px;
  min-width: 0;
  overflow: clip;
  display: flex;
  flex-direction: column;
}
.offer.pinned { outline: 1px solid #a8d5c6; border-color: #a8d5c6; }
.offer-art:hover, .offer-hire:hover:not(:disabled) { background-color: #405b42; }
.offer-hire:disabled { color: #a9b39a; background: #212f25; }
.offer > button:focus-visible { outline-offset: -3px; }
.offer-art {
  width: 100%; position: relative; min-height: 51px; display: grid; place-items: center; border: 0; padding: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 5px, #d6e9b205 5px, #d6e9b205 6px), #30483b;
  border-bottom: 1px solid #566d55;
}
.offer-art img { width: 51px; height: 51px; filter: drop-shadow(0 3px #223329); }
.pet-tier { position: absolute; left: 7px; top: 5px; color: #e6ecd3; font-size: 10px; }
.offer-info {
  padding: 7px 8px 2px; width: 100%; display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between; gap: 1px 4px;
}
.pet-name { font-size: 15px; }
.path { font-size: 10px; font-weight: 750; color: var(--path); }
.offer-info .pet-stats { flex-basis: 100%; }
.offer-skill { padding: 3px 8px 7px; color: #c9d4b9; font-size: 11px; line-height: 1.46; }
.offer-skill strong { color: #f1e5c0; font-weight: 750; }
.offer-footer {
  display: flex; gap: 2px; justify-content: space-between; align-items: center;
  color: #e6f2cf; background: #354b36; border: 0; border-top: 1px solid #526a50;
  font-size: 12px; font-weight: 700; min-height: 29px; width: 100%; padding: 4px 8px; margin-top: auto;
}
.cost { color: #ffdb8d; display: flex; align-items: center; gap: 4px; }
.cost::before { content: ''; }
.pin {
  position: absolute; top: 4px; right: 4px; width: 29px; height: 29px; padding: 0;
  border: 1px solid #688073; border-radius: 4px; color: #dbeddb; background: #283d34; line-height: 1;
}
.pin[aria-pressed="true"] { color: #d1f8ea; background: #346055; border-color: #a8d5c6; }
.pin:disabled { opacity: .6; }
.empty-offer {
  min-height: 108px; border-style: dashed; display: grid; place-content: center; justify-items: center; gap: 4px;
  color: #a8b59a; font-size: 12px; background: var(--inset);
}
.stock-icon { font-size: 24px; color: #818d65; }

.roadbook { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.route-choice { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid #557049; }
.route-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.route-option {
  text-align: start; min-height: 52px; padding: 5px 7px; color: #f4e5bd;
  background: #254236; border: 1px solid #5b7757; border-radius: 4px;
}
.route-option strong, .route-option span { display: block; }
.route-option strong { font-size: 13px; }
.route-option span { color: #d5ddc0; font-size: 11px; line-height: 1.5; }
.route-option[aria-pressed="true"] { background: #4b4d32; border-color: #e3bf75; }
.route-option:hover:not(:disabled) { border-color: var(--amber); }
.roadbook > section + section { border-left: 1px solid var(--edge); padding-left: 8px; }
.field-overlay h3 { margin: 0; font-size: 13px; }
.results { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.win-grid { display: flex; flex: 1; gap: 4px; }
.win-grid i { height: 7px; flex: 1; border-radius: 2px; background: #334b38; border: 1px solid #536b4d; }
.win-grid .earned { background: var(--amber); border-color: #fae1a1; }
.wins { font-size: 13px; color: #ffda8d; white-space: nowrap; }
.trail { padding: 0; margin: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; }
.stop {
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 6px;
  min-height: 24px; padding: 1px 5px; border: 1px solid transparent;
  color: #b0bda2; font-size: 12px;
}
.stop.current { background: #334936; border-color: #7d8d61; border-radius: 4px; color: #f8edc4; }
.stop-stamp { display: grid; place-items: center; justify-self: start; width: 19px; height: 18px; background: #293f31; border-radius: 3px; font-size: 11px; }
.stop.current .stop-stamp, .stop.win .stop-stamp { background: #e9bf74; color: #302817; font-weight: 800; }
.stop.loss .stop-stamp { background: #673f37; color: #ffd2bf; }
.stop.draw .stop-stamp { background: #514d34; color: #f3e2a3; }
.stop-mark { color: #d5cca5; white-space: nowrap; }
.opponents { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
.rival {
  display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 5px;
  min-height: 58px; align-items: center; color: #f3e6c3; font-size: 12px; text-align: left;
  padding: 5px 6px; background: #21372c; border: 1px solid #4e6850; border-radius: 5px;
}
.rival:hover { border-color: var(--amber); background: #314a37; }
.rival img { width: 36px; grid-row: 1 / 4; }
.rival-identity { display: flex; align-items: baseline; justify-content: space-between; gap: 3px; }
.rival-identity small { color: #e8d092; white-space: nowrap; }
.rival .pet-stats { font-size: 10px; gap: 4px; }
.rival-skill { color: #dec8a0; font-size: 11px; }
.scout p { font-size: 12px; line-height: 1.6; }
.order-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 6px 0; }
.order-buttons button { padding-inline: 3px; }
.order-buttons [aria-pressed="true"] { color: #fce9b1; background: #535334; border-color: #bda369; }
.commands {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 8px 14px; background: #15271f; border-top: 1px solid #526b4e;
}
.command-context { flex: 1; min-width: 0; }
.commands p { color: #e5e8ce; font-size: 13px; }
.arena:has(.battle-result:not([hidden])):not(:has(.field-overlay:not([hidden]))) #status {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.commands #selection-detail { color: #fae5ad; font-size: 12px; }
.commands #prep-hint { color: #c6dfae; font-size: 11px; }
#selection-detail:not([hidden]) + #prep-hint { display: none; }
.commands .primary { min-width: 124px; }
.synergy-list { padding: 0; margin: 0; list-style: none; display: grid; gap: 5px; }
.synergy-item {
  text-align: start; width: 100%; padding: 6px 8px;
  border-radius: 5px; border: 1px solid #5d8459; background: #243e30; color: #dcebc5;
}
.synergy-item span { display: block; color: #c3e69b; font-size: 10px; font-weight: 780; }
.synergy-item strong { font-size: 12px; }
.synergy-item.warning { border-color: #9f8250; background: #403d2b; color: #ffe4b6; }
.synergy-item.warning span { color: #ffd190; }
.synergy-item:hover { border-color: #f2cc7f; }
.battle-log { font-size: 13px; }
.battle-log .section-head {
  margin-bottom: 3px; padding-bottom: 4px;
}
.log-heading, .log-filters { display: flex; align-items: center; gap: 6px; }
.log-filters .quiet { min-height: 32px; padding-inline: 8px; }
.log-filters [aria-pressed="true"] { color: #ffe8a8; background: #4c4e32; border-color: #a89965; }
.battle-log ol {
  padding: 0; margin: 0; list-style: none; color: #d0dac0;
  display: grid; gap: 3px;
}
.battle-log li { border-bottom: 1px solid #405844; }
.log-jump-hint { margin: 2px 0 5px; }
.log-jump {
  display: flex; align-items: baseline; gap: 6px; width: 100%; min-height: 26px; padding: 4px 2px;
  border: 0; background: transparent; text-align: start; line-height: 1.35;
}
.log-jump:hover:not(:disabled), .log-jump[aria-current="step"] { background: #344b38; }
.log-missed { color: #ffe1a7; }
.battle-log[data-filter="key"] .log-hit { display: none; }
.battle-recap { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin: 4px 0 8px; }
.recap-item { padding: 3px 5px; border: 1px solid #48624e; border-radius: 4px; background: #24392f; }
.recap-item dt { color: #f4e6bc; font-size: 11px; margin-bottom: 2px; white-space: nowrap; }
.recap-item dd { display: flex; flex-wrap: wrap; gap: 0 5px; margin: 0; font-size: 11px; font-variant-numeric: tabular-nums; }
.recap-ally { color: #d3efbc; }
.recap-enemy { color: #ffd9bd; }
.log-index { flex: none; min-width: 2ch; color: #a6b398; font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.log-side { flex: none; font-size: 10px; font-weight: 750; padding: 1px 5px; border-radius: 3px; }
.log-side-ally { color: #d3efbc; background: #344e3a; }
.log-side-enemy { color: #ffd9bd; background: #553e31; }
.log-skill, .log-summon { color: #f4d99d; }
.log-shield { color: #aedbd9; }

dialog {
  width: min(520px, calc(100% - 30px));
  max-height: calc(100dvh - 2 * var(--screen-margin) - 16px);
  color: var(--text); padding: 18px;
  background: var(--panel); border: 1px solid #778c65; border-radius: 9px;
  box-shadow: 0 15px 40px #0009;
}
dialog::backdrop { background: #081710b8; }
dialog p, .instructions { color: #d4dec6; font-size: 14px; margin: 12px 0; }
.instructions { padding-left: 23px; }
.instructions li + li { margin-top: 6px; }
.dialog-actions { justify-content: end; margin-top: 17px; }
#challenge-dialog label { display: block; margin: 8px 0 3px; font-size: 12px; color: #d7e1c1; }
.challenge-share { display: flex; flex-wrap: wrap; gap: 4px; }
#challenge-dialog input {
  min-width: 0; width: 100%; padding: 6px; border: 1px solid #687f60; border-radius: 4px;
  font: inherit; color: #fff1c8; background: #142820;
}
.challenge-share #challenge-current { flex: 1 1 96px; }
.challenge-share .quiet { padding-inline: 6px; }
#challenge-status { font-size: 12px; color: #f1d496; margin-bottom: 0; }

.unit-identity { display: flex; align-items: center; gap: 10px; }
.unit-portrait {
  display: grid; place-items: center; flex: none; width: 57px; height: 57px;
  background: #2b4636; border: 1px solid #536b4e; border-radius: 5px;
}
.unit-portrait img { width: 50px; }
.unit-identity p { display: flex; flex-wrap: wrap; gap: 3px; font-size: 11px; color: var(--muted); margin: 0 0 3px; }
.unit-identity p span { padding: 0 4px; background: #263c30; border-radius: 3px; white-space: nowrap; }
.unit-identity h2 { font-family: var(--title); font-size: 23px; }
.unit-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px;
  padding: 0; margin: 10px 0;
}
.unit-stats div { background: var(--inset); border: 1px solid var(--edge); border-radius: 5px; padding: 5px 7px; }
.unit-stats dt { font-size: 11px; color: var(--muted); }
.unit-stats dd { margin: 0; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.shield-stat { color: #c5ecfa; }
.unit-skill { padding: 8px 10px; background: #263d30; border-left: 2px solid #d5b275; }
.unit-skill h3 { color: #ffe3a5; margin: 0; font-size: 15px; }
.unit-skill p { margin: 3px 0 0; line-height: 1.6; }

.unit-hover {
  position: absolute;
  inset: 0 auto auto 0;
  z-index: 9;
  width: min(248px, calc(100% - 16px));
  pointer-events: none;
  padding: 8px 10px;
  border: 1px solid #9a925e;
  border-radius: 5px;
  background: #183027;
  color: #ecedd5;
  box-shadow: 0 4px 14px #0a161399;
  font-size: 12px;
}
.pet-dragging .unit-hover { display: none; }
.unit-hover-heading, .unit-hover-stats { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 8px; }
.unit-hover-heading { justify-content: space-between; }
.unit-hover-heading > strong { color: #fff0c5; font-size: 15px; }
.unit-hover-heading > span { color: #bacbaa; font-size: 11px; }
.unit-hover-stats { margin-top: 2px; font-variant-numeric: tabular-nums; font-weight: 700; }
.unit-hover-skill { margin-top: 5px; padding-top: 5px; border-top: 1px solid #4b6550; }
.unit-hover-skill strong { color: #f9d58a; }

@media (max-width: 760px) {
  :root { --screen-margin: 6px; }
  .game-screen { border-radius: 8px; box-shadow: 0 0 0 2px #283e33; }
  .masthead { padding: 6px 8px; gap: 6px; }
  .branding { gap: 6px; }
  .branding h1 { font-size: clamp(19px, 5vw, 29px); letter-spacing: .035em; }
  .back { width: 32px; height: 34px; }
  .utility { gap: 4px; }
  .utility .quiet { min-height: 34px; padding-inline: 6px; font-size: 11px; }
  .stage-name { padding: 3px 7px; }
  .stage-name span { font-size: 10px; }
  .stage-name h2 { font-size: clamp(15px, 4vw, 23px); }
  .route-trigger { top: calc(var(--hud-gap) + 57px); min-height: 26px; padding-inline: 5px; font-size: 11px; }
  .stage-phase, .stage-wins { padding: 3px 7px; font-size: 11px; }
  .field-tools { top: calc(var(--hud-gap) + 29px); gap: 4px; }
  .field-tools .quiet, .battle-actions button { min-height: 32px; padding-inline: 6px; font-size: 11px; }
  .field-overlay { top: calc(var(--hud-gap) + 68px); max-height: calc(100% - var(--hud-gap) - 74px); }
  .market { padding: 5px 7px 6px; }
  .market-label p { font-size: 10px; }
  .market-actions { gap: 4px; }
  .wallet, .market-actions .quiet { min-height: 30px; padding-inline: 6px; }
  .commands { gap: 5px; padding: 6px 8px; }
  .commands p { font-size: 12px; }
  .commands .primary { min-width: 0; padding-inline: 9px; font-size: 13px; }
  .commands .quiet { padding-inline: 6px; }
  .battle-result { gap: 6px; grid-template-columns: 38px minmax(0, 1fr); padding: 8px; }
  .result-medal { min-height: 39px; font-size: 25px; }
  .game-screen .cache-update { right: 6px; bottom: 60px; max-width: calc(100% - 12px); }
}
@media (max-width: 540px) {
  .commands { flex-wrap: wrap; }
  .command-context { min-width: 100px; }
  .commands #prep-hint { font-size: 10px; line-height: 1.35; }
  .market-head { margin-bottom: 4px; }
  .shop-grid { gap: 4px; }
  .offer-art { min-height: 45px; }
  .offer-art img { width: 42px; height: 42px; }
  .offer-info { padding: 3px 4px 2px; }
  .offer-info .pet-name { font-size: 12px; }
  .offer-info .path { display: none; }
  .offer-info .pet-stats { font-size: 9px; gap: 3px; }
  .offer-skill { font-size: 10px; padding: 2px 4px 4px; }
  .offer-footer { font-size: 10px; min-height: 26px; padding: 3px 3px 3px 4px; white-space: nowrap; }
  .cost { gap: 2px; }
  .cost::before { width: 8px; height: 8px; }
  .market .pin { top: 3px; right: 3px; width: 20px; height: 22px; min-height: 0; font-size: 11px; }
  .empty-offer { min-height: 96px; }
  .roadbook { grid-template-columns: minmax(0, 1fr); }
  .roadbook > section + section { border-left: 0; border-top: 1px solid var(--edge); padding: 6px 0 0; }
}
@media (max-height: 530px) and (orientation: landscape) {
  :root { --screen-margin: 4px; }
  .arena { grid-template-columns: minmax(0, 1fr) minmax(210px, 34%); }
  .arena:has(#market[hidden]) { grid-template-columns: minmax(0, 1fr); }
  .battlefield { grid-area: 1 / 1; }
  .field-controls { display: contents; }
  .masthead, .commands { padding-block: 4px; }
  .commands { grid-column: 1 / -1; }
  .market {
    grid-area: 1 / 2; min-height: 0; min-width: 0; overflow: auto;
    padding: 4px 6px; border-left: 1px solid #7d8158; background: #21372c;
  }
  .market-head { gap: 4px; }
  .market-label { gap: 1px; }
  .market-label h2 { font-size: 14px; }
  .market-label p { font-size: 10px; }
  .market-actions { gap: 4px; }
  .market-actions .quiet, .market .wallet { min-height: 30px; padding-inline: 5px; }
  .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .offer-info { padding: 3px 5px 2px; }
  .offer-info .pet-name { font-size: 12px; }
  .offer-skill { padding: 2px 5px 3px; }
  .offer-art img { width: 37px; height: 37px; }
  .offer-art { min-height: 39px; }
  .offer-footer { min-height: 25px; }
  .market .pin { min-height: 0; width: 27px; height: 27px; }
  .empty-offer { min-height: 92px; }
  .battle-result { top: 85px; padding-block: 6px; }
  .result-body h2 { font-size: 27px; }
  .result-metrics { margin-top: 4px; }
  .result-actions { margin-top: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .battle-result.is-celebrating, .battle-result.is-celebrating .result-medal { animation: none; }
  .battle-result.is-celebrating .result-medal::after { display: none; }
}
