/* Last Bastion: interface styles.
   The island is the picture; the interface sits on it like game components on a table:
   dark sea-ink panels, cardboard tiles for the hand, brass for everything that counts. */

:root {
  --ink: #10242b;
  --ink-raised: #1a3a45;
  --ink-line: rgba(233, 241, 236, 0.14);
  --panel: rgba(13, 31, 38, 0.82);
  --foam: #e9f1ec;
  --mist: #a8bdc1;
  --brass: #d9a441;
  --brass-hi: #f3cf74;
  --brass-lo: #96691c;
  --madder: #c8452f;
  --madder-hi: #ef7059;
  --verdigris: #4fa89a;
  --rift: #b48cff;
  --card: #efe6d2;
  --card-edge: #cbb98f;
  --card-under: #a08a5e;
  --card-ink: #2a2721;
  --card-mute: #6d6553;
  --cat-road: #b3843a;
  --cat-tower: #b7412c;
  --cat-trap: #6a59a6;
  --cat-support: #3d8c80;
  --font-display: 'Grenze Gotisch', 'Alegreya Sans', serif;
  --font-ui: 'Alegreya Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius-panel: 14px;
  --radius-control: 10px;
  --shadow-panel: 0 14px 34px -12px rgba(2, 10, 14, 0.7);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--foam);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p,
ol,
ul {
  margin: 0;
  padding: 0;
}

ol,
ul {
  list-style: none;
}

:focus-visible {
  outline: 2px solid var(--brass-hi);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#scene.is-dragging {
  cursor: grabbing;
}

#scene.is-placing {
  cursor: crosshair;
}

#scene.is-pointing {
  cursor: pointer;
}

#app {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#app > * {
  pointer-events: none;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  vertical-align: -0.2em;
}

/* ------------------------------------------------------------------ shared pieces */

.panel {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
}

.btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-control);
  background: var(--ink-raised);
  color: var(--foam);
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
  transition: transform 0.12s var(--ease-out), background 0.15s, box-shadow 0.15s, filter 0.15s;
}

.btn:hover:not(:disabled) {
  background: #23505e;
}

.btn:active:not(:disabled) {
  transform: translateY(2px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-primary {
  border: 0;
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 55%, #c08d2c);
  color: #33240a;
  box-shadow: 0 3px 0 var(--brass-lo), 0 10px 18px -6px rgba(0, 0, 0, 0.6);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffe08f, #e6b450 55%, #cb9733);
}

.btn-primary:active:not(:disabled) {
  box-shadow: 0 1px 0 var(--brass-lo), 0 4px 8px -4px rgba(0, 0, 0, 0.6);
}

.btn-danger {
  background: #4a2420;
  border-color: rgba(239, 112, 89, 0.35);
}

.btn-danger:hover:not(:disabled) {
  background: #6a2c25;
}

.btn-small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-control);
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 20px;
  transition: background 0.15s, transform 0.12s;
}

.icon-btn:hover {
  background: #23505e;
}

.icon-btn:active {
  transform: translateY(1px);
}

.price {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  font-weight: 800;
  color: var(--brass-hi);
  font-variant-numeric: tabular-nums;
}

.btn-primary .price {
  color: #33240a;
}

kbd {
  font: inherit;
  font-size: 0.72em;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(0, 0, 0, 0.18);
}

.segmented {
  pointer-events: auto;
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-control);
  background: var(--panel);
  border: 1px solid var(--ink-line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.segmented button {
  min-width: 40px;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--mist);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s, color 0.15s;
}

.segmented button:hover {
  color: var(--foam);
  background: rgba(255, 255, 255, 0.07);
}

.segmented button[aria-pressed='true'] {
  background: var(--brass);
  color: #33240a;
}

/* ------------------------------------------------------------------ top rail */

.hud {
  position: absolute;
  inset: 0;
  transition: opacity 0.4s;
}

.hud.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.rail {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.rail-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px 0 11px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--ink-line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-panel);
  font-variant-numeric: tabular-nums;
}

.chip .icon {
  font-size: 22px;
}

.chip-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  line-height: 1;
  transform: translateY(1px);
}

.chip-sub {
  color: var(--mist);
  font-weight: 500;
  font-size: 15px;
}

.chip-lives .icon {
  color: var(--madder-hi);
}

.chip-gold .icon {
  color: var(--brass-hi);
}

.chip.is-bumped .chip-num {
  animation: bump 0.35s var(--ease-out);
}

.chip.is-hurt {
  animation: hurt 0.45s;
}

@keyframes bump {
  30% {
    transform: translateY(-3px) scale(1.18);
  }
}

@keyframes hurt {
  20% {
    background: rgba(200, 69, 47, 0.85);
    transform: translateX(-3px);
  }
  50% {
    transform: translateX(3px);
  }
}

/* Wave track: the round marker of a board game, one space per wave. */
.track-wrap {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 7px 16px 9px;
  border-radius: var(--radius-panel);
  background: var(--panel);
  border: 1px solid var(--ink-line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-panel);
}

.track-label {
  font-size: 15px;
  color: var(--mist);
  white-space: nowrap;
}

.track-label b {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--foam);
  margin: 0 2px;
}

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

.pip {
  position: relative;
  width: 13px;
  height: 13px;
  border-radius: 4px;
  border: 1.5px solid rgba(233, 241, 236, 0.3);
  transition: background 0.3s, border-color 0.3s, transform 0.3s;
}

.pip.is-done {
  background: rgba(217, 164, 65, 0.55);
  border-color: transparent;
}

.pip.is-now {
  background: var(--brass-hi);
  border-color: #fff3cf;
  transform: scale(1.35);
  box-shadow: 0 0 0 3px rgba(243, 207, 116, 0.25);
}

.pip.is-boss {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: rgba(233, 241, 236, 0.6);
  border-color: rgba(180, 140, 255, 0.6);
}

.pip.is-boss .icon {
  width: 14px;
  height: 14px;
}

.pip.is-boss.is-done {
  background: rgba(180, 140, 255, 0.4);
  color: var(--foam);
}

.pip.is-boss.is-now {
  background: var(--rift);
  color: #1c1230;
  transform: scale(1.2);
  box-shadow: 0 0 0 3px rgba(180, 140, 255, 0.3);
}

/* ------------------------------------------------------------------ side panels */

.wave-panel {
  position: absolute;
  top: 84px;
  left: max(12px, env(safe-area-inset-left));
  width: 232px;
  padding: 12px 12px 10px;
}

.panel-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 23px;
  line-height: 1.1;
}

.panel-note {
  color: var(--mist);
  font-size: 15px;
}

.wave-theme {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 2px 9px 2px 7px;
  border-radius: 999px;
  background: rgba(180, 140, 255, 0.2);
  color: #dccbff;
  font-weight: 700;
  font-size: 14px;
}

.foes {
  margin-top: 8px;
  display: grid;
  gap: 2px;
}

.foe {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 38px auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 3px 6px 3px 2px;
  border-radius: 9px;
}

.foe:hover {
  background: rgba(255, 255, 255, 0.06);
}

.foe img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(233, 241, 236, 0.2), rgba(233, 241, 236, 0) 70%);
}

.foe.is-boss .foe-count {
  display: none;
}

.foe.is-boss .foe-name {
  grid-column: 2 / 4;
  font-weight: 700;
}

.foe-count {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  min-width: 26px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.foe-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.foe-traits {
  display: flex;
  gap: 3px;
  color: var(--mist);
  font-size: 15px;
}

.foe-new {
  align-self: center;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--madder);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 17px;
}

.foe.is-gone {
  opacity: 0.35;
}

.relics {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  bottom: 236px;
  width: 232px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.relic {
  pointer-events: auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2d5a68, #173640 70%);
  border: 1.5px solid rgba(243, 207, 116, 0.55);
  color: var(--brass-hi);
  font-size: 19px;
  box-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.7);
}

.relic.is-rare {
  border-color: var(--rift);
  color: #dccbff;
}

.inspect {
  position: absolute;
  top: 84px;
  right: max(12px, env(safe-area-inset-right));
  width: 272px;
  padding: 12px;
}

.inspect-head {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 10px;
  align-items: center;
}

.inspect-head img {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.inspect-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--mist);
  font-size: 16px;
}

.inspect-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--foam);
}

.level {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  color: var(--mist);
  font-size: 14px;
}

.level i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  transform: rotate(45deg);
  border: 1.5px solid rgba(243, 207, 116, 0.6);
}

.level i.is-on {
  background: var(--brass-hi);
}

.inspect-text {
  margin-top: 8px;
  color: var(--mist);
  font-size: 15px;
}

.stats {
  margin-top: 10px;
  display: grid;
  gap: 1px;
  border-radius: 9px;
  overflow: hidden;
}

.stat {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 15px;
}

.stat .icon {
  color: var(--mist);
  font-size: 17px;
}

.stat b {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.stat .gain {
  color: #8fe3b0;
  font-weight: 700;
  margin-left: 4px;
}

.stat .buff {
  color: var(--brass-hi);
  font-weight: 500;
  font-size: 13px;
  margin-left: 4px;
}

.inspect-label {
  margin: 10px 0 5px;
  color: var(--mist);
  font-size: 14px;
}

.inspect .segmented {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  border: 0;
}

.inspect .segmented button {
  flex: 1;
  font-size: 14px;
  padding: 0 4px;
}

.inspect-actions {
  margin-top: 12px;
  display: grid;
  gap: 7px;
}

.inspect-foot {
  margin-top: 8px;
  color: var(--mist);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.inspect-foot:empty {
  display: none;
}

/* ------------------------------------------------------------------ boss bar */

.boss-bar {
  position: absolute;
  top: 98px;
  left: 50%;
  width: min(460px, 46vw);
  transform: translateX(-50%);
  text-align: center;
}

.boss-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.boss-meter {
  height: 12px;
  margin-top: 2px;
  border-radius: 6px;
  background: rgba(13, 31, 38, 0.85);
  border: 1px solid rgba(180, 140, 255, 0.5);
  overflow: hidden;
}

.boss-meter i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left;
  background: linear-gradient(90deg, #8a5cf0, #d7a8ff);
  transition: transform 0.2s linear;
}

/* ------------------------------------------------------------------ dock and hand */

.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 22px;
  padding: 0 16px;
  transition: transform 0.45s var(--ease-out), opacity 0.3s;
}

.dock.is-away {
  transform: translateY(125%);
  opacity: 0;
}

.hand {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  min-height: 190px;
}

.card {
  pointer-events: auto;
  position: relative;
  flex: none;
  width: 136px;
  height: 190px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .3 0 0 0 0 .2 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--card-ink);
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 3px 0 var(--card-edge), 0 6px 0 var(--card-under), 0 18px 24px -8px rgba(2, 10, 14, 0.75);
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.18s var(--ease-out), box-shadow 0.18s, filter 0.2s;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-14px) rotate(0deg);
}

.card[aria-pressed='true'] {
  transform: translateY(-26px) rotate(0deg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 3px 0 var(--card-edge), 0 6px 0 var(--card-under), 0 0 0 3px var(--brass-hi), 0 30px 30px -10px rgba(2, 10, 14, 0.8);
}

.card.is-poor,
.card.is-stuck {
  filter: saturate(0.45) brightness(0.86);
}

.card-art {
  display: block;
  height: 104px;
  margin: 7px 7px 0;
  border-radius: 8px;
  background: radial-gradient(120% 90% at 50% 100%, var(--art-b), var(--art-a));
  overflow: hidden;
}

.card-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 5px 4px rgba(40, 30, 10, 0.3));
  transform: scale(1.08) translateY(2px);
}

.cat-road {
  --cat: var(--cat-road);
  --art-a: #f3e5bd;
  --art-b: #dcc58c;
}

.cat-tower {
  --cat: var(--cat-tower);
  --art-a: #f6dccb;
  --art-b: #e2b299;
}

.cat-trap {
  --cat: var(--cat-trap);
  --art-a: #e3dcf3;
  --art-b: #bfb2e0;
}

.cat-support {
  --cat: var(--cat-support);
  --art-a: #d8eee4;
  --art-b: #a5d3c2;
}

.card-kind {
  display: block;
  margin: 7px 10px 0;
  color: var(--cat);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.card-name {
  display: block;
  margin: 2px 10px 0;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

.card-facts {
  display: flex;
  gap: 10px;
  margin: 5px 10px 0;
  color: var(--card-mute);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.card-facts span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.card-cost {
  position: absolute;
  top: -9px;
  left: -9px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #ffe9a8, var(--brass) 58%, #a9781f);
  color: #33240a;
  font-weight: 800;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35), 0 2px 0 var(--brass-lo), 0 5px 8px rgba(0, 0, 0, 0.45);
}

.card.is-poor .card-cost {
  background: radial-gradient(circle at 35% 28%, #d8d2c6, #9d9483 60%, #7a715f);
  color: #7a1f12;
}

.card-key {
  position: absolute;
  top: 12px;
  right: 13px;
  min-width: 20px;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(42, 39, 33, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  line-height: 18px;
}

.hand-empty {
  pointer-events: auto;
  align-self: center;
  max-width: 300px;
  padding: 14px 18px;
  border-radius: var(--radius-panel);
  background: var(--panel);
  border: 1px dashed var(--ink-line);
  color: var(--mist);
  text-align: center;
}

.dock-side {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-bottom: 4px;
}

.btn-wave {
  min-height: 62px;
  padding: 0 22px;
  font-size: 21px;
}

.btn-wave .icon {
  font-size: 26px;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 226px;
  transform: translateX(-50%);
  max-width: min(640px, 80vw);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(13, 31, 38, 0.72);
  color: var(--foam);
  font-size: 16px;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.25s, bottom 0.45s var(--ease-out);
}

.hint.is-warn {
  background: rgba(120, 36, 26, 0.85);
}

.hint:empty {
  opacity: 0;
}

.hud.is-fighting .hint {
  bottom: max(18px, env(safe-area-inset-bottom));
}

.cam-tools {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: grid;
  gap: 6px;
}

.cam-tools .icon-btn {
  width: 40px;
  height: 40px;
  font-size: 18px;
}

/* ------------------------------------------------------------------ floating numbers and toasts */

.floaters {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.floater {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--brass-hi);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55), 0 0 10px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  animation: float-up 0.95s var(--ease-out) forwards;
}

.floater.is-loss {
  color: #ff8a73;
  font-size: 30px;
}

@keyframes float-up {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.6);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -70%) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -230%) scale(1);
  }
}

.toasts {
  position: absolute;
  top: 150px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(560px, 90vw);
}

.toast {
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(13, 31, 38, 0.92);
  border: 1px solid var(--ink-line);
  box-shadow: var(--shadow-panel);
  font-size: 17px;
  text-align: center;
  animation: toast-in 0.3s var(--ease-out);
}

.toast b {
  color: var(--brass-hi);
}

.toast.is-bad {
  background: rgba(120, 36, 26, 0.95);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.3s, transform 0.3s;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
}

.banner {
  position: absolute;
  top: 30%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(46px, 8vw, 104px);
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--foam);
  text-shadow: 0 4px 0 rgba(6, 20, 26, 0.7), 0 0 44px rgba(6, 20, 26, 0.9);
}

.banner small {
  display: block;
  margin-top: 6px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: clamp(17px, 2vw, 24px);
  letter-spacing: 0;
  color: var(--brass-hi);
}

.banner.is-boss small {
  color: #dccbff;
}

/* ------------------------------------------------------------------ tooltip */

.tooltip {
  position: fixed;
  z-index: 50;
  max-width: 290px;
  padding: 10px 12px;
  border-radius: 11px;
  background: rgba(8, 22, 28, 0.96);
  border: 1px solid var(--ink-line);
  box-shadow: 0 14px 30px -8px rgba(0, 0, 0, 0.8);
  font-size: 15px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s, transform 0.12s;
}

.tooltip.is-on {
  opacity: 1;
  transform: none;
}

.tip-title {
  font-weight: 800;
  font-size: 17px;
}

.tip-kind {
  color: var(--mist);
  font-size: 14px;
}

.tip-text {
  margin-top: 5px;
  color: #cfdcdc;
}

.tip-facts {
  margin-top: 7px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  font-variant-numeric: tabular-nums;
}

.tip-facts dt {
  color: var(--mist);
}

.tip-facts dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.tip-traits {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 13px;
  font-weight: 700;
}

/* ------------------------------------------------------------------ modals */

.modal-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(ellipse at center, rgba(6, 20, 26, 0.55), rgba(6, 20, 26, 0.86));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

#app > .modal-layer.is-open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.modal-layer.is-clear {
  background: radial-gradient(ellipse at center, rgba(6, 20, 26, 0.64), rgba(6, 20, 26, 0.88));
}

.modal {
  pointer-events: auto;
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  padding: 24px;
  border-radius: 18px;
  background: #132c35;
  border: 1px solid var(--ink-line);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9);
  user-select: text;
  -webkit-user-select: text;
}

.modal:focus {
  outline: none;
}

.modal-wide {
  width: min(840px, 100%);
}

.modal-bare {
  background: none;
  border: 0;
  box-shadow: none;
  text-align: center;
  overflow: visible;
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 38px;
  line-height: 1.05;
}

.modal-bare .modal-title {
  font-weight: 900;
  font-size: clamp(42px, 6.5vw, 76px);
  text-shadow: 0 4px 0 rgba(6, 20, 26, 0.7);
}

.modal-lead {
  margin-top: 6px;
  color: var(--mist);
  font-size: 18px;
}

.modal-bare .modal-lead {
  color: #d6e4e2;
  font-size: 20px;
}

.modal-body {
  margin-top: 18px;
}

.modal-actions {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.modal-bare .modal-actions {
  justify-content: center;
}

.menu-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

/* What the run has collected so far, shown in the pause menu. */
.deck {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--ink-line);
}

.deck-label {
  color: var(--mist);
  font-size: 15px;
}

.deck-row {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.deck-piece {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
}

.deck-piece img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.deck-row .relic {
  width: 40px;
  height: 40px;
}

/* Reward choice */
.rewards {
  margin-top: 26px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}

.reward {
  pointer-events: auto;
  position: relative;
  width: 214px;
  min-height: 286px;
  padding: 12px 14px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .3 0 0 0 0 .2 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--card-ink);
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 4px 0 var(--card-edge), 0 8px 0 var(--card-under), 0 26px 34px -10px rgba(0, 0, 0, 0.8);
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s;
}

.reward:hover,
.reward:focus-visible {
  transform: translateY(-10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 4px 0 var(--card-edge), 0 8px 0 var(--card-under), 0 0 0 3px var(--brass-hi), 0 34px 40px -10px rgba(0, 0, 0, 0.85);
}

.reward-art {
  display: grid;
  place-items: center;
  height: 124px;
  border-radius: 9px;
  background: radial-gradient(120% 90% at 50% 100%, var(--art-b, #cdbd96), var(--art-a, #e8dcbd));
}

.reward-art img {
  height: 120px;
  filter: drop-shadow(0 6px 5px rgba(40, 30, 10, 0.3));
}

.reward-medal {
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #2f6272, #153540 72%);
  border: 3px solid var(--brass);
  color: var(--brass-hi);
  font-size: 46px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
}

.reward.is-rare .reward-medal {
  border-color: #8a5cf0;
  color: #dccbff;
}

.reward-kind {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--cat, var(--brass-lo));
}

.reward.is-rare .reward-kind {
  color: #6a45c4;
}

.reward-name {
  margin-top: 1px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
}

.reward-text {
  margin-top: 6px;
  color: #4d473b;
  font-size: 15px;
  line-height: 1.3;
}

/* Run summary */
.summary {
  margin: 20px auto 0;
  display: grid;
  grid-template-columns: repeat(4, auto);
  justify-content: center;
  gap: 8px 30px;
}

.summary div {
  text-align: center;
}

.summary b {
  display: block;
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
}

.summary span {
  color: var(--mist);
  font-size: 15px;
}

/* Saves */
.slots {
  display: grid;
  gap: 8px;
}

.slot {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 11px 12px 11px 14px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
}

.slot-name {
  font-weight: 800;
  font-size: 17px;
}

.slot-info {
  color: var(--mist);
  font-size: 15px;
}

.slot-actions {
  grid-row: span 2;
  display: flex;
  gap: 6px;
}

.file-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--ink-line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.file-row p {
  flex: 1 1 200px;
  color: var(--mist);
  font-size: 15px;
}

/* New game */
.choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.choice {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 13px 13px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--ink-line);
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.choice:hover {
  background: rgba(255, 255, 255, 0.08);
}

.choice[aria-pressed='true'] {
  border-color: var(--brass-hi);
  background: rgba(217, 164, 65, 0.14);
}

.choice b {
  display: block;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 700;
  line-height: 1.1;
}

.choice span {
  display: block;
  margin-top: 4px;
  color: var(--mist);
  font-size: 15px;
  line-height: 1.3;
}

.field {
  margin-top: 16px;
  display: grid;
  gap: 6px;
}

.field label,
.field .label {
  font-weight: 700;
}

.field small {
  color: var(--mist);
  font-size: 14px;
}

.field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

input[type='text'] {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--ink-line);
  background: rgba(0, 0, 0, 0.25);
  user-select: text;
  -webkit-user-select: text;
}

input[type='range'] {
  flex: 1;
  accent-color: var(--brass);
  height: 28px;
}

.field output {
  min-width: 46px;
  text-align: right;
  color: var(--mist);
  font-variant-numeric: tabular-nums;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.switch input {
  width: 20px;
  height: 20px;
  accent-color: var(--brass);
}

/* How to play */
.rules {
  display: grid;
  gap: 12px;
}

.rule {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: start;
}

.rule-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: rgba(217, 164, 65, 0.16);
  color: var(--brass-hi);
  font-size: 24px;
}

.rule b {
  display: block;
  font-size: 18px;
}

.rule span {
  color: #cfdcdc;
}

.keys {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--ink-line);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px 18px;
  color: var(--mist);
  font-size: 15px;
}

.keys kbd {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--foam);
  margin-right: 4px;
}

.credits {
  margin-top: 14px;
  color: var(--mist);
  font-size: 14px;
}

.credits a {
  color: var(--foam);
}

/* ------------------------------------------------------------------ title screen */

.title {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(20px, 5vw, 64px);
  background: linear-gradient(100deg, rgba(8, 24, 30, 0.9) 0%, rgba(8, 24, 30, 0.55) 38%, rgba(8, 24, 30, 0) 68%), linear-gradient(0deg, rgba(8, 24, 30, 0.6), rgba(8, 24, 30, 0) 45%);
  transition: opacity 0.5s, visibility 0.5s;
}

.title.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.title-name {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(64px, 12.5vw, 190px);
  line-height: 0.84;
  letter-spacing: -0.01em;
  color: var(--foam);
  text-shadow: 0 5px 0 rgba(6, 20, 26, 0.6), 0 0 60px rgba(6, 20, 26, 0.6);
}

.title-name span {
  display: block;
}

.title-lead {
  margin-top: clamp(14px, 2vw, 24px);
  max-width: 30ch;
  font-size: clamp(18px, 1.7vw, 23px);
  line-height: 1.3;
  color: #d6e4e2;
}

.title-menu {
  margin-top: clamp(18px, 3vw, 34px);
  display: grid;
  justify-items: start;
  gap: 4px;
}

.title-link {
  pointer-events: auto;
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  padding: 5px 14px 5px 0;
  border: 0;
  background: none;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(26px, 2.7vw, 36px);
  line-height: 1.15;
  color: var(--foam);
  text-align: left;
  transition: color 0.15s, transform 0.2s var(--ease-out);
}

.title-link::before {
  content: '';
  align-self: center;
  width: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--brass-hi);
  transition: width 0.2s var(--ease-out);
}

.title-link:hover,
.title-link:focus-visible {
  color: var(--brass-hi);
  outline: none;
}

.title-link:hover::before,
.title-link:focus-visible::before {
  width: 26px;
}

.title-link small {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 500;
  color: var(--mist);
}

.title-link.is-main {
  font-weight: 700;
  color: var(--brass-hi);
}

.title-foot {
  margin-top: clamp(16px, 3vw, 40px);
  color: var(--mist);
  font-size: 15px;
}

.title-foot b {
  color: var(--foam);
}

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--ink);
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--mist);
  transition: opacity 0.6s, visibility 0.6s;
}

.loading.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.loading.is-error {
  pointer-events: auto;
  padding: 24px;
  font-family: var(--font-ui);
  font-size: 18px;
  text-align: center;
  color: var(--foam);
}

/* ------------------------------------------------------------------ smaller screens */

@media (max-width: 1180px) {
  .track {
    display: none;
  }

  .track-wrap {
    padding: 9px 16px;
  }
}

@media (max-width: 1100px) {
  .cam-tools {
    display: none;
  }
}

@media (max-width: 1100px), (max-height: 760px) {
  .card {
    width: 112px;
    height: 164px;
  }

  .card-art {
    height: 84px;
  }

  .card-name {
    font-size: 16px;
  }

  .card-facts {
    font-size: 13px;
    gap: 7px;
  }

  .hand {
    gap: 9px;
    min-height: 164px;
  }

  .hint {
    bottom: 198px;
  }

  .relics {
    bottom: 204px;
  }

  .wave-panel {
    width: 204px;
  }

  .btn-wave {
    min-height: 54px;
    font-size: 19px;
  }

  .btn-wave kbd {
    display: none;
  }
}

@media (max-width: 820px) {
  .dock {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .dock-side {
    flex-direction: row;
  }

  .hand {
    max-width: 100%;
    overflow-x: auto;
    padding: 30px 12px 10px;
    margin-top: -30px;
  }

  .hint {
    bottom: 268px;
  }

  .relics {
    display: none;
  }

  .wave-panel {
    top: 68px;
    width: 180px;
    padding: 9px;
  }

  .foe {
    grid-template-columns: 30px auto 1fr;
  }

  .foe img {
    width: 30px;
    height: 30px;
  }

  .foe-traits {
    display: none;
  }

  .inspect {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    z-index: 5;
  }

  .cam-tools {
    display: none;
  }

  .chip {
    height: 40px;
    padding: 0 11px 0 9px;
  }

  .chip-num {
    font-size: 24px;
  }

  .chip-sub {
    display: none;
  }

  .segmented button {
    min-width: 34px;
    padding: 0 7px;
  }

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

  .summary {
    grid-template-columns: repeat(2, auto);
  }

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

  .title {
    background: linear-gradient(0deg, rgba(8, 24, 30, 0.92) 0%, rgba(8, 24, 30, 0.6) 55%, rgba(8, 24, 30, 0.1) 100%);
  }
}

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

/* Narrow phones held upright: the rail wraps into two rows. */
@media (max-width: 620px) {
  .rail {
    flex-wrap: wrap;
    row-gap: 6px;
    column-gap: 6px;
  }

  .rail-group:last-child {
    margin-left: auto;
  }

  .track-wrap {
    order: 3;
    padding: 5px 12px;
  }

  .wave-panel {
    top: 108px;
  }

  .boss-bar {
    top: 112px;
    width: 46vw;
    left: auto;
    right: 12px;
    transform: none;
  }

  .toasts {
    top: 160px;
  }

  .hand {
    justify-content: flex-start;
  }

  .modal {
    padding: 18px;
  }

  .modal-title {
    font-size: 32px;
  }

  .rewards {
    gap: 12px;
  }

  .reward {
    width: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: 84px 1fr;
    column-gap: 12px;
    text-align: left;
    padding: 10px 12px 12px;
  }

  .reward-art {
    grid-row: span 3;
    height: 84px;
  }

  .reward-art img {
    height: 80px;
  }

  .reward-medal {
    width: 64px;
    height: 64px;
    font-size: 34px;
  }

  .reward-kind {
    margin-top: 2px;
  }
}

/* Phones held sideways: little height, so the hand shrinks to art and name. */
@media (max-height: 500px) {
  .card {
    width: 94px;
    height: 122px;
  }

  .card-art {
    height: 70px;
    margin: 5px 5px 0;
  }

  .card-kind,
  .card-facts,
  .card-key {
    display: none;
  }

  .card-name {
    margin: 6px 8px 0;
    font-size: 14px;
  }

  .card-cost {
    top: -7px;
    left: -7px;
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .hand {
    min-height: 122px;
    gap: 8px;
  }

  .dock {
    gap: 12px;
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .hint {
    bottom: 140px;
    font-size: 14px;
    padding: 4px 12px;
  }

  .relics,
  .cam-tools {
    display: none;
  }

  .wave-panel {
    top: 62px;
    width: 172px;
    padding: 8px;
  }

  .panel-title {
    font-size: 19px;
  }

  .foe {
    grid-template-columns: 26px auto 1fr;
    padding: 1px 4px 1px 2px;
  }

  .foe img {
    width: 26px;
    height: 26px;
  }

  .foe-count {
    font-size: 18px;
    min-width: 20px;
  }

  .foe-traits {
    display: none;
  }

  .inspect {
    top: 62px;
    bottom: auto;
    left: auto;
    right: 12px;
    width: 250px;
    max-height: calc(100dvh - 72px);
    overflow: auto;
  }

  .inspect-text {
    display: none;
  }

  .btn-wave {
    min-height: 46px;
    font-size: 17px;
  }

  .chip,
  .icon-btn {
    height: 40px;
  }

  .toasts {
    top: 62px;
  }

  .boss-bar {
    top: 58px;
  }
}
