* {
  box-sizing: border-box;
}
/* Character selection and shared equipment. */
.hero-navigation {
  display: block;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}
.hero-navigation > button {
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 24px;
}
.class-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.class-tabs button {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  padding: 9px 14px;
  font-size: 13px;
}
.class-tabs .selected {
  border-bottom-color: #f4c65b;
  color: #f4c65b;
}
.character-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.8fr);
  gap: 36px;
  align-items: center;
  border-block: 1px solid #354045;
  padding: 20px 0;
}
.paper-doll {
  position: relative;
  min-width: 0;
  height: 400px;
  touch-action: pan-y;
  user-select: none;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.hero-arrow {
  position: absolute;
  top: 55%;
  transform: translateY(-50%);
  z-index: 2;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 25px;
  color: #fff4d3;
  background: #162322ed;
  border-color: #c3d5cb;
}
#previous-hero {
  left: 30px;
}
#next-hero {
  right: 30px;
}
#hero-display {
  position: absolute;
  inset: 80px 100px 22px;
  display: grid;
  place-items: center;
}
#hero-display img {
  width: 100%;
  height: 100%;
  max-width: 280px;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
  filter: drop-shadow(0 12px 8px #0008);
}
.equipment-slot {
  --rarity: #79868b;
  position: absolute;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  width: 86px;
  height: 105px;
  padding: 5px;
  border-color: var(--rarity);
  background: var(--shade, #20292d);
  box-shadow: inset 0 3px var(--rarity);
}
.equipment-slot small {
  color: #e9f0ed;
  font-size: 11px;
}
.equipment-slot img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}
.equipment-slot span {
  font-size: 11px;
}
.equipment-slot b {
  color: var(--rarity);
  font-size: 9px;
  text-transform: uppercase;
}
.slot-head {
  top: 0;
  left: calc(50% - 43px);
}
.slot-weapon {
  left: 10px;
  top: 85px;
}
.slot-armor {
  left: 10px;
  top: 255px;
}
.slot-charm {
  right: 10px;
  top: 85px;
}
.slot-legs {
  right: 10px;
  top: 255px;
}
.hero-sheet h2 {
  font-size: 30px;
  margin: 8px 0;
}
.hero-sheet > p {
  margin: 5px 0 16px;
}
#hero-stats {
  margin: 0;
}
#hero-stats > div {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #354045;
  padding: 10px 0;
  gap: 8px;
}
#hero-stats dt {
  text-transform: capitalize;
  font-size: 14px;
  color: #bccbc7;
}
#hero-stats dd {
  margin: 0;
  font-size: 18px;
  font-weight: bold;
  color: #f4d27b;
}
.hero-sheet h3 {
  font-size: 13px;
  margin: 18px 0 5px;
}
#gear-bonuses {
  font-size: 12px;
  color: #91e2b3;
}
.class-abilities {
  margin-top: 16px;
}
.class-abilities summary {
  cursor: pointer;
  font-weight: bold;
  padding: 12px 0;
}
#gear-dialog {
  width: min(740px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  padding: 18px;
  background: #151e21;
  color: #e6e1d7;
  border: 1px solid #758b88;
  border-radius: 6px;
}
#gear-dialog::backdrop {
  background: #000b;
}
.gear-dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.gear-dialog-heading h2 {
  margin: 0;
}
#close-gear {
  width: 40px;
  height: 40px;
  font-size: 24px;
  padding: 0;
}
.gear-slot-tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0;
}
.gear-slot-tabs button {
  flex: 1;
  font-size: 12px;
  padding: 8px 4px;
}
.gear-slot-tabs [aria-pressed="true"] {
  border-color: #f4c65b;
  color: #f4c65b;
}
#equipped-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-block: 1px solid var(--rarity, #526365);
  padding: 12px 0;
}
#equipped-summary strong,
#equipped-summary span {
  display: block;
  margin: 5px 0;
}
#equipped-summary strong {
  color: var(--rarity, #e6e1d7);
}
#equipped-summary span {
  font-size: 13px;
}
#equipped-summary button {
  font-size: 12px;
}
.gear-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 0;
  font-size: 12px;
}
#gear-sort {
  background: #253237;
  color: #e6e1d7;
  border: 1px solid #758b88;
  padding: 6px;
}
#gear-dialog #equipment {
  max-height: none;
}
#gear-dialog .gear-item {
  background: var(--shade, #252d31);
  border: 1px solid var(--rarity);
  border-left-width: 4px;
  border-radius: 4px;
}
.gear-comparison {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  margin-top: 8px;
}
.gear-comparison .gain {
  color: #83e6a3;
}
.gear-comparison .loss {
  color: #ff9292;
}
.empty-slot {
  padding: 28px 0;
  text-align: center;
}
@media (max-width: 640px) {
  .hero-navigation {
    gap: 4px;
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }
  .hero-navigation > button {
    width: 36px;
    height: 40px;
  }
  .class-tabs {
    gap: 0;
  }
  .class-tabs button {
    padding: 8px 4px;
    font-size: 10px;
  }
  .character-layout {
    grid-template-columns: minmax(0, 1fr) 100px;
    gap: 10px;
    padding: 14px 0;
  }
  .paper-doll {
    height: 326px;
  }
  .hero-arrow {
    width: 40px;
    height: 40px;
    font-size: 23px;
    top: 58%;
  }
  #previous-hero {
    left: 7px;
  }
  #next-hero {
    right: 7px;
  }
  #hero-display {
    inset: 75px 25px 65px;
  }
  .equipment-slot {
    width: 56px;
    height: 75px;
    gap: 1px;
    padding: 3px;
  }
  .equipment-slot img {
    width: 22px;
    height: 22px;
  }
  .equipment-slot small,
  .equipment-slot span {
    font-size: 9px;
  }
  .equipment-slot b {
    font-size: 7px;
  }
  .slot-head {
    left: calc(50% - 28px);
  }
  .slot-weapon {
    left: 0;
    top: 82px;
  }
  .slot-charm {
    right: 0;
    top: 82px;
  }
  .slot-armor {
    left: 0;
    top: 232px;
  }
  .slot-legs {
    right: 0;
    top: 232px;
  }
  .hero-sheet h2 {
    font-size: 20px;
    overflow-wrap: anywhere;
  }
  .hero-sheet > p {
    font-size: 11px;
  }
  #hero-stats > div {
    padding: 7px 0;
    gap: 3px;
  }
  #hero-stats dt {
    font-size: 10px;
  }
  #hero-stats dd {
    font-size: 13px;
  }
  .hero-sheet h3 {
    font-size: 11px;
  }
  #gear-bonuses {
    font-size: 10px;
  }
  #gear-dialog {
    padding: 12px;
  }
}
:root {
  color-scheme: dark;
  font-family: "Trebuchet MS", system-ui, sans-serif;
  color: #e6e1d7;
  background: #101417;
  letter-spacing: 0;
}
body {
  margin: 0;
  background: #171d20;
  min-height: 100vh;
}
button,
input,
select {
  font: inherit;
}
button,
.button {
  cursor: pointer;
  border: 2px solid #596b69;
  background: #293c37;
  color: #f0e7d7;
  border-radius: 4px;
  box-shadow: 0 3px 0 #090e10;
  font-weight: 700;
  padding: 10px 15px;
  text-decoration: none;
}
button:hover {
  border-color: #e0ba70;
  background: #364246;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid #edc780;
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.45;
  cursor: wait;
}
.primary {
  background: #f4c65b;
  color: #161b20;
  border-color: #ffdf90;
  font-weight: bold;
  min-height: 48px;
}
header {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #354045;
  font: 13px system-ui;
  flex-wrap: wrap;
}
header a {
  color: #afc6c4;
  text-decoration: none;
}
.settings {
  margin-left: auto;
  display: flex;
  gap: 14px;
}
.settings label {
  display: flex;
  align-items: center;
  gap: 4px;
}
main {
  max-width: 1120px;
  margin: auto;
  padding: 24px;
}
.title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
small {
  font: 11px system-ui;
  color: #9daead;
}
h1 {
  font-size: 34px;
  margin: 4px 0 0;
  font-weight: 900;
  color: #f8f3df;
  text-shadow: 0 3px #050d10;
}
h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 12px 0;
}
p {
  color: #bbc5c4;
  line-height: 1.5;
}
.wallet {
  font:
    800 26px "Trebuchet MS",
    sans-serif;
  color: #efd085;
}
.section-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.classes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.class-card {
  text-align: left;
  min-width: 0;
  padding: 15px;
  background: #20292d;
}
.class-card.selected {
  border-color: #f4cf7d;
  box-shadow: inset 0 -3px #d6b774;
}
.portrait {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #d6e4df;
  border-bottom: 4px solid #101b1b;
  margin-bottom: 12px;
}
.portrait img {
  object-fit: contain;
  width: 144px;
  height: 144px;
  image-rendering: pixelated;
}
.class-card strong {
  font-size: 20px;
  display: block;
}
.class-card:nth-child(2) .portrait {
  background: #c6e6bc;
}
.class-card:nth-child(3) .portrait {
  background: #c2e3ee;
}
.class-card:nth-child(4) .portrait {
  background: #f3dfb0;
}
.class-card.selected .portrait {
  border-bottom-color: #f4c65b;
}
.class-card p {
  font: 12px system-ui;
  margin: 7px 0;
}
.class-card .numbers {
  font: 600 15px/1.8 system-ui;
  color: #d1dfdb;
}
.preparation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 24px;
  border-top: 1px solid #354045;
  padding-top: 8px;
}
.training-row,
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #303b3f;
  padding: 10px 0;
  font: 15px system-ui;
}
.item-row img {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
}
.item-row span {
  flex: 1;
}
.item-row small {
  display: block;
}
#equipment {
  max-height: 250px;
  overflow: auto;
}
.start-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0;
  gap: 12px;
}
input[type="number"] {
  width: 90px;
  background: #202a30;
  color: #fff;
  border: 1px solid #647271;
  padding: 10px;
  margin-left: 8px;
}
#stage {
  position: relative;
  width: 100%;
  aspect-ratio: 2/1;
  background: #171d24;
  overflow: hidden;
  border-block: 1px solid #455256;
}
#stage canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0 !important;
  display: block;
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
}
#environment-track {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#environment-track img {
  position: absolute;
  top: 0;
  width: 150%;
  height: 100%;
  max-width: none;
  image-rendering: auto;
}
#environment-track img:nth-child(even) {
  transform: scaleX(-1);
}
.stats {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr));
  gap: 16px;
  padding: 22px 0;
  border-bottom: 1px solid #455256;
  font-family: system-ui, sans-serif;
}
.stat {
  min-width: 0;
  border-top: 3px solid var(--stat-color);
  padding-top: 10px;
  --stat-color: #eac778;
}
.stat-health {
  --stat-color: #7ce2a5;
}
.stat-defense {
  --stat-color: #82c9ee;
}
.stat-dodge {
  --stat-color: #ded7f8;
}
.stat-crit {
  --stat-color: #f7988e;
}
.stat-label {
  display: block;
  color: #e6e1d7;
  font-size: 14px;
  font-weight: 600;
  text-transform: capitalize;
}
.stat-value {
  display: block;
  color: var(--stat-color);
  font-size: 32px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat-max {
  font-size: 18px;
  color: #d2ded8;
}
.stat-bonus {
  display: block;
  font-size: 13px;
  color: #b9c9c5;
}
.reward-stat {
  display: block;
  font: 600 15px system-ui;
}
.reward-preview {
  display: block;
  margin-top: 12px;
  font: 18px system-ui;
  color: #e6e1d7;
}
.reward-preview b {
  color: #99ebbc;
}
.choices button {
  overflow-wrap: anywhere;
}
#reward h2 {
  font-size: 24px;
}
#stats + .enemy-roster {
  margin-bottom: 8px;
}
#dice-tray {
  height: 270px;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  overflow: hidden;
}
#dice-tray canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.dice span {
  border-bottom: 3px solid var(--die-color, #ddd);
}
@media (max-width: 600px) {
  #dice-tray {
    height: 210px;
  }
}
.combat-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0 18px;
}
.combat-controls .primary {
  margin-left: auto;
  min-width: 180px;
}
.dice {
  display: flex;
  gap: 8px;
}
.dice span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 52px;
  background: #e1d8bf;
  color: #252c34;
  font: bold 23px Georgia;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  filter: drop-shadow(0 2px #000);
}
.choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.choices button {
  text-align: left;
  min-height: 90px;
}
.choices strong {
  display: block;
  font-size: 23px;
  margin: 8px 0;
}
.reward-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.reward-heading h2 {
  margin-bottom: 0;
}
#reroll {
  justify-self: center;
  min-width: 170px;
}
.reward-card {
  --rarity: #b1b7bd;
  --shade: #292f34;
  border-color: var(--rarity);
  background: var(--shade);
  box-shadow: inset 0 3px var(--rarity);
}
.uncommon {
  --rarity: #79df9a;
  --shade: #183c2a;
}
.rare {
  --rarity: #7ebaff;
  --shade: #1a304e;
}
.epic {
  --rarity: #ce9aff;
  --shade: #382449;
}
.legendary {
  --rarity: #ffd363;
  --shade: #58380f;
}
.shard-wallet {
  font-size: 18px;
  color: #97e7da;
  margin-top: 6px;
}
.wallet {
  text-align: right;
}
#account-change {
  border-left: 3px solid #f4c65b;
  padding: 8px 12px;
  font-size: 14px;
}
.spell-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 12px 0 20px;
}
.spell-entry {
  min-width: 0;
  border-top: 3px solid var(--rarity);
  padding: 10px 0;
}
.spell-entry strong {
  display: block;
  font-size: 18px;
  margin: 6px 0;
  color: var(--rarity);
}
.spell-entry span,
.ability-description {
  display: block;
  font: 14px/1.5 system-ui;
  color: #e0e5e5;
  overflow-wrap: anywhere;
}
.spell-entry small {
  color: var(--rarity);
}
.ability-card .reward-preview {
  margin-top: 12px;
}
.loadout-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #354045;
  padding: 14px 0;
}
.loadout-row img,
.gear-item img {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}
.loadout-row div {
  flex: 1;
  min-width: 0;
}
.loadout-row strong,
.loadout-row span {
  display: block;
  overflow-wrap: anywhere;
}
.loadout-row span {
  font: 14px/1.8 system-ui;
  color: #b8ceca;
}
#equipment {
  max-height: 480px;
}
.gear-item {
  --rarity: #b1b7bd;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  border-left: 3px solid var(--rarity);
  border-bottom: 1px solid #354045;
  padding: 12px;
  margin-bottom: 12px;
}
.gear-item.uncommon {
  --rarity: #79df9a;
}
.gear-item.rare {
  --rarity: #7ebaff;
}
.gear-item.epic {
  --rarity: #ce9aff;
}
.gear-item.legendary {
  --rarity: #ffd363;
}
.gear-info strong,
.gear-info span {
  display: block;
  overflow-wrap: anywhere;
}
.gear-info strong {
  font-size: 17px;
  color: var(--rarity);
  margin: 4px 0;
}
.gear-info span {
  font: 14px/1.5 system-ui;
}
.gear-actions {
  grid-column: 1/-1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.gear-actions button {
  font-size: 12px;
  padding: 8px;
}
#ward-status {
  color: #ffd363;
  font: 600 14px system-ui;
}
.empty-build {
  font: 14px system-ui;
  color: #9daead;
}
.ability-total {
  display: block;
  font: 600 15px/1.6 system-ui;
  margin-bottom: 6px;
  color: #fff;
}
@media (max-width: 640px) {
  .spell-grid {
    grid-template-columns: 1fr;
  }
  .title {
    align-items: flex-start;
  }
  .wallet {
    font-size: 22px;
  }
  .shard-wallet {
    font-size: 16px;
  }
  .wallet small {
    display: block;
  }
  .loadout-row {
    gap: 8px;
  }
}
.reward-card small,
.reward-card > strong {
  color: var(--rarity);
}
.reward-card:hover {
  border-color: var(--rarity);
  background: var(--shade);
  filter: brightness(1.2);
}
#reroll:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}
#log {
  border-top: 1px solid #354045;
  margin-top: 20px;
  padding: 14px 0;
  list-style: none;
  font: 13px/1.8 system-ui;
  color: #a7b9b7;
  max-height: 150px;
  overflow: auto;
}
#notice {
  font: 14px system-ui;
  color: #d7c493;
  min-height: 24px;
  margin-bottom: 12px;
}
#cleared {
  padding: 12px 0;
}
[hidden] {
  display: none !important;
}
@media (max-width: 640px) {
  main {
    padding: 16px;
  }
  header {
    padding: 12px 16px;
    gap: 10px;
  }
  .settings {
    width: 100%;
    margin: 0;
  }
  h1 {
    font-size: 29px;
  }
  .classes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .preparation {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .portrait {
    height: 112px;
  }
  .portrait img {
    width: 104px;
    height: 104px;
  }
  .combat-controls {
    gap: 8px;
    flex-wrap: wrap;
  }
  .combat-controls .primary {
    min-width: 0;
    flex: 1;
  }
  .dice span {
    width: 34px;
    height: 40px;
    font-size: 19px;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 16px 0;
  }
  .stat-health {
    grid-column: 1 / -1;
  }
  .choices {
    gap: 10px;
    grid-template-columns: 1fr;
  }
  .choices button {
    padding: 14px;
    font-size: 16px;
  }
  .choices strong {
    font-size: 26px;
  }
  #stage {
    aspect-ratio: 2/1;
  }
  .wallet {
    font-size: 22px;
  }
  .section-line h2 {
    font-size: 16px;
  }
  .start-line {
    flex-wrap: wrap;
  }
}
.enemy-roster {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #354045;
  font: 12px system-ui;
}
.enemy-roster > span {
  flex: 1;
  min-width: 125px;
}
.enemy-roster strong {
  color: #d2a89c;
}
.enemy-roster small {
  display: block;
  color: #a6b9c0;
  margin-top: 3px;
}

/* During a run, the battlefield and decision dock share one viewport. */
body.in-run {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.in-run header {
  flex: 0 0 auto;
  padding: 6px 14px;
  gap: 12px;
  font-size: 11px;
}
.in-run main {
  width: 100%;
  max-width: 1800px;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 6px 12px 10px;
}
.in-run .title {
  margin: 0;
  gap: 8px;
  min-height: 30px;
}
.in-run .title > div > small,
.in-run #account-change {
  display: none;
}
.in-run h1 {
  font-size: 18px;
  margin: 0;
}
.in-run .wallet {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
}
.in-run .shard-wallet {
  margin: 0;
  font-size: 13px;
}
.in-run .wallet small {
  display: inline;
  font-size: 9px;
}
.in-run #notice {
  min-height: 0;
  margin: 0;
  font-size: 12px;
}
.in-run #notice:empty {
  display: none;
}
.in-run #retry {
  position: absolute;
  z-index: 30;
  top: 90px;
  right: 16px;
}
#play {
  position: relative;
}
.in-run #play {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.in-run #play > .section-line {
  flex: 0 0 36px;
  gap: 6px;
}
.in-run #location {
  font-size: 13px;
  margin: 0;
}
.in-run #leave {
  font-size: 11px;
  padding: 6px 9px;
  white-space: nowrap;
}
.arena {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #0e1517;
  border: 1px solid #405251;
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
}
.battlefield {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #15231f;
}
.in-run #stage {
  flex: none;
  max-width: 100%;
  border: 0;
}
.in-run #stats {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  z-index: 3;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 5px 8px;
  border: 0;
  background: #101719d9;
  width: fit-content;
  margin: 0 auto;
  pointer-events: none;
}
.in-run .stat {
  display: flex;
  gap: 5px;
  align-items: baseline;
  border: 0;
  padding: 0;
}
.in-run .stat-label,
.in-run .stat-value,
.in-run .stat-max {
  font-size: 11px;
  line-height: 1.3;
}
.in-run .stat-bonus {
  display: none;
}
.in-run .stat-health {
  grid-column: auto;
}
#run-details {
  position: absolute;
  z-index: 10;
  right: 8px;
  top: 39px;
  font-size: 11px;
}
#run-details summary {
  cursor: pointer;
  padding: 7px 10px;
  background: #101719e8;
  border: 1px solid #6a8380;
}
.build-panel {
  position: absolute;
  right: 0;
  top: 35px;
  width: min(520px, calc(100vw - 40px));
  max-height: calc(100dvh - 200px);
  overflow: auto;
  background: #121a1df5;
  border: 1px solid #6a8380;
  padding: 14px;
}
.build-panel .spell-grid {
  grid-template-columns: 1fr;
}
.encounter-dock {
  flex: 0 0 auto;
  min-height: 180px;
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(0, 2fr);
  gap: 16px;
  align-items: center;
  padding: 10px 14px;
  border-top: 1px solid #405251;
  background: #111b1e;
}
.dice-area {
  min-width: 0;
}
.in-run #dice-tray {
  height: 130px;
  max-width: 340px;
}
.in-run .combat-controls {
  padding: 0;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: center;
}
.in-run .dice {
  gap: 4px;
}
.in-run .dice span {
  width: 25px;
  height: 27px;
  font-size: 14px;
}
.in-run #multiplier {
  font-size: 12px;
  white-space: nowrap;
}
.in-run #attack {
  min-width: 0;
  min-height: 32px;
  margin-left: 4px;
  padding: 6px 9px;
  font-size: 11px;
  flex: 0 0 auto;
}
.arena[data-phase="combat"] .encounter-dock {
  display: flex;
  justify-content: center;
}
.arena[data-phase="combat"] .dice-area {
  width: 380px;
  max-width: 100%;
}
.in-run #reward {
  min-width: 0;
}
.in-run .reward-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 8px;
  gap: 8px;
}
.in-run #reward h2 {
  font-size: 15px;
  margin: 0;
}
.in-run #reroll {
  min-width: 0;
  font-size: 11px;
  padding: 6px 9px;
}
.in-run .choices {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.in-run .choices button {
  min-height: 136px;
  padding: 10px;
  box-shadow: inset 0 3px var(--rarity);
  border-width: 1px;
}
.in-run .choices strong {
  font-size: 18px;
  margin: 6px 0;
}
.in-run .choices small {
  font-size: 10px;
}
.in-run .ability-description {
  font-size: 12px;
  line-height: 1.35;
}
.in-run .reward-stat {
  font-size: 11px;
}
.in-run .reward-preview {
  font-size: 13px;
  margin-top: 8px;
}
.in-run #cleared {
  padding: 0;
}
.in-run #cleared h2 {
  font-size: 18px;
}
.in-run #cleared p {
  font-size: 13px;
}

@media (max-width: 640px) {
  .in-run header {
    padding: 5px 8px;
    gap: 6px;
  }
  .in-run #identity {
    display: none;
  }
  .in-run .settings {
    width: auto;
    margin-left: auto;
    gap: 5px;
    font-size: 10px;
  }
  .in-run .settings label {
    gap: 0;
  }
  .in-run .settings input {
    margin: 0 3px;
  }
  .in-run main {
    padding: 4px 5px 5px;
  }
  .arena {
    flex: 0 1 auto;
    max-width: 100%;
    height: min(100%, calc((100vw - 12px) / 2 + 290px));
    margin-block: auto;
  }
  .encounter-dock {
    min-height: 288px !important;
    justify-content: center;
  }
  .in-run h1 {
    font-size: 16px;
  }
  .in-run .wallet {
    gap: 8px;
    font-size: 13px;
  }
  .in-run .shard-wallet {
    font-size: 12px;
  }
  .in-run .wallet small {
    font-size: 8px;
  }
  .in-run #location {
    font-size: 11px;
  }
  .in-run #play > .section-line {
    flex-basis: 36px;
  }
  .in-run #stats {
    gap: 4px 8px;
    top: 4px;
    padding: 4px;
  }
  .in-run .stat-label,
  .in-run .stat-value,
  .in-run .stat-max {
    font-size: 10px;
  }
  #run-details {
    top: 32px;
    right: 4px;
  }
  #run-details summary {
    padding: 5px 7px;
    font-size: 10px;
  }
  .encounter-dock {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px;
    min-height: 0;
  }
  .dice-area {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }
  .in-run #dice-tray {
    width: 155px;
    height: 76px;
    margin: 0;
  }
  .in-run .combat-controls {
    flex-wrap: wrap;
    max-width: 170px;
    gap: 5px;
  }
  .in-run #attack {
    width: 100%;
    margin: 0;
  }
  .arena[data-phase="combat"] .dice-area {
    width: 100%;
  }
  .arena[data-phase="combat"] #dice-tray {
    width: 190px;
    height: 105px;
  }
  .in-run #reward {
    width: 100%;
  }
  .in-run .reward-heading {
    margin-bottom: 6px;
  }
  .in-run #reward h2 {
    font-size: 13px;
  }
  .in-run .choices {
    gap: 5px;
  }
  .in-run .choices button {
    padding: 7px;
    min-height: 156px;
  }
  .in-run .choices strong {
    font-size: 14px;
    margin: 5px 0;
  }
  .in-run .choices small {
    font-size: 9px;
  }
  .in-run .ability-description {
    font-size: 11px;
    line-height: 1.3;
  }
  .in-run .reward-preview {
    font-size: 11px;
    margin-top: 6px;
  }
}
@media (max-height: 500px) and (min-width: 641px) {
  #run-details {
    top: auto;
    bottom: 8px;
    right: 370px;
  }
  .in-run header {
    display: none;
  }
  .arena {
    flex-direction: row;
  }
  .battlefield {
    min-width: 0;
  }
  .encounter-dock {
    width: 360px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    border-top: 0;
    border-left: 1px solid #405251;
  }
  .arena[data-phase="combat"] .encounter-dock {
    width: 240px;
  }
  .dice-area {
    display: flex;
    align-items: center;
  }
  .in-run #dice-tray {
    width: 130px;
    height: 64px;
  }
  .in-run .combat-controls {
    flex-wrap: wrap;
    max-width: 160px;
  }
  .in-run .choices strong {
    font-size: 14px;
  }
  .in-run .choices button {
    padding: 6px;
    min-height: 135px;
  }
  .in-run .ability-description {
    font-size: 11px;
  }
  .arena {
    max-width: 100%;
  }
}

/* Desktop uses the left rail for rolling and the current floor's chosen rewards. */
.arena {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 260px;
}
.battlefield {
  grid-area: 1 / 2;
}
.arena .encounter-dock {
  display: contents;
}
.arena[data-phase="combat"] .encounter-dock {
  display: contents;
}
.run-sidebar {
  grid-area: 1 / 1 / 3 / 2;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #405251;
  background: #141d20;
  padding: 12px;
}
.arena .dice-area {
  width: 100%;
  max-width: none;
  flex: 0 0 auto;
}
.in-run #dice-tray {
  width: 100%;
  height: 220px;
  max-width: none;
  margin: 0;
}
.reward-history-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 18px;
  border-top: 1px solid #405251;
}
.reward-history-panel h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  margin: 14px 0 10px;
}
#reward-count {
  color: #c9d1d3;
  font-size: 12px;
}
.reward-history {
  list-style: none;
  padding: 0;
  margin: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.reward-history li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 3px;
  border-bottom: 1px solid #344144;
  font-size: 12px;
}
.reward-history strong {
  display: block;
  color: var(--rarity, #d2d7d9);
  text-transform: capitalize;
}
.reward-history li > div {
  flex: 1;
  min-width: 0;
}
.reward-history li > div > span {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  margin-top: 4px;
}
.reward-history small {
  color: #acbbbf;
  font-size: 10px;
}
.reward-art {
  display: block;
  width: 80px;
  height: 80px;
  flex: 0 0 auto;
  background-image: url("assets/rewards-v15.webp");
  background-size: 500% 500%;
  background-repeat: no-repeat;
  image-rendering: auto;
}
.reward-history .reward-art {
  width: 42px;
  height: 42px;
}
.mobile-reward-history {
  display: none;
}
.in-run #reward,
.in-run #cleared {
  grid-area: 2 / 2;
  padding: 10px 14px;
  border-top: 1px solid #405251;
  background: #111b1e;
}
.in-run .choices button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 200px;
}
.in-run .choices .reward-art {
  align-self: center;
  margin: auto auto 0;
}
.arena[data-phase="combat"] {
  grid-template-rows: minmax(0, 1fr);
}
.arena[data-phase="combat"] .battlefield {
  grid-row: 1 / 3;
}

@media (max-width: 900px), (max-height: 500px) {
  .run-sidebar {
    display: contents;
  }
  .reward-history-panel {
    display: none;
  }
  .mobile-reward-history {
    display: block;
  }
}
@media (max-width: 900px) and (min-height: 501px) {
  .arena,
  .arena[data-phase="combat"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(100px, 1fr) 76px auto;
    height: min(100%, calc((100vw - 12px) / 2 + 320px));
    flex: 0 1 auto;
    margin-block: auto;
  }
  .arena .battlefield,
  .arena[data-phase="combat"] .battlefield {
    grid-area: 1 / 1;
  }
  .arena .dice-area,
  .arena[data-phase="combat"] .dice-area {
    grid-area: 2 / 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }
  .in-run #dice-tray,
  .arena[data-phase="combat"] #dice-tray {
    width: 180px;
    height: 76px;
  }
  .in-run .combat-controls {
    flex-wrap: wrap;
    max-width: 150px;
  }
  .in-run #reward,
  .in-run #cleared {
    grid-area: 3 / 1;
    padding: 6px;
  }
  .in-run .choices button {
    min-height: 186px;
    padding: 6px;
  }
  .in-run .choices .reward-art {
    width: 44px;
    height: 44px;
  }
  .in-run .reward-preview {
    margin-top: 4px;
  }
  .arena[data-phase="combat"] {
    grid-template-rows: minmax(100px, 1fr) 100px;
  }
}
@media (max-height: 500px) and (min-width: 641px) {
  .arena,
  .arena[data-phase="combat"] {
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-rows: 68px minmax(0, 1fr);
  }
  .arena .battlefield,
  .arena[data-phase="combat"] .battlefield {
    grid-area: 1 / 1 / 3 / 2;
  }
  .arena .dice-area,
  .arena[data-phase="combat"] .dice-area {
    grid-area: 1 / 2;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .in-run #dice-tray {
    width: 150px;
    height: 64px;
  }
  .in-run #reward,
  .in-run #cleared {
    grid-area: 2 / 2;
    padding: 4px 6px;
  }
  .in-run .choices button {
    min-height: 180px;
  }
  .in-run .choices .reward-art {
    width: 38px;
    height: 38px;
  }
  .in-run .reward-preview {
    font-size: 11px;
    margin-top: 4px;
  }
  .in-run .choices strong {
    margin: 4px 0;
  }
}
