:root {
  color-scheme: dark;
  --void: #07090c;
  --screen: #0c1015;
  --screen-soft: #141a21;
  --paper: #e8d8ae;
  --paper-deep: #c3a875;
  --ink: #17140f;
  --cream: #f3ead0;
  --muted: #8d918f;
  --line: rgba(238, 229, 204, 0.17);
  --gold: #d8b24c;
  --cyan: #36c6da;
  --coral: #e96452;
  --violet: #9a6cbd;
  --green: #74ad5a;
  --danger: #e0524e;
  --radius: 3px;
  min-height: 100%;
  background: var(--void);
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--cream);
  background: #080a0d url("assets/game/fadebreak-screen-texture-v2.png") center / cover fixed;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

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

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.85);
  opacity: 0.42;
}

svg {
  display: block;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Prototype frame ------------------------------------------------ */

.prototype-stage {
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100dvh;
  padding: 14px;
}

.phone-shell {
  --world-sat: 0.52;
  width: min(430px, calc(100vw - 28px));
  height: min(900px, calc(100dvh - 28px));
  min-height: 620px;
}

.phone-shell.chroma-level-1 { --world-sat: 0.18; }
.phone-shell.chroma-level-2 { --world-sat: 0.36; }
.phone-shell.chroma-level-3 { --world-sat: 0.62; }
.phone-shell.chroma-level-4 { --world-sat: 0.82; }
.phone-shell.chroma-level-5 { --world-sat: 1; }

.phone-frame {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 11px;
  width: 100%;
  height: 100%;
  padding: 10px 9px 7px;
  border: 2px solid #4e535d;
  border-radius: 32px;
  background: #191c22;
  box-shadow:
    0 0 0 3px #08090c,
    0 20px 70px rgba(0, 0, 0, 0.58),
    inset 0 0 0 1px #747985;
}

.phone-screen {
  position: relative;
  display: grid;
  grid-template-rows: 20px 50px minmax(0, 1fr) 58px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #303640;
  border-radius: 22px 22px 10px 10px;
  background: var(--screen) url("assets/game/fadebreak-phone-background-v3.png") center top / cover;
  box-shadow: inset 0 0 36px rgba(0, 0, 0, 0.5);
}

.phone-screen.active-battle,
.phone-screen.run-summary-visible {
  grid-template-rows: 20px 50px minmax(0, 1fr);
}

.phone-screen.active-battle > .nav,
.phone-screen.run-summary-visible > .nav {
  display: none;
}

.phone-screen::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 50%;
  z-index: 10;
  width: 72px;
  height: 4px;
  border-radius: 4px;
  background: #030406;
  transform: translateX(-50%);
}

.phone-status {
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  color: rgba(243, 234, 208, 0.64);
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.5rem;
  font-weight: 900;
}

.phone-sensors {
  display: flex;
  align-items: center;
  gap: 4px;
}

.phone-sensors i {
  width: 5px;
  height: 5px;
  background: currentColor;
}

.phone-sensors b {
  padding: 1px 2px;
  border: 1px solid currentColor;
  font-size: inherit;
  line-height: 1;
}

.home-indicator {
  align-self: end;
  justify-self: center;
  width: 112px;
  height: 4px;
  background: #60656e;
}

.wrapper-brand {
  display: none;
}

@media (min-width: 940px) {
  .prototype-stage {
    grid-template-columns: minmax(280px, 360px) 430px;
    justify-content: center;
    gap: clamp(38px, 6vw, 78px);
  }

  .wrapper-brand {
    position: relative;
    display: grid;
    align-content: center;
    gap: 16px;
    color: rgba(243, 234, 208, 0.5);
  }

  .wrapper-brand::before {
    content: "ARCHIVE TERMINAL // FB-01";
    color: rgba(243, 234, 208, 0.28);
    font-size: 0.5rem;
    font-weight: 900;
    letter-spacing: 0.14em;
  }

  .wrapper-brand img {
    display: block;
    width: 100%;
    image-rendering: pixelated;
    filter: drop-shadow(8px 8px 0 rgba(0, 0, 0, 0.5));
  }

  .wrapper-manifesto {
    color: var(--gold);
    font-size: 0.7rem;
    font-weight: 950;
    letter-spacing: 0.11em;
    text-align: center;
  }

  .wrapper-brand p {
    max-width: 285px;
    margin: 0 auto;
    font-size: 0.62rem;
    line-height: 1.6;
    text-align: center;
  }

  .wrapper-rule {
    display: grid;
    grid-template-columns: 1fr 7px 1fr;
    align-items: center;
    gap: 8px;
  }

  .wrapper-rule span {
    height: 1px;
    background: rgba(216, 178, 76, 0.55);
  }

  .wrapper-rule span:last-child {
    transform: rotate(180deg);
  }

  .wrapper-rule i {
    width: 7px;
    height: 7px;
    border: 1px solid var(--gold);
    transform: rotate(45deg);
  }
}

/* App chrome ----------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 0 6px;
  border: solid transparent;
  border-width: 7px 10px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 7px 10px;
  border-image-outset: 0;
  border-image-repeat: stretch;
  background: #090d12;
  image-rendering: pixelated;
}

.brand {
  flex: 1 1 auto;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: min(150px, 42vw);
  height: 30px;
  object-fit: contain;
  object-position: left center;
  image-rendering: pixelated;
  filter: saturate(var(--world-sat)) drop-shadow(2px 2px 0 #000);
}

.wallet {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
}

.wallet span {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 26px;
  padding: 0 7px;
  color: var(--gold);
  border-left: 1px solid var(--line);
  font-size: 0.6rem;
  font-weight: 950;
}

.wallet .chroma-balance,
.run-wallet span:nth-child(2) {
  color: var(--cyan);
}

.wallet .pixel-ui-icon-coin {
  width: 22px;
  height: 22px;
  background-image: url("assets/game/ui-icon-coin-v4.png");
}

.run-wallet span:first-child {
  color: #a9bdd1;
}

.app-viewport {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
  padding: 6px 8px;
}

.app-viewport::-webkit-scrollbar,
.copies-modal::-webkit-scrollbar {
  display: none;
}

.nav {
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 0 2px;
  border: solid transparent;
  border-width: 7px 10px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 7px 10px;
  border-image-outset: 0;
  border-image-repeat: stretch;
  background: #080c11;
  image-rendering: pixelated;
}

.nav-button {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 42px;
  padding: 3px;
  color: rgba(243, 234, 208, 0.48);
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0.5rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-button.active {
  color: var(--gold);
}

.nav-button.active::after {
  content: "";
  width: 34px;
  height: 2px;
  background: var(--gold);
  box-shadow: 0 0 8px color-mix(in srgb, var(--gold) 55%, transparent);
}

/* Shared type and controls --------------------------------------- */

h2,
h3,
p {
  margin-top: 0;
}

h2,
h3 {
  color: var(--cream);
  letter-spacing: -0.03em;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

h3 {
  margin-bottom: 5px;
  font-size: 0.78rem;
}

p {
  margin-bottom: 0;
  color: rgba(243, 234, 208, 0.62);
  font-size: 0.62rem;
  line-height: 1.5;
}

.section-kicker {
  color: var(--gold);
  font-size: 0.47rem;
  font-weight: 950;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.section-title {
  margin: 0;
}

.small-note {
  color: rgba(243, 234, 208, 0.48);
  font-size: 0.49rem;
  line-height: 1.35;
}

.section-header,
.deck-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.deck-header {
  padding: 1px 1px 8px;
  border-bottom: 1px solid var(--line);
}

.primary-button,
.ghost-button,
.mini-button,
.chip,
.loadout-ready-button {
  min-height: 34px;
  border: 1px solid rgba(243, 234, 208, 0.22);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  font-size: 0.54rem;
  font-weight: 950;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.primary-button,
.loadout-ready-button {
  min-height: 40px;
  padding: 6px 18px;
  color: #f9edc9;
  border: 0;
  background: #171109 url("assets/game/ui-primary-button-v2.png") center / 100% 100% no-repeat;
  text-shadow: 1px 2px #000;
}

.ghost-button {
  padding: 0 10px;
  color: rgba(243, 234, 208, 0.72);
  border: 0;
  background: #0a0f15 url("assets/game/ui-dark-plaque-v2.png") center / 100% 100% no-repeat;
}

.mini-button {
  min-width: 26px;
  min-height: 26px;
  padding: 0;
  border: 0;
  background: #0a0f15 url("assets/game/ui-dark-plaque-v2.png") center / 100% 100% no-repeat;
}

.message {
  padding: 7px 1px 0;
  color: rgba(243, 234, 208, 0.5);
  font-size: 0.52rem;
  line-height: 1.45;
}

.empty-state {
  padding: 16px;
  color: rgba(243, 234, 208, 0.44);
  border: 1px dashed var(--line);
  font-size: 0.58rem;
  text-align: center;
}

.compact-empty {
  grid-column: 1 / -1;
}

.surface-panel {
  min-width: 0;
}

.wide-surface,
.screen-stack,
.archive-screen {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.archive-screen {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100%;
  gap: 6px;
  overflow: hidden;
}

.archive-screen > .message {
  min-height: 10px;
  padding: 0;
  overflow: hidden;
  font-size: 0.43rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress,
.mini-progress {
  overflow: hidden;
  height: 4px;
  background: rgba(243, 234, 208, 0.12);
}

.progress-fill,
.mini-progress span {
  display: block;
  width: var(--pct, 0%);
  height: 100%;
  background: var(--gold);
}

.rarity-pill {
  color: var(--cream);
  font-size: 0.45rem;
  font-weight: 950;
  text-transform: uppercase;
}

.uncommon { --rarity: #71aa68; }
.rare { --rarity: #4fb4d3; }
.epic { --rarity: #a176ce; }
.silver-foil { --rarity: #c9d1d6; }
.gold-foil { --rarity: #e7bd52; }
.platinum-foil { --rarity: #9de1e5; }
.godlike { --rarity: #ef6558; }
.common { --rarity: #b9ad8e; }

/* Generated game sprites ---------------------------------------- */

.game-sprite {
  display: block;
  background-repeat: no-repeat;
  background-size: 200% 200%;
  image-rendering: pixelated;
  filter: saturate(var(--world-sat)) drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.48));
}

.tile-sprite {
  width: 74%;
  height: 74%;
  background-image: url("assets/game/fadebreak-tile-sprites.png");
}

.tile-sprite-coin {
  width: 82%;
  height: 82%;
  background-image: url("assets/game/ui-icon-coin-v4.png");
  background-position: center;
  background-size: contain;
}
.tile-sprite-mana { background-position: 100% 0; }
.tile-sprite-sword { background-position: 0 100%; }
.tile-sprite-shield { background-position: 100% 100%; }

.enemy-sprite {
  width: 92%;
  height: 92%;
  background-image: url("assets/game/fadebreak-enemy-sprites.png");
}

.enemy-sprite-leech { background-position: 0 0; }
.enemy-sprite-scout { background-position: 100% 0; }
.enemy-sprite-tick { background-position: 0 100%; }
.enemy-sprite-wraith { background-position: 100% 100%; }

.pixel-ui-icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  image-rendering: pixelated;
  filter: saturate(var(--world-sat)) drop-shadow(1px 2px 0 #000);
}

.pixel-ui-icon-run { background-image: url("assets/game/ui-icon-run-v2.png"); }
.pixel-ui-icon-tasks { background-image: url("assets/game/ui-icon-tasks-v2.png"); }
.pixel-ui-icon-book { background-image: url("assets/game/ui-icon-book-v2.png"); }
.pixel-ui-icon-coin { background-image: url("assets/game/ui-icon-coin-v4.png"); }
.pixel-ui-icon-mana { background-image: url("assets/game/ui-icon-mana-v2.png"); }
.pixel-ui-icon-chroma { background-image: url("assets/game/ui-icon-chroma-v2.png"); }
.pixel-ui-icon-battle { background-image: url("assets/game/ui-icon-battle-v2.png"); }
.pixel-ui-icon-shield { background-image: url("assets/game/base-shield-full-v2.png"); }

.nav-pixel-icon {
  width: 26px;
  height: 26px;
  opacity: 0.62;
}

.nav-button.active .nav-pixel-icon {
  opacity: 1;
}

/* Card system ---------------------------------------------------- */

.card-face-card {
  --rarity: #b9ad8e;
  --card-frame: url("assets/game/card-frame-common-v2.png");
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 56%) minmax(0, 44%);
  min-width: 0;
  aspect-ratio: 5 / 7;
  overflow: hidden;
  padding: 8px;
  color: var(--ink);
  border: 0;
  border-radius: 0;
  background: #d9c798;
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.42);
  text-align: left;
}

.card-face-card::after {
  content: "";
  position: absolute;
  z-index: 8;
  inset: 0;
  border: solid transparent;
  border-width: 9px 8px;
  border-image-source: var(--card-frame);
  border-image-slice: 54 46 54 46;
  border-image-width: 9px 8px;
  border-image-outset: 0;
  border-image-repeat: stretch;
  background: none;
  image-rendering: pixelated;
  pointer-events: none;
}

.card-face-card.uncommon { --card-frame: url("assets/game/card-frame-uncommon-v2.png"); }
.card-face-card.rare { --card-frame: url("assets/game/card-frame-rare-v2.png"); }
.card-face-card.epic,
.card-face-card.silver-foil,
.card-face-card.gold-foil,
.card-face-card.platinum-foil,
.card-face-card.godlike { --card-frame: url("assets/game/card-frame-epic-v2.png"); }

.card-face-card.active {
  transform: translateY(-2px);
  filter: brightness(1.16) drop-shadow(0 0 4px rgba(216, 178, 76, 0.68));
  box-shadow: 3px 5px 0 rgba(0, 0, 0, 0.48);
}

.card-face-visual {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  background: #14171c;
}

.card-face-nameplate {
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 3px;
  min-height: 20px;
  padding: 3px 4px;
  color: var(--cream);
  background: rgba(8, 10, 13, 0.94);
}

.card-face-title {
  overflow: hidden;
  font-size: clamp(0.42rem, 1.7vw, 0.58rem);
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-rarity-mark {
  display: grid;
  place-items: center;
  min-width: 15px;
  height: 15px;
  color: #0f1114;
  background: var(--rarity);
  font-size: 0.43rem;
  font-weight: 950;
}

.card-face-art {
  display: grid;
  place-items: center;
  min-height: 0;
  color: rgba(255, 255, 255, 0.88);
  background: #11151b;
  image-rendering: pixelated;
  filter: saturate(var(--world-sat));
}

.card-face-art > svg {
  width: 38%;
  height: 38%;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.48));
}

.generated-card-art {
  background-repeat: no-repeat;
}

.generated-card-art svg {
  display: none;
}

.hero-card-art {
  background-image: url("assets/game/fadebreak-hero-art-atlas-v2.png");
  background-size: 300% auto;
}

.relic-card-art {
  background-image: url("assets/game/fadebreak-relic-art-atlas-v2.png");
  background-size: 300% auto;
}

.action-card-art {
  background-image: url("assets/game/fadebreak-action-art-atlas-v2.png");
  background-size: 400% auto;
}

.generated-card-art-chrona,
.generated-card-art-mana-clock { background-position: 0 20%; }
.generated-card-art-spark-blade { background-position: 0 20%; }
.generated-card-art-mira,
.generated-card-art-loaded-sleeve { background-position: 50% 20%; }
.generated-card-art-bramble,
.generated-card-art-overguard-plate { background-position: 100% 20%; }
.generated-card-art-orrin,
.generated-card-art-finders-pouch { background-position: 0 80%; }
.generated-card-art-vessa,
.generated-card-art-sharp-eye-lens { background-position: 50% 80%; }
.generated-card-art-repair-charm { background-position: 100% 80%; }
.generated-card-art-spellblade-conduit { background-position: 0 20%; }

.generated-card-art-coin-rush { background-position: 33.333% 20%; }
.generated-card-art-shield-wall { background-position: 66.667% 20%; }
.generated-card-art-corner-cache { background-position: 100% 20%; }
.generated-card-art-forge-order { background-position: 0 50%; }
.generated-card-art-mana-tide { background-position: 33.333% 50%; }
.generated-card-art-rally-banner { background-position: 66.667% 50%; }
.generated-card-art-storm-ledger { background-position: 100% 50%; }
.generated-card-art-coin-press { background-position: 0 80%; }
.generated-card-art-calm-mind { background-position: 33.333% 80%; }
.generated-card-art-gate-fee { background-position: 66.667% 80%; }
.generated-card-art-blade-singer { background-position: 100% 80%; }

.card-face-art-empty {
  background: #1b1e22 url("assets/game/ui-icon-book-v2.png") center / 42% auto no-repeat;
  opacity: 0.72;
}

.card-face-copy {
  z-index: 1;
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 0;
  padding: 5px;
  background: var(--paper);
}

.card-face-subtitle,
.card-face-meta {
  color: rgba(23, 20, 15, 0.58);
}

.card-text {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: #211b12;
  font-size: clamp(0.38rem, 1.55vw, 0.52rem);
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-tags,
.listing-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.tag,
.card-copy {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.4rem;
  font-weight: 900;
}

.tag svg {
  width: 9px;
  height: 9px;
}

.locked-card {
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  color: rgba(243, 234, 208, 0.45);
  border-style: dashed;
  background: #171a1e;
}

.locked-card-mark svg {
  width: 25px;
  height: 25px;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 8px;
  min-width: 0;
}

.collection-card {
  cursor: pointer;
}

.collection-card.dragging-card,
.deck-slot.dragging-card {
  opacity: 0.45;
}

.card-drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: 88px;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-3deg);
  transform-origin: center;
  opacity: 0.9;
  will-change: transform;
}

.card-drag-ghost.play-card-drag-ghost {
  width: 128px;
  max-width: none;
  margin: 0;
  opacity: 0.96;
  filter: brightness(1.12) drop-shadow(0 8px 0 rgba(0, 0, 0, 0.72));
  transition: none;
}

.card-drag-ghost.play-card-drag-ghost.valid-drop {
  filter: brightness(1.26) drop-shadow(0 0 7px rgba(216, 178, 76, 0.9)) drop-shadow(0 9px 0 rgba(0, 0, 0, 0.72));
}

body.card-dragging {
  cursor: grabbing;
  user-select: none;
}

/* Run start and task screens ------------------------------------- */

.loadout-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.loadout-slot {
  min-width: 0;
}

.loadout-slot:first-child,
.loadout-summary > button {
  grid-column: 1 / -1;
}

.hero-action-copy {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.hero-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--cyan);
}

.hero-avatar svg {
  width: 22px;
  height: 22px;
}

.campaign-brief {
  display: grid;
  gap: 16px;
}

.campaign-objective {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.campaign-objective .primary-button {
  min-width: 100px;
}

.active-contracts,
.run-contract-panel,
.resource-panel {
  display: grid;
  gap: 8px;
}

.active-contract-list {
  display: grid;
  gap: 8px;
}

.active-contract {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.active-contract > div {
  display: grid;
  gap: 4px;
}

.active-contract span {
  color: rgba(243, 234, 208, 0.48);
  font-size: 0.5rem;
}

.contract-grid {
  display: grid;
  gap: 14px;
}

.contract-card {
  display: grid;
  gap: 9px;
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--line);
}

.contract-card-header,
.contract-stakes,
.contract-reward,
.contract-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.contract-stakes,
.contract-reward {
  font-size: 0.55rem;
}

.contract-results {
  display: grid;
  gap: 6px;
}

.result-panel {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

/* Run summary ---------------------------------------------------- */

.run-summary-screen {
  display: grid;
  height: 100%;
  min-height: 0;
  place-items: center;
  overflow: hidden;
}

.run-summary-panel {
  display: grid;
  width: 100%;
  max-height: 100%;
  gap: 8px;
  padding: 6px 8px 8px;
  overflow: hidden;
  color: var(--cream);
  border: solid transparent;
  border-width: 9px 12px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 9px 12px;
  border-image-repeat: stretch;
  background: #080c11;
  image-rendering: pixelated;
}

.run-summary-banner {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  min-height: 74px;
  gap: 9px;
  padding: 4px 7px;
  border: solid transparent;
  border-width: 8px 11px;
  border-image-source: url("assets/game/ui-danger-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 8px 11px;
  border-image-repeat: stretch;
  background: #210d12;
  image-rendering: pixelated;
}

.run-summary-banner h2 {
  margin: 1px 0 2px;
  color: #fff0dc;
  font-size: 1.12rem;
  text-transform: uppercase;
}

.run-summary-banner p {
  font-size: 0.54rem;
}

.run-summary-emblem {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
}

.run-summary-emblem .pixel-ui-icon {
  width: 42px;
  height: 42px;
  filter: grayscale(0.72) saturate(var(--world-sat)) drop-shadow(2px 3px 0 #000);
}

.run-summary-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: 52px;
  border-block: 1px solid rgba(216, 178, 76, 0.28);
}

.run-summary-stats > div {
  display: grid;
  place-content: center;
  text-align: center;
}

.run-summary-stats > div + div {
  border-left: 1px solid rgba(216, 178, 76, 0.2);
}

.run-summary-stats strong {
  color: var(--gold);
  font-size: 1rem;
  line-height: 1;
}

.run-summary-stats span {
  margin-top: 3px;
  color: rgba(243, 234, 208, 0.48);
  font-size: 0.43rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.run-summary-yield,
.run-summary-contracts,
.run-summary-harvest {
  display: grid;
  gap: 5px;
}

.run-summary-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
}

.run-summary-heading h3 {
  margin: 0;
  font-size: 0.72rem;
}

.run-summary-heading > span {
  color: rgba(243, 234, 208, 0.4);
  font-size: 0.42rem;
}

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

.run-summary-reward {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  min-width: 0;
  min-height: 58px;
  gap: 4px;
  padding: 2px 5px;
  border: solid transparent;
  border-width: 7px 9px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 7px 9px;
  border-image-repeat: stretch;
  background: #090e14;
  image-rendering: pixelated;
}

.run-summary-reward .pixel-ui-icon {
  width: 27px;
  height: 27px;
}

.run-summary-reward > span {
  font-size: 0.52rem;
  font-weight: 900;
}

.run-summary-reward > strong {
  color: var(--gold);
  font-size: 0.84rem;
}

.run-summary-reward.chroma > strong {
  color: var(--cyan);
}

.run-summary-reward small {
  grid-column: 1 / -1;
  overflow: hidden;
  color: rgba(243, 234, 208, 0.42);
  font-size: 0.38rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-summary-harvest > div:last-child {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

.run-summary-harvest span {
  display: grid;
  grid-template-columns: 22px auto;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.run-summary-harvest .tile-sprite {
  width: 22px;
  height: 22px;
}

.run-summary-harvest b {
  color: var(--cream);
  font-size: 0.65rem;
}

.run-summary-harvest small {
  grid-column: 1 / -1;
  color: rgba(243, 234, 208, 0.38);
  font-size: 0.37rem;
  text-align: center;
}

.run-summary-contracts .contract-results {
  gap: 3px;
}

.run-summary-contracts .contract-result {
  min-height: 24px;
  padding: 2px 5px;
  color: rgba(243, 234, 208, 0.62);
  border-bottom: 1px solid rgba(243, 234, 208, 0.12);
  font-size: 0.45rem;
}

.run-summary-contracts .contract-result.won strong {
  color: var(--cyan);
}

.run-summary-contracts .contract-result.lost strong {
  color: #e95f4d;
}

.run-summary-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: 6px;
  margin-top: auto;
}

.run-summary-actions button {
  min-height: 40px;
}

/* Battle --------------------------------------------------------- */

.game-surface,
.battle-screen {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.battle-screen {
  height: 100%;
  align-content: start;
  overflow: hidden;
}

.battle-objective {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 3px 8px;
}

.contract-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.contract-title > svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--gold);
}

.contract-title > .pixel-ui-icon {
  width: 22px;
  height: 22px;
}

.contract-title span,
.battle-turn span {
  color: rgba(243, 234, 208, 0.48);
  font-size: 0.49rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.contract-title h2 {
  overflow: hidden;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-turn {
  display: grid;
  justify-items: end;
  font-size: 0.62rem;
}

.battle-objective .progress {
  grid-column: 1 / -1;
}

.combat-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.68fr) minmax(0, 1.02fr);
  align-items: center;
  gap: 3px;
  padding: 0 8px;
  border: solid transparent;
  border-width: 7px 10px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 7px 10px;
  border-image-outset: 0;
  border-image-repeat: stretch;
  background: #090d12;
  image-rendering: pixelated;
}

.combat-stat {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 1px 5px;
  min-width: 0;
}

.combat-stat > .pixel-ui-icon {
  grid-row: 1 / span 2;
  width: 24px;
  height: 24px;
}

.combat-stat > span {
  color: rgba(243, 234, 208, 0.44);
  font-size: 0.46rem;
  text-transform: uppercase;
}

.combat-stat strong {
  font-size: 0.62rem;
}

.mana-stat {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: 2px;
}

.mana-stat-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
}

.mana-stat-heading > .pixel-ui-icon {
  width: 14px;
  height: 14px;
}

.mana-stat-heading > span {
  color: rgba(243, 234, 208, 0.62);
  font-size: 0.48rem;
  font-weight: 950;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mana-stat-heading > strong {
  color: var(--cyan);
  font-size: 0.62rem;
}

.mana-pip-strip {
  display: grid;
  grid-template-columns: repeat(var(--mana-slots), minmax(0, 1fr));
  align-items: center;
  gap: 1px;
  min-height: 8px;
  max-height: 9px;
  overflow: hidden;
}

.mana-pip {
  display: block;
  width: 100%;
  max-width: 9px;
  aspect-ratio: 1;
  justify-self: center;
  background: url("assets/game/ui-icon-mana-v2.png") center / contain no-repeat;
  image-rendering: pixelated;
}

.mana-pip.full {
  filter: saturate(var(--world-sat)) drop-shadow(0 1px 0 #000);
}

.mana-pip.empty {
  filter: grayscale(1) brightness(0.7);
  opacity: 0.22;
}

.danger-stat.active strong { color: var(--coral); }

.enemy-wave-stat {
  display: grid;
  grid-template-columns: 1fr;
  align-content: center;
  gap: 1px;
}

.enemy-status-strip {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  min-height: 25px;
}

.enemy-status-icon {
  position: relative;
  display: grid;
  flex: 0 0 24px;
  place-items: center;
  width: 24px;
  height: 24px;
}

.enemy-status-icon .enemy-sprite {
  width: 23px;
  height: 23px;
}

.enemy-status-icon.queued .enemy-sprite {
  opacity: 0.42;
  filter: grayscale(1) brightness(0.72) drop-shadow(1px 2px 0 #000);
}

.enemy-status-icon.defeated .enemy-sprite {
  opacity: 0.22;
  filter: grayscale(1) brightness(0.45);
}

.enemy-status-icon.defeated b {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ef6558;
  font-size: 1.25rem;
  line-height: 1;
  text-shadow: 1px 1px #000;
}

.enemy-status-strip:is(.enemy-count-5, .enemy-count-6, .enemy-count-7) .enemy-status-icon,
.enemy-status-strip:is(.enemy-count-5, .enemy-count-6, .enemy-count-7) .enemy-sprite {
  width: 20px;
  height: 20px;
}

.enemy-status-strip:is(.enemy-count-5, .enemy-count-6, .enemy-count-7) .enemy-status-icon {
  flex-basis: 20px;
}

.enemy-status-strip:is(.enemy-count-6, .enemy-count-7) {
  gap: 1px;
}

.enemy-status-strip:is(.enemy-count-6, .enemy-count-7) .enemy-status-icon,
.enemy-status-strip:is(.enemy-count-6, .enemy-count-7) .enemy-sprite {
  width: 17px;
  height: 17px;
}

.enemy-status-strip:is(.enemy-count-6, .enemy-count-7) .enemy-status-icon {
  flex-basis: 17px;
}

.enemy-status-strip.enemy-count-7 .enemy-status-icon,
.enemy-status-strip.enemy-count-7 .enemy-sprite {
  width: 15px;
  height: 15px;
}

.enemy-status-strip.enemy-count-7 .enemy-status-icon {
  flex-basis: 15px;
}

.enemy-status-strip:is(.enemy-count-6, .enemy-count-7) .enemy-status-icon.defeated b {
  font-size: 0.86rem;
}

.board-zone,
.board-wrap {
  min-width: 0;
}

.board-wrap {
  display: grid;
  gap: 2px;
}

.active-battle .board-wrap {
  position: relative;
}

.enemy-entry-reservoir {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
  gap: 2px;
  width: min(100%, 258px);
  min-height: 30px;
  justify-self: center;
  padding: 0 3px;
  image-rendering: pixelated;
}

.enemy-entry-lane {
  position: relative;
  display: grid;
  min-width: 0;
  height: 30px;
  place-items: center;
}

.enemy-entry-lane .enemy-sprite {
  width: 27px;
  height: 27px;
}

.enemy-entry-lane.future .enemy-sprite {
  opacity: 0.48;
  filter: grayscale(1) brightness(0.72) drop-shadow(1px 2px 0 #000);
}

.enemy-entry-lane.ready .enemy-sprite {
  filter: brightness(1.12) saturate(var(--world-sat)) drop-shadow(0 0 2px #e94f48) drop-shadow(1px 2px 0 #000);
  animation: reservoir-ready 700ms steps(2, end) infinite;
}

.enemy-entry-lane.blocked .enemy-sprite {
  opacity: 0.72;
  filter: grayscale(0.65) brightness(0.72) drop-shadow(0 0 2px #e94f48) drop-shadow(1px 2px 0 #000);
  animation: none;
}

.enemy-entry-lane small {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 1px 2px;
  color: rgba(243, 234, 208, 0.72);
  background: rgba(5, 8, 11, 0.88);
  font-size: 0.36rem;
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0.03em;
  text-shadow: 1px 1px #000;
}

.enemy-entry-lane.ready small {
  color: #ff7164;
}

.enemy-entry-lane > b {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--gold);
  font-size: 0.4rem;
  line-height: 1;
  text-shadow: 1px 1px #000;
}

@keyframes reservoir-ready {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(2px); }
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 2px;
  width: min(100%, 258px);
  aspect-ratio: 1;
  justify-self: center;
  padding: 3px;
  border: 0;
  border-radius: 0;
  background: #070a0e;
  box-shadow: none;
}

.board.card-drop-ready {
  filter: brightness(1.12);
}

.board.card-drop-ready::before {
  content: "DROP CARD TO PLAY";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 20;
  min-width: 150px;
  padding: 9px 16px;
  color: var(--cream);
  border: 8px solid transparent;
  border-width: 8px 12px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 8px 12px;
  background: #090d12;
  font-size: 0.52rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 1px 2px #000;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.board.card-drop-ready.drag-over {
  filter: brightness(1.28) saturate(1.2);
}

.board.card-drop-ready.drag-over::before {
  content: "RELEASE TO PLAY";
  color: var(--gold);
}

.active-battle .board {
  width: min(100%, 374px);
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  color: var(--cream);
  border: 6px solid transparent;
  border-image-source: url("assets/game/board-cell-normal-v2.png");
  border-image-slice: 82 fill;
  border-image-width: 6px;
  border-image-outset: 0;
  border-image-repeat: stretch;
  border-radius: 0;
  background: #111820;
  box-shadow: none;
  cursor: pointer;
  touch-action: none;
}

.tile:disabled {
  cursor: default;
  filter: none;
  opacity: 1;
}

.tile.selected {
  border-width: 6px 7px;
  border-image-source: url("assets/game/board-cell-selected-v2.png");
  border-image-slice: 84 96 84 96 fill;
  border-image-width: 6px 7px;
  background: #201d12;
  box-shadow: none;
}

.tile.enemy-will-attack {
  border-width: 6px 7px;
  border-image-source: url("assets/game/board-cell-danger-v2.png");
  border-image-slice: 84 96 84 96 fill;
  border-image-width: 6px 7px;
  background: #291015;
}

.tile.enemy-will-attack .enemy-hp-text,
.tile.enemy-will-attack .enemy-atk,
.tile.enemy-will-attack .enemy-critical-badge {
  color: #fff1e7;
}

.tile-rank,
.enemy-atk,
.enemy-hp-text,
.enemy-target-badge,
.enemy-critical-badge {
  position: absolute;
  z-index: 3;
  font-size: 0.4rem;
  font-weight: 950;
}

.tile-rank {
  right: 2px;
  top: 2px;
  color: var(--gold);
}

.enemy-hpbar {
  position: absolute;
  right: 4px;
  bottom: 3px;
  left: 4px;
  z-index: 2;
  height: 3px;
  background: rgba(0, 0, 0, 0.7);
}

.enemy-hpbar span {
  display: block;
  width: var(--pct, 0%);
  height: 100%;
  background: var(--coral);
}

.enemy-hp-text {
  left: 3px;
  bottom: 7px;
  color: white;
  text-shadow: 1px 1px #000;
}

.enemy-atk {
  top: 2px;
  right: 3px;
  color: var(--coral);
  text-shadow: 1px 1px #000;
}

.enemy-target-badge {
  top: 2px;
  left: 2px;
  color: #fff;
  background: var(--danger);
}

.enemy-critical-badge {
  right: 2px;
  bottom: 7px;
  color: #fff;
}

.selection-pill {
  min-height: 16px;
  color: rgba(243, 234, 208, 0.58);
  font-size: 0.42rem;
  line-height: 1.2;
  text-align: center;
}

.selection-pill svg {
  display: inline-block;
  width: 10px;
  height: 10px;
}

.base-rail {
  position: relative;
  display: grid;
  align-items: center;
  width: min(100%, 264px);
  min-height: 0;
  aspect-ratio: 1414 / 136;
  margin-top: -3px;
  margin-bottom: 8px;
  justify-self: center;
  padding: 0;
  background: url("assets/game/ui-base-rail-compact-v4.png") center / 100% 100% no-repeat;
  image-rendering: pixelated;
  transform-origin: 50% 0;
}

.active-battle .base-rail {
  width: min(100%, 378px);
  margin-top: -4px;
}

.active-battle .selection-pill,
.active-battle .battle-message {
  display: none;
}

.base-rail-shields {
  position: absolute;
  top: 16%;
  right: 5.2%;
  left: 5.2%;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  height: 62%;
  gap: 0;
}

.base-shield {
  display: block;
  width: 78%;
  aspect-ratio: 1;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  image-rendering: pixelated;
}

.base-shield.full { background-image: url("assets/game/base-shield-full-v2.png"); }
.base-shield.empty { background-image: url("assets/game/base-shield-empty-v2.png"); }

.base-rail > strong {
  position: absolute;
  right: 0;
  bottom: -9px;
  left: 0;
  color: var(--cream);
  font-size: 0.43rem;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 1px 2px #000;
}

.battle-tray {
  position: relative;
  z-index: 6;
  display: grid;
  gap: 3px;
  padding-top: 0;
}

.battle-hand {
  min-width: 0;
}

.hand-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
  color: var(--gold);
  font-size: 0.47rem;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.hand-label small {
  color: rgba(243, 234, 208, 0.42);
  font-size: 0.43rem;
  letter-spacing: 0;
}

.hand {
  display: flex;
  justify-content: center;
  min-height: 116px;
  padding: 2px 32px 0;
}

.play-card {
  flex: 0 0 27%;
  grid-template-rows: minmax(0, 45%) minmax(0, 55%);
  max-width: 86px;
  padding: 8px 7px 9px;
  cursor: grab;
  transform: rotate(-3deg);
  transform-origin: 50% 100%;
  touch-action: none;
  transition:
    transform 160ms steps(5, end),
    filter 160ms steps(4, end);
  will-change: transform;
}

.play-card::after {
  border-width: 6px 5px;
  border-image-width: 6px 5px;
}

.play-card .card-face-nameplate {
  grid-template-columns: minmax(0, 1fr);
  min-height: 18px;
  padding: 2px 3px;
}

.play-card .card-face-title {
  font-size: 0.42rem;
}

.play-card .card-rarity-mark {
  position: absolute;
  top: 30px;
  right: 9px;
  z-index: 7;
  min-width: 13px;
  height: 13px;
  font-size: 0.36rem;
}

.play-card .card-face-copy {
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 2px;
  overflow: hidden;
  padding: 4px 3px 3px;
}

.play-card .card-text {
  font-size: 0.4rem;
  line-height: 1.15;
  -webkit-line-clamp: 5;
}

.play-card .card-face-tags {
  display: none;
}

.play-card .tag {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 0.34rem;
  white-space: nowrap;
}

.play-card + .play-card {
  margin-left: -5px;
}

.play-card:nth-child(2) {
  z-index: 2;
  transform: translateY(-4px);
}

.play-card:nth-child(3) {
  transform: rotate(3deg);
}

.play-card:is(:hover, :focus, :active) {
  z-index: 20;
  grid-template-rows: minmax(0, 38%) minmax(0, 62%);
  filter: brightness(1.12) drop-shadow(0 8px 0 rgba(0, 0, 0, 0.68));
  transform: translateY(-53px) scale(2.05) rotate(0);
}

.play-card:is(:hover, :focus, :active) .card-text {
  display: block;
  overflow: visible;
  font-size: 0.46rem;
  line-height: 1.15;
  -webkit-line-clamp: unset;
}

.play-card:is(:hover, :focus, :active) .card-face-title {
  font-size: 0.47rem;
}

.play-card:is(:hover, :focus, :active) .card-face-tags {
  display: none;
}

.play-card:disabled:hover {
  opacity: 0.78;
  filter: grayscale(0.85) brightness(1.12) drop-shadow(0 8px 0 rgba(0, 0, 0, 0.68));
}

.play-card.dragging-card {
  cursor: grabbing;
  opacity: 0.08;
}

.active-battle .hand {
  min-height: 116px;
  padding-top: 0;
}

.active-battle .hand-label {
  display: none;
}

.active-battle .play-card {
  max-width: 82px;
}

.battle-command-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.compact-hero-command,
.hero-action-button {
  min-width: 0;
}

.hero-action-button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  width: 100%;
  min-height: 44px;
  padding: 2px 5px;
  color: var(--cream);
  border: 0;
  border-radius: 0;
  background: #171109;
  cursor: pointer;
  text-align: left;
}

.hero-action-button .hero-avatar {
  width: 26px;
  height: 26px;
  color: var(--gold);
}

.hero-command-copy {
  display: grid;
  gap: 1px;
}

.hero-command-copy small {
  color: rgba(243, 234, 208, 0.62);
  font-size: 0.46rem;
  font-style: normal;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-command-copy strong {
  color: var(--cream);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-command-copy em {
  color: var(--gold);
  font-size: 0.43rem;
  font-style: normal;
  font-weight: 950;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-command-cost {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-items: center;
  gap: 0 2px;
  color: var(--cyan);
}

.hero-command-cost .pixel-ui-icon {
  width: 18px;
  height: 18px;
}

.hero-command-cost b {
  font-size: 0.7rem;
}

.hero-command-cost small {
  grid-column: 1 / -1;
  color: rgba(243, 234, 208, 0.58);
  font-size: 0.38rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-action-button:disabled {
  filter: grayscale(0.68);
  opacity: 0.68;
}

.run-details {
  position: relative;
}

.run-details > summary {
  display: grid;
  place-items: center;
  width: 88px;
  min-height: 44px;
  color: var(--cream);
  border: 1px solid var(--line);
  cursor: pointer;
  list-style: none;
}

.run-details > summary::-webkit-details-marker {
  display: none;
}

.run-info-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  width: 100%;
}

.run-info-control > .pixel-ui-icon {
  width: 22px;
  height: 22px;
}

.run-info-copy {
  display: grid;
  gap: 2px;
  text-align: left;
}

.run-info-copy b {
  color: var(--gold);
  font-size: 0.52rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.run-info-copy em {
  color: rgba(243, 234, 208, 0.58);
  font-size: 0.36rem;
  font-style: normal;
  white-space: nowrap;
}

.run-details-content {
  position: absolute;
  right: 0;
  bottom: 52px;
  z-index: 30;
  display: grid;
  gap: 12px;
  width: min(334px, calc(100vw - 20px));
  max-height: 230px;
  padding: 12px;
  overflow: auto;
  border: solid transparent;
  border-width: 8px 12px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 8px 12px;
  border-image-outset: 0;
  border-image-repeat: stretch;
  background: #090d12;
  image-rendering: pixelated;
}

.run-details[open] {
  grid-column: auto;
}

.run-details[open] .run-details-content {
  min-width: 0;
}

.resource-grid,
.run-yield-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.yield-card-main {
  display: flex;
  align-items: center;
  gap: 5px;
}

.yield-card small {
  color: rgba(243, 234, 208, 0.4);
  font-size: 0.43rem;
}

.battle-message {
  min-height: 10px;
  padding: 0;
  overflow: hidden;
  font-size: 0.43rem;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-leaving {
  animation: tile-leave 180ms ease-in forwards;
}

.tile-dropping {
  animation: tile-drop 420ms cubic-bezier(0.18, 0.9, 0.18, 1.08) var(--drop-delay) backwards;
}

.enemy-slamming .enemy-sprite {
  animation: enemy-slam 220ms steps(4, end);
}

.enemy-dropping .enemy-sprite {
  animation: enemy-drop 300ms cubic-bezier(0.12, 0.88, 0.18, 1.12) backwards;
}

.enemy-damaged .enemy-sprite {
  animation: enemy-hit 320ms steps(2, end);
}

.base-under-attack {
  animation: base-impact 220ms steps(3, end);
}

@keyframes tile-leave {
  to { opacity: 0; transform: scale(0.35); }
}

@keyframes tile-drop {
  from { transform: translateY(var(--drop-y)); }
}

@keyframes enemy-slam {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(18%) scaleX(0.92) scaleY(1.08); }
  70% { transform: translateY(34%) scaleX(1.12) scaleY(0.72); filter: brightness(1.8) saturate(var(--world-sat)); }
  100% { transform: translateY(4%) scale(1); }
}

@keyframes enemy-drop {
  0% { transform: translateY(-118%) scaleX(0.82) scaleY(1.15); }
  78% { transform: translateY(8%) scaleX(1.12) scaleY(0.78); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes enemy-hit {
  0%, 100% { transform: translateX(0); filter: saturate(var(--world-sat)); }
  30% { transform: translateX(-5px); filter: brightness(2.4) saturate(0); }
  60% { transform: translateX(5px); filter: brightness(1.6) saturate(var(--world-sat)); }
}

@keyframes base-impact {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-5px); filter: brightness(1.8); }
  60% { transform: translateX(5px); }
}

/* Archive tabs --------------------------------------------------- */

.archive-mode-tabs {
  display: flex;
  gap: 18px;
  padding: 0 2px;
}

.archive-mode-tabs button {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 0 5px;
  color: rgba(243, 234, 208, 0.44);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 0.56rem;
  font-weight: 950;
  text-transform: uppercase;
}

.archive-mode-tabs button svg {
  width: 15px;
  height: 15px;
}

.archive-mode-tabs button.active {
  color: var(--gold);
  border-color: var(--gold);
}

/* Collection book ------------------------------------------------ */

.collection-book {
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 6.5% 6.2%;
  overflow: hidden;
  color: #302316;
  background: url("assets/game/fadebreak-book-texture.png") center / 100% 100% no-repeat;
  image-rendering: pixelated;
  filter: saturate(var(--world-sat));
  touch-action: pan-y;
  user-select: none;
}

.book-spread {
  display: grid;
  grid-template-columns: 40% minmax(0, 60%);
  gap: 8px;
  min-height: 0;
  height: 100%;
}

.collection-book[data-book-page="progress"] .book-pocket-page {
  animation: book-page-from-left 180ms steps(4, end);
}

.collection-book[data-book-page="cards"] .book-pocket-page {
  animation: book-page-from-right 180ms steps(4, end);
}

@keyframes book-page-from-left {
  from { opacity: 0.25; transform: translateX(-18px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes book-page-from-right {
  from { opacity: 0.25; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

.book-summary-page,
.book-pocket-page {
  min-width: 0;
}

.book-summary-page {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 8px;
  padding: 5px 5px 0 0;
  text-align: center;
}

.book-volume,
.book-page-heading span,
.book-page-heading small {
  color: rgba(48, 35, 22, 0.58);
  font-size: 0.36rem;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.book-seal {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #2d2114;
  border: 2px solid #7a5824;
  border-radius: 50%;
}

.book-seal svg {
  width: 16px;
  height: 16px;
}

.book-summary-page h3 {
  margin: 2px 0 0;
  color: #2d2114;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 0.94;
  text-transform: uppercase;
}

.book-chapter-name {
  color: #934735;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.67rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.book-found,
.book-completion {
  display: grid;
  justify-items: center;
  gap: 1px;
}

.book-found strong {
  font-size: 1.06rem;
}

.book-found span,
.book-completion span {
  font-size: 0.38rem;
  font-weight: 950;
}

.book-completion {
  width: 100%;
  padding: 7px 4px;
  color: #f4df9e;
  background: #1e6072;
  box-shadow: 2px 3px 0 rgba(65, 40, 20, 0.3);
}

.book-completion strong {
  font-size: 0.9rem;
}

.book-milestones {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 100%;
}

.book-milestones span {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 4px 1px;
  color: rgba(48, 35, 22, 0.42);
  border-bottom: 2px solid rgba(48, 35, 22, 0.2);
  font-size: 0.38rem;
}

.book-milestones span.reached {
  color: #8c4c28;
  border-color: #b77a31;
}

.book-milestones svg {
  width: 13px;
  height: 13px;
}

.book-pack-button {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 5px;
  width: 100%;
  min-height: 34px;
  margin-top: auto;
  padding: 4px 18px;
  color: #f6e5b3;
  border: 0;
  background: #171109 url("assets/game/ui-primary-button-v2.png") center / 100% 100% no-repeat;
  cursor: pointer;
  font-size: 0.43rem;
  font-weight: 950;
  text-align: left;
  text-transform: uppercase;
}

.book-pack-button svg {
  width: 16px;
  height: 16px;
}

.book-pocket-page {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 6px;
  padding: 4px 0 0 4px;
}

.book-page-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
}

.book-page-heading span,
.book-page-heading strong {
  grid-column: 1;
}

.book-page-heading strong {
  color: #2d2114;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
}

.book-page-heading small {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  writing-mode: vertical-rl;
}

.book-chapter-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}

.book-chapter-tabs .chip,
.loadout-library-tabs .chip {
  min-height: 27px;
  padding: 0 3px;
  color: rgba(48, 35, 22, 0.52);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
}

.book-chapter-tabs .chip.active {
  color: #7d382b;
  border-color: #a0523d;
}

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

.book-pocket-grid .card-face-card,
.book-empty-pocket {
  aspect-ratio: 5 / 7;
}

.book-pocket-grid .card-face-card {
  grid-template-rows: 1fr;
  padding: 2px;
  border-width: 1px;
  border-radius: 2px;
  box-shadow: 2px 2px 0 rgba(53, 35, 18, 0.25);
}

.book-pocket-grid .card-face-copy {
  display: none;
}

.book-pocket-grid .card-face-title {
  font-size: clamp(0.28rem, 1.3vw, 0.4rem);
}

.book-pocket-grid .card-face-nameplate {
  min-height: 16px;
  padding: 2px;
}

.book-pocket-grid .card-rarity-mark {
  min-width: 11px;
  height: 11px;
  font-size: 0.3rem;
}

.book-empty-pocket {
  display: grid;
  place-items: center;
  color: rgba(48, 35, 22, 0.18);
  border: 1px dashed rgba(48, 35, 22, 0.22);
}

.book-empty-pocket svg {
  width: 20px;
  height: 20px;
}

.book-folio {
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: center;
  gap: 5px;
}

.book-folio button {
  min-height: 26px;
  color: #3b2918;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 950;
}

.book-folio span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.55rem;
  font-weight: 900;
  text-align: center;
}

/* Loadout table -------------------------------------------------- */

.archive-loadout-view {
  display: grid;
  gap: 18px;
  padding: 4px 3px 10px;
  background: transparent;
}

.loadout-switcher {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
}

.loadout-switcher button {
  min-height: 34px;
  color: var(--gold);
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
}

.loadout-switcher > div {
  display: grid;
  justify-items: center;
  gap: 3px;
}

.loadout-switcher span {
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.loadout-switcher strong {
  color: rgba(243, 234, 208, 0.52);
  font-size: 0.45rem;
}

.equipped-cards-panel {
  display: grid;
  gap: 13px;
}

.key-slot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  padding: 0 28px;
}

.key-slot-grid > div {
  display: grid;
  justify-items: center;
  gap: 5px;
}

.key-slot-grid > div > span {
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.key-card-slot {
  width: 100%;
}

.key-slot-footer {
  position: absolute;
  right: 5px;
  bottom: 4px;
  z-index: 3;
}

.action-deck-heading {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
}

.action-deck-heading span {
  height: 1px;
  background: var(--gold);
}

.action-deck-heading span:last-child {
  transform: rotate(180deg);
}

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

.deck-slot {
  cursor: grab;
}

.deck-slot .card-face-copy {
  padding: 3px;
}

.deck-slot .card-face-subtitle,
.deck-slot .card-face-text,
.deck-slot .card-face-tags,
.deck-slot .key-slot-footer {
  display: none;
}

.deck-slot .mini-button {
  position: absolute;
  top: 20px;
  right: 3px;
  z-index: 5;
  width: 18px;
  min-width: 18px;
  min-height: 18px;
  color: white;
  border: 0;
  background: rgba(0, 0, 0, 0.64);
  font-size: 0.45rem;
}

.loadout-drop-zone.drag-over {
  box-shadow: 0 0 0 3px var(--cyan), 0 0 18px rgba(54, 198, 218, 0.4);
}

.available-cards-panel {
  display: grid;
  gap: 12px;
  padding-top: 2px;
}

.loadout-library-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.loadout-library-tabs .chip {
  color: rgba(243, 234, 208, 0.42);
}

.loadout-library-tabs .chip.active {
  color: var(--gold);
  border-color: var(--gold);
}

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

.loadout-ready-button {
  position: sticky;
  bottom: 2px;
  justify-self: center;
  min-width: 180px;
  min-height: 44px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.8rem;
}

/* Legacy filters retained for modal/library edge cases ----------- */

.card-filter-bar,
.filter-groups {
  display: grid;
  gap: 9px;
}

.card-filter-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
}

.card-filter-search input {
  min-width: 0;
  min-height: 34px;
  padding: 0 9px;
  color: var(--cream);
  border: 1px solid var(--line);
  background: #10141a;
  font-size: 0.55rem;
}

.filter-group {
  display: grid;
  gap: 5px;
}

.filter-group > span,
.filter-drawer summary {
  color: rgba(243, 234, 208, 0.48);
  font-size: 0.48rem;
  text-transform: uppercase;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  min-height: 28px;
  padding: 0 8px;
}

.chip.active {
  color: #17130b;
  border-color: var(--gold);
  background: var(--gold);
}

.filter-drawer {
  border-top: 1px solid var(--line);
}

.filter-drawer summary {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  cursor: pointer;
}

/* Copies and provenance modal ------------------------------------ */

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: end;
  padding: 12px;
  background: rgba(1, 3, 5, 0.8);
  backdrop-filter: blur(3px);
}

.copies-modal {
  max-height: 88%;
  overflow-y: auto;
  padding: 14px;
  border: 1px solid rgba(243, 234, 208, 0.24);
  border-radius: 8px 8px 2px 2px;
  background: #11161c;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
}

.copy-panel,
.provenance-detail {
  display: grid;
  gap: 12px;
}

.modal-header-actions,
.token-title,
.provenance-title,
.copy-facts,
.token-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.copy-grid,
.history-list {
  display: grid;
  gap: 7px;
}

.copy-tile {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  color: var(--cream);
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.copy-tile.active {
  border-color: var(--gold);
}

.token-emblem {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  color: white;
  background: var(--art, #345);
}

.token-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.token-detail-grid > div {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-left: 2px solid var(--line);
}

.token-detail-grid span,
.history-event span,
.history-event time {
  color: rgba(243, 234, 208, 0.42);
  font-size: 0.44rem;
}

.history-event {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.history-event p {
  font-size: 0.5rem;
}

/* Nine-slice component borders ---------------------------------- */

:is(
  .ghost-button,
  .mini-button,
  .chip,
  .nav-button,
  .archive-mode-tabs button,
  .loadout-switcher button,
  .copy-tile,
  .run-details > summary
) {
  border: 7px solid transparent;
  border-width: 7px 10px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 7px 10px;
  border-image-outset: 0;
  border-image-repeat: stretch;
  border-radius: 0;
  background: #0a0f15;
  image-rendering: pixelated;
}

:is(
  .primary-button,
  .loadout-ready-button,
  .book-pack-button,
  .hero-action-button
) {
  border: 9px solid transparent;
  border-width: 9px 14px;
  border-image-source: url("assets/game/ui-primary-button-v2.png");
  border-image-slice: 78 122 78 122 fill;
  border-image-width: 9px 14px;
  border-image-outset: 0;
  border-image-repeat: stretch;
  border-radius: 0;
  background: #171109;
  image-rendering: pixelated;
}

.hero-action-button {
  border-width: 7px 10px;
  border-image-width: 7px 10px;
}

:is(
  .book-chapter-tabs .chip,
  .book-folio button
) {
  border: solid transparent;
  border-width: 6px 5px;
  border-image-source: url("assets/game/card-frame-common-v2.png");
  border-image-slice: 54 46 54 46 fill;
  border-image-width: 6px 5px;
  border-image-outset: 0;
  border-image-repeat: stretch;
  border-radius: 0;
  background: #d9c798;
  color: #3b2918;
  image-rendering: pixelated;
}

.book-chapter-tabs .chip.active {
  border-image-source: url("assets/game/card-frame-uncommon-v2.png");
  color: #7d382b;
}

.toast {
  position: absolute;
  right: 12px;
  bottom: 68px;
  left: 12px;
  z-index: 40;
  padding: 9px 11px;
  color: #17130b;
  background: var(--gold);
  box-shadow: 4px 5px 0 rgba(0, 0, 0, 0.45);
  font-size: 0.55rem;
  font-weight: 900;
  animation: toast-pop 1050ms ease forwards;
}

@keyframes toast-pop {
  0% { opacity: 0; transform: translateY(8px); }
  15%, 76% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(4px); }
}

/* Responsive ----------------------------------------------------- */

@media (max-width: 480px) {
  .prototype-stage {
    padding: 0;
  }

  .phone-shell {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
  }

  .phone-frame {
    grid-template-rows: minmax(0, 1fr);
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .phone-screen {
    border: 0;
    border-radius: 0;
  }

  .home-indicator {
    display: none;
  }
}

@media (max-width: 370px) {
  .app-viewport {
    padding: 5px 6px;
  }

  .wallet span {
    padding: 0 4px;
  }

  .brand-logo {
    width: 122px;
  }

  .collection-book {
    min-height: 0;
  }

  .book-summary-page h3 {
    font-size: 0.92rem;
  }

  .key-slot-grid {
    gap: 20px;
    padding: 0 22px;
  }
}

@media (max-height: 760px) {
  .app-viewport {
    padding: 4px 8px;
  }

  .game-surface,
  .battle-screen {
    gap: 2px;
  }

  .battle-objective {
    gap-block: 1px;
  }

  .contract-title > .pixel-ui-icon {
    width: 19px;
    height: 19px;
  }

  .contract-title h2 {
    font-size: 0.64rem;
  }

  .board {
    width: min(100%, 195px);
  }

  .base-rail {
    width: min(100%, 200px);
    margin-top: -2px;
  }

  .phone-screen.active-battle .board {
    width: min(100%, 250px);
  }

  .phone-screen.active-battle .base-rail {
    width: min(100%, 255px);
    margin-top: -3px;
  }

  .selection-pill {
    min-height: 12px;
    font-size: 0.36rem;
  }

  .battle-tray {
    gap: 2px;
  }

  .hand-label {
    margin-bottom: 0;
    font-size: 0.4rem;
  }

  .hand-label small {
    font-size: 0.36rem;
  }

  .hand {
    min-height: 90px;
    padding-inline: 60px;
  }

  .phone-screen.active-battle .hand {
    min-height: 90px;
    padding-inline: 60px;
  }

  .play-card {
    max-width: 64px;
  }

  .phone-screen.active-battle .play-card {
    max-width: 64px;
  }

  .hero-action-button,
  .run-details > summary {
    min-height: 38px;
  }

  .run-details > summary {
    width: 72px;
  }

  .hero-action-button .hero-avatar {
    width: 22px;
    height: 22px;
  }

  .battle-message {
    display: none;
  }

  .collection-book {
    padding: 3.5% 6%;
  }

  .book-summary-page {
    gap: 5px;
  }

  .book-pocket-page {
    gap: 3px;
  }

  .book-pocket-grid {
    grid-template-columns: repeat(3, minmax(0, 56px));
    justify-content: center;
    gap: 3px;
  }

  .book-folio {
    grid-template-columns: 26px 1fr 26px;
    gap: 3px;
  }
}

/* Focused mobile architecture ----------------------------------- */

.phone-screen.active-battle {
  grid-template-rows: 20px 43px minmax(0, 1fr);
}

.active-battle .topbar {
  padding-inline: 4px;
  border-width: 5px 8px;
  border-image-width: 5px 8px;
}

.active-battle .brand-logo {
  width: min(132px, 38vw);
  height: 25px;
}

.active-battle .wallet span {
  min-height: 22px;
  padding-inline: 5px;
}

.active-battle .app-viewport {
  padding: 3px 2px 2px;
}

.battle-screen {
  position: relative;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  gap: 4px;
}

.battle-hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 8px;
  min-height: 48px;
  padding: 1px 7px;
  border: solid transparent;
  border-width: 6px 9px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 6px 9px;
  border-image-repeat: stretch;
  background: #090d12;
  image-rendering: pixelated;
}

.battle-hud-title {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.battle-hud-title > .pixel-ui-icon {
  width: 23px;
  height: 23px;
}

.battle-hud-title > div {
  display: grid;
  min-width: 0;
}

.battle-hud-title span,
.battle-hud-turn span {
  color: rgba(243, 234, 208, 0.46);
  font-size: 0.39rem;
  font-weight: 950;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.battle-hud-title h2 {
  overflow: hidden;
  margin: 0;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-hud-turn {
  display: grid;
  justify-items: end;
}

.battle-hud-turn strong {
  color: var(--gold);
  font-size: 0.58rem;
}

.battle-hud-roster {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  min-height: 18px;
  gap: 5px;
}

.battle-hud-roster .enemy-status-strip {
  flex: 1 1 auto;
  min-height: 18px;
}

.battle-hud-roster .enemy-status-icon,
.battle-hud-roster .enemy-status-icon .enemy-sprite {
  width: 18px;
  height: 18px;
}

.battle-hud-roster .enemy-status-icon {
  flex-basis: 18px;
}

.battle-hud-danger {
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--coral);
  font-size: 0.56rem;
}

.battle-hud-danger .pixel-ui-icon {
  width: 17px;
  height: 17px;
}

.battle-hud > .progress {
  grid-column: 1 / -1;
  height: 2px;
}

.board-zone {
  display: grid;
  min-height: 0;
  place-items: center;
}

.active-battle .board-wrap {
  width: 100%;
}

.phone-screen.active-battle .board {
  width: min(100%, 386px);
}

.phone-screen.active-battle .enemy-entry-reservoir {
  width: min(100%, 386px);
}

.phone-screen.active-battle .base-rail {
  width: min(100%, 386px);
  margin-top: -4px;
}

.battle-dock {
  z-index: 9;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  min-height: 49px;
}

.battle-dock button {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: 1fr auto;
  align-items: center;
  justify-content: center;
  gap: 0 5px;
  min-width: 0;
  min-height: 47px;
  padding: 1px 5px;
  color: rgba(243, 234, 208, 0.62);
  border: solid transparent;
  border-width: 6px 9px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 6px 9px;
  border-image-repeat: stretch;
  background: #090d12;
  cursor: pointer;
  image-rendering: pixelated;
}

.battle-dock button.active {
  color: var(--gold);
  filter: brightness(1.25);
}

.battle-dock .pixel-ui-icon,
.dock-hero-icon {
  grid-row: 1 / span 2;
  width: 24px;
  height: 24px;
}

.dock-hero-icon {
  display: grid;
  place-items: center;
}

.dock-hero-icon svg {
  width: 20px;
  height: 20px;
}

.battle-dock span:not(.pixel-ui-icon, .dock-hero-icon) {
  align-self: end;
  font-size: 0.48rem;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.battle-dock b {
  align-self: start;
  color: var(--cyan);
  font-size: 0.4rem;
}

.game-bottom-sheet {
  position: absolute;
  right: 2px;
  bottom: 52px;
  left: 2px;
  z-index: 25;
  display: grid;
  gap: 6px;
  max-height: 56%;
  padding: 7px 9px 9px;
  overflow: hidden;
  border: solid transparent;
  border-width: 9px 12px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 9px 12px;
  border-image-repeat: stretch;
  background: #080c11;
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.68);
  image-rendering: pixelated;
}

.bottom-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(216, 178, 76, 0.24);
}

.bottom-sheet-header h2,
.bottom-sheet-header h3 {
  margin: 0;
}

.bottom-sheet-content {
  min-height: 0;
  overflow: auto;
}

.battle-bottom-sheet.battle-hand {
  max-height: 245px;
}

.battle-bottom-sheet .battle-hand {
  display: grid;
}

.battle-bottom-sheet .hand-label {
  display: none;
}

.battle-bottom-sheet .hand {
  min-height: 160px;
  padding: 2px 48px 0;
}

.battle-bottom-sheet .play-card,
.phone-screen.active-battle .battle-bottom-sheet .play-card {
  max-width: 92px;
}

.battle-bottom-sheet .play-card:is(:hover, :focus, :active) {
  transform: translateY(-34px) scale(1.48) rotate(0);
}

.hero-sheet-copy {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.hero-sheet-copy p {
  font-size: 0.55rem;
}

.battle-bottom-sheet .hero-action-button {
  min-height: 52px;
}

.battle-bottom-sheet.battle-run {
  max-height: 62%;
}

.battle-bottom-sheet.battle-run .bottom-sheet-content {
  display: grid;
  gap: 13px;
}

.campaign-home {
  display: grid;
  height: 100%;
  place-items: center;
}

.campaign-launch-panel {
  display: grid;
  width: 100%;
  gap: 14px;
  padding: 10px 10px 12px;
  border: solid transparent;
  border-width: 9px 12px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 9px 12px;
  border-image-repeat: stretch;
  background: #080c11;
  image-rendering: pixelated;
}

.launch-loadout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid rgba(216, 178, 76, 0.25);
}

.launch-loadout-slot {
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  gap: 5px;
  padding: 10px 5px;
}

.launch-loadout-slot + .launch-loadout-slot {
  border-left: 1px solid rgba(216, 178, 76, 0.18);
}

.launch-slot-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  color: var(--gold);
}

.launch-slot-icon svg {
  width: 21px;
  height: 21px;
}

.launch-loadout-slot > span:last-child {
  display: grid;
  min-width: 0;
}

.launch-loadout-slot small,
.run-launch-copy span,
.run-launch-copy small {
  color: rgba(243, 234, 208, 0.42);
  font-size: 0.38rem;
  font-weight: 900;
  text-transform: uppercase;
}

.launch-loadout-slot strong {
  overflow: hidden;
  font-size: 0.5rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-launch-actions {
  display: grid;
  gap: 9px;
}

.run-launch-copy {
  display: grid;
  justify-items: center;
  gap: 3px;
  text-align: center;
}

.run-launch-copy strong {
  color: var(--cream);
  font-size: 0.78rem;
}

.run-start-button {
  width: 100%;
  min-height: 55px;
  font-size: 0.72rem;
}

.run-setup-links,
.loadout-workshop-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.run-setup-links button,
.loadout-workshop-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.run-setup-links svg,
.loadout-workshop-actions svg {
  width: 16px;
  height: 16px;
}

.contract-screen {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  height: 100%;
  min-height: 0;
  gap: 8px;
  overflow: hidden;
}

.contract-wallet {
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--gold);
}

.contract-screen-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-inline: 3px;
  color: var(--gold);
  font-size: 0.52rem;
  text-transform: uppercase;
}

.contract-screen-summary small {
  color: rgba(243, 234, 208, 0.4);
  font-size: 0.39rem;
  text-transform: none;
}

.contract-list {
  display: grid;
  align-content: start;
  align-self: start;
  min-height: 0;
  padding: 3px 6px;
  overflow: hidden;
  border: solid transparent;
  border-width: 8px 11px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 8px 11px;
  border-image-repeat: stretch;
  background: #080c11;
  image-rendering: pixelated;
}

.contract-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  min-width: 0;
  min-height: 70px;
  gap: 7px;
  padding: 6px 4px;
  color: var(--cream);
  border: 0;
  border-bottom: 1px solid rgba(243, 234, 208, 0.12);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.contract-row:last-child {
  border-bottom: 0;
}

.contract-row.active {
  color: var(--cyan);
}

.contract-row-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--gold);
}

.contract-row-icon svg {
  width: 23px;
  height: 23px;
}

.contract-row-copy,
.contract-row-stakes {
  display: grid;
  min-width: 0;
}

.contract-row-copy strong {
  overflow: hidden;
  font-size: 0.62rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contract-row small,
.contract-row em {
  color: rgba(243, 234, 208, 0.42);
  font-size: 0.38rem;
  font-style: normal;
  text-transform: uppercase;
}

.contract-row-stakes {
  justify-items: end;
}

.contract-row-stakes strong {
  color: var(--gold);
  font-size: 0.55rem;
}

.contract-play-button {
  width: 100%;
}

.screen-overlay-backdrop {
  z-index: 35;
}

.screen-detail-sheet {
  display: grid;
  width: 100%;
  gap: 13px;
  max-height: 82%;
  padding: 12px;
  overflow: hidden;
  color: var(--cream);
  border: solid transparent;
  border-width: 10px 13px;
  border-image-source: url("assets/game/ui-dark-plaque-v2.png");
  border-image-slice: 52 72 52 72 fill;
  border-image-width: 10px 13px;
  border-image-repeat: stretch;
  background: #080c11;
  image-rendering: pixelated;
}

.contract-detail-target {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.contract-detail-target > span {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: var(--gold);
}

.contract-detail-target svg {
  width: 34px;
  height: 34px;
}

.contract-detail-target div,
.contract-detail-stakes span {
  display: grid;
}

.contract-detail-target small,
.contract-detail-stakes small {
  color: rgba(243, 234, 208, 0.45);
  font-size: 0.44rem;
  text-transform: uppercase;
}

.contract-detail-target strong {
  font-size: 0.82rem;
}

.contract-detail-stakes {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding-block: 9px;
  border-block: 1px solid rgba(216, 178, 76, 0.22);
}

.contract-detail-stakes span {
  justify-items: center;
}

.contract-detail-stakes strong {
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--gold);
  font-size: 0.8rem;
}

.collection-book {
  padding: 5% 7%;
}

.book-spread {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.book-summary-page {
  display: none;
}

.book-pocket-page {
  padding: 3px 2px;
}

.book-page-heading {
  grid-template-columns: minmax(0, 1fr) auto;
}

.book-progress-trigger {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 0 4px;
  min-width: 82px;
  padding: 3px 6px;
  color: #3b2918;
  border: solid transparent;
  border-width: 6px 5px;
  border-image-source: url("assets/game/card-frame-uncommon-v2.png");
  border-image-slice: 54 46 54 46 fill;
  border-image-width: 6px 5px;
  background: #d9c798;
  image-rendering: pixelated;
}

.book-progress-trigger svg {
  grid-row: 1 / span 2;
  width: 17px;
  height: 17px;
}

.book-progress-trigger b {
  font-size: 0.52rem;
}

.book-progress-trigger small {
  color: rgba(48, 35, 22, 0.62);
  font-size: 0.33rem;
}

.book-pocket-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: center;
  gap: 8px;
}

.book-pocket-grid .card-face-title {
  font-size: clamp(0.36rem, 1.8vw, 0.48rem);
}

.collection-progress-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.collection-progress-emblem {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  color: var(--cyan);
}

.collection-progress-emblem svg {
  width: 42px;
  height: 42px;
}

.collection-progress-main > div {
  display: grid;
}

.collection-progress-main strong {
  color: var(--gold);
  font-size: 1.5rem;
  line-height: 1;
}

.collection-progress-main span {
  color: rgba(243, 234, 208, 0.45);
  font-size: 0.46rem;
  text-transform: uppercase;
}

.collection-progress-track {
  height: 6px;
  background: rgba(243, 234, 208, 0.1);
}

.collection-progress-track span {
  display: block;
  width: var(--pct);
  height: 100%;
  background: var(--cyan);
}

.collection-progress-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid rgba(216, 178, 76, 0.22);
}

.collection-progress-facts span {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 9px 3px;
}

.collection-progress-facts span + span {
  border-left: 1px solid rgba(216, 178, 76, 0.18);
}

.collection-progress-facts b {
  color: var(--cream);
  font-size: 0.72rem;
}

.collection-progress-facts small {
  color: rgba(243, 234, 208, 0.42);
  font-size: 0.38rem;
  text-transform: uppercase;
}

.archive-loadout-view {
  position: relative;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  gap: 7px;
  padding: 0 2px 3px;
  overflow: hidden;
}

.archive-loadout-view .loadout-switcher {
  min-height: 38px;
}

.archive-loadout-view .equipped-cards-panel {
  align-content: start;
  min-height: 0;
  gap: 6px;
}

.archive-loadout-view .key-slot-grid {
  gap: 40px;
  padding-inline: 46px;
}

.archive-loadout-view .deck-slot-grid {
  gap: 5px;
}

.loadout-workshop-actions .loadout-ready-button {
  position: static;
  min-width: 0;
  min-height: 40px;
}

.loadout-library-sheet {
  right: 0;
  bottom: 48px;
  left: 0;
  max-height: 58%;
}

.loadout-library-sheet .loadout-library-tabs {
  gap: 3px;
}

.loadout-library-sheet .loadout-library-tabs .chip.active {
  color: #1e160e;
}

.loadout-library-sheet .loadout-library-grid {
  min-height: 0;
  overflow: auto;
  gap: 5px;
}

.loadout-library-sheet .collection-card {
  min-height: 130px;
}

.library-equip-button {
  position: absolute;
  right: 5px;
  bottom: 5px;
  z-index: 8;
  min-height: 24px;
  padding: 0 7px;
  color: #f9edc9;
  border: solid transparent;
  border-width: 5px 7px;
  border-image-source: url("assets/game/ui-primary-button-v2.png");
  border-image-slice: 78 122 78 122 fill;
  border-image-width: 5px 7px;
  background: #171109;
  font-size: 0.38rem;
  font-weight: 950;
  text-transform: uppercase;
  image-rendering: pixelated;
}

@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;
  }
}
