/* Ashbound — Dark Fantasy Stylesheet */
:root {
  --bg-dark: #0b0907;
  --bg-card: rgba(18, 14, 12, 0.94);
  --bg-card-hover: rgba(28, 22, 19, 0.96);
  --bg-overlay: rgba(8, 6, 5, 0.88);
  --color-bone: #d8ccae;
  --color-bone-dim: #9e9480;
  --color-gold: #d4af37;
  --color-gold-bright: #ffd050;
  --color-ember: #ff8a3a;
  --color-ember-glow: rgba(255, 138, 58, 0.4);
  --color-blood: #b3202a;
  --color-blood-glow: rgba(179, 32, 42, 0.6);
  --color-soul: #8fd8ff;
  --border-gold: rgba(212, 175, 55, 0.35);
  --border-gold-bright: rgba(255, 208, 80, 0.8);
  --border-dark: rgba(216, 204, 174, 0.15);
  --font-serif: Georgia, 'Times New Roman', Garamond, serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--color-bone);
  font-family: var(--font-serif);
  position: fixed;
  inset: 0;
  touch-action: manipulation;
}

/* Canvas background */
canvas#game {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
  pointer-events: auto;
  image-rendering: pixelated;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Common hidden utility */
.hidden {
  display: none !important;
}

/* ------------------------------------------------------------- */
/* HUD LAYER (In-run)                                           */
/* ------------------------------------------------------------- */
#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* XP Bar */
#xpbar {
  position: relative;
  width: 100%;
  height: 6px;
  background: rgba(14, 11, 10, 0.9);
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

#xpfill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff6a1a 0%, #ffaa3a 50%, #ffd050 100%);
  box-shadow: 0 0 6px rgba(255, 138, 58, 0.8);
  transition: width 0.15s ease-out;
}

#lvl {
  position: absolute;
  top: 9px;
  right: 12px;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.05em;
  color: var(--color-gold-bright);
  background: rgba(15, 12, 10, 0.9);
  border: 1px solid var(--border-gold);
  border-radius: 2px;
  padding: 2px 7px;
  text-shadow: 0 1px 2px #000;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* HUD Top Row */
#hudrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(11, 9, 7, 0.8) 0%, rgba(11, 9, 7, 0) 100%);
}

#timer {
  font-size: 1.15rem;
  font-weight: bold;
  letter-spacing: 0.08em;
  color: var(--color-bone);
  text-shadow: 0 2px 4px #000, 0 0 8px rgba(0, 0, 0, 0.8);
  min-width: 55px;
}

#kills, #souls {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--color-bone);
  text-shadow: 0 1px 3px #000;
}

#kills .skull, #souls .soulico {
  display: inline-block;
  width: 18px;
  height: 18px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  image-rendering: pixelated;
}

#souls {
  color: var(--color-soul);
  text-shadow: 0 0 6px rgba(143, 216, 255, 0.4);
}

#pausebtn {
  position: relative;
  top: 18px;
  pointer-events: auto;
  min-width: 48px;
  min-height: 48px;
  width: 48px;
  height: 48px;
  background: rgba(20, 16, 14, 0.85);
  color: var(--color-gold);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

#pausebtn:active {
  transform: scale(0.95);
  background: rgba(30, 24, 20, 0.95);
  border-color: var(--color-gold-bright);
}

/* Loadout */
#loadout {
  padding: 4px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 200px;
}

.loadout-row {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.loadout-slot {
  width: 26px;
  height: 31px;
  background: rgba(14, 11, 10, 0.78);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  position: relative;
}

.loadout-slot.maxed {
  border-color: var(--color-gold);
  box-shadow: 0 0 6px rgba(212, 175, 55, 0.5);
}

.loadout-ico {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
}

.loadout-pips {
  display: flex;
  gap: 1px;
  margin-top: 2px;
  align-items: center;
}

.loadout-pip {
  width: 2px;
  height: 2px;
  background: rgba(216, 204, 174, 0.4);
  border-radius: 1px;
}

.loadout-pip.filled {
  background: var(--color-gold-bright);
  box-shadow: 0 0 2px var(--color-gold-bright);
}

/* Buffs */
#buffs {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 96px);
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

#gainfeed {
  position: absolute;
  left: 10px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 72px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  pointer-events: none;
}

.gain-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 4px;
  background: rgba(14, 11, 10, 0.78);
  border-left: 2px solid var(--color-gold);
  border-radius: 2px;
  font-size: 12px;
  color: #efe6d0;
  text-shadow: 0 1px 2px #000;
  animation: gain-in 0.25s ease-out;
  transition: opacity 0.6s, transform 0.6s;
}

.gain-row b { font-weight: bold; }
.gain-row i { color: var(--color-gold-bright); font-style: normal; font-size: 11px; }
.gain-row.gain-evo { border-left-color: #c89cff; box-shadow: 0 0 8px rgba(200, 156, 255, 0.35); }
.gain-row.gain-evo i { color: #d8b8ff; }
.gain-row.gain-out { opacity: 0; transform: translateX(-16px); }

.gain-ico {
  width: 20px;
  height: 20px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

@keyframes gain-in {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: none; }
}

.buff-chip {
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.05em;
  background: rgba(15, 12, 10, 0.85);
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: var(--color-bone);
  text-shadow: 0 1px 2px #000;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.buff-chip.buff-wrath {
  border-color: #ff3b3b;
  color: #ff8a8a;
  box-shadow: 0 0 6px rgba(255, 59, 59, 0.4);
}

.buff-chip.buff-haste {
  border-color: #9cff8a;
  color: #c4ffba;
  box-shadow: 0 0 6px rgba(156, 255, 138, 0.4);
}

.buff-chip.buff-ward {
  border-color: #ffe38a;
  color: #fff3c4;
  box-shadow: 0 0 6px rgba(255, 227, 138, 0.4);
}

.buff-chip.buff-shrine {
  border-color: #b8a6d8;
  color: #e6dcff;
  box-shadow: 0 0 6px rgba(184, 166, 216, 0.45);
}

.buff-chip.buff-frozen {
  border-color: #bfefff;
  color: #e0f7ff;
  box-shadow: 0 0 6px rgba(191, 239, 255, 0.4);
}

/* Boss Bar */
#bossbar {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  left: 50%;
  transform: translateX(-50%);
  width: min(85%, 360px);
  text-align: center;
  pointer-events: none;
}

#bossname {
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-blood);
  text-shadow: 0 0 8px rgba(179, 32, 42, 0.8), 0 1px 2px #000;
  margin-bottom: 3px;
}

#bosshp {
  width: 100%;
  height: 9px;
  background: rgba(20, 5, 5, 0.85);
  border: 1px solid var(--color-blood);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(179, 32, 42, 0.5), inset 0 0 4px #000;
  overflow: hidden;
}

#bossfill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #b3202a 0%, #ff3b3b 100%);
  transition: width 0.1s linear;
}

/* Banner */
#banner {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 24px;
  background: rgba(11, 9, 7, 0.94);
  border-top: 1px solid var(--color-gold);
  border-bottom: 1px solid var(--color-gold);
  color: var(--color-gold-bright);
  font-size: clamp(0.95rem, 3.5vw, 1.25rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
  text-shadow: 0 0 12px rgba(212, 175, 55, 0.6), 0 2px 4px #000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease;
  width: max-content;
  max-width: 90%;
}

#banner.banner-boss {
  border-color: var(--color-blood);
  color: #ff6b6b;
  text-shadow: 0 0 12px rgba(179, 32, 42, 0.8);
}

#banner.banner-warn {
  border-color: var(--color-ember);
  color: #ffaa4a;
}

#banner.fade-out {
  opacity: 0;
}

/* ------------------------------------------------------------- */
/* SCREENS CONTAINER                                             */
/* ------------------------------------------------------------- */
#screens {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 50% 35%, rgba(32, 22, 18, 0.96) 0%, rgba(14, 11, 9, 0.98) 70%, #070605 100%);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.2s ease-out;
}

.screen.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

.screen.overlay {
  background: rgba(6, 5, 4, 0.9);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ------------------------------------------------------------- */
/* TYPOGRAPHY & COMMON ELEMENTS                                  */
/* ------------------------------------------------------------- */
h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: normal;
  text-align: center;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2rem, 7.5vw, 3.2rem);
  letter-spacing: 0.22em;
  color: var(--color-gold);
  text-shadow: 0 0 16px rgba(212, 175, 55, 0.45), 0 2px 4px #000;
  margin-bottom: 6px;
}

h2 {
  font-size: clamp(1.2rem, 4.5vw, 1.7rem);
  letter-spacing: 0.16em;
  color: var(--color-bone);
  text-shadow: 0 0 10px rgba(216, 204, 174, 0.25), 0 2px 4px #000;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-gold);
  padding-bottom: 6px;
  width: min(92%, 480px);
}

.glow {
  text-shadow: 0 0 14px rgba(212, 175, 55, 0.6), 0 2px 4px #000;
}

.glow.gold {
  color: var(--color-gold-bright);
  text-shadow: 0 0 16px rgba(255, 208, 80, 0.7), 0 2px 4px #000;
}

p.sub {
  color: var(--color-bone-dim);
  font-size: 0.95rem;
  font-style: italic;
  letter-spacing: 0.05em;
  margin-bottom: 24px;
  text-align: center;
  text-shadow: 0 1px 3px #000;
}

p.hint {
  color: var(--color-bone-dim);
  font-size: 0.85rem;
  font-style: italic;
  margin-bottom: 12px;
  text-align: center;
  max-width: 420px;
}

p.souls-line {
  color: var(--color-soul);
  font-size: 0.95rem;
  margin-top: 16px;
  text-shadow: 0 0 8px rgba(143, 216, 255, 0.35);
  text-align: center;
  letter-spacing: 0.05em;
}

.soulcount {
  color: #d6f2ff;
  font-weight: bold;
}

/* ------------------------------------------------------------- */
/* BUTTONS (>= 48px Touch Targets)                               */
/* ------------------------------------------------------------- */
.btn {
  min-height: 48px;
  min-width: 48px;
  padding: 10px 18px;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-bone);
  background: linear-gradient(180deg, #241d19 0%, #14100e 100%);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn:hover {
  background: linear-gradient(180deg, #2e2520 0%, #1a1512 100%);
  border-color: var(--color-gold);
}

.btn:active {
  transform: scale(0.97);
  background: #14100e;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
}

.btn:focus-visible {
  outline: 2px solid var(--color-gold-bright);
}

.btn.big {
  min-height: 52px;
  padding: 12px 28px;
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--color-gold-bright);
  border-color: var(--color-gold);
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn.small {
  min-height: 48px;
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn.danger {
  color: #ff7575;
  border-color: rgba(179, 32, 42, 0.6);
  background: linear-gradient(180deg, #281214 0%, #16080a 100%);
}

.btn.danger:hover {
  border-color: #ff3b3b;
  box-shadow: 0 0 10px rgba(179, 32, 42, 0.4);
}

.btn.active {
  background: linear-gradient(180deg, #3a1618 0%, #200a0c 100%);
  border-color: #ff3b3b;
  color: #ff8a8a;
  box-shadow: 0 0 12px rgba(255, 59, 59, 0.5);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--border-dark);
  color: var(--color-bone-dim);
  box-shadow: none;
  transform: none;
}

/* Rows & Layout Containers */
.menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(85%, 280px);
  margin: 0 auto;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
  width: min(100%, 480px);
}

.cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 480px);
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-gold) transparent;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(100%, 480px);
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-gold) transparent;
}

/* ------------------------------------------------------------- */
/* TITLE SCREEN & DRIFTING EMBERS                                */
/* ------------------------------------------------------------- */
.title-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  width: 100%;
}

.flame-mark {
  width: 32px;
  height: 44px;
  margin: 0 auto 12px;
  background: radial-gradient(ellipse at 50% 75%, #ffffff 0%, #ffd050 30%, #ff6a1a 65%, rgba(255, 106, 26, 0) 100%);
  filter: drop-shadow(0 0 10px #ff6a1a);
  border-radius: 50% 50% 35% 35% / 60% 60% 40% 40%;
  animation: flamePulse 2.4s infinite ease-in-out alternate;
}

@keyframes flamePulse {
  0% { transform: scale(0.94); filter: drop-shadow(0 0 8px #ff6a1a); }
  100% { transform: scale(1.06); filter: drop-shadow(0 0 16px #ff8a3a); }
}

/* CSS-Only Embers */
.embers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.embers i {
  position: absolute;
  bottom: -20px;
  background: radial-gradient(circle, #ffe08a 0%, #ff8a3a 60%, rgba(255, 138, 58, 0) 100%);
  border-radius: 50%;
  box-shadow: 0 0 8px #ff6a1a;
  animation: emberRise linear infinite;
  opacity: 0;
}

.embers i:nth-child(1) { left: 10%; width: 4px; height: 4px; animation-duration: 6.5s; animation-delay: 0.2s; }
.embers i:nth-child(2) { left: 22%; width: 5px; height: 5px; animation-duration: 5.2s; animation-delay: 1.5s; }
.embers i:nth-child(3) { left: 35%; width: 3px; height: 3px; animation-duration: 7.0s; animation-delay: 0.8s; }
.embers i:nth-child(4) { left: 48%; width: 6px; height: 6px; animation-duration: 5.8s; animation-delay: 2.1s; }
.embers i:nth-child(5) { left: 58%; width: 4px; height: 4px; animation-duration: 6.2s; animation-delay: 0.5s; }
.embers i:nth-child(6) { left: 70%; width: 5px; height: 5px; animation-duration: 5.0s; animation-delay: 1.8s; }
.embers i:nth-child(7) { left: 82%; width: 3px; height: 3px; animation-duration: 7.4s; animation-delay: 2.7s; }
.embers i:nth-child(8) { left: 92%; width: 4px; height: 4px; animation-duration: 6.0s; animation-delay: 0.9s; }
.embers i:nth-child(9) { left: 18%; width: 4px; height: 4px; animation-duration: 6.8s; animation-delay: 3.4s; }
.embers i:nth-child(10) { left: 40%; width: 5px; height: 5px; animation-duration: 5.5s; animation-delay: 3.8s; }
.embers i:nth-child(11) { left: 65%; width: 3px; height: 3px; animation-duration: 7.2s; animation-delay: 4.2s; }
.embers i:nth-child(12) { left: 85%; width: 6px; height: 6px; animation-duration: 5.3s; animation-delay: 3.1s; }
.embers i:nth-child(13) { left: 28%; width: 4px; height: 4px; animation-duration: 6.4s; animation-delay: 4.8s; }
.embers i:nth-child(14) { left: 52%; width: 5px; height: 5px; animation-duration: 5.9s; animation-delay: 4.0s; }
.embers i:nth-child(15) { left: 76%; width: 4px; height: 4px; animation-duration: 6.7s; animation-delay: 5.0s; }

@keyframes emberRise {
  0% {
    transform: translateY(0) translateX(0) scale(0.8);
    opacity: 0;
  }
  15% {
    opacity: 0.9;
  }
  60% {
    transform: translateY(-50vh) translateX(25px) scale(1.1);
    opacity: 0.8;
  }
  100% {
    transform: translateY(-105vh) translateX(-15px) scale(0.6);
    opacity: 0;
  }
}

/* ------------------------------------------------------------- */
/* CLASS SELECT & ARMORY CARDS                                   */
/* ------------------------------------------------------------- */
.class-card, .armory-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.class-card:hover, .armory-card:hover {
  background: var(--bg-card-hover);
}

.class-card.selected, .armory-card.selected {
  border: 1.5px solid var(--color-gold-bright);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.4), inset 0 0 10px rgba(212, 175, 55, 0.1);
}

.class-card.locked {
  opacity: 0.65;
  border-color: var(--border-dark);
}

.hero-preview {
  width: 48px;
  height: 56px;
  background: rgba(10, 8, 7, 0.8);
  border: 1px solid var(--border-gold);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hero-preview canvas {
  width: 42px;
  height: 50px;
  image-rendering: pixelated;
}

.class-info {
  flex: 1;
  min-width: 0;
}

.class-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}

.class-title {
  font-size: 1rem;
  font-weight: bold;
  color: var(--color-bone);
  letter-spacing: 0.05em;
}

.class-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 2px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge-selected {
  background: rgba(212, 175, 55, 0.25);
  border: 1px solid var(--color-gold);
  color: var(--color-gold-bright);
}

.badge-locked {
  background: rgba(100, 100, 100, 0.2);
  border: 1px solid rgba(120, 120, 120, 0.4);
  color: var(--color-bone-dim);
}

.class-weapon {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--color-bone-dim);
  margin-bottom: 3px;
}

.class-weapon img {
  width: 14px;
  height: 14px;
  image-rendering: pixelated;
}

.class-perk {
  font-size: 0.8rem;
  color: var(--color-ember);
  letter-spacing: 0.02em;
}

.class-actions {
  flex-shrink: 0;
}

/* Curse Row */
#curserow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
  padding: 8px 16px;
  background: rgba(16, 12, 10, 0.8);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  width: min(100%, 480px);
}

#curserow span {
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--color-ember);
}

#cursev {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--color-gold-bright);
  min-width: 24px;
  text-align: center;
}

#cursedesc {
  display: block;
  font-size: 0.8rem;
  color: var(--color-bone-dim);
  text-align: center;
  margin-top: 4px;
}

/* ------------------------------------------------------------- */
/* SHOP ITEMS                                                    */
/* ------------------------------------------------------------- */
.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.shop-info {
  flex: 1;
  min-width: 0;
}

.shop-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.shop-name {
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--color-bone);
}

.shop-desc {
  font-size: 0.8rem;
  color: var(--color-bone-dim);
}

.shop-pips {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}

.shop-pip {
  width: 8px;
  height: 4px;
  background: rgba(216, 204, 174, 0.2);
  border-radius: 1px;
}

.shop-pip.filled {
  background: var(--color-gold-bright);
  box-shadow: 0 0 3px var(--color-gold-bright);
}

/* ------------------------------------------------------------- */
/* SETTINGS TOGGLES                                              */
/* ------------------------------------------------------------- */
.toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 0 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--color-bone);
  letter-spacing: 0.04em;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* volume sliders: label, track, percent */
.slider {
  display: grid;
  grid-template-columns: 7.5em 1fr 3em;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  font-size: 0.95rem;
  color: var(--color-bone);
  letter-spacing: 0.04em;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.slider b {
  text-align: right;
  font-weight: normal;
  color: var(--color-bone-dim);
  font-variant-numeric: tabular-nums;
}

.slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin: 0;
  border-radius: 3px;
  border: 1px solid var(--border-gold);
  background: linear-gradient(to right, var(--color-gold) var(--fill, 80%), rgba(10, 8, 7, 0.9) var(--fill, 80%));
  cursor: pointer;
}

.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-bone);
  border: 2px solid var(--color-gold-bright);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.7);
}

.slider input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-bone);
  border: 2px solid var(--color-gold-bright);
}

.toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  background: rgba(10, 8, 7, 0.9);
  border: 1px solid var(--border-gold);
  border-radius: 3px;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.toggle input[type="checkbox"]:checked {
  background: var(--color-gold);
  border-color: var(--color-gold-bright);
}

.toggle input[type="checkbox"]:checked::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid #0b0907;
  border-bottom: 2px solid #0b0907;
  transform: rotate(-45deg) translate(1px, -1px);
}

/* ------------------------------------------------------------- */
/* LEVEL UP / TREASURE OVERLAYS                                  */
/* ------------------------------------------------------------- */
.choice-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 10px 14px;
  background: rgba(20, 16, 14, 0.95);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.7);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.choice-card:hover {
  background: rgba(28, 22, 19, 0.98);
}

.choice-card:active {
  transform: scale(0.98);
}

.choice-card.choice-evo {
  border: 1.5px solid var(--color-gold-bright);
  box-shadow: 0 0 16px rgba(255, 208, 80, 0.4), inset 0 0 8px rgba(255, 208, 80, 0.15);
  animation: evoPulse 2s infinite alternate ease-in-out;
}

.chest-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 104px;
  color: var(--color-gold-bright);
  text-shadow: 0 0 9px rgba(255, 195, 80, 0.55);
}

.chest-intro canvas {
  width: 88px;
  height: 80px;
  image-rendering: pixelated;
}

.chest-intro p {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: sealFlicker 0.7s ease-in-out infinite alternate;
}

#chestitems.chest-items-hidden { display: none; }

#chestitems.treasure-arrival .choice-card {
  animation: chestLootRise 0.28s both ease-out;
}

#chestitems.treasure-arrival .choice-card:nth-child(2) { animation-delay: 0.06s; }
#chestitems.treasure-arrival .choice-card:nth-child(3) { animation-delay: 0.12s; }

@keyframes chestLootRise {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes sealFlicker {
  from { opacity: 0.62; }
  to { opacity: 1; }
}

@keyframes evoPulse {
  0% { box-shadow: 0 0 12px rgba(255, 208, 80, 0.3); }
  100% { box-shadow: 0 0 20px rgba(255, 208, 80, 0.6); }
}

.choice-card.banish-target {
  border-color: #ff3b3b !important;
  box-shadow: 0 0 14px rgba(255, 59, 59, 0.6) !important;
}

.choice-icon-wrap {
  width: 44px;
  height: 44px;
  background: rgba(10, 8, 7, 0.85);
  border: 1px solid var(--border-gold);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.choice-icon {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
}

.choice-info {
  flex: 1;
  min-width: 0;
}

.choice-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.choice-name {
  font-size: 1rem;
  font-weight: bold;
  color: var(--color-bone);
  letter-spacing: 0.04em;
}

.choice-badge {
  font-size: 10px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 2px;
  letter-spacing: 0.08em;
  background: rgba(212, 175, 55, 0.2);
  border: 1px solid var(--border-gold);
  color: var(--color-gold-bright);
}

.choice-badge.badge-new {
  background: rgba(60, 160, 80, 0.25);
  border-color: #4cd468;
  color: #72f58e;
}

.choice-badge.badge-evo {
  background: rgba(255, 208, 80, 0.3);
  border-color: var(--color-gold-bright);
  color: #fff;
  box-shadow: 0 0 6px rgba(255, 208, 80, 0.5);
}

.choice-text {
  font-size: 0.85rem;
  color: var(--color-gold-bright);
  letter-spacing: 0.02em;
}

.choice-desc {
  font-size: 0.78rem;
  color: var(--color-bone-dim);
  font-style: italic;
  margin-top: 2px;
}

/* ------------------------------------------------------------- */
/* PAUSE & GAME OVER STATS                                       */
/* ------------------------------------------------------------- */
.stats {
  width: min(100%, 440px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-box {
  background: rgba(14, 11, 10, 0.85);
  border: 1px solid var(--border-gold);
  border-radius: 3px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.stat-label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--color-bone-dim);
  text-transform: uppercase;
}

.stat-val {
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--color-gold-bright);
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.build-summary {
  background: rgba(14, 11, 10, 0.85);
  border: 1px solid var(--border-gold);
  border-radius: 3px;
  padding: 10px 12px;
}

.build-summary h3 {
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  color: var(--color-bone-dim);
  margin-bottom: 8px;
  text-align: left;
}

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

.build-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(22, 18, 15, 0.9);
  border: 1px solid var(--border-dark);
  border-radius: 3px;
  padding: 4px 8px;
}

.build-item img {
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
}

.build-item span {
  font-size: 0.8rem;
  color: var(--color-bone);
}

.build-item b {
  font-size: 0.75rem;
  color: var(--color-gold-bright);
}

/* YOU DIED / DAWN BREAKS */
.youdied {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 8.5vw, 3.6rem);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--color-blood);
  text-shadow: 0 0 24px rgba(179, 32, 42, 0.85), 0 0 48px rgba(90, 0, 0, 0.95);
  opacity: 0;
  animation: youDiedFade 2s ease-out forwards;
  margin-bottom: 12px;
  text-align: center;
}

@keyframes youDiedFade {
  0% {
    opacity: 0;
    transform: scale(0.92);
    filter: blur(6px);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

.youdied.won {
  color: var(--color-gold);
  text-shadow: 0 0 25px rgba(212, 175, 55, 0.9), 0 0 50px rgba(255, 208, 80, 0.6);
  animation: dawnBreaksFade 2s ease-out forwards;
}

@keyframes dawnBreaksFade {
  0% {
    opacity: 0;
    transform: scale(0.92);
    filter: blur(6px);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

/* ------------------------------------------------------------- */
/* TOAST NOTIFICATIONS                                           */
/* ------------------------------------------------------------- */
#toast {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 12, 10, 0.96);
  color: var(--color-gold-bright);
  border: 1px solid var(--color-gold);
  border-radius: 4px;
  padding: 10px 22px;
  font-size: 0.92rem;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.9), 0 0 8px rgba(212, 175, 55, 0.3);
  z-index: 100;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease;
  width: max-content;
  max-width: 90%;
  text-align: center;
}

#toast.fade-out {
  opacity: 0;
}

/* ------------------------------------------------------------- */
/* RESPONSIVE LAYOUT (360x640 portrait & 800x360 landscape)      */
/* ------------------------------------------------------------- */
@media (max-width: 420px) {
  h1 { font-size: 2.1rem; letter-spacing: 0.2em; }
  h2 { font-size: 1.25rem; letter-spacing: 0.12em; }
  .btn { font-size: 0.9rem; padding: 8px 14px; }
  .btn.big { font-size: 1rem; padding: 10px 20px; }
  .cards, .list { width: 100%; max-height: 56vh; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .screen {
    padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    justify-content: flex-start;
  }
  .title-wrap {
    transform: scale(0.85);
    margin: auto 0;
  }
  .flame-mark {
    width: 24px;
    height: 32px;
    margin-bottom: 6px;
  }
  .menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: min(90%, 420px);
  }
  .menu .btn.big {
    grid-column: 1 / -1;
  }
  h1 { font-size: 1.8rem; margin-bottom: 2px; }
  p.sub { margin-bottom: 12px; font-size: 0.85rem; }
  h2 { font-size: 1.15rem; margin-bottom: 8px; padding-bottom: 4px; }
  .cards, .list { max-height: 50vh; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .youdied { font-size: 2rem; margin-bottom: 6px; }
  #hudrow { padding: 4px 12px; }
  #pausebtn { min-width: 44px; min-height: 44px; width: 44px; height: 44px; }
}


/* ---------- Hub HUD (the Last Hearth) ---------- */
#hubhud {
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) calc(env(safe-area-inset-right, 0px) + 12px) calc(env(safe-area-inset-bottom, 0px) + 18px) calc(env(safe-area-inset-left, 0px) + 12px);
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
}
#hubhud.hidden { display: none; }
#hubhud .hubtop { width: 100%; display: flex; justify-content: space-between; align-items: center; }
#hubhud .hubcinders { display: flex; align-items: center; gap: 6px; color: #f4c84a; font: bold 18px Georgia, serif; text-shadow: 0 1px 3px #000; }
#hubhud .hubcinders .soulico { width: 22px; height: 22px; background-size: contain; background-repeat: no-repeat; display: inline-block; }
#hubhud button { pointer-events: auto; }
#hubhud .hubhint { margin: 6px 0 0; color: rgba(216, 204, 174, 0.55); font: italic 13px Georgia, serif; text-align: center; }
#hubactwrap { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: auto; }
#hubactwrap.hidden { display: none; }
#hubactwrap small { color: rgba(216, 204, 174, 0.75); font: italic 13px Georgia, serif; text-shadow: 0 1px 3px #000; }
#hubact { min-width: 230px; animation: hubpulse 2.2s ease-in-out infinite; }
@keyframes hubpulse { 0%, 100% { box-shadow: 0 0 10px rgba(255, 138, 58, 0.25); } 50% { box-shadow: 0 0 22px rgba(255, 138, 58, 0.55); } }

.buildtag {
  display: block;
  margin-top: -6px;
  margin-bottom: 10px;
  font-size: 11px;
  color: rgba(239, 230, 208, 0.45);
  letter-spacing: 0.05em;
}

/* ---------- pause: abandon confirm ---------- */
.confirm { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 6px; }
.confirm.hidden, #pauserow.hidden { display: none; }
.confirm p { margin: 0; color: var(--color-bone-dim); font-style: italic; text-align: center; max-width: 300px; }

/* ---------- shop layout ---------- */
#s-shop { justify-content: flex-start; padding-top: max(28px, calc(env(safe-area-inset-top) + 16px)); }
#s-shop h2 { margin-top: 0; }
#s-shop .list { flex: 1 1 auto; min-height: 0; max-height: none; }
#s-shop .shop-foot { flex: 0 0 auto; padding-top: 10px; }
.shop-item { padding: 8px 10px 8px 14px; }
.shop-pips { align-items: center; gap: 4px; margin-top: 5px; }
.shop-pip { width: 9px; height: 9px; border-radius: 50%; background: transparent; border: 1px solid rgba(216, 204, 174, 0.35); box-shadow: none; }
.shop-pip.filled { background: var(--color-gold-bright); border-color: var(--color-gold-bright); box-shadow: 0 0 4px var(--color-gold-bright); }
.shop-rank { margin-left: 4px; font-size: 0.72rem; color: var(--color-bone-dim); letter-spacing: 0.04em; }
.btn.shop-buy { flex: 0 0 104px; width: 104px; min-width: 104px; padding: 4px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; letter-spacing: 0.06em; }
.btn.shop-buy b { font-size: 1rem; color: var(--color-gold-bright); }
.btn.shop-buy small { font-size: 0.62rem; color: var(--color-bone-dim); }
.btn.shop-buy.poor:disabled { opacity: 1; border-style: dashed; border-color: rgba(179, 32, 42, 0.45); background: rgba(20, 14, 12, 0.6); }
.btn.shop-buy.poor b { color: #b86a5e; }
.btn.shop-buy.maxed:disabled { opacity: 1; color: var(--color-gold); border-color: var(--border-gold); font-size: 0.85rem; letter-spacing: 0.15em; }

/* The Gravekeeper's short, scrollable field guide. */
#s-guide .guide-list { flex: 1 1 auto; min-height: 0; max-height: min(60vh, 600px); gap: 10px; }
#s-guide .row { flex: 0 0 auto; padding-top: 10px; }
.guide-entry { width: 100%; padding: 12px 14px; border: 1px solid rgba(164, 132, 76, 0.5); border-radius: 5px; background: rgba(8, 7, 6, 0.55); text-align: left; }
.guide-entry h3 { margin: 0 0 5px; color: #e4c780; font: bold 16px Georgia, serif; }
.guide-entry p { margin: 0; color: #ddd2bd; font: 14px/1.45 Georgia, serif; }
