:root {
  color-scheme: dark;
  --bg: #000;
  --header: #000;
  --panel: #000;
  --fill: #141414;
  --line: #3a3a3a;
  --text: #fff;
  --muted: #bdbdbd;
  --edge: #fff;
  --button: #000;
  --button-line: #fff;
  font-family: "Courier New", Courier, "Lucida Console", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
}

button,
a,
label,
input,
select,
textarea,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--button);
  border: 2px solid var(--edge);
  border-radius: 8px;
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 4px #cfcfcf;
  cursor: pointer;
}

button:hover:not(:disabled),
button:focus-visible {
  background: #141414;
  color: #fff;
  border-color: #8a8a8a;
  box-shadow: none;
  outline: 1px dashed #8a8a8a;
  outline-offset: 3px;
}

button[aria-pressed="true"],
button[aria-pressed="true"]:hover,
button[aria-pressed="true"]:focus-visible {
  background: #1a1a1a;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: none;
  outline: none;
}

#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  box-sizing: border-box;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

#backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#title,
#play {
  position: relative;
}

#party {
  position: fixed;
  inset: 0;
  z-index: 3;
  overflow: auto;
  padding:
    max(16px, env(safe-area-inset-top))
    16px
    max(16px, env(safe-area-inset-bottom));
  background: #000;
  background-image: url("assets/backdrops/mead_hall_backdrop_512.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  image-rendering: pixelated;
}

.party-card {
  width: min(52rem, 100%);
  margin: 0 auto 12px;
}

.party-card h1 {
  font-size: 1.8rem;
}

.party-layout {
  display: grid;
  gap: 18px;
}

.step-label,
.roster-heading {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choices button,
#party-add,
#party-cancel {
  min-height: 44px;
  padding: 10px 14px;
  touch-action: manipulation;
}

.choices button.class-choice,
button.face-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.class-portrait {
  width: 64px;
  height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
  background: transparent;
  flex: none;
  pointer-events: none;
}

button.face-button .class-portrait,
.who.has-face .class-portrait,
.sheet-hero .class-portrait {
  width: 40px;
  height: 40px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.stat {
  padding: 8px 4px;
  text-align: center;
  background: #000;
  border: 2px solid #fff;
  border-radius: 8px;
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 4px #cfcfcf;
}

.stat b {
  display: block;
  font-size: 1.25rem;
}

.stat span {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.note {
  min-height: 1.35em;
  margin: 8px 0;
  color: var(--text);
}

#party-name {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0 0 10px;
  padding: 10px 12px;
  color: #fff;
  background: #000;
  border: 2px solid #fff;
  border-radius: 8px;
  font: inherit;
}

.roster {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.member {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 2px solid #fff;
  border-radius: 10px;
  background: #000;
}

.member p {
  margin: 0;
  line-height: 1.35;
}

.member .meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.member .slot-actions {
  display: flex;
  gap: 6px;
}

.slot-actions button {
  min-height: 44px;
  padding: 8px 12px;
  touch-action: manipulation;
}

button:disabled {
  opacity: 1;
  color: var(--muted);
  background: #000;
  border-color: #6e6e6e;
  box-shadow: none;
  cursor: default;
}

.roster .meta {
  color: var(--muted);
}

.party-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.party-panel {
  grid-area: party;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 8px;
  background: transparent;
  border: 0;
}

.who {
  flex: 1 1 7.5rem;
  min-width: 9.6rem;
  padding: 6px 8px;
  background: #000;
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 4px #cfcfcf;
}

.who.has-face {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  column-gap: 8px;
  align-items: center;
}

.who.has-face .class-portrait {
  grid-row: 1 / span 5;
}

.who strong,
.who span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who strong {
  font-size: 0.92rem;
}

.gold-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 4px 8px;
  background: #000;
  border: 2px solid #fff;
  border-radius: 8px;
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 4px #cfcfcf;
  color: #fff;
}

.coin {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #000 0 7px, #cfcfcf 8px 14px, #000 15px 17px, #fff 18px);
  border: 2px solid #fff;
}

.who span {
  color: #fff;
  font-size: 0.78rem;
}

.who .vitals {
  display: grid;
  overflow: visible;
  grid-template-columns: 2.4rem max-content;
  gap: 0 6px;
  white-space: normal;
}

.who .vitals span {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.xp-line {
  color: var(--muted);
}

.xp-bar {
  display: block;
  height: 3px;
  margin-top: 3px;
  background: #2a2e3a;
  border-radius: 2px;
  overflow: hidden;
}

.xp-bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: #fff;
}

.who .xp-line {
  margin-top: 2px;
  font-size: 0.72rem;
}

.who .xp-bar,
.who .xp-bar > span {
  text-overflow: clip;
}

#title {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: block;
  padding: 0;
  background: #000;
  overflow: hidden;
}

.card,
.inn-panel,
.statue-card {
  width: min(28rem, 100%);
  padding: 18px 16px 16px;
  background: linear-gradient(#161616, #000 42%);
  color: #fff;
  border: 2px solid #fff;
  border-radius: 14px;
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 5px #d0d0d0;
}

.party-card {
  width: min(52rem, 100%);
}

.card h1 {
  margin: 0 0 10px;
  font-size: 2.25rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.rule {
  width: 100%;
  height: 0;
  margin: 0 0 12px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
}

.lede {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
}

.controls {
  margin: 16px 0 20px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.controls li + li {
  margin-top: 4px;
}

.start {
  width: 100%;
  padding: 12px 16px;
  background: #000;
  color: #fff;
  border-color: #fff;
  font-weight: 700;
}

.start:hover:not(:disabled) {
  background: #141414;
  color: #fff;
  border-color: #8a8a8a;
  box-shadow: none;
  outline: 1px dashed #8a8a8a;
  outline-offset: 3px;
}

.start:disabled {
  opacity: 1;
  color: var(--muted);
  border-color: #6e6e6e;
  box-shadow: none;
  cursor: default;
}

.continue {
  width: 100%;
  margin-top: 8px;
  padding: 12px 16px;
  background: transparent;
  color: var(--text);
  font-weight: 700;
}

#title[hidden],
#info[hidden],
#title-thanks[hidden],
#play[hidden],
#party[hidden],
#town[hidden],
#combat[hidden],
#backdrop[hidden],
.party-panel[hidden],
#combat-commands[hidden],
#combat-targets[hidden],
#combat-steal[hidden],
#combat-magic[hidden],
#combat-auto[hidden],
#combat-actor[hidden],
#combat-summary[hidden],
#combat-done[hidden],
.town-places[hidden],
#dungeon-menu[hidden],
#equip[hidden],
#spell-book[hidden],
#settings[hidden],
#inn-panel[hidden],
#inn-confirm[hidden],
#tavern-confirm[hidden],
#inn-sheet[hidden],
#inn-menu[hidden],
#smith-panel[hidden],
#smith-menu[hidden],
#smith-body[hidden],
#smith-back[hidden],
#gate-panel[hidden],
#town-statue-gate[hidden],
#statue-prompt[hidden],
.doll[hidden],
.pack-grid[hidden],
.equip-board[hidden],
.doll-panel[hidden],
.loot-panel[hidden],
.equip-controls[hidden],
.equip-actions[hidden],
#shop-buy[hidden],
.equip-gold[hidden] {
  display: none !important;
}

.town {
  position: fixed;
  inset: 0;
  z-index: 2;
  overflow: auto;
  padding:
    max(16px, env(safe-area-inset-top))
    16px
    max(16px, env(safe-area-inset-bottom));
  background: #000 url("assets/town-bg.jpg") center / cover no-repeat;
}

.town::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  pointer-events: none;
}

.town-card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: min(28rem, 100%);
  margin: 0 auto;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.town-card h1 {
  align-self: stretch;
  margin: 0 0 8px;
  padding: 8px 12px;
  background: #000;
  border: 2px solid #fff;
  border-radius: 12px;
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 5px #d0d0d0;
  font-size: 1.4rem;
}

.town-places {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0;
  margin: 0 0 8px;
  padding: 6px;
  background: #000;
  border: 2px solid #fff;
  border-radius: 12px;
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 5px #d0d0d0;
}

.town-places button {
  flex: none;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  box-shadow: none;
  text-align: left;
  touch-action: manipulation;
}

.town-places button:hover:not(:disabled),
.town-places button:focus-visible {
  background: #141414;
  color: #fff;
  box-shadow: none;
  outline: 1px dashed #8a8a8a;
  outline-offset: -4px;
}

.town-places button span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.town-card .start {
  margin-top: 4px;
}

.statue-prompt {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 9, 12, 0.62);
}

.statue-card {
  width: min(24rem, 100%);
  margin: 0;
}

.statue-card h2 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.statue-floors {
  margin: 0 0 16px;
  color: var(--text);
  font-weight: 700;
}

.statue-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.statue-actions button {
  width: 100%;
  min-height: 56px;
  font-size: 1.15rem;
  touch-action: manipulation;
}

.gold-line {
  align-self: flex-end;
  width: fit-content;
  margin: 0 0 8px;
  padding: 6px 12px;
  background: #000;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 4px #d0d0d0;
  font-weight: 700;
}

.town-card .inn-panel {
  width: auto;
  margin: 8px 0 0;
}

.inn-panel h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.inn-note:empty {
  display: none;
}

.inn-actions {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  margin: 0 0 12px;
}

#tavern-panel {
  position: fixed;
  inset: 0;
  z-index: 4;
  overflow: auto;
  padding:
    max(12px, env(safe-area-inset-top))
    12px
    max(12px, env(safe-area-inset-bottom));
  background: #000;
  background-image: url("assets/backdrops/mead_hall_backdrop_512.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  image-rendering: pixelated;
}

#tavern-panel[hidden] {
  display: none !important;
}

.roster-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: min(60rem, 100%);
  max-height: calc(100dvh - 24px);
  margin: 0 auto;
  padding: 16px 14px 14px;
  background: #000;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 14px;
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 5px #d0d0d0;
}

.roster-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 4px;
}

.roster-head h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.08em;
}

.roster-count,
.roster-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
}

.roster-kicker {
  margin: 12px 0 8px;
}

.roster-party {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.roster-slot {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
  padding: 8px;
  text-align: left;
}

.roster-slot .class-portrait {
  width: 48px;
  height: 48px;
}

.roster-slot-empty {
  min-height: 7.5rem;
}

.roster-all {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: flex-start;
  align-content: start;
  min-height: 0;
  max-height: 46vh;
  margin: 0;
  padding: 0 4px 0 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.roster-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1.3fr) auto auto auto auto;
  gap: 8px 10px;
  align-items: center;
  width: 100%;
  margin: 0 0 8px;
  padding: 8px;
  text-align: left;
}

.roster-face {
  position: relative;
  width: 48px;
  height: 48px;
  flex: none;
}

.roster-face .class-portrait {
  width: 48px;
  height: 48px;
}

.roster-badge {
  position: absolute;
  right: -6px;
  bottom: -4px;
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
  pointer-events: none;
}

.roster-id {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  min-width: 0;
}

.roster-name {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster-meta {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.roster-pill,
.roster-chip {
  border: 2px solid #fff;
  border-radius: 8px;
  padding: 1px 6px;
  background: #000;
  color: #fff;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.roster-pill {
  border-radius: 999px;
}

.roster-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 4.6rem;
}

.roster-stat-line {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
}

.roster-icon {
  width: 16px;
  height: 16px;
  flex: none;
  image-rendering: pixelated;
}

.roster-bar {
  position: relative;
  display: block;
  width: 100%;
  height: 8px;
  background: url("assets/ui/roster/bar_empty.png") left center / 100% 100% no-repeat;
  image-rendering: pixelated;
}

.roster-bar > span {
  position: absolute;
  inset: 0;
  background: url("assets/ui/roster/bar_full.png") left center / 100% 100% no-repeat;
  image-rendering: pixelated;
  clip-path: inset(0 var(--rest) 0 0);
}

.roster-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.roster-actions button {
  width: auto;
  min-width: 5.5rem;
  min-height: 44px;
  padding: 8px 12px;
}

.roster-note {
  margin: 0;
  color: var(--text);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}

button.roster-slot.is-selected,
button.roster-row.is-selected,
button[aria-pressed="true"].roster-slot.is-selected,
button[aria-pressed="true"].roster-row.is-selected {
  outline: 1px dashed #8a8a8a;
  outline-offset: 3px;
}

@media (max-width: 720px) {
  .roster-party {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .roster-stat {
    grid-column: 2;
    min-width: 0;
  }

  .roster-chip {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }
}

#smith-panel {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  max-height: calc(100dvh - 6.5rem);
  overflow: hidden;
}

#smith-panel > h2,
#smith-panel > .gold-line,
#smith-panel > .inn-note,
#smith-menu,
#smith-back {
  flex: 0 0 auto;
}

#smith-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: flex-start;
  align-content: start;
  min-height: 0;
  margin-bottom: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#smith-menu,
#smith-back {
  flex: none;
}

.inn-actions button,
.inn-sheet > button,
#smith-back {
  width: 100%;
  min-height: 44px;
  touch-action: manipulation;
}

#inn-panel,
#temple-panel,
#gate-panel {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  max-height: calc(100dvh - 6.5rem);
  overflow: hidden;
}

#inn-panel > h2,
#temple-panel > h2,
#gate-panel > h2,
.inn-panel > .gold-line,
.inn-panel > .inn-note {
  flex: 0 0 auto;
}

#inn-sheet {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 0;
  overflow: hidden;
}

#inn-sheet .sheet,
#gate-list,
.temple-loot {
  flex: 1 1 auto;
  justify-content: flex-start;
  align-content: start;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#inn-sheet > button,
#temple-panel > .inn-actions,
#gate-panel > .inn-note {
  flex: 0 0 auto;
}

.sheet {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.sheet li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.sheet li:last-child {
  margin-bottom: 0;
}

.sheet .meta {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.sheet-hero {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  text-align: left;
  touch-action: manipulation;
}

.sheet-hero.sheet-cols {
  display: grid;
  grid-template-columns: 40px minmax(4rem, 1.4fr) 3.2rem 6.4rem 6.4rem;
  column-gap: 8px;
  row-gap: 2px;
  align-items: center;
}

.sheet-hero .class-portrait {
  grid-column: 1;
  grid-row: 1 / span 4;
}

.sheet-hero .col-name { grid-column: 2; }
.sheet-hero .col-lv { grid-column: 3; }
.sheet-hero .col-hp { grid-column: 4; }
.sheet-hero .col-mp { grid-column: 5; }

.sheet-hero .col-name,
.sheet-hero .col-lv,
.sheet-hero .col-hp,
.sheet-hero .col-mp {
  white-space: nowrap;
}

.sheet-cols .col-lv,
.sheet-cols .col-hp,
.sheet-cols .col-mp {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.price-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.price-row .price-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.price-row .price {
  margin-left: auto;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sheet-hero strong,
.sheet-hero .meta,
.sheet-hero .xp-line,
.sheet-hero .xp-bar {
  display: block;
}

.sheet-hero .meta,
.sheet-hero .xp-line,
.sheet-hero .xp-bar {
  grid-column: 2 / -1;
}

.sheet-hero .xp-line {
  margin-top: 4px;
  font-size: 0.86rem;
}

@media (max-width: 520px) {
  .sheet-hero.sheet-cols {
    grid-template-columns: 32px minmax(0, 1fr) 2.4rem 4.8rem 4.8rem;
    font-size: 0.78rem;
  }

  .sheet-hero .class-portrait,
  .who.has-face .class-portrait {
    width: 32px;
    height: 32px;
  }

}

#dungeon-menu {
  min-height: 44px;
  padding: 8px 14px;
  white-space: nowrap;
}

#equip {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding:
    max(16px, env(safe-area-inset-top))
    16px
    max(16px, env(safe-area-inset-bottom));
  background: #000;
}

.equip-card {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: min(64rem, 100%);
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(#161616, #000 42%);
}

.equip-class {
  margin: -4px 0 8px;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.equip-board {
  display: flex;
  flex: 1 1 auto;
  gap: 12px;
  align-items: stretch;
  min-height: 0;
  margin: 0;
  overflow: hidden;
}

.doll-panel,
.loot-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 10px;
  background: #000;
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #000, inset 0 0 0 4px #fff;
}

.loot-panel {
  overflow: hidden;
}

.equip-static {
  display: flex;
  flex-direction: column;
  flex: 0 1 26rem;
  width: min(26rem, 46%);
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.doll-panel {
  flex: 1 1 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.equip-board:not(.is-hero) {
  flex-direction: column;
}

.equip-board:not(.is-hero) .equip-static {
  flex: 0 0 auto;
  width: 100%;
  height: auto;
}

.equip-controls {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
  margin-top: 8px;
}

.equip-switch {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.equip-who {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.equip-controls button {
  width: auto;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 40px;
  padding: 6px 8px;
}

.equip-controls button.equip-arrow {
  min-width: 2.2rem;
  padding-left: 0;
  padding-right: 0;
}

.equip-gold,
.equip-static > h1,
.equip-class,
.equip .xp,
.equip-line,
.equip-note,
.equip-actions {
  flex: 0 0 auto;
}

.equip-slots {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.equip-gold {
  margin: 0 0 12px;
}

.equip-card h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.equip-line {
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}

.equip-note {
  margin: -4px 0 12px;
}

.equip .xp {
  margin: 0 0 12px;
}

.equip .xp-line {
  margin: 0;
  font-size: 0.95rem;
}

.equip-slots,
.equip-pack {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.equip-slots li,
.equip-pack li {
  margin: 0 0 8px;
}

.equip-actions {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
}

.equip-actions button,
.equip-slots button,
.equip-pack button {
  width: 100%;
  min-height: 44px;
  touch-action: manipulation;
}

.doll {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  align-content: stretch;
  gap: 8px;
  height: 100%;
  min-height: 0;
  min-width: 0;
  margin: 0;
}

.doll .slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 0;
  height: auto;
  overflow: hidden;
  padding: 4px 2px;
  text-align: center;
  touch-action: manipulation;
}

.doll .slot {
  background: #000;
  border: 2px solid #fff;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px #000, inset 0 0 0 3px #fff;
}

.doll .slot.amulet { grid-area: 1 / 1; }
.doll .slot.head { grid-area: 1 / 2; }
.doll .slot.ring { grid-area: 1 / 3; }
.doll .slot.right { grid-area: 2 / 1; }
.doll .slot.body { grid-area: 2 / 2; }
.doll .slot.left { grid-area: 2 / 3; }
.doll .slot.hands { grid-area: 3 / 1; }
.doll .slot.greaves { grid-area: 3 / 2; }
.doll .slot.boots { grid-area: 3 / 3; }

.slot-stats {
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.15;
  letter-spacing: 0;
  text-transform: none;
}

.doll .mark,
.pack-tile .mark {
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
}

.slot-label {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.slot-name {
  max-width: 100%;
  font-size: 0.78rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.doll .slot.empty .slot-name,
.pack-empty {
  color: var(--muted);
}

.doll .slot.ready,
.pack-tile.picked,
.pack-tile.picked:hover,
.pack-tile.picked:focus-visible {
  background: #1a1a1a;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: none;
  outline: none;
}

.pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.4rem, 1fr));
  gap: 8px;
  margin: 0 0 14px;
}

.pack-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 64px;
  padding: 8px 6px;
  text-align: center;
  touch-action: manipulation;
}

.item-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
  background: transparent;
  border: 0;
}

.loot-tools {
  display: flex;
  gap: 8px;
  margin: 0 0 8px;
}

.loot-tools button {
  flex: 1 1 0;
  min-height: 44px;
}

.loot-list {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-content: start;
  gap: 6px;
  min-height: 0;
}

.loot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 4px 8px;
  text-align: left;
  background: #000;
  color: #fff;
}

.loot-row .slot-name {
  flex: 1 1 auto;
}

.loot-row.picked,
.loot-row.picked:hover,
.loot-row.picked:focus-visible {
  background: #1a1a1a;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: none;
  outline: none;
}

.loot-x {
  margin-left: auto;
  color: #6e6e6e;
  font-weight: 700;
}

button.loot-row.locked,
button.loot-row.locked:disabled,
button.loot-row.locked:hover,
button.loot-row.locked:focus-visible,
button.pack-tile.locked,
button.pack-tile.locked:disabled,
button.pack-tile.locked:hover,
button.pack-tile.locked:focus-visible {
  color: #6e6e6e;
  background: #000;
  border: 2px solid #3a3a3a;
  box-shadow: none;
  opacity: 1;
  cursor: default;
}

.pack-tile.locked .item-icon {
  opacity: 0.4;
}

.pack-empty {
  grid-column: 1 / -1;
  margin: 0;
}

.smith-heroes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.smith-heroes button {
  flex: 1 1 40%;
  width: auto;
  min-height: 44px;
}

.smith-heroes button[aria-pressed="true"],
.smith-heroes button[aria-pressed="true"]:hover,
.smith-heroes button[aria-pressed="true"]:focus-visible {
  background: #1a1a1a;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: none;
  outline: none;
}

.smith-who {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.temple-loot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 8px;
}

.temple-row {
  margin: 0;
  min-height: 44px;
  padding: 8px 10px;
  color: #fff;
}

.temple-loot button.temple-row {
  width: 100%;
  text-align: left;
  white-space: normal;
}

.shop-grid,
.loot-list.shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
  max-height: none;
}

.loot-panel .loot-tools,
.loot-panel .equip-compare {
  flex: 0 0 auto;
}

.loot-panel .equip-compare {
  max-height: 5.5rem;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.loot-panel .loot-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

@media (max-height: 760px) {
  #equip .class-portrait {
    width: 40px;
    height: 40px;
  }

  .equip-card h1 {
    margin-bottom: 4px;
    font-size: 1.2rem;
  }

  .equip-class,
  .equip .xp,
  .equip-line,
  .equip-gold {
    margin-bottom: 4px;
  }

  .equip-board {
    margin-bottom: 0;
  }

  .doll {
    gap: 4px;
  }

  .doll .item-icon {
    width: 24px;
    height: 24px;
  }

  .doll .slot-stats {
    display: none;
  }
}

@media (max-width: 520px) {
  .equip-board {
    flex-direction: column;
  }

  .equip-static {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
  }

  .doll-panel {
    flex: 0 0 auto;
    max-height: none;
  }

  .doll {
    height: auto;
    grid-template-rows: repeat(3, auto);
  }

  .doll .slot {
    min-height: 44px;
    padding: 4px 2px;
  }

  .equip-controls button,
  .equip-who {
    font-size: 0.75rem;
    letter-spacing: 0;
  }

  .equip-controls button {
    padding: 6px 5px;
  }

  .loot-panel {
    flex: 1 1 auto;
    min-height: 0;
  }

  .doll .item-icon {
    width: 24px;
    height: 24px;
  }

  .doll .slot-stats {
    display: none;
  }

  #equip .smith-heroes {
    flex-wrap: nowrap;
  }

  #equip .smith-heroes button {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 4px;
  }
}

#shop-buy {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: transparent;
}

.shop-buy-card {
  width: min(22rem, 100%);
  padding: 16px;
  background: #000;
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #000, inset 0 0 0 4px #fff;
}

.shop-buy-name {
  margin: 0 0 6px;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.shop-buy-stats,
.shop-buy-price,
.shop-buy-total {
  margin: 0 0 8px;
}

.shop-buy-stats,
.shop-buy-price {
  color: var(--muted);
}

.shop-buy-qty {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
}

.shop-buy-qty button {
  min-width: 2.6rem;
  min-height: 44px;
  padding: 6px 8px;
}

.shop-buy-count {
  flex: 1 1 auto;
  text-align: center;
  font-weight: 700;
}

.shop-buy-actions {
  display: flex;
  gap: 8px;
}

.shop-buy-actions button {
  flex: 1 1 0;
  min-height: 44px;
}

#shop-buy button:disabled {
  color: #6e6e6e;
  background: #000;
  border-color: #3a3a3a;
  box-shadow: none;
  cursor: default;
}

.shop-tile,
.loot-list.shop-grid .loot-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 92px;
  padding: 8px 6px;
  text-align: center;
  background: #000;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 8px;
  box-shadow: none;
}

.shop-tile .slot-name,
.loot-list.shop-grid .loot-row .slot-name {
  max-width: 100%;
}

.shop-tile .price,
.loot-list.shop-grid .loot-row .price {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.shop-tile.locked,
.loot-list.shop-grid .loot-row.locked {
  color: var(--muted);
}

.shop-tile.locked .item-icon,
.loot-list.shop-grid .loot-row.locked .item-icon {
  opacity: 0.45;
}

.combat {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  padding: 10px;
  background: #000;
  pointer-events: auto;
}

.battle-bar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 6px 12px;
  background: #000;
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 4px #cfcfcf;
}

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

.battle-floor {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
}

#combat-heading {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
}

.auto-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  background: #000;
  border-width: 2px;
  border-radius: 10px;
  box-shadow: none;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auto-toggle .ico-sm {
  display: block;
  width: 16px;
  height: 16px;
}

.auto-toggle .ico-lg {
  display: none;
  width: 32px;
  height: 32px;
}

.auto-knob {
  width: 24px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 9px;
  background: #000;
}

.combat-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border: 2px solid #fff;
  border-radius: 10px;
  background: #000 url("assets/wall.png") center / 160px 160px repeat;
  image-rendering: pixelated;
}

.combat-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #000;
  opacity: 0.42;
  pointer-events: none;
}

.combat-foes {
  position: absolute;
  top: 10px;
  right: 10px;
  left: 10px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
}

.foe-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 10px;
  background: #000;
  border: 2px solid #fff;
  border-radius: 8px;
  pointer-events: auto;
  cursor: pointer;
}

.foe-chip.picked {
  background: #141414;
  border-width: 3px;
}

button.foe-chip,
button.foe-chip:hover,
button.foe-chip:focus-visible,
button.foe-chip:disabled {
  width: auto;
  min-height: 0;
  box-shadow: none;
  outline: none;
}

.foe-name {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.foe-chip .hp-bar {
  width: 72px;
  height: 8px;
  margin: 0;
}

.combat-monsters {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.combat-monsters button {
  position: absolute;
  width: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: translateX(-50%);
  z-index: auto;
  pointer-events: auto;
  touch-action: manipulation;
}

.combat-monsters button:hover,
.combat-monsters button:disabled {
  background: transparent;
  border: 0;
  box-shadow: none;
  opacity: 1;
}

.combat-monsters button.picked .monster-meta {
  background: #1a1a1a;
  border: 3px solid #fff;
  box-shadow: none;
}

.combat-monsters button.picked .monster-name {
  color: var(--text);
}

.combat-monsters button.down {
  opacity: 0.38;
}

.monster-art {
  position: relative;
  display: block;
  overflow: visible;
  background: transparent;
}

.fx-sheet {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  pointer-events: none;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  transform: translate(-50%, -50%);
}

.fx-status-row {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 6;
  display: flex;
  gap: 2px;
  pointer-events: none;
  transform: translate(-50%, -100%);
}

#combat-party .fx-status-row {
  top: 4px;
  right: 4px;
  left: auto;
  transform: none;
}

.fx-status {
  display: block;
  flex: 0 0 auto;
  pointer-events: none;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

@media (prefers-reduced-motion: reduce) {
  .fx-sheet {
    visibility: hidden;
  }
}

.monster-art img {
  display: block;
  width: auto;
  height: 120px;
  max-width: none;
  background: transparent;
  image-rendering: pixelated;
  pointer-events: none;
}

.combat-monsters button.down .monster-art img {
  filter: grayscale(0.8);
}

.monster-zz {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 0 4px;
  color: #fff;
  background: #000;
  border: 1px solid #fff;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.35;
}

.monster-meta {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: max-content;
  max-width: none;
  padding: 2px 6px 3px;
  background: #000;
  border: 1px solid #fff;
  border-radius: 6px;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.monster-name {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 0.68rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.monster-hps {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 0.68rem;
  line-height: 1.2;
  white-space: nowrap;
}

.monster-hps span {
  margin: 0 0.15em;
}

.monster-hps .now {
  color: var(--text);
  font-weight: 700;
}

.monster-hps .out {
  color: var(--muted);
}

.hp-bar {
  display: block;
  width: 100%;
  height: 5px;
  margin-top: 2px;
  overflow: hidden;
  background: #2a2a2a;
  border-radius: 3px;
}

.hp-bar span {
  display: block;
  height: 100%;
  background: #fff;
}

.combat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.combat-list li {
  padding: 8px 10px;
  background: #1c1f2a;
  border: 1px solid var(--button-line);
  border-radius: 8px;
}

.combat-list li.down,
.combat-list button.down {
  color: var(--muted);
}

.combat-list button {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  text-align: left;
  touch-action: manipulation;
}

.combat-list button.picked,
.combat-list li.picked,
#combat-party button.picked,
#combat-party button.picked:hover,
#combat-party button.picked:focus-visible {
  background: #1a1a1a;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: none;
  outline: none;
}

.combat-prompt {
  flex: 0 0 auto;
  align-self: stretch;
  max-width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 10px 14px;
  overflow: hidden;
  background: #000;
  border: 2px solid #fff;
  border-radius: 10px;
  color: #fff;
  font-size: 16px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.combat-prompt:empty {
  display: none;
}

.combat-summary {
  flex: 0 0 auto;
  max-height: 5.5rem;
  margin: 0;
  padding: 8px 14px;
  overflow: auto;
  background: #000;
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #000, inset 0 0 0 3px #d0d0d0;
  color: #fff;
  pointer-events: none;
}

.combat-summary p {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}

.combat-narrow .combat-summary {
  overflow: auto;
}

.combat-narrow .combat-log {
  font-size: 0.64rem;
}

.combat-narrow .combat-log p {
  line-height: 1.15;
}

.combat-log {
  display: none !important;
}

.combat-log p {
  margin: 0;
  line-height: 1.25;
  white-space: nowrap;
}

.battle-dock {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: minmax(15rem, 62%) minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  max-height: none;
}

.battle-menu {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 8px;
  overflow: hidden;
  background: #000;
  border: 2px solid #fff;
  border-radius: 12px;
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 4px #cfcfcf;
}

.battle-actor {
  flex: 0 0 auto;
  margin: 0 0 4px;
  padding: 0 4px 4px;
  border-bottom: 1px solid #3a3a3a;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.battle-menu.spell-open .combat-commands {
  visibility: hidden;
}

#combat-party {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  list-style: none;
  pointer-events: auto;
}

#combat-party button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: auto;
  min-width: 0;
  min-height: 44px;
  height: 100%;
  padding: 8px 6px;
  overflow: hidden;
  background: #000;
  border: 2px solid #fff;
  box-shadow: none;
  color: #fff;
  font-size: 13px;
  line-height: 1.2;
  text-align: center;
  text-overflow: clip;
  white-space: normal;
}

#combat-party button:hover:not(:disabled),
#combat-party button:focus-visible {
  background: #000;
  border-color: #fff;
  box-shadow: none;
  outline: none;
}

#combat-party button:disabled {
  opacity: 1;
  color: var(--text);
}

#combat-party button.down {
  color: var(--muted);
}

#combat-party .class-portrait {
  width: 40px;
  height: 40px;
  object-fit: contain;
  image-rendering: auto;
}

#combat-party .combat-who,
#combat-party .combat-vitals,
#combat-party .combat-lv {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: clip;
  white-space: normal;
}

#combat-party .combat-who {
  font-weight: 700;
}

#combat-party .combat-lv {
  display: none;
  color: var(--muted);
}

#combat-party .combat-vitals {
  display: flex;
  justify-content: space-between;
  width: 100%;
  color: var(--muted);
  font-size: 11px;
}

#combat-party .combat-vitals span:last-child {
  color: #fff;
  font-weight: 700;
}

#combat-party .mp-none {
  color: #6e6e6e;
}

#combat-party .hp-bar {
  width: 100%;
  height: 5px;
  margin-top: 1px;
}

.combat-narrow #combat-party {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  background: transparent;
}

.combat-narrow #combat-party button {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 44px;
  overflow: hidden;
  background: #000;
  font-size: 13px;
  text-align: center;
  text-overflow: clip;
  white-space: normal;
}

.combat-narrow .monster-name,
.combat-narrow .monster-hps,
.combat-narrow .foe-name {
  font-size: 15px;
}

.combat-narrow #combat-party .combat-who,
.combat-narrow #combat-party .combat-vitals {
  display: block;
  max-width: 100%;
  white-space: normal;
}

.combat-narrow #combat-party .combat-vitals {
  display: flex;
}

.command-box {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  height: calc(8 * 44px + 7 * 2px);
  overflow: hidden;
}

.combat-commands,
.combat-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  pointer-events: auto;
}

.combat-commands {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: repeat(8, 44px);
  gap: 2px;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#combat-attack { grid-row: 1; }
#combat-defend { grid-row: 2; }
#combat-cover { grid-row: 3; }
#combat-magic { grid-row: 4; }
#combat-steal { grid-row: 5; }
#combat-item { grid-row: 6; }
#combat-gear { grid-row: 7; }
#combat-run { grid-row: 8; }

.combat-commands button.cmd-blank {
  visibility: hidden;
  pointer-events: none;
}

.cmd-ico {
  display: block;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}

.combat-commands button,
.combat-actions button,
.combat-targets button {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 4px 8px 4px 28px;
  background: transparent;
  border: 2px solid transparent;
  box-shadow: none;
  color: #fff;
  font-size: 17px;
  letter-spacing: 0;
  text-align: left;
  white-space: nowrap;
  pointer-events: auto;
  touch-action: manipulation;
}

.combat-commands button:hover:not(:disabled),
.combat-commands button:focus-visible,
.combat-targets button:hover:not(:disabled),
.combat-targets button:focus-visible {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  outline: none;
}

.combat-commands button.menu-on,
.combat-commands button.menu-on:hover,
.combat-commands button.menu-on:focus-visible {
  background: #141414;
  border: 2px solid #fff;
  box-shadow: none;
  outline: none;
}

.combat-commands button.menu-on::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 8px;
  width: 0;
  height: 0;
  margin-top: -6px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid #fff;
  pointer-events: none;
}

.combat-commands button:disabled {
  opacity: 1;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.combat-narrow .combat-commands button,
.combat-narrow .combat-targets button {
  min-height: 44px;
  padding: 4px 8px 4px 28px;
  font-size: 17px;
}

.combat-targets {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 8px;
  box-shadow: none;
  pointer-events: auto;
}

.battle-menu .combat-targets {
  border: 0;
  border-radius: 0;
}

.command-box .combat-targets {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 2px;
  max-height: none;
  overflow: hidden;
}

.command-box .combat-targets #combat-target-list {
  max-height: none;
}

.command-box .combat-targets button {
  flex: 0 0 44px;
  height: 44px;
  max-height: 44px;
}

.combat-targets p {
  display: flex;
  flex: 0 0 44px;
  align-items: center;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0 8px;
  overflow: hidden;
  color: #fff;
  font-size: 17px;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.combat-targets button {
  flex: 0 0 auto;
  width: 100%;
}

#combat-target-list button {
  padding-left: 10px;
}

.combat-targets .loot-row,
.combat-targets .loot-row:hover:not(:disabled),
.combat-targets .loot-row:focus-visible {
  padding: 4px 8px;
  background: #000;
  border: 2px solid #fff;
  box-shadow: none;
  outline: none;
}

.combat-targets.loot-pop {
  flex-direction: column;
  align-items: stretch;
  max-height: 100%;
  overflow: hidden;
}

.combat-targets #combat-target-list,
.combat-targets.loot-pop #combat-target-list {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  justify-content: flex-start;
  align-content: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 0;
  max-height: min(42vh, 18rem);
  overflow: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#combat-target-back,
#spell-back {
  flex: 0 0 auto;
  width: 100%;
  padding-left: 60px;
  background-image: url("assets/ui/icon_back_32.png");
  background-repeat: no-repeat;
  background-position: 28px center;
  background-size: 24px 24px;
  image-rendering: pixelated;
}

.combat-targets.loot-pop .loot-row,
.combat-targets.loot-pop .loot-tools {
  flex: 0 0 44px;
  width: 100%;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
}

.combat-targets.loot-pop .loot-tools {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  gap: 2px;
  width: 100%;
  height: auto;
  max-height: none;
}

.command-box .combat-targets .loot-tools button {
  flex: 0 0 44px;
  width: 100%;
  height: 44px;
  max-height: 44px;
}

.command-box .item-icon {
  width: 24px;
  height: 24px;
}

.combat-actions .start {
  background: #000;
  color: #fff;
  border-color: #fff;
  opacity: 1;
}

#play.in-combat header,
#play.in-combat .log,
#play.in-combat .pad,
#play.in-combat .stage {
  display: none !important;
}

#play.in-combat .party-panel {
  display: none !important;
}

@media (min-width: 860px) {
  .combat {
    gap: 10px;
    padding: 16px 20px;
  }

  .battle-bar,
  .combat-stage,
  .combat-prompt,
  .combat-summary,
  .battle-menu {
    border-width: 3px;
  }

  .battle-floor {
    font-size: 18px;
  }

  #combat-heading {
    font-size: 26px;
  }

  .auto-toggle {
    min-height: 52px;
    border-width: 3px;
    font-size: 18px;
  }

  .auto-toggle .ico-sm {
    display: none;
  }

  .auto-toggle .ico-lg {
    display: block;
  }

  .combat-prompt,
  .combat-summary p {
    font-size: 22px;
  }

  .foe-name {
    font-size: 24px;
  }

  .foe-chip {
    border-width: 3px;
    padding: 8px 14px;
  }

  .foe-chip .hp-bar {
    width: 160px;
    height: 12px;
  }

  .battle-dock {
    grid-template-columns: minmax(18rem, 24rem) minmax(0, 1fr);
    max-height: none;
  }

  .command-box .combat-targets {
    gap: 4px;
  }

  .combat-targets p,
  .command-box .combat-targets button,
  .combat-targets.loot-pop .loot-row {
    flex-basis: 48px;
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    font-size: 18px;
  }

  .command-box .combat-targets .loot-tools {
    flex-basis: auto;
    height: auto;
    max-height: none;
    gap: 4px;
  }

  .command-box .combat-targets #combat-target-list {
    gap: 4px;
  }

  .battle-actor {
    font-size: 20px;
  }

  .command-box {
    height: calc(4 * 48px + 3 * 4px);
  }

  .combat-commands {
    display: grid;
    grid-template-rows: repeat(4, 48px);
    grid-template-columns: 1fr 1fr;
    align-content: start;
    gap: 4px 8px;
  }

  #combat-attack { grid-column: 1; grid-row: 1; }
  #combat-defend { grid-column: 1; grid-row: 2; }
  #combat-cover { grid-column: 1; grid-row: 3; }
  #combat-magic { grid-column: 1; grid-row: 4; }
  #combat-steal { grid-column: 2; grid-row: 1; }
  #combat-item { grid-column: 2; grid-row: 2; }
  #combat-gear { grid-column: 2; grid-row: 3; }
  #combat-run { grid-column: 2; grid-row: 4; }

  .combat-commands button,
  .combat-targets button,
  #spell-book.combat-spell button {
    min-height: 48px;
    font-size: 18px;
  }

  .combat-commands button.menu-on,
  .combat-commands button.menu-on:hover,
  .combat-commands button.menu-on:focus-visible {
    border-width: 3px;
  }

  .cmd-ico,
  #combat-target-back,
  #spell-back {
    background-size: 32px 32px;
  }

  .cmd-ico {
    width: 32px;
    height: 32px;
  }

  .combat:not(.combat-narrow) #combat-party {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  #combat-party button {
    align-items: flex-start;
    padding: 14px 12px;
    border-width: 3px;
    font-size: 18px;
    text-align: left;
  }

  #combat-party button.acting,
  #combat-party button.acting:hover,
  #combat-party button.acting:focus-visible {
    border-width: 4px;
  }

  #combat-party .class-portrait {
    width: 72px;
    height: 72px;
  }

  #combat-party .combat-who {
    font-size: 22px;
  }

  #combat-party .combat-lv {
    display: block;
    font-size: 18px;
  }

  #combat-party .combat-vitals {
    font-size: 18px;
  }

  #combat-party .hp-bar {
    height: 8px;
  }
}

#play {
  z-index: 1;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  grid-template-areas:
    "header"
    "log"
    "party"
    "stage"
    "pad";
  background: var(--bg);
}

header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 8px 0;
  padding: 8px 12px;
  background: #000;
  border: 2px solid #fff;
  border-radius: 12px;
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 5px #d0d0d0;
}

.log {
  grid-area: log;
  margin: 6px 8px;
  min-height: 1.35em;
  padding: 6px 12px;
  background: #000;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #000, inset 0 0 0 3px #d0d0d0;
  font-size: 0.92rem;
  line-height: 1.35;
}

.brand {
  margin-right: auto;
}

.kicker {
  margin: 0;
  color: var(--text);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.floor {
  margin: 2px 0 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.hint {
  margin: 0;
  color: #d8d8d8;
  font-size: 0.92rem;
}

.stage {
  grid-area: stage;
  min-width: 0;
  min-height: 0;
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.pad {
  grid-area: pad;
  display: grid;
  grid-template-columns: 64px 64px 64px;
  grid-template-areas:
    ". up ."
    "left down right";
  gap: 8px;
  justify-content: center;
  padding: 10px 16px 16px;
  touch-action: none;
  user-select: none;
}

.pad button {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.pad .up { grid-area: up; }
.pad .left { grid-area: left; }
.pad .down { grid-area: down; }
.pad .right { grid-area: right; }

.pad button[aria-pressed="true"],
.pad button[aria-pressed="true"]:hover,
.pad button[aria-pressed="true"]:focus-visible {
  background: #1a1a1a;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: none;
  outline: none;
}

@media (min-width: 800px) {
  .party-layout {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    align-items: start;
  }
}

@media (min-width: 860px) {
  #play {
    grid-template-columns: 11.5rem minmax(0, 1fr) auto;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "header header header"
      "log log log"
      "party stage pad";
  }

  .party-panel {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    border: 0;
    padding: 8px;
  }

  .pad {
    align-self: center;
    padding: 16px 22px 16px 8px;
  }
}

@media (max-width: 859px) {
  #play.in-combat .party-panel {
    display: none !important;
  }
}

@media (max-width: 720px) {
  .hint {
    display: none;
  }

  header {
    padding: 10px 14px 4px;
  }

  .log {
    padding: 0 14px 8px;
  }
}

@media (max-height: 640px) {
  .pad {
    gap: 6px;
    padding-top: 6px;
    padding-bottom: 8px;
  }

  .pad button {
    width: 52px;
    height: 52px;
  }

  .card {
    padding: 20px 18px 16px;
  }

  .card h1 {
    font-size: 1.8rem;
  }
}

.noscript {
  margin: 24px;
  color: var(--text);
}

#settings-open,
#info-open,
#info-back {
  width: 100%;
  margin-top: 8px;
  min-height: 44px;
}

.title-screen {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
}

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

.title-art {
  position: absolute;
  inset: 0;
}

.title-art:empty {
  display: none;
}

.title-backdrop,
.title-backdrop img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.title-backdrop img {
  object-fit: cover;
  object-position: center center;
  image-rendering: pixelated;
}

.title-embers {
  --fh: max(720px, 100vh, calc(100vw * 9 / 16));
  --fw: calc(var(--fh) * 16 / 9);
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.title-embers-strip {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--fw) * 16);
  height: var(--fh);
  background: url("assets/title/title_embers_v2_strip.png") 0 0 / 100% 100% no-repeat;
  image-rendering: pixelated;
  transform: translate(calc(50vw - var(--fw) / 2), calc(50vh - var(--fh) / 2));
  animation: title-embers-move calc(16s / 12) steps(16, end) infinite;
}

@keyframes title-embers-move {
  to {
    transform: translate(calc(50vw - var(--fw) / 2 - 16 * var(--fw)), calc(50vh - var(--fh) / 2));
  }
}

.title-logo {
  position: absolute;
  z-index: 2;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  width: min(640px, 86vw);
  max-height: 22vh;
  object-fit: contain;
  object-position: top center;
  transform: translateX(-50%);
  image-rendering: pixelated;
}

.title-menu {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(284px, calc(100vw - 24px));
  transform: translateX(-50%);
  background: transparent;
  border: 0;
  box-shadow: none;
}

.title-actions {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 5px;
  margin: 0;
}

#title .title-actions .title-btn,
#title .title-actions .title-btn:hover,
#title .title-actions .title-btn:focus,
#title .title-actions .title-btn:focus-visible,
#title .title-actions .start,
#title .title-actions .start:hover:not(:disabled) {
  position: relative;
  width: 100%;
  height: 52px;
  min-height: 52px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #0a0a0a;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  outline: none;
  color: #6a6a6a;
  font-weight: 400;
}

.title-actions .title-btn img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  image-rendering: pixelated;
  pointer-events: none;
}

.title-actions .title-btn .is-selected,
.title-actions .title-btn .is-disabled {
  opacity: 0;
}

.title-actions .title-btn:hover .is-selected,
.title-actions .title-btn:focus-visible .is-selected {
  opacity: 1;
}

.title-actions .title-btn:hover .is-normal,
.title-actions .title-btn:focus-visible .is-normal {
  opacity: 0;
}

.title-actions .title-btn:focus-visible {
  outline: none;
}

.title-actions .title-btn span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

#continue:disabled {
  opacity: 1;
  background: #0a0a0a;
  color: #6a6a6a;
  border: 0;
  box-shadow: inset 0 0 0 2px #555, inset 0 0 0 4px #0a0a0a, inset 0 0 0 6px #555;
  cursor: default;
}

#continue:disabled .is-normal,
#continue:disabled .is-selected,
#continue:disabled:hover .is-selected,
#continue:disabled:focus-visible .is-selected {
  opacity: 0;
}

#continue:disabled .is-disabled {
  opacity: 1;
}

.title-btn-fallback img {
  display: none;
}

.title-btn-fallback span {
  position: static;
  width: auto;
  height: auto;
  clip: auto;
  color: #fff;
  font-size: 16px;
  line-height: 52px;
}

#continue.title-btn-fallback:disabled {
  border: 2px solid #555;
  box-shadow: inset 0 0 0 3px #0a0a0a, inset 0 0 0 5px #555;
}

#continue.title-btn-fallback:disabled span {
  color: #6a6a6a;
}

#title-thanks {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #000;
}

.thanks-card {
  width: min(22rem, 100%);
  text-align: center;
}

.thanks-card h1 {
  margin: 0 0 16px;
  font-size: 1.6rem;
}

#thanks-back {
  width: 100%;
  min-height: 44px;
}

@media (max-height: 640px) and (orientation: landscape) {
  .title-backdrop img {
    object-position: center bottom;
  }

  .title-logo {
    width: min(420px, 48vw);
    max-height: 18vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .title-embers-strip {
    animation: none;
  }
}

#info {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding:
    max(16px, env(safe-area-inset-top))
    16px
    max(16px, env(safe-area-inset-bottom));
  background: #000;
}

.info-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: min(28rem, 100%);
  height: 100%;
  max-height: 100%;
  margin: 0 auto;
  overflow: hidden;
}

.info-card > h1,
.info-card > .rule,
#info-back {
  flex: 0 0 auto;
}

.info-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#settings {
  position: fixed;
  inset: 0;
  z-index: 9;
  overflow: auto;
  padding:
    max(16px, env(safe-area-inset-top))
    16px
    max(16px, env(safe-area-inset-bottom));
  background: #000;
}

.settings-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: min(28rem, 100%);
  margin: 0 auto;
}

.settings-credit {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.settings-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.settings-label span.is-silent,
.audio-status {
  color: #fff;
  font-weight: bold;
}

.audio-status {
  margin: 12px 0 0;
}

.settings-field input[type="range"] {
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  accent-color: #fff;
  background: transparent;
}

#settings button {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
}

#spell-book {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: flex;
  padding: 8px;
  background: #000;
}

.spell-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: min(28rem, 100%);
  max-height: calc(100dvh - 16px);
  margin: 0 auto;
  padding: 12px;
  background: #000;
  border: 2px solid #fff;
  border-radius: 8px;
}

.spell-card h1,
.spell-card > .spell-note {
  flex: 0 0 auto;
}

.spell-card h1 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.spell-note,
.spell-school {
  margin: 0 0 8px;
  color: #fff;
}

.spell-school {
  margin-top: 10px;
}

.spell-list {
  flex: 1 1 auto;
  justify-content: flex-start;
  align-content: start;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spell-row {
  display: flex;
  gap: 8px;
}

#spell-book button {
  width: 100%;
  min-height: 44px;
  text-align: left;
  white-space: normal;
  cursor: default;
  touch-action: manipulation;
}

#spell-book .spell-row button:first-child {
  flex: 1 1 auto;
}

#spell-book .spell-row button:last-child {
  flex: none;
  width: auto;
  min-width: 5.5rem;
  text-align: center;
}

#spell-back {
  flex: none;
  margin-top: 8px;
}

#spell-book.combat-spell {
  inset: auto;
  z-index: 14;
  padding: 0;
  overflow: hidden;
  background: #000;
  border: 2px solid #fff;
  border-radius: 12px;
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 4px #cfcfcf;
}

#spell-book.combat-spell .spell-card {
  width: 100%;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 8px;
  background: transparent;
  border: 0;
}

#spell-book.combat-spell .spell-card h1,
#spell-book.combat-spell .spell-note {
  flex: 0 0 auto;
}

#spell-book.combat-spell .spell-card h1 {
  display: flex;
  align-items: center;
  height: 44px;
  min-height: 44px;
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#spell-book.combat-spell .spell-note {
  margin: 0;
  min-height: 0;
  font-size: 15px;
  line-height: 1.2;
}

#spell-book.combat-spell .spell-list {
  flex: 1 1 auto;
  justify-content: flex-start;
  gap: 2px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#spell-book.combat-spell button {
  flex: 0 0 44px;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  font-size: 17px;
}

#spell-book.combat-spell #spell-back {
  margin-top: 0;
}

@media (min-width: 860px) {
  #spell-book.combat-spell .spell-card h1,
  #spell-book.combat-spell button {
    flex-basis: 48px;
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    font-size: 18px;
  }

  #spell-book.combat-spell .spell-list {
    gap: 4px;
  }
}

.item-tip {
  position: fixed;
  z-index: 40;
  max-width: min(22rem, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  padding: 8px 10px;
  overflow: auto;
  background: #000;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #000, inset 0 0 0 3px #cfcfcf;
  font-size: 0.78rem;
  line-height: 1.35;
  pointer-events: none;
}

.item-tip[hidden] {
  display: none !important;
}

.item-tip strong,
.item-tip p {
  margin: 0;
}

.item-tip strong {
  margin-bottom: 4px;
}

.equip-compare {
  margin: 0 0 8px;
  padding: 8px;
  background: #000;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #000, inset 0 0 0 3px #cfcfcf;
  font-size: 0.72rem;
  line-height: 1.35;
}

.equip-compare[hidden] {
  display: none !important;
}

#smith-compare {
  position: sticky;
  top: 0;
  z-index: 2;
}

.compare-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 4px;
}

.compare-side {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.compare-side span {
  overflow-wrap: anywhere;
}

.compare-slot,
.compare-note,
.compare-overall,
.compare-line {
  margin: 0;
}

.compare-overall {
  margin-top: 4px;
}

.tip-up {
  color: #3ddc84;
}

.tip-down {
  color: #ff5c5c;
}

.tip-same {
  color: var(--muted);
}

.tip-arrow {
  width: 16px;
  height: 16px;
  margin-right: 4px;
  vertical-align: middle;
  image-rendering: pixelated;
}

.tip-same::before {
  display: inline-block;
  margin-right: 4px;
  content: "–";
}

.loot-name {
  border-bottom: 1px dashed #fff;
  cursor: default;
}

#combat-party button.acting,
#combat-party button.acting:hover,
#combat-party button.acting:focus-visible,
.who.acting {
  position: relative;
  background: #141414;
  border: 3px solid #fff;
  outline: none;
  box-shadow: 0 0 0 2px #fff, 0 0 12px #fff;
  animation: turn-pulse 1.1s ease-in-out infinite;
}

@media (min-width: 860px) {
  #combat-party button.acting,
  #combat-party button.acting:hover,
  #combat-party button.acting:focus-visible {
    border-width: 4px;
    background: #141414;
  }
}

#combat-party button.acting::before,
.who.acting::before {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid #fff;
  content: "";
  pointer-events: none;
}

@keyframes turn-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 2px #fff, 0 0 6px #fff;
  }

  50% {
    box-shadow: 0 0 0 2px #fff, 0 0 16px #fff;
  }
}

@media (prefers-reduced-motion: reduce) {
  #combat-party button.acting,
  #combat-party button.acting:hover,
  #combat-party button.acting:focus-visible,
  .who.acting {
    animation: none;
    box-shadow: 0 0 0 2px #fff, 0 0 12px #fff;
  }
}
