:root {
  --cream: #f4e6c4;
  --cream-dim: #d9c49a;
  --umber: #3a2418;
  --ink: #2a1a12;
  --wood: #5b3a22;
  --wood-dark: #382216;
  --rust: #c4552f;
  --rust-dark: #7f2f1b;
  --gold: #e8a64a;
  --gold-light: #fff3b0;
  --teal: #2fc2b0;
  --red: #d63c3c;
  --violet: #2a1e2e;
  --stone: #9a9a8e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #2a1e2e;
  color: var(--cream);
  font-family: 'VT323', monospace;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

img { image-rendering: pixelated; image-rendering: crisp-edges; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #2a1e2e;
}

#stage {
  position: absolute;
  inset: 0;
  transition: filter 700ms steps(4);
}
#stage canvas { display: block; }
#stage.sepia { filter: sepia(0.85) saturate(0.6) brightness(0.78); }

#sepia {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: #4a2e1f;
  opacity: 0;
  transition: opacity 800ms steps(5);
}
#sepia.on { opacity: 0.28; }

.hidden { display: none !important; }

/* ---------- shared frames ---------- */
.wood-frame {
  border: 13px solid transparent;
  border-image: url(assets/ui_kit_01_wooden_panel.webp) 34 fill / 13px stretch;
  background-color: #241812;
  color: var(--cream);
}

.parchment-frame {
  border: 15px solid transparent;
  border-image: url(assets/ui_kit_02_parchment_card.webp) 30 fill / 15px stretch;
  background-color: #e6d3a2;
  color: var(--umber);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 8px 22px;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: var(--rust);
  color: var(--cream);
  font-family: 'Pixelify Sans', sans-serif;
  font-size: clamp(18px, 2.6vw, 28px);
  letter-spacing: 0.06em;
  text-shadow: 0 2px 0 rgba(42, 26, 18, 0.65);
  box-shadow: 0 4px 0 var(--rust-dark), 0 0 0 3px rgba(232, 166, 74, 0.28);
  transition: transform 80ms steps(2), box-shadow 80ms steps(2);
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--rust-dark); }
.btn-big { min-height: 56px; padding: 10px 40px; font-size: clamp(22px, 3.4vw, 36px); }
.btn-wood {
  background: var(--wood);
  box-shadow: 0 4px 0 var(--wood-dark), 0 0 0 3px rgba(232, 166, 74, 0.22);
}
.btn-sell {
  background: #7c2b22;
  box-shadow: 0 4px 0 #4a1712, 0 0 0 3px rgba(232, 166, 74, 0.22);
  font-size: clamp(14px, 1.9vw, 20px);
  min-height: 40px;
  padding: 6px 16px;
}
.btn:disabled {
  background: #6b5a48;
  color: #b9a684;
  box-shadow: 0 4px 0 #4a3d2f;
  cursor: not-allowed;
  transform: none;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

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

.left-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  flex: 0 0 auto;
  min-width: 0;
}

.right-stack {
  display: flex;
  align-items: flex-start;
  gap: clamp(4px, 1vw, 8px);
  flex: 0 0 auto;
}

.pause-btn {
  width: clamp(38px, min(8vh, 9vw), 56px);
  aspect-ratio: 1;
  padding: 0;
  border: 3px solid #382216;
  background: #241812;
  box-shadow: 0 0 0 2px #c99a45, 0 4px 0 rgba(20, 10, 8, 0.5);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.pause-btn:active { transform: translateY(2px); }
.pause-bars { display: flex; gap: clamp(4px, 0.8vw, 6px); }
.pause-bars i {
  display: block;
  width: clamp(5px, 0.9vw, 8px);
  height: clamp(16px, 3vh, 24px);
  background: var(--cream);
  box-shadow: inset 0 0 0 1px #2a1a12, 0 0 6px rgba(255, 243, 176, 0.25);
}

.hp-cluster {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  flex: 0 0 auto;
  min-width: 0;
}

.portrait-frame {
  position: relative;
  width: clamp(48px, min(10vw, 9vh), 86px);
  aspect-ratio: 1;
  flex: 0 0 auto;
  overflow: hidden;
  border: 3px solid #c99a45;
  outline: 3px solid #382216;
  box-shadow: inset 0 0 0 2px #241812;
  background: #2a1e2e;
}
.portrait-frame::before,
.portrait-frame::after {
  content: "";
  position: absolute;
  width: 5px; height: 5px;
  background: #e8c06a;
  box-shadow: 0 0 0 1px #6b4a1e;
  z-index: 2;
}
.portrait-frame::before { top: 1px; left: 1px; }
.portrait-frame::after { bottom: 1px; right: 1px; }
.portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  display: block;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 2px;
  flex: 0 0 auto;
  width: clamp(100px, 22vw, 230px);
}

.bar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.bar-ic {
  width: clamp(15px, 2.4vw, 21px);
  height: clamp(15px, 2.4vw, 21px);
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 1px 0 #2a1a12);
}
.bar-track {
  position: relative;
  flex: 1 1 auto;
  height: clamp(15px, 2.3vh, 22px);
  background: #241812;
  border: 2px solid #241812;
  box-shadow: 0 0 0 2px #c99a45, inset 0 2px 0 rgba(0,0,0,0.35);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 100%;
  background: #d63c3c;
  box-shadow: inset 0 2px 0 #f06a5a, inset 0 -3px 0 #8f1f26;
  transition: width 160ms steps(4);
}
.exp-track { height: clamp(9px, 1.5vh, 15px); }
.exp-fill {
  background: var(--teal);
  box-shadow: inset 0 2px 0 #6fe3d2, inset 0 -2px 0 #167f75;
}
.bar-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Silkscreen', monospace;
  font-size: clamp(10px, 1.6vw, 14px);
  color: #fff6dc;
  text-shadow: 0 1px 0 #2a1a12, 1px 0 0 #2a1a12, -1px 0 0 #2a1a12;
  pointer-events: none;
}
.exp-track .bar-num { font-size: clamp(8px, 1.3vw, 12px); }

.round-cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 3px 8px 5px;
  width: 100%;
  min-width: 0;
  max-width: none;
  margin-top: 0;
  flex: 0 0 auto;
}
.round-text {
  font-family: 'Silkscreen', monospace;
  font-weight: 700;
  font-size: clamp(14px, 3vw, 24px);
  letter-spacing: 0.04em;
  color: var(--cream);
  text-shadow: 0 2px 0 #2a1a12;
  white-space: nowrap;
}
.pips { display: flex; gap: 2px; }
.pip {
  width: clamp(7px, 1.2vw, 10px);
  height: clamp(7px, 1.2vw, 10px);
  background: #3d2b20;
  box-shadow: inset 0 0 0 1px #6c4d2b;
}
.pip.on { background: var(--gold); box-shadow: inset 0 0 0 1px #fff3b0; }
.pip.boss { background: var(--red); box-shadow: inset 0 0 0 1px #ff9a8a; }
.boss-note {
  font-family: 'VT323', monospace;
  font-size: clamp(10px, 1.7vw, 14px);
  color: var(--cream-dim);
  letter-spacing: 0.08em;
  line-height: 1;
  white-space: nowrap;
}

.coin-cluster {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1.1vw, 12px);
  padding: 4px 7px;
  min-height: clamp(28px, 4vh, 40px);
  flex: 0 0 auto;
  align-self: flex-start;
}
.cur {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: 'Silkscreen', monospace;
  font-size: clamp(13px, 2.2vw, 18px);
  color: var(--cream);
  text-shadow: 0 1px 0 #2a1a12;
  white-space: nowrap;
}
.cur img {
  width: clamp(17px, 2.7vw, 25px);
  height: clamp(17px, 2.7vw, 25px);
  object-fit: contain;
  filter: drop-shadow(0 1px 0 #2a1a12);
}
.shard-ic { filter: hue-rotate(96deg) saturate(1.5) brightness(1.15) drop-shadow(0 1px 0 #2a1a12) !important; }
.shard-cur b { color: #d9b8ff; }

.coin-cluster.compact { gap: 4px; padding: 3px 5px; }
.coin-cluster.compact .cur { font-size: clamp(10px, 1.8vw, 14px); }
.coin-cluster.compact .cur img { width: clamp(14px, 2.2vw, 20px); height: clamp(14px, 2.2vw, 20px); }

.boss-hud {
  position: absolute;
  left: 50%;
  top: 96px;
  transform: translateX(-50%);
  width: min(70vw, 520px);
  z-index: 22;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.boss-hud.hidden { display: none; }
.boss-hud-name {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(10px, 2.2vw, 15px);
  letter-spacing: 0.05em;
  color: #f4e6c4;
  text-shadow: 2px 2px 0 #241812;
  padding: 1px 8px;
  background: #2a1a12;
  border: 2px solid #c99a45;
  box-shadow: inset 0 0 0 1px #6b4a1e;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.boss-hud-track {
  width: 100%;
  height: clamp(12px, 2.4vh, 18px);
  background: #241812;
  border: 2px solid #c99a45;
  box-shadow: inset 0 0 0 1px #6b4a1e;
  padding: 2px;
  box-sizing: border-box;
}
.boss-hud-fill {
  height: 100%;
  width: 100%;
  background: #d63c3c;
  box-shadow: inset 0 2px 0 #f06a5a, inset 0 -3px 0 #8f1f26;
  transition: width 120ms steps(4);
}

.hud-bottom {
  position: absolute;
  left: max(8px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.skill-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  pointer-events: auto;
}
.skill-label {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(7px, 1.1vw, 10px);
  letter-spacing: 0.16em;
  color: #d9c49a;
  text-shadow: 0 1px 0 #2a1a12;
  padding-left: 4px;
}
.skill-bar {
  display: flex;
  align-items: flex-end;
  gap: clamp(4px, 0.9vw, 10px);
  pointer-events: auto;
}
.skill-slot {
  position: relative;
  width: clamp(40px, min(8.2vh, 10.2vw), 68px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: transparent;
  filter: drop-shadow(0 3px 0 rgba(20, 10, 8, 0.55));
}
.skill-slot .slot-bg,
.skill-slot .slot-icon,
.skill-slot .slot-frame {
  position: absolute;
  display: block;
  image-rendering: pixelated;
}
.skill-slot .slot-bg { inset: 0; width: 100%; height: 100%; }
.skill-slot .slot-icon {
  inset: 16%;
  width: 68%;
  height: 68%;
  object-fit: contain;
}
.skill-slot.empty { opacity: 0.6; filter: grayscale(0.55) brightness(0.85); }
.skill-slot.empty .slot-frame { opacity: 0.55; }
.skill-slot .slot-frame {
  inset: -4%;
  width: 108%;
  height: 108%;
  object-fit: contain;
  pointer-events: none;
}
.skill-slot .sweep {
  position: absolute;
  inset: 6%;
  background: conic-gradient(rgba(14, 8, 18, 0.38) calc(var(--p, 0) * 360deg), transparent 0);
  pointer-events: none;
}
.skill-slot .slot-lvl {
  position: absolute;
  right: 2px;
  bottom: 0;
  font-family: 'Silkscreen', monospace;
  font-size: clamp(8px, 1.2vw, 12px);
  color: var(--cream);
  text-shadow: 0 1px 0 #2a1a12, 1px 1px 0 #2a1a12;
  z-index: 3;
}
.skill-slot .slot-key {
  position: absolute;
  left: 4px;
  top: 2px;
  font-family: 'Silkscreen', monospace;
  font-size: clamp(7px, 1vw, 10px);
  color: #d9c49a;
  z-index: 3;
}

.actions {
  display: flex;
  align-items: flex-end;
  gap: clamp(6px, 1.5vw, 14px);
  pointer-events: auto;
}

.speed-btn {
  position: relative;
  width: clamp(44px, min(9vh, 11vw), 68px);
  aspect-ratio: 1;
  padding: 8px 2px 2px;
  border: 3px solid #382216;
  background: #241812;
  box-shadow: 0 0 0 2px #c99a45, 0 4px 0 rgba(20, 10, 8, 0.5);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}
.speed-btn span {
  font-family: 'VT323', monospace;
  font-size: clamp(7px, 1.05vw, 10px);
  letter-spacing: 0.08em;
  color: #d9c49a;
  line-height: 1;
}
.speed-btn b {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(13px, 2vw, 19px);
  color: var(--cream);
  line-height: 1;
}
.speed-btn.fast {
  background: #4c3320;
  box-shadow: 0 0 0 2px #fff3b0, 0 0 12px rgba(255, 243, 176, 0.35), 0 4px 0 rgba(20, 10, 8, 0.5);
}
.speed-btn.fast b { color: var(--gold-light); }
.speed-btn:active { transform: translateY(2px); }

.potion-btn {
  position: relative;
  width: clamp(44px, min(9vh, 11vw), 68px);
  aspect-ratio: 1;
  padding: 0;
  border: 3px solid #382216;
  background: #1f1418;
  box-shadow: 0 0 0 2px #c99a45, 0 4px 0 rgba(20, 10, 8, 0.5);
  border-radius: 0;
}
.potion-btn img {
  position: absolute;
  inset: 6%;
  width: 88%;
  height: 88%;
  object-fit: contain;
}
.potion-btn:active { transform: translateY(2px); }
.potion-btn.empty { filter: grayscale(0.85) brightness(0.65); }
.potion-count {
  position: absolute;
  right: 1px;
  bottom: 0;
  font-family: 'Silkscreen', monospace;
  font-size: clamp(10px, 1.6vw, 15px);
  color: var(--cream);
  text-shadow: 0 1px 0 #2a1a12, 1px 1px 0 #2a1a12;
  z-index: 2;
}
.key-hint {
  position: absolute;
  left: 2px;
  top: -1px;
  font-family: 'Silkscreen', monospace;
  font-size: clamp(7px, 1vw, 10px);
  color: #d9c49a;
  text-shadow: 0 1px 0 #2a1a12;
  z-index: 2;
}

.burst-btn {
  position: relative;
  width: clamp(84px, min(17vh, 21vw), 140px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: transparent;
  filter: drop-shadow(0 5px 0 rgba(20, 10, 8, 0.55));
}
.burst-btn .burst-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.burst-btn .burst-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Pixelify Sans', sans-serif;
  font-size: clamp(12px, 3.8vmin, 22px);
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  padding: 0 8%;
  color: var(--cream);
  text-shadow: 0 2px 0 #6b2415, 0 0 6px rgba(255, 200, 100, 0.35);
  pointer-events: none;
  z-index: 3;
}
.burst-btn .sweep {
  position: absolute;
  inset: 11%;
  border-radius: 50%;
  background: conic-gradient(rgba(14, 8, 18, 0.46) calc(var(--p, 0) * 360deg), transparent 0);
  pointer-events: none;
  z-index: 2;
}
.burst-btn.ready .burst-art { animation: burstPulse 1400ms steps(2) infinite; }
.burst-btn .burst-key { left: 50%; top: auto; bottom: -2px; transform: translateX(-50%); }
@keyframes burstPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 30;
}
#title {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(42,30,46,0.28) 0%, rgba(42,30,46,0) 26%, rgba(42,30,46,0) 62%, rgba(42,30,46,0.3) 100%);
}
.title-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.2vh, 14px);
  padding-top: max(2vh, env(safe-area-inset-top));
  width: min(92vw, 820px);
  pointer-events: none;
}
.title-art {
  width: min(86vw, 700px);
  max-height: 34vh;
  object-fit: contain;
  filter: drop-shadow(0 8px 0 rgba(42, 26, 18, 0.35));
  animation: titleFloat 3200ms steps(4) infinite;
}
@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.tagline {
  margin: 0;
  font-family: 'VT323', monospace;
  font-size: clamp(13px, 2.2vw, 22px);
  letter-spacing: 0.28em;
  color: var(--cream);
  text-shadow: 0 2px 0 #2a1a12;
  text-align: center;
}
.title-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(10px, 2vw, 22px);
  margin-top: clamp(4px, 1.5vh, 18px);
  pointer-events: auto;
}
.hint {
  margin: clamp(2px, 1.4vh, 16px) 0 0;
  font-family: 'VT323', monospace;
  font-size: clamp(11px, 1.7vw, 17px);
  letter-spacing: 0.12em;
  color: #f4e6c4;
  background: rgba(42, 30, 46, 0.55);
  padding: 2px 10px;
  text-align: center;
}

/* death */
#death {
  z-index: 56;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(58, 36, 24, 0.52);
}
.death-card {
  width: min(94vw, 470px);
  max-height: 92vh;
  overflow-y: auto;
  padding: 10px 12px 18px;
  text-align: center;
  animation: cardIn 400ms steps(4) both;
}
@keyframes cardIn {
  from { transform: translateY(18px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.card-title {
  margin: 4px 0 0;
  font-family: 'Pixelify Sans', sans-serif;
  font-size: clamp(26px, 5vw, 42px);
  letter-spacing: 0.04em;
  color: var(--umber);
  text-shadow: 0 2px 0 rgba(244, 230, 196, 0.55);
}
.card-sub {
  margin: 0 0 8px;
  font-family: 'VT323', monospace;
  font-size: clamp(13px, 2vw, 19px);
  letter-spacing: 0.24em;
  color: #7a4e2b;
}
.tally {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 4px auto 8px;
  width: min(100%, 330px);
}
.tally-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  border-bottom: 2px dashed rgba(122, 78, 43, 0.4);
  padding: 2px 4px;
  font-family: 'VT323', monospace;
  font-size: clamp(15px, 2.2vw, 21px);
  color: #5b3a22;
}
.tally-row b {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(14px, 2vw, 20px);
  color: #3a2418;
}
.reward-row {
  display: flex;
  justify-content: center;
  gap: clamp(14px, 4vw, 40px);
  margin: 8px 0 4px;
}
.reward-row .cur {
  color: #3a2418;
  font-size: clamp(17px, 2.6vw, 24px);
  text-shadow: none;
}
.best-item {
  margin: 2px 0 10px;
  font-family: 'VT323', monospace;
  font-size: clamp(13px, 1.9vw, 18px);
  color: #5b3a22;
  min-height: 1.2em;
}
.run-badge {
  display: block;
  width: fit-content;
  margin: 2px auto 8px;
  padding: 3px 10px;
  border: 2px solid var(--gold);
  border-radius: 3px;
  background: rgba(122, 78, 43, 0.14);
  font-family: 'VT323', monospace;
  font-size: clamp(12px, 1.9vw, 16px);
  letter-spacing: 0.16em;
  color: #8a5716;
}
.finds {
  width: min(100%, 330px);
  margin: 2px auto 6px;
}
.finds-title {
  margin: 6px 0 4px;
  font-family: 'VT323', monospace;
  font-size: clamp(11px, 1.7vw, 15px);
  letter-spacing: 0.18em;
  color: #7a4e2b;
}
.finds-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.find-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 5px;
  border-bottom: 2px dashed rgba(122, 78, 43, 0.3);
  font-family: 'VT323', monospace;
  font-size: clamp(13px, 1.9vw, 17px);
  color: #3a2418;
}
.find-row em {
  font-style: normal;
  opacity: 0.72;
  font-size: 0.86em;
}
.find-empty {
  margin: 2px 0 4px;
  font-family: 'VT323', monospace;
  font-size: clamp(12px, 1.8vw, 16px);
  color: #7a4e2b;
}
@media (max-height: 620px) {
  .death-card .finds-title { margin: 2px 0 2px; }
  .death-card .best-item { display: none; }
}

/* pause */
#pause {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(20, 12, 16, 0.62);
  z-index: 45;
}
.pause-card {
  width: min(92vw, 430px);
  max-height: 92vh;
  overflow-y: auto;
  padding: 10px 12px 16px;
  text-align: center;
  animation: cardIn 240ms steps(4) both;
}
.pause-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}
.pause-btns .btn { width: 100%; }
.pause-note {
  margin: 10px 0 0;
  font-family: 'VT323', monospace;
  font-size: clamp(11px, 1.7vw, 15px);
  letter-spacing: 0.08em;
  color: #7a4e2b;
}
@media (max-height: 470px) {
  .pause-card { padding: 4px 12px 10px; }
  .pause-btns { flex-direction: row; }
  .pause-btns .btn { min-height: 44px; font-size: clamp(16px, 3vw, 22px); }
}

/* camp */
#camp { background: #171020; }
.camp-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 58%;
}
#camp::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(18,12,24,0.3) 0%, rgba(18,12,24,0) 30%, rgba(18,12,24,0) 70%, rgba(18,12,24,0.5) 100%);
  pointer-events: none;
}
.fire-fx {
  position: absolute;
  left: 50%;
  top: 74%;
  width: min(26vw, 190px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}
.fire-fx .glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 170, 70, 0.4) 0%, rgba(255, 120, 40, 0.16) 38%, rgba(255, 120, 40, 0) 66%);
  animation: fireFlicker 620ms steps(3) infinite;
  mix-blend-mode: screen;
}
@keyframes fireFlicker {
  0% { transform: scale(1) translateY(0); opacity: 0.95; }
  33% { transform: scale(1.08, 0.94) translateY(-2px); opacity: 0.75; }
  66% { transform: scale(0.94, 1.07) translateY(1px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 0.95; }
}
.ember {
  position: absolute;
  left: calc(50% + var(--x));
  bottom: 28%;
  width: var(--s);
  height: var(--s);
  background: #ffb04a;
  box-shadow: 0 0 4px #ff7a2a;
  opacity: 0;
  animation: emberRise 2600ms steps(8) infinite;
  animation-delay: var(--d);
}
@keyframes emberRise {
  0% { opacity: 0; transform: translateY(0); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-120px) translateX(10px); }
}
.camp-top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: clamp(10px, 3vw, 26px);
  padding: 4px 12px;
  background: rgba(36, 24, 18, 0.82);
  border: 3px solid #2a1a12;
  box-shadow: 0 0 0 2px #c99a45;
}
.camp-best {
  font-family: 'VT323', monospace;
  font-size: clamp(13px, 1.9vw, 19px);
  letter-spacing: 0.1em;
  color: var(--cream-dim);
}
.camp-best b { color: var(--gold-light); font-family: 'Silkscreen', monospace; }
.camp-heading {
  position: absolute;
  top: clamp(58px, 9vh, 96px);
  left: 0;
  right: 0;
  text-align: center;
  z-index: 3;
  pointer-events: none;
}
.camp-heading h1 {
  margin: 0;
  font-family: 'Pixelify Sans', sans-serif;
  font-size: clamp(30px, 6vw, 62px);
  letter-spacing: 0.16em;
  color: var(--cream);
  text-shadow: 0 4px 0 #2a1a12, 0 0 22px rgba(255, 180, 90, 0.22);
}
.camp-heading p {
  margin: 0;
  font-family: 'VT323', monospace;
  font-size: clamp(12px, 1.9vw, 20px);
  letter-spacing: 0.26em;
  color: var(--cream-dim);
  text-shadow: 0 2px 0 #2a1a12;
}
.camp-signs {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(6px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(4px, 2.2vw, 40px);
  z-index: 4;
  padding: 0 8px;
}
.signboard {
  position: relative;
  width: clamp(80px, min(22vw, 19vh), 170px);
  aspect-ratio: 331 / 257;
  padding: 0;
  border: 0;
  background: transparent;
  filter: drop-shadow(0 6px 0 rgba(12, 8, 14, 0.55));
  transition: transform 90ms steps(2);
}
.signboard:active { transform: translateY(3px); }
.signboard img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.signboard span {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 15%;
  height: 34%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Pixelify Sans', sans-serif;
  font-size: clamp(12px, min(2.7vw, 2.5vh), 24px);
  letter-spacing: 0.05em;
  color: var(--cream);
  text-shadow: 0 2px 0 #2a1a12;
  transform: rotate(-1deg);
  pointer-events: none;
}
.signboard em {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 50%;
  height: 16%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'VT323', monospace;
  font-style: normal;
  font-size: clamp(9px, min(1.9vw, 1.8vh), 15px);
  letter-spacing: 0.08em;
  color: #e8d3a4;
  opacity: 0.9;
  pointer-events: none;
}

/* region banner */
.region-banner {
  position: absolute;
  top: clamp(92px, 15vh, 170px);
  left: 50%;
  width: min(68vw, 310px);
  aspect-ratio: 252 / 260;
  transform: translate(-50%, -24px);
  z-index: 34;
  pointer-events: none;
  opacity: 0;
  transition: opacity 260ms steps(3), transform 320ms steps(4);
}
.region-banner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 0 rgba(42, 26, 18, 0.28));
}
.region-banner span {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 27%;
  height: 17%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'Pixelify Sans', sans-serif;
  font-size: clamp(11px, 2.7vw, 18px);
  letter-spacing: 0.02em;
  color: #3a2418;
  text-shadow: 0 1px 0 rgba(244, 230, 196, 0.7);
}
.region-banner.show { opacity: 1; transform: translate(-50%, 0); }
.region-banner.small { width: min(62vw, 320px); }

/* level up stamp */
.stamp {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 36;
  transform: translate(-50%, -50%) rotate(-4deg);
  font-family: 'Pixelify Sans', sans-serif;
  font-size: clamp(30px, 7vw, 72px);
  letter-spacing: 0.04em;
  color: var(--gold-light);
  text-shadow: 0 4px 0 #7f2f1b, 0 0 0 #2a1a12, 4px 0 0 #2a1a12, -4px 0 0 #2a1a12, 0 4px 0 #2a1a12;
  pointer-events: none;
  animation: stampPop 1100ms steps(6) both;
}
@keyframes stampPop {
  0% { transform: translate(-50%, -50%) scale(0.3) rotate(-9deg); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1.15) rotate(-4deg); opacity: 1; }
  55% { transform: translate(-50%, -50%) scale(1) rotate(-4deg); opacity: 1; }
  100% { transform: translate(-50%, -62%) scale(1) rotate(-4deg); opacity: 0; }
}

.toast {
  position: absolute;
  left: 50%;
  top: clamp(104px, 15vh, 190px);
  transform: translateX(-50%);
  z-index: 40;
  padding: 5px 16px;
  background: #e6d3a2;
  border: 3px solid #7a4e2b;
  box-shadow: 0 0 0 2px #2a1a12, 0 4px 0 rgba(42, 26, 18, 0.35);
  color: #3a2418;
  font-family: 'VT323', monospace;
  font-size: clamp(14px, 2vw, 20px);
  letter-spacing: 0.08em;
  text-align: center;
  pointer-events: none;
  animation: toastIn 180ms steps(2);
  max-width: 88vw;
}
@keyframes toastIn {
  from { transform: translate(-50%, -8px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.god-flash {
  position: absolute;
  inset: 0;
  z-index: 38;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-family: 'Pixelify Sans', sans-serif;
  font-size: clamp(34px, 8vw, 90px);
  letter-spacing: 0.08em;
  color: #fffbe8;
  text-shadow: 0 0 18px #fff3b0, 0 4px 0 #b06a20, 4px 0 0 #7a4e2b, -4px 0 0 #7a4e2b;
  background: radial-gradient(circle, rgba(255, 240, 180, 0.28), rgba(255, 220, 130, 0) 62%);
  animation: godFlash 1100ms steps(6) both;
}
@keyframes godFlash {
  0% { opacity: 0; transform: scale(0.7); }
  20% { opacity: 1; transform: scale(1.05); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.02); }
}

/* ---------- modal ---------- */
.modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  background: rgba(20, 12, 22, 0.78);
}
.modal-panel {
  width: min(96vw, 760px);
  max-height: min(94vh, 820px);
  display: flex;
  flex-direction: column;
  padding: 6px 10px 12px;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 6px;
}
.modal-head h2 {
  margin: 0;
  font-family: 'Pixelify Sans', sans-serif;
  font-size: clamp(22px, 4vw, 38px);
  letter-spacing: 0.1em;
  color: var(--cream);
  text-shadow: 0 3px 0 #2a1a12;
}
.close-btn {
  width: clamp(36px, 6vw, 46px);
  height: clamp(36px, 6vw, 46px);
  border: 3px solid #2a1a12;
  background: var(--rust);
  color: var(--cream);
  font-family: 'Silkscreen', monospace;
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1;
  box-shadow: 0 3px 0 var(--rust-dark);
  padding: 0;
}
.close-btn:active { transform: translateY(2px); box-shadow: none; }

#gearView, #shopView, #rarityView {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  flex: 1 1 auto;
}
.rarity-card {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  min-height: 0;
}
.rarity-level {
  font-family: 'Pixelify Sans', sans-serif;
  font-size: clamp(20px, 3.6vw, 32px);
  letter-spacing: 0.04em;
  color: #3a2418;
  text-align: center;
  text-shadow: 0 2px 0 rgba(244, 230, 196, 0.55);
}
.rarity-god {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(10px, 1.7vw, 15px);
  letter-spacing: 0.04em;
  color: #7a4e2b;
  text-align: center;
  border-top: 2px solid rgba(122, 78, 43, 0.35);
  border-bottom: 2px solid rgba(122, 78, 43, 0.35);
  padding: 3px 0;
}
.rarity-desc {
  margin: 0;
  font-family: 'VT323', monospace;
  font-size: clamp(13px, 1.9vw, 18px);
  line-height: 1.1;
  color: #5b3a22;
  text-align: center;
}
.rarity-tiers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px 10px;
}
.rarity-row {
  display: flex;
  align-items: center;
  gap: 5px;
  border-bottom: 1px dashed rgba(122, 78, 43, 0.35);
  padding: 1px 2px;
  font-family: 'VT323', monospace;
  font-size: clamp(12px, 1.8vw, 16px);
  color: #5b3a22;
}
.rarity-row img {
  width: clamp(18px, 3vw, 25px);
  height: clamp(18px, 3vw, 25px);
  object-fit: contain;
  flex: 0 0 auto;
}
.rarity-row b {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(8px, 1.3vw, 11px);
  font-weight: 700;
  flex: 0 0 auto;
}
.rarity-row span {
  margin-left: auto;
  font-family: 'Silkscreen', monospace;
  font-size: clamp(8px, 1.25vw, 11px);
  color: #3a2418;
  white-space: nowrap;
}
.rarity-row.god-row {
  border-bottom: none;
  background: rgba(232, 166, 74, 0.22);
  box-shadow: inset 0 0 0 1px rgba(122, 78, 43, 0.3);
}
.rarity-buy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.rarity-have {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(9px, 1.5vw, 12px);
  color: #5b3a22;
}
.rarity-buy .btn {
  font-size: clamp(12px, 1.9vw, 18px);
  min-height: 38px;
}
.rarity-next {
  margin: 0;
  font-family: 'VT323', monospace;
  font-size: clamp(12px, 1.8vw, 16px);
  color: #7a4e2b;
  text-align: center;
}
@media (max-width: 520px) {
  .rarity-tiers { grid-template-columns: 1fr; }
}

.gear-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(56px, 12vw, 84px), 1fr));
  gap: clamp(5px, 1.2vw, 10px);
  overflow-y: auto;
  padding: 4px;
  max-height: min(34vh, 280px);
  min-height: 74px;
  background: rgba(20, 12, 16, 0.5);
  border: 2px solid #1a1008;
  box-shadow: inset 0 0 0 2px rgba(201, 154, 69, 0.22);
}
.gear-grid:empty::after {
  content: "EMPTY";
  grid-column: 1 / -1;
  font-family: 'VT323', monospace;
  color: #8d7a5c;
  text-align: center;
  padding: 18px 0;
  letter-spacing: 0.2em;
}
.item-cell {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: #1c1218;
  box-shadow: 0 0 0 2px #2a1a12;
}
.item-cell .cell-frame,
.item-cell .cell-icon {
  position: absolute;
  display: block;
  object-fit: contain;
}
.item-cell .cell-frame { inset: -3%; width: 106%; height: 106%; }
.item-cell .cell-icon { inset: 22%; width: 56%; height: 56%; }
.item-cell.sel { box-shadow: 0 0 0 2px #fff3b0, 0 0 12px rgba(255, 243, 176, 0.45); }
.item-cell .equipped-tag {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(42, 26, 18, 0.82);
  color: var(--gold-light);
  font-family: 'Silkscreen', monospace;
  font-size: clamp(6px, 1.1vw, 9px);
  letter-spacing: 0.04em;
  text-align: center;
  padding: 1px 0;
  z-index: 2;
}
.gear-detail {
  padding: 8px 12px 10px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 38vh;
}
.empty-note {
  margin: 0;
  font-family: 'VT323', monospace;
  font-size: clamp(14px, 2vw, 19px);
  letter-spacing: 0.1em;
  color: #6b5236;
  text-align: center;
  padding-top: 24px;
}
.detail-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.detail-icon-wrap {
  position: relative;
  width: clamp(48px, 10vw, 62px);
  aspect-ratio: 1;
  flex: 0 0 auto;
}
.detail-icon-wrap img { position: absolute; object-fit: contain; }
.detail-icon-wrap .di-frame { inset: -4%; width: 108%; height: 108%; }
.detail-icon-wrap .di-icon { inset: 22%; width: 56%; height: 56%; }
.detail-name { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.detail-name b {
  font-family: 'Pixelify Sans', sans-serif;
  font-size: clamp(15px, 2.5vw, 22px);
  letter-spacing: 0.02em;
  color: #3a2418;
  line-height: 1.1;
}
.detail-name span {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(9px, 1.4vw, 12px);
  letter-spacing: 0.06em;
}
.detail-desc {
  margin: 0;
  font-family: 'VT323', monospace;
  font-size: clamp(13px, 1.9vw, 17px);
  line-height: 1.1;
  color: #5b3a22;
}
.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-family: 'Silkscreen', monospace;
  font-size: clamp(9px, 1.4vw, 12px);
  color: #3a2418;
}
.detail-stats .up { color: #2d7a3e; }
.detail-stats .down { color: #8f2b26; }
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.detail-actions .btn { font-size: clamp(12px, 1.8vw, 17px); min-height: 38px; padding: 5px 12px; }
.detail-actions .btn-sell { font-size: clamp(11px, 1.6vw, 15px); }
.detail-cost {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(9px, 1.4vw, 12px);
  color: #6b4a1e;
}
.sell-price {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.sell-price img { width: 14px; height: 14px; }

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(130px, 30vw, 200px), 1fr));
  gap: clamp(6px, 1.5vw, 12px);
  overflow-y: auto;
  padding: 4px;
}
.shop-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px;
  background: #4a2a2a;
  border: 3px solid #2a1a12;
  box-shadow: inset 0 0 0 2px rgba(201, 154, 69, 0.25);
}
.shop-card .shop-top {
  display: flex;
  align-items: center;
  gap: 7px;
}
.shop-card .shop-icon {
  width: clamp(38px, 8vw, 54px);
  height: clamp(38px, 8vw, 54px);
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 0 #2a1a12);
}
.shop-card h3 {
  margin: 0;
  font-family: 'Pixelify Sans', sans-serif;
  font-size: clamp(13px, 2vw, 18px);
  letter-spacing: 0.02em;
  color: var(--cream);
  line-height: 1.05;
}
.shop-card p {
  margin: 0;
  font-family: 'VT323', monospace;
  font-size: clamp(12px, 1.7vw, 15px);
  line-height: 1.05;
  color: #e6d3a2;
  flex: 1 1 auto;
}
.shop-buy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
}
.shop-owned {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(9px, 1.3vw, 11px);
  color: var(--cream-dim);
}
.shop-buy .btn {
  min-height: 34px;
  padding: 3px 10px;
  font-size: clamp(12px, 1.8vw, 16px);
}
.shop-buy .cur { font-size: clamp(11px, 1.6vw, 15px); }
.shop-note {
  margin: 4px 2px 0;
  font-family: 'VT323', monospace;
  font-size: clamp(11px, 1.6vw, 15px);
  letter-spacing: 0.06em;
  color: var(--cream-dim);
  text-align: center;
}

/* ---------- first-run tutorial ---------- */
#tutorial {
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: rgba(20, 12, 18, 0.74);
  pointer-events: auto;
}
.tutorial-card {
  width: min(94vw, 700px);
  max-height: 100%;
  overflow-y: auto;
  padding: clamp(10px, 1.8vh, 20px) clamp(14px, 3.6vw, 30px) clamp(12px, 2vh, 20px);
  display: flex;
  flex-direction: column;
  gap: clamp(5px, 1.2vh, 10px);
  box-shadow: 0 10px 0 rgba(20, 10, 8, 0.35);
  text-align: center;
  pointer-events: auto;
}
.tutorial-title {
  margin: 0;
  font-family: 'Pixelify Sans', sans-serif;
  font-weight: 400;
  font-size: clamp(24px, 5.4vw, 40px);
  line-height: 0.95;
  letter-spacing: 0.02em;
  color: #5b3a22;
}
.tutorial-sub {
  margin: 0;
  font-family: 'VT323', monospace;
  font-size: clamp(12px, 2.2vw, 17px);
  letter-spacing: 0.05em;
  color: #6b4a2e;
}
.tutorial-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(3px, 0.8vh, 7px);
  text-align: left;
}
.tutorial-row {
  display: grid;
  grid-template-columns: clamp(30px, 6.4vh, 42px) 1fr;
  align-items: center;
  gap: clamp(7px, 1.6vw, 12px);
  padding: clamp(2px, 0.5vh, 4px) 2px;
  border-bottom: 1px dashed rgba(91, 58, 34, 0.28);
}
.tutorial-row:last-child { border-bottom: 0; }
.tut-ic {
  width: 100%;
  height: clamp(26px, 5.4vh, 38px);
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 0 rgba(58, 36, 24, 0.32));
}
.tut-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(28px, 5.4vh, 38px);
  height: clamp(24px, 5vh, 34px);
  justify-self: center;
  background: #5b3a22;
  border: 2px solid #382216;
  box-shadow: inset 0 0 0 2px #c99a45;
  color: #fff3b0;
  font-family: 'Silkscreen', monospace;
  font-size: clamp(9px, 1.5vw, 12px);
  letter-spacing: 0.04em;
}
.tutorial-row b {
  display: block;
  font-family: 'Silkscreen', monospace;
  font-size: clamp(9px, 1.5vw, 12px);
  letter-spacing: 0.05em;
  line-height: 1.15;
  color: #3a2418;
}
.tutorial-row b em {
  font-style: normal;
  margin-left: 4px;
  color: #8a3a22;
}
.tutorial-row div span {
  display: block;
  font-family: 'VT323', monospace;
  font-size: clamp(12px, 2vw, 17px);
  line-height: 1.08;
  color: #4f3422;
}
.tutorial-begin {
  width: 100%;
  margin-top: 2px;
  flex: 0 0 auto;
}
@media (min-aspect-ratio: 1/1) {
  .tutorial-card { width: min(92vw, 900px); }
  .tutorial-list {
    grid-template-columns: 1fr 1fr;
    column-gap: clamp(14px, 3vw, 28px);
  }
}

/* very narrow */
@media (max-width: 430px) {
  .hud-top { gap: 4px; }
  .bars { width: clamp(86px, 24vw, 120px); }
  .round-cluster { padding: 2px 5px 4px; }
  .round-text { font-size: 11px; }
  .boss-note { font-size: 8px; }
  .coin-cluster { padding: 3px 6px; gap: 6px; }
  .cur { font-size: 11px; }
  .title-art { width: 88vw; }
  .camp-heading h1 { font-size: 30px; }
  .camp-signs { gap: 4px; }
  .signboard span { font-size: 12px; }
}
@media (max-height: 470px) {
  .title-art { max-height: 30vh; }
  .tagline { display: none; }
  .hint { display: none; }
  .title-wrap { padding-top: 1vh; gap: 4px; }
  .camp-heading { display: none; }
}


/* portrait camp: full scene as a postcard at the bottom, signs on the horizon */
@media (max-aspect-ratio: 1/1) {
  #camp { background: #1b1430; }
  #camp::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 66.67vw;
    background-color: #1b1430;
    background-image:
      radial-gradient(circle, #fff3b0 0 1.4px, transparent 1.7px),
      radial-gradient(circle, #cbb98a 0 1px, transparent 1.3px),
      radial-gradient(circle, #8f86d8 0 1px, transparent 1.3px);
    background-size: 97px 83px, 61px 71px, 131px 109px;
    background-position: 10px 24px, 34px 51px, 70px 12px;
    opacity: 0.9;
    pointer-events: none;
  }
  #camp::after { background: linear-gradient(180deg, rgba(18,12,24,0.35) 0%, rgba(18,12,24,0) 24%, rgba(18,12,24,0) 72%, rgba(18,12,24,0.55) 100%); }
  .camp-bg {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    object-position: 50% 100%;
    z-index: 1;
  }
  .fire-fx { top: auto; bottom: 6vw; }
  .camp-heading { top: clamp(54px, 10vh, 100px); }
  .camp-heading h1 { font-size: clamp(30px, 8vw, 54px); }
  .camp-signs {
    bottom: calc(66.67vw - 2px);
    gap: clamp(4px, 2.4vw, 14px);
    z-index: 4;
  }
  .signboard { width: clamp(78px, 21.5vw, 120px); }
  .signboard span { font-size: clamp(11px, 2.7vw, 16px); }
  .signboard em { font-size: clamp(8px, 1.8vw, 11px); }
  .camp-top { top: max(8px, env(safe-area-inset-top)); }
  .camp-top .cur { font-size: 11px; }
  .camp-best { font-size: 10px; }
}


@media (max-width: 380px) {
  .coin-cluster { padding: 3px 4px; gap: 2px; flex-direction: column; align-items: flex-start; }
  .cur { font-size: 10px; }
  .cur img { width: 15px; height: 15px; }
  .bars { width: 82px; }
  .hp-cluster { gap: 5px; }
}

@media (max-width: 400px) {
  .skill-slot { width: clamp(32px, 8.6vw, 42px); }
  .potion-btn, .speed-btn { width: 40px; }
  .burst-btn { width: 72px; }
  .actions { gap: 4px; }
  .skill-bar { gap: 3px; }
  .hud-bottom { gap: 6px; }
}


/* title boss roster */
.boss-roster {
  position: absolute;
  left: 50%;
  bottom: max(8px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 2;
  width: min(94vw, 430px);
  padding: 4px 8px 6px;
  background: rgba(36, 24, 18, 0.82);
  border: 2px solid #c99a45;
  box-shadow: 0 0 0 2px #2a1a12, 0 4px 0 rgba(20, 10, 8, 0.4);
  pointer-events: none;
}
.boss-roster-label {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(7px, 1.15vw, 10px);
  letter-spacing: 0.12em;
  color: #e8d3a4;
  text-align: center;
  text-shadow: 0 1px 0 #2a1a12;
}
.boss-roster-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px 6px;
  margin-top: 2px;
}
.boss-thumb { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.boss-thumb img {
  height: clamp(30px, 4.8vh, 50px);
  width: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 1px 0 #2a1a12);
}
.boss-thumb span {
  font-family: 'VT323', monospace;
  font-size: clamp(7px, 1.2vw, 10px);
  letter-spacing: 0.04em;
  color: var(--cream);
  text-align: center;
  line-height: 1;
  white-space: nowrap;
}

/* ---------- character name ---------- */
#nameEntry {
  z-index: 58;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(8vh, env(safe-area-inset-top)) 12px 12px;
  background: rgba(20, 12, 18, 0.66);
  pointer-events: auto;
  overflow-y: auto;
}
.name-card {
  width: min(92vw, 480px);
  max-height: 92vh;
  overflow-y: auto;
  padding: clamp(12px, 2.4vh, 24px) clamp(16px, 4vw, 30px);
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: center;
  animation: cardIn 280ms steps(4) both;
}
.name-label {
  margin-top: 4px;
  font-family: 'Silkscreen', monospace;
  font-size: clamp(9px, 1.6vw, 12px);
  letter-spacing: 0.12em;
  color: #7a4e2b;
  text-align: left;
}
.name-input {
  width: 100%;
  padding: 7px 10px;
  border: 3px solid #3a2418;
  border-radius: 0;
  background: #fff6dc;
  color: #3a2418;
  font-family: 'Pixelify Sans', sans-serif;
  font-size: clamp(22px, 4.4vw, 30px);
  text-align: center;
  letter-spacing: 0.04em;
  box-shadow: inset 0 0 0 2px #c99a45;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.name-input:focus {
  box-shadow: inset 0 0 0 2px #2fc2b0, 0 0 0 3px rgba(47, 194, 176, 0.35);
}
.name-note {
  margin: 0;
  font-family: 'VT323', monospace;
  font-size: clamp(12px, 1.9vw, 16px);
  letter-spacing: 0.05em;
  color: #7a4e2b;
}
.name-btns {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-top: 4px;
}
.name-btns .btn { flex: 1 1 0; }
@media (max-height: 470px) {
  .name-card { padding: 4px 14px 10px; gap: 4px; }
  .name-btns .btn { min-height: 44px; font-size: clamp(16px, 3vw, 22px); }
}

/* ---------- furthest-round leaderboard ---------- */
#leaderboard {
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(20, 12, 18, 0.62);
  pointer-events: auto;
}
.lb-card {
  width: min(94vw, 700px);
  max-height: 92vh;
  overflow-y: auto;
  padding: clamp(10px, 2vh, 20px) clamp(10px, 2.6vw, 22px);
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: center;
  animation: cardIn 280ms steps(4) both;
}
.lb-standing {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px clamp(8px, 2vw, 14px);
  background: rgba(232, 166, 74, 0.22);
  border: 2px solid rgba(122, 78, 43, 0.5);
  border-radius: 3px;
}
.lb-standing.hidden { display: none; }
.lb-standing-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.lb-standing-label {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(8px, 1.3vw, 11px);
  letter-spacing: 0.08em;
  color: #7a4e2b;
  text-align: left;
}
.lb-standing-rank {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(18px, 3.4vw, 28px);
  line-height: 1;
  color: #3a2418;
  white-space: nowrap;
}
.lb-standing-rank em {
  font-style: normal;
  font-size: 0.55em;
  color: #7a4e2b;
}
.lb-standing-line {
  margin: 0;
  font-family: 'VT323', monospace;
  font-size: clamp(12px, 1.9vw, 16px);
  letter-spacing: 0.04em;
  line-height: 1.15;
  color: #4a2f1c;
  text-align: left;
}
.lb-standing-line b { color: #a35f13; font-weight: 400; }
.lb-gap {
  margin: 0;
  padding: 2px 0;
  font-family: 'VT323', monospace;
  font-size: clamp(12px, 1.8vw, 15px);
  letter-spacing: 0.3em;
  color: #7a4e2b;
  text-align: center;
}
.lb-list {
  display: flex;
  flex-direction: column;
  min-height: 96px;
  max-height: min(54vh, 420px);
  overflow-y: auto;
  background: rgba(122, 78, 43, 0.08);
  border: 2px solid rgba(122, 78, 43, 0.35);
  padding: 2px 4px;
}
.lb-head,
.lb-row {
  display: grid;
  grid-template-columns: clamp(26px, 6vw, 38px) minmax(0, 1fr) clamp(58px, 15vw, 86px) clamp(66px, 17vw, 92px);
  align-items: center;
  gap: 5px;
  padding: 4px 3px;
  text-align: left;
}
.lb-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #e6d3a2;
  border-bottom: 2px solid rgba(122, 78, 43, 0.5);
  font-family: 'Silkscreen', monospace;
  font-size: clamp(7px, 1.2vw, 10px);
  letter-spacing: 0.05em;
  color: #7a4e2b;
}
.lb-head span:last-child,
.lb-head span:nth-child(3) { text-align: right; }
.lb-row { border-bottom: 1px dashed rgba(122, 78, 43, 0.35); }
.lb-row:last-child { border-bottom: 0; }
.lb-row.mine { background: rgba(232, 166, 74, 0.24); }
.lb-rank {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(11px, 1.9vw, 15px);
  color: #5b3a22;
  text-align: center;
}
.lb-row:nth-child(2) .lb-rank { color: #a8791f; }
.lb-who { min-width: 0; }
.lb-who b,
.lb-who a {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'Pixelify Sans', sans-serif;
  font-weight: 400;
  font-size: clamp(15px, 2.5vw, 21px);
  line-height: 1.05;
  letter-spacing: 0.02em;
  color: #3a2418;
}
.lb-who a { text-decoration: none; }
.lb-who a:active { text-decoration: underline; }
.lb-who span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'VT323', monospace;
  font-size: clamp(11px, 1.7vw, 15px);
  line-height: 1.05;
  color: #7a4e2b;
}
.lb-round {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(12px, 2vw, 16px);
  color: #3a2418;
  text-align: right;
  white-space: nowrap;
}
.lb-when {
  font-family: 'VT323', monospace;
  font-size: clamp(11px, 1.7vw, 15px);
  color: #5b3a22;
  text-align: right;
  white-space: nowrap;
}
.lb-empty {
  margin: 0;
  padding: 28px 12px;
  font-family: 'VT323', monospace;
  font-size: clamp(13px, 2vw, 18px);
  letter-spacing: 0.06em;
  color: #6b5236;
  text-align: center;
}
.lb-note {
  margin: 0;
  min-height: 1.1em;
  font-family: 'VT323', monospace;
  font-size: clamp(11px, 1.7vw, 15px);
  letter-spacing: 0.04em;
  color: #7a4e2b;
  text-align: center;
}
.lb-btns {
  display: flex;
  gap: 10px;
  margin-top: 2px;
}
.lb-btns .btn { flex: 1 1 0; }
@media (max-height: 470px) {
  .lb-card { padding: 4px 12px 8px; gap: 3px; }
  .lb-list { max-height: 46vh; }
  .lb-btns .btn { min-height: 42px; font-size: clamp(16px, 3vw, 22px); }
}
@media (max-width: 380px) {
  .lb-head,
  .lb-row { grid-template-columns: 24px minmax(0, 1fr) 52px 58px; gap: 3px; }
  .lb-btns { gap: 6px; }
  .lb-btns .btn { min-width: 0; padding: 6px 8px; font-size: 16px; letter-spacing: 0.02em; }
  .lb-standing-rank { font-size: 20px; }
}

@media (max-width: 620px) {
  .title-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: min(92vw, 460px);
    gap: 10px;
  }
  .title-btns #playBtn { grid-column: 1 / -1; }
  .title-btns .btn {
    padding-left: 12px;
    padding-right: 12px;
    width: 100%;
  }
}
