.ui-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  vertical-align: middle;
}
.rail-icon .ui-icon {
  width: 28px;
  height: 28px;
}
.coin-balance {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  color: #ffe39b;
}
.playing .stack-stage {
  display: grid;
  grid-template-columns: minmax(250px, 45%) minmax(0, 1fr);
  overflow: hidden;
  gap: 12px;
}
.dungeon-map {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 8px;
}
.stack-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
  font-size: 13px;
}
.stack-heading small {
  color: var(--muted);
  font-size: 10px;
}
.stack-scroll {
  overflow: auto;
  min-height: 0;
  flex: 1;
}
.stack-layout {
  --card-w: 68px;
  --card-h: 91px;
  --row-gap: 48px;
  position: relative;
  width: calc(var(--stack-width) * var(--card-w) + 16px);
  height: calc((var(--stack-floors) - 1) * var(--row-gap) + var(--card-h) + 12px);
  margin: 5px auto;
}
.stack-card {
  position: absolute;
  left: calc(50% + var(--node-x) * var(--card-w) - var(--card-w) / 2);
  top: calc(var(--node-y) * var(--row-gap));
  width: calc(var(--card-w) - 6px);
  height: var(--card-h);
  padding: 5px 3px;
  border: 2px solid #0c2d36;
  border-radius: 9px;
  box-shadow: 0 3px 8px #0007;
  background: #1d6075;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  text-align: center;
}
.stack-card small {
  font-size: 9px;
  font-weight: 500;
}
.stack-card strong {
  font-size: 10px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.stack-card span {
  font-size: 8px;
  margin-top: auto;
}
.stack-card.is-hidden strong {
  font:
    24px Georgia,
    serif;
}
.stack-card.is-open {
  background: #4f982c;
  border-color: #90d257;
  color: white;
}
.stack-card.is-known {
  background: #574524;
  border-color: #d9ae60;
  color: #fff0c4;
}
.stack-card.is-current {
  outline: 2px solid white;
  outline-offset: 2px;
}
.stack-card:hover:not(:disabled) {
  transform: none;
  filter: brightness(1.2);
}
.stack-card:focus-visible {
  z-index: 10 !important;
}
.playing .stack-stage .active-obstacle {
  min-width: 0;
  overflow: auto;
}
.route-choice {
  padding: 18px;
}
.route-choice h2 {
  font-size: 26px;
}
.route-choice p {
  font-size: 13px;
}
.approach-outcomes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 10px;
  margin-top: 8px;
}
.playing .compact-encounter .approach-outcomes p {
  font-size: 11px;
  line-height: 1.3;
  margin: 1px 0;
}
.approach-outcomes small {
  font-size: 12px;
}
.playing .stack-stage .compact-encounter .encounter-copy h3 {
  font-size: clamp(21px, 2.3vw, 30px);
  margin-bottom: 6px;
}
.playing .stack-stage .encounter.compact-encounter {
  padding: 8px 24px 8px 5px;
}
.chosen-outcome {
  color: #ffe39b;
  font-size: 12px;
  line-height: 1.3;
  padding-top: 5px;
}
.market-panel {
  overflow-y: auto;
  min-height: 0;
  padding: 16px 24px;
}
.market-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.market-heading h2 {
  margin: 0;
  font-size: 25px;
}
.market-panel > p {
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0;
}
.market-stock {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 16px;
  max-width: 1000px;
  margin: 12px auto;
}
.market-stock article {
  min-width: 0;
  display: grid;
  gap: 8px;
  align-content: start;
}
.market-card {
  width: 100%;
  aspect-ratio: 2 / 3;
  position: relative;
  container-type: inline-size;
}
.market-card .player-face {
  width: 100%;
  height: 100%;
}
.market-stock button {
  font-size: 12px;
  padding: 8px;
}
.market-sales {
  padding: 12px 0;
}
.market-sales > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.market-sales button {
  font-size: 12px;
}

@media (max-width: 760px) {
  .playing .stack-stage {
    grid-template-columns: minmax(120px, 39%) minmax(0, 1fr);
    gap: 4px;
  }
  .stack-layout {
    --card-w: 48px;
    --card-h: 68px;
    --row-gap: 34px;
  }
  .stack-card small {
    font-size: 7px;
  }
  .stack-card strong {
    font-size: 8px;
  }
  .stack-card span {
    font-size: 7px;
  }
  .dungeon-map {
    padding: 3px;
  }
  .stack-heading small {
    display: none;
  }
  .approach-outcomes {
    grid-template-columns: 1fr;
  }
  .route-choice {
    padding: 6px;
  }
  .route-choice h2 {
    font-size: 20px;
  }
  .route-choice p {
    font-size: 11px;
  }
  .market-panel {
    padding: 10px;
  }
  .market-stock {
    grid-template-columns: repeat(2, minmax(110px, 1fr));
  }
  .market-heading h2 {
    font-size: 20px;
  }
  .rail-menu {
    overflow-x: auto;
  }
  .rail-icon {
    flex: 0 0 32px;
  }
  .rail-icon .ui-icon {
    width: 25px;
    height: 25px;
  }
}
.rail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  background: #102824;
}
.rail-actions button {
  padding: 7px 10px;
  min-height: 34px;
  font-size: 11px;
}
.rail-actions .encounter-tools,
.rail-actions .event-actions {
  display: contents;
}
.rail-actions button:disabled {
  opacity: 0.45;
}
.rail-actions button[aria-pressed='true'] {
  border-color: #ffdc7b;
  background: #826c27;
  box-shadow: 0 0 0 1px #ffdc7b;
}
.route-vote-status {
  display: grid;
  gap: 2px;
  padding-right: 8px;
  font-size: 12px;
}
.route-vote-status small {
  font-size: 10px;
  color: var(--muted);
}
.diamond-choices {
  display: flex;
  align-items: center;
  gap: 4px;
}
.diamond-choices select {
  min-height: 30px;
  height: 44px;
  padding: 3px;
}
.rail-actions .round-recovery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.rail-actions .round-recovery p {
  margin: 0;
  font-size: 12px;
}
@media (max-width: 760px) {
  .rail-actions {
    gap: 3px;
    padding: 4px;
  }
  .rail-actions button {
    padding: 6px;
    min-height: 32px;
  }
}

.playing .market-board {
  grid-template-rows: minmax(120px, 1fr) auto minmax(100px, 0.65fr);
}
.market-board .market-panel {
  padding-block: 6px;
}
.market-board .market-stock {
  display: flex;
  justify-content: center;
  gap: 12px;
  height: calc(100% - 42px);
  margin: 6px auto;
  overflow: auto;
}
.market-board .market-stock article {
  flex: 0 0 auto;
  height: 100%;
  aspect-ratio: 5 / 7;
}
.market-board .market-card {
  width: auto;
  height: 100%;
  aspect-ratio: 5 / 7;
}
.market-sale-picker {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.market-sale-picker select {
  padding: 6px;
  min-height: 32px;
  width: min(250px, 40vw);
}
.market-rail > p {
  margin: 0;
  padding: 3px;
  text-align: center;
  font-size: 11px;
}
.market-owned {
  min-height: 0;
  overflow: auto;
  padding: 6px 12px;
}
.market-owned > div {
  display: flex;
  gap: 10px;
  height: calc(100% - 24px);
}
.market-owned h3 {
  font-size: 14px;
  margin: 0 0 4px;
}
.market-owned-card {
  flex: 0 0 auto;
  height: 100%;
  aspect-ratio: 5 / 7;
}
.market-owned-card .player-face {
  height: 100%;
}
/* Reserve space for both the encounter and hand when actions wrap. */
.playing .play-board:not(.market-board) {
  grid-template-rows: minmax(100px, 0.8fr) auto minmax(140px, 1.2fr);
}
@media (max-width: 760px) {
  .game-rail {
    gap: 6px;
    padding-inline: 6px;
  }
  .game-rail .rail-menu {
    flex: 1 1 auto;
    min-width: 0;
  }
}
@media (max-height: 500px) {
  .playing .play-board {
    overflow-y: auto;
  }
  .playing .play-board:not(.market-board) {
    grid-template-rows: minmax(100px, 0.8fr) auto minmax(120px, 1fr);
  }
}
/* Shop prices are readable on the cards; the whole card is the purchase/sale target. */
.market-card-button {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  flex: 0 0 auto;
  height: 100%;
  aspect-ratio: 5 / 7;
  isolation: isolate;
}
.market-card-button .player-face {
  height: 100%;
  width: 100%;
}
.market-card-button:hover:not(:disabled) {
  background: transparent;
  transform: translateY(-2px);
  box-shadow:
    0 0 0 2px #ffe39b,
    0 6px 20px #0005;
}
.market-card-button:disabled {
  opacity: 0.55;
}
.market-card-button .frame-footer {
  display: none;
}
.market-price-tag {
  position: absolute;
  z-index: 5;
  right: 6%;
  top: 16%;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  background: #ffe1a1;
  color: #282314;
  border: 2px solid #8c5b22;
  border-radius: 4px;
  box-shadow: 0 3px 6px #0007;
  pointer-events: none;
}
.market-price-tag b {
  font: 800 clamp(22px, 2vw, 30px) / 1 system-ui;
}
.market-price-tag small {
  font: 750 11px/1 system-ui;
}
.market-price-tag .ui-icon {
  width: 26px;
  height: 26px;
}
.market-board .market-stock {
  justify-content: flex-start;
  width: max-content;
  max-width: 100%;
  padding: 3px;
}
.market-owned > div {
  padding: 3px;
}
.market-card-button .frame-description {
  font-size: 5.2cqw;
}
.market-card-button .frame-description small {
  font-size: 4cqw;
}
.market-card-button .frame-title {
  font-size: 6.8cqw;
}
.market-sale-preview {
  display: grid;
  justify-items: center;
  gap: 12px;
}
.market-sale-preview > div {
  width: min(220px, 50vw);
}
.market-sale-preview p {
  margin: 0;
  font-size: 16px;
}
.coin-flight {
  position: fixed;
  width: 24px;
  height: 24px;
  object-fit: contain;
  z-index: 1500;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px #0008);
}
.game-rail [data-coin-wallet] {
  flex: 0 0 auto;
}
.game-rail [data-coin-wallet] b {
  font-size: 16px;
  min-width: 1.5ch;
}
@media (prefers-reduced-motion: reduce) {
  .coin-flight {
    display: none;
  }
}
