:root {
  color-scheme: dark;
  --ink: #11120f;
  --panel: rgba(21, 24, 23, 0.96);
  --panel-2: rgba(32, 38, 34, 0.98);
  --line: rgba(237, 219, 165, 0.28);
  --cream: #f3e6bb;
  --muted: #a8b0a5;
  --amber: #f1a735;
  --orange: #d66a2c;
  --green: #8eb45a;
  --teal: #4fc5b0;
  --red: #df6255;
  --blue: #6f9cdf;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  font-family: "Cascadia Mono", "Lucida Console", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: #10120f;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  background:
    radial-gradient(circle at 15% -10%, rgba(177, 93, 37, 0.2), transparent 34rem),
    radial-gradient(circle at 90% 25%, rgba(57, 122, 89, 0.15), transparent 30rem),
    linear-gradient(145deg, #11140f, #171914 54%, #0c0e0c);
}

button,
select,
input {
  font: inherit;
}

button {
  color: inherit;
}

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

.page-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 2vw, 28px) 30px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.brand-kicker,
.dialog-kicker {
  display: block;
  color: var(--amber);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.brand h1 {
  margin: 3px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.9rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.055em;
}

.brand p {
  margin: 7px 0 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 0.75rem;
}

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

.select-control {
  display: grid;
  gap: 5px;
}

.select-control span {
  color: var(--muted);
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Battle Tools' painted enemy chooser stays inside the fixed game window. */
.battle-game #toolsDialog .tools-enemy-set {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 6px 12px;
  margin-top: 14px;
}
.battle-game #toolsDialog .tools-enemy-set .select-control { min-width: 0; }
.battle-game #toolsDialog .tools-enemy-set .raster-select { min-width: 0; }
.battle-game #toolsDialog .tools-enemy-set > p {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--cream);
}
.battle-game #toolsDialog #enemySetHint { color: var(--muted); font-size: 10px; }
.battle-game #toolsDialog .tools-enemy-set > button { min-height: 32px; }

select,
.top-button,
.restart-button,
.primary-button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--cream);
  background: #222720;
  cursor: pointer;
}

.top-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.top-button:hover,
.restart-button:hover,
.primary-button:hover,
select:hover {
  border-color: rgba(241, 167, 53, 0.7);
  background: #2c3228;
}

.top-button.accent,
.primary-button {
  color: #1a160e;
  border-color: #ffca64;
  background: linear-gradient(#f6bc50, #db8927);
  font-weight: 900;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

.battle-console {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111;
  box-shadow: var(--shadow);
}

.battle-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  isolation: isolate;
  background:
    url("../art/battle-backgrounds/autumn-clock-clearing-640x360-v1.png")
    center / cover no-repeat;
}

.stage-shade {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.07), transparent 34%, rgba(0, 0, 0, 0.12)),
    radial-gradient(ellipse at center, transparent 48%, rgba(15, 18, 10, 0.12));
  pointer-events: none;
}

.encounter-tag {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 3px;
  background: rgba(10, 12, 9, 0.7);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.28);
  font-size: clamp(0.62rem, 1.2vw, 0.8rem);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px rgba(241, 167, 53, 0.8);
}

.actor-layer,
.effect-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.combatant {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -100%);
  transition:
    filter 160ms,
    opacity 300ms,
    transform 160ms;
}

.combatant.targetable {
  pointer-events: auto;
  cursor: crosshair;
  filter:
    drop-shadow(0 0 2px #fff)
    drop-shadow(0 0 8px var(--amber));
}

.combatant.targetable:hover {
  transform: translate(-50%, -100%) scale(1.08);
}

.combatant.selected {
  filter:
    drop-shadow(0 0 3px #fff)
    drop-shadow(0 0 12px var(--teal));
}

.combatant.ko {
  opacity: 0.45;
  filter: grayscale(1);
  transform: translate(-50%, -82%) rotate(-82deg);
}

.combatant.hit {
  animation: hit-flash 300ms steps(2);
}

.combatant.acting {
  animation: actor-pulse 500ms ease-out;
}

.party-sprite {
  width: calc(clamp(80px, 12.25vw, 156px) * var(--aot-sprite-canvas-ratio, 1));
  height: auto;
  image-rendering: auto;
  transform-origin: bottom center;
  filter: drop-shadow(0 8px 3px rgba(0, 0, 0, 0.34));
}

.enemy-sprite {
  display: block;
  width: calc(clamp(118px, 15.5vw, var(--enemy-sprite-width, 180px)) * var(--aot-sprite-canvas-ratio, 1));
  height: auto;
  image-rendering: auto;
  transform-origin: bottom center;
  filter: drop-shadow(0 9px 4px rgba(0, 0, 0, 0.42));
}

.enemy-sprite-fallback {
  display: none;
  place-items: center;
  width: clamp(64px, 9vw, 108px);
  aspect-ratio: 1;
  border: 2px solid rgba(243, 230, 187, 0.58);
  border-radius: 48% 52% 44% 56%;
  color: #1b1d18;
  background:
    radial-gradient(circle at 36% 30%, rgba(255, 255, 255, 0.62), transparent 30%),
    linear-gradient(145deg, #d6b568, #7d5632);
  box-shadow:
    inset 0 0 0 4px rgba(17, 18, 15, 0.18),
    0 8px 4px rgba(0, 0, 0, 0.35);
  font: 900 clamp(1.25rem, 3.2vw, 2.4rem) Georgia, serif;
}

.combatant.sprite-missing .enemy-sprite-fallback {
  display: grid;
}

.enemy-body {
  position: relative;
  width: clamp(52px, 7.75vw, 97px);
  aspect-ratio: 1;
  transform-origin: bottom center;
  filter: drop-shadow(0 8px 3px rgba(0, 0, 0, 0.4));
}

.enemy-body::before,
.enemy-body::after {
  content: "";
  position: absolute;
}

.enemy-body.ticktoad {
  border: 5px solid #4d5331;
  border-radius: 48% 48% 35% 35%;
  background:
    radial-gradient(circle at 31% 35%, #f9dd73 0 5%, #1c2519 6% 9%, transparent 10%),
    radial-gradient(circle at 69% 35%, #f9dd73 0 5%, #1c2519 6% 9%, transparent 10%),
    linear-gradient(135deg, #8da94c, #43582d);
  box-shadow: inset 0 -14px 0 rgba(40, 53, 32, 0.45);
}

.enemy-body.ticktoad::before {
  left: -16%;
  right: -16%;
  bottom: -7%;
  height: 24%;
  border-radius: 50%;
  background: #4f6533;
  z-index: -1;
}

.enemy-body.ticktoad::after {
  left: 31%;
  bottom: 22%;
  width: 38%;
  height: 8%;
  border-bottom: 4px solid #232819;
  border-radius: 50%;
}

.enemy-body.sourgeist {
  border: 4px solid #6a3f72;
  border-radius: 52% 48% 46% 42%;
  background:
    radial-gradient(circle at 35% 38%, #fff1a2 0 4%, #291d30 5% 8%, transparent 9%),
    radial-gradient(circle at 65% 38%, #fff1a2 0 4%, #291d30 5% 8%, transparent 9%),
    radial-gradient(circle at 42% 25%, #d69ce6, #6f3e82 55%, #3e2448);
  animation: geist-float 2.2s ease-in-out infinite;
}

.enemy-body.sourgeist::after {
  left: 17%;
  bottom: -24%;
  width: 66%;
  height: 42%;
  background: linear-gradient(135deg, #704183, #40234b);
  clip-path: polygon(0 0, 100% 0, 85% 100%, 62% 72%, 48% 100%, 28% 68%, 0 100%);
}

.enemy-body.caskjackal {
  width: clamp(62px, 9vw, 111px);
  aspect-ratio: 1.25;
  border: 5px solid #4c2a18;
  border-radius: 38% 47% 33% 42%;
  background:
    radial-gradient(circle at 68% 33%, #f9cf64 0 4%, #27180f 5% 8%, transparent 9%),
    linear-gradient(145deg, #ba6a31, #5f351d 60%, #3b2418);
}

.enemy-body.caskjackal::before {
  top: -22%;
  right: 6%;
  width: 31%;
  height: 43%;
  background: #6e3a20;
  clip-path: polygon(0 100%, 38% 0, 100% 100%);
}

.enemy-body.caskjackal::after {
  right: -24%;
  bottom: 12%;
  width: 42%;
  height: 23%;
  border-radius: 60%;
  background: #6a3c23;
  transform: rotate(-26deg);
  z-index: -1;
}

.actor-nameplate {
  position: absolute;
  left: 50%;
  bottom: -18px;
  min-width: 90px;
  transform: translateX(-50%);
  text-align: center;
  text-shadow: 0 2px 2px #000;
  font-size: clamp(0.58rem, 1vw, 0.72rem);
  white-space: nowrap;
}

.enemy-intel {
  display: block;
  margin-top: 2px;
  color: #f4d993;
  font-size: 0.48rem;
  letter-spacing: 0.02em;
}

.enemy-hp-mini {
  display: block;
  width: 80%;
  height: 3px;
  margin: 3px auto 0;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.75);
}

.enemy-hp-mini i {
  display: block;
  height: 100%;
  background: var(--red);
  transition: width 300ms;
}

.message-strip {
  position: absolute;
  left: 50%;
  bottom: 11px;
  z-index: 12;
  display: flex;
  align-items: center;
  width: min(70%, 720px);
  min-height: 34px;
  transform: translateX(-50%);
  padding: 7px 12px;
  border: 1px solid rgba(247, 231, 188, 0.36);
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(49, 56, 52, 0.96), rgba(20, 23, 22, 0.97));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 6px 18px rgba(0, 0, 0, 0.36);
  font-size: clamp(0.62rem, 1.25vw, 0.82rem);
}

.message-icon {
  margin-right: 9px;
  color: var(--amber);
  font-size: 1.1em;
}

.paused-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 20;
  transform: translate(-50%, -50%);
  padding: 10px 18px;
  border: 2px solid var(--cream);
  background: rgba(15, 17, 15, 0.9);
  box-shadow: var(--shadow);
  letter-spacing: 0.24em;
  font-weight: 900;
}

.battle-hud {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(310px, 0.9fr);
  min-height: 224px;
  border-top: 1px solid var(--line);
  background:
    linear-gradient(160deg, rgba(39, 45, 41, 0.98), rgba(17, 20, 18, 0.99));
}

.party-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-right: 1px solid var(--line);
}

.status-card {
  position: relative;
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  padding: 16px 14px 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent);
}

.status-card:last-child {
  border-right: 0;
}

.status-card.ready {
  background:
    linear-gradient(180deg, rgba(241, 167, 53, 0.15), transparent 64%);
}

.status-card.commanding::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--amber);
  box-shadow: 0 0 12px rgba(241, 167, 53, 0.55);
}

.status-name-row,
.number-row,
.atb-label,
.command-heading,
.rail-heading,
.catalog-toolbar,
.dialog-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.status-name-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.65vw, 1.35rem);
  white-space: nowrap;
}

.level-tag {
  color: var(--muted);
  font-size: 0.68rem;
}

.number-row {
  font-size: clamp(0.66rem, 1.1vw, 0.8rem);
}

.number-row span:first-child {
  color: var(--muted);
}

.number-row strong {
  font-size: 1.05em;
}

.hp-track,
.mp-track,
.atb-track {
  height: 7px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(4, 5, 4, 0.74);
  box-shadow: inset 0 1px 2px #000;
}

.hp-track i,
.mp-track i,
.atb-track i {
  display: block;
  height: 100%;
  transition: width 180ms linear;
}

.hp-track i {
  background: linear-gradient(90deg, #a9c45c, #e3c75e);
}

.hp-track.low i {
  background: linear-gradient(90deg, #b7413f, #e87a4c);
}

.mp-track i {
  background: linear-gradient(90deg, #4b7fc4, #6fd2db);
}

.atb-label {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.atb-track {
  height: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.atb-track i {
  background: linear-gradient(90deg, #5b8561, #a2cf71);
}

.status-card.ready .atb-track i {
  background: linear-gradient(90deg, #e5862b, #ffd36e);
  box-shadow: 0 0 10px rgba(255, 193, 73, 0.65);
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 18px;
}

.status-pill {
  padding: 2px 5px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  color: #e7e0ca;
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.58rem;
}

.status-pill.positive {
  color: #b7f0d1;
  border-color: rgba(79, 197, 176, 0.45);
}

.status-pill.negative {
  color: #ffada5;
  border-color: rgba(223, 98, 85, 0.45);
}

.command-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  padding: 15px;
}

.command-heading {
  margin-bottom: 12px;
  min-height: 40px;
}

.command-heading > div {
  min-width: 0;
}

.command-actor {
  display: block;
  color: var(--amber);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.command-heading strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  text-overflow: ellipsis;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  white-space: nowrap;
}

.back-button,
.text-button,
.close-button {
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.back-button:hover,
.text-button:hover,
.close-button:hover {
  color: var(--cream);
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 7px;
}

.command-button,
.command-placeholder,
.submenu-button,
.target-button {
  min-width: 0;
  min-height: 42px;
  padding: 8px 9px;
  border: 1px solid rgba(245, 228, 181, 0.24);
  border-radius: 3px;
  text-align: left;
  background:
    linear-gradient(180deg, rgba(72, 80, 74, 0.88), rgba(36, 41, 38, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.command-button:hover,
.submenu-button:hover,
.target-button:hover {
  border-color: var(--amber);
  background:
    linear-gradient(180deg, rgba(96, 91, 67, 0.92), rgba(50, 47, 37, 0.98));
}

.command-button:disabled,
.command-placeholder,
.submenu-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.command-button strong,
.submenu-button strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-button small,
.submenu-button small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.62rem;
}

.command-button.combo-ready {
  color: #fff0b8;
  border-color: rgba(241, 167, 53, 0.55);
}

.submenu {
  max-height: 144px;
  overflow: auto;
  padding-right: 3px;
  scrollbar-color: #806b42 #1d211e;
}

.submenu-list {
  display: grid;
  gap: 5px;
}

.submenu-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: 100%;
}

.submenu-button .cost {
  align-self: center;
  margin-left: 8px;
  color: #7fd7e6;
  font-weight: 800;
}

.detail-line {
  min-height: 30px;
  padding-top: 8px;
  color: var(--muted);
  font-size: 0.61rem;
  line-height: 1.35;
}

.side-rail {
  display: grid;
  gap: 12px;
}

.rail-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(27, 31, 27, 0.88);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.rail-heading {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
}

.rail-heading strong {
  color: var(--amber);
  font-size: 0.65rem;
}

.flow-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 13px 9px;
  font-size: 0.58rem;
  text-transform: uppercase;
}

.flow-track span {
  color: #697068;
}

.flow-track span.active {
  color: var(--cream);
}

.flow-track i {
  width: 12px;
  height: 1px;
  background: #50564f;
}

.battle-log {
  height: 250px;
  margin: 0;
  padding: 8px 12px 12px 32px;
  overflow: auto;
  color: #c4c8bc;
  font-size: 0.66rem;
  line-height: 1.45;
  scrollbar-color: #806b42 #1d211e;
}

.battle-log li {
  padding: 5px 0 6px 3px;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.08);
}

.battle-log li::marker {
  color: #6b746a;
}

.battle-log .damage-log {
  color: #f0b49b;
}

.battle-log .heal-log {
  color: #9fe0bd;
}

.battle-log .system-log {
  color: #f2c66e;
}

.keys-card dl {
  margin: 0;
  padding: 9px 12px 12px;
}

.keys-card dl div {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.61rem;
}

.keys-card dt {
  color: var(--cream);
}

.keys-card dd {
  margin: 0;
  color: var(--muted);
}

.restart-button {
  width: 100%;
  border-color: rgba(241, 167, 53, 0.5);
  color: #f7d999;
  background: rgba(62, 46, 27, 0.78);
  font-size: 0.72rem;
}

footer {
  padding: 14px 4px 0;
  color: #7e857d;
  font-size: 0.66rem;
  text-align: center;
}

.effect-burst,
.damage-number {
  position: absolute;
  z-index: 30;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.effect-burst {
  width: clamp(50px, 9vw, 120px);
  aspect-ratio: 1;
  border: 4px solid currentColor;
  border-radius: 50%;
  opacity: 0;
  animation: burst 650ms ease-out;
  box-shadow:
    0 0 20px currentColor,
    inset 0 0 22px currentColor;
}

.damage-number {
  color: #fff4cc;
  font-size: clamp(0.78rem, 2vw, 1.35rem);
  font-weight: 900;
  text-shadow:
    0 2px #16120d,
    1px 0 #16120d,
    -1px 0 #16120d;
  animation: number-float 850ms ease-out forwards;
}

.damage-number.heal {
  color: #83ebad;
}

.damage-number.miss {
  color: #c6cbc4;
  font-size: 0.78rem;
}

.system-dialog {
  width: min(1160px, calc(100vw - 30px));
  max-height: calc(100vh - 30px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(244, 222, 166, 0.36);
  border-radius: 7px;
  color: var(--cream);
  background: #171b18;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.72);
}

.system-dialog::backdrop {
  background: rgba(5, 7, 6, 0.77);
  backdrop-filter: blur(5px);
}

.dialog-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100vh - 34px);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 0 0, rgba(175, 88, 35, 0.15), transparent 35rem),
    #20251f;
}

.dialog-header h2 {
  margin: 3px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  font-weight: 500;
}

.dialog-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.close-button {
  font-size: 1.8rem;
  line-height: 1;
}

.party-editor,
.catalog-content {
  min-height: 0;
  overflow: auto;
  scrollbar-color: #806b42 #1d211e;
}

.party-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.party-editor-card {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  background: #20251f;
}

.party-editor-card.selected {
  border-color: rgba(241, 167, 53, 0.7);
  background: #29281f;
}

.party-editor-card img {
  align-self: end;
  width: 88px;
  image-rendering: auto;
}

.party-editor-info {
  min-width: 0;
}

.party-select-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.party-select-line label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
}

.party-editor-info p {
  margin: 3px 0 9px;
  color: var(--muted);
  font-size: 0.62rem;
}

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

.loadout-grid label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 0.55rem;
  text-transform: uppercase;
}

.loadout-grid select {
  min-width: 0;
  min-height: 31px;
  padding: 4px 6px;
  font-size: 0.6rem;
}

.dialog-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: #20251f;
  color: var(--muted);
  font-size: 0.68rem;
}

.catalog-dialog .dialog-card {
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.catalog-tabs {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #191d1a;
}

.catalog-tab {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  color: var(--muted);
  background: #252a25;
  font-size: 0.65rem;
  cursor: pointer;
}

.catalog-tab.active {
  color: #17140e;
  border-color: var(--amber);
  background: var(--amber);
  font-weight: 900;
}

.catalog-toolbar {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: #202520;
}

.catalog-toolbar input {
  width: min(420px, 70%);
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  color: var(--cream);
  background: #111411;
}

.catalog-toolbar span {
  color: var(--muted);
  font-size: 0.65rem;
}

.catalog-content {
  padding: 12px;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.catalog-entry {
  min-width: 0;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: #202520;
}

.catalog-entry header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 0;
}

.catalog-entry h3 {
  margin: 0;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.catalog-entry .entry-tag {
  flex: 0 0 auto;
  color: var(--amber);
  font-size: 0.58rem;
  text-transform: uppercase;
}

.catalog-entry p {
  min-height: 2.4em;
  margin: 7px 0;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.4;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.entry-meta span {
  padding: 3px 5px;
  border-radius: 2px;
  color: #d5d7cf;
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.55rem;
}

.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 7, 6, 0.78);
  backdrop-filter: blur(6px);
}

.result-overlay[hidden] {
  display: none;
}

.result-card {
  width: min(520px, 100%);
  padding: 28px;
  border: 1px solid rgba(245, 222, 164, 0.45);
  border-radius: 7px;
  background:
    radial-gradient(circle at 50% 0, rgba(196, 111, 41, 0.17), transparent 24rem),
    #20241f;
  box-shadow: 0 30px 100px #000;
  text-align: center;
}

.result-card h2 {
  margin: 6px 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.8rem;
  font-weight: 500;
}

.result-card > p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.72rem;
}

.reward-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 16px 0 22px;
}

.reward-cell {
  padding: 11px 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.reward-cell strong {
  display: block;
  font-size: 1.15rem;
}

.reward-cell span {
  color: var(--muted);
  font-size: 0.56rem;
  text-transform: uppercase;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

@keyframes hit-flash {
  0%,
  100% {
    filter: brightness(1);
  }
  30%,
  65% {
    filter: brightness(3) saturate(0);
  }
}

@keyframes actor-pulse {
  0% {
    transform: translate(-50%, -100%) scale(1);
  }
  45% {
    transform: translate(-50%, -100%) scale(1.1);
    filter: brightness(1.45);
  }
  100% {
    transform: translate(-50%, -100%) scale(1);
  }
}

@keyframes geist-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
}

@keyframes burst {
  0% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(0.25);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.5);
  }
}

@keyframes number-float {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -160%);
  }
}

@media (max-width: 1080px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

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

  .restart-button {
    grid-column: 1 / -1;
  }

  .battle-log {
    height: 150px;
  }
}

@media (max-width: 760px) {
  .page-shell {
    padding: 12px 8px 24px;
  }

  .topbar {
    display: grid;
  }

  .topbar-controls {
    justify-content: flex-start;
  }

  .battle-hud {
    grid-template-columns: 1fr;
  }

  .party-status {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .status-card {
    padding: 10px 8px;
  }

  .command-panel {
    min-height: 210px;
  }

  .side-rail {
    grid-template-columns: 1fr;
  }

  .party-editor {
    grid-template-columns: 1fr;
  }

  .reward-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 470px) {
  .topbar-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .topbar-controls > * {
    width: 100%;
  }

  .party-status {
    grid-template-columns: 1fr;
  }

  .status-card {
    grid-template-columns: 1fr 1fr;
  }

  .status-name-row,
  .status-pills {
    grid-column: 1 / -1;
  }

  .party-editor-card {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .party-editor-card img {
    width: 68px;
  }

  .loadout-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
