/* ============================================================
   EMBERFALL — The Cinder Crown
   UI stylesheet: dark-fantasy parchment & ember
   ============================================================ */

@font-face {
  font-family: 'Cinzel';
  src: url('assets/fonts/cinzel.woff2') format('woff2');
  font-weight: 500 700;
  font-display: swap;
}
@font-face {
  font-family: 'Alegreya Sans';
  src: url('assets/fonts/alegreya-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Alegreya Sans';
  src: url('assets/fonts/alegreya-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Alegreya Sans';
  src: url('assets/fonts/alegreya-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #07060b;
  --ink-2: #0d0a12;
  --ink-3: #14101b;
  --panel: #17121f;
  --panel-2: #1e1828;
  --panel-3: #261e31;
  --parchment: #eddcb8;
  --parchment-dim: #c8b58f;
  --muted: #9b8da8;
  --muted-2: #756a82;
  --gold: #dda74b;
  --gold-2: #f2d18c;
  --gold-3: #a7772d;
  --ember: #e2672c;
  --ember-2: #ffb066;
  --blood: #b43b3b;
  --moss: #7fa25b;
  --steel: #8ba6bd;
  --violet: #9b7bc4;
  --line: rgba(221, 167, 75, 0.28);
  --line-soft: rgba(237, 220, 184, 0.12);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
  --font-display: 'Cinzel', 'Palatino Linotype', Georgia, serif;
  --font-body: 'Alegreya Sans', 'Trebuchet MS', sans-serif;
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--ink); }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--parchment);
  background:
    radial-gradient(1200px 800px at 20% -10%, rgba(120, 64, 40, 0.22), transparent 60%),
    radial-gradient(900px 700px at 90% 110%, rgba(74, 45, 80, 0.25), transparent 65%),
    var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
a { color: var(--gold-2); }
svg { display: block; }
[hidden] { display: none !important; }
::selection { background: rgba(221, 167, 75, 0.35); color: #fff; }

.app {
  position: relative;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  isolation: isolate;
}
.app-noise {
  position: fixed;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* ---------- shared primitives ---------- */
.pixel { image-rendering: pixelated; image-rendering: crisp-edges; }
.eyebrow {
  margin: 0 0 10px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow--gold { color: var(--gold); }
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: 0.02em;
  margin: 0;
}
h1 { font-size: clamp(30px, 4vw, 52px); }
h2 { font-size: clamp(22px, 2.5vw, 32px); }
h3 { font-size: 17px; letter-spacing: 0.06em; }
p { line-height: 1.55; }
.text-link {
  font-size: 13px;
  color: var(--parchment-dim);
  text-decoration: none;
  border-bottom: 1px solid rgba(221, 167, 75, 0.3);
  padding-bottom: 1px;
}
.text-link:hover { color: var(--gold-2); border-color: var(--gold); }

.keycap {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  margin: 0 2px;
  border-radius: 5px;
  border: 1px solid rgba(237, 220, 184, 0.22);
  border-bottom-color: rgba(237, 220, 184, 0.42);
  background: linear-gradient(#2a2332, #16111d);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  vertical-align: middle;
}

/* ---------- buttons ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 11px 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(41, 33, 52, 0.95), rgba(21, 16, 28, 0.95));
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 22px rgba(0, 0, 0, 0.25);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease, color 140ms ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: rgba(221, 167, 75, 0.6); background: linear-gradient(180deg, rgba(54, 42, 67, 0.98), rgba(27, 20, 35, 0.98)); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(0.995); }
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, .hud-round-btn:focus-visible {
  outline: 2px solid var(--gold-2);
  outline-offset: 3px;
}
.btn-primary {
  border-color: #e7bc6d;
  background:
    linear-gradient(180deg, #f1cb82 0%, #d99f43 48%, #a97329 100%);
  color: #241507;
  text-shadow: 0 1px 0 rgba(255, 245, 220, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -2px 0 rgba(87, 49, 10, 0.35),
    0 10px 26px rgba(183, 112, 34, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #ffe0a0 0%, #e8b45c 48%, #b98132 100%);
  border-color: #ffe1a1;
  color: #1e1002;
}
.btn-ghost {
  background: rgba(15, 11, 21, 0.55);
  border-color: rgba(237, 220, 184, 0.2);
}
.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--parchment-dim);
  box-shadow: none;
}
.btn-quiet:hover { color: var(--parchment); background: rgba(237, 220, 184, 0.06); border-color: rgba(237, 220, 184, 0.12); }
.btn-small { min-height: 34px; padding: 7px 13px; font-size: 12px; border-radius: 8px; }
.btn-back { padding-left: 8px; gap: 4px; }
.btn-back svg { width: 18px; height: 18px; }
.btn[disabled], .btn.is-locked {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.6);
  transform: none;
}
.btn-hero {
  min-height: 64px;
  flex-direction: column;
  gap: 2px;
  padding: 12px 30px;
}
.btn-hero-label { font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: 0.1em; }
.btn-hero-sub { font-size: 11px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.7; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(237, 220, 184, 0.16);
  background: rgba(12, 9, 17, 0.5);
  color: var(--parchment-dim);
  transition: color 140ms, border-color 140ms, background 140ms;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { color: var(--gold-2); border-color: var(--line); background: rgba(221, 167, 75, 0.08); }

/* ---------- screens & page shell ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  overflow: hidden;
  z-index: 2;
}
.screen.is-active { display: flex; }
.screen-page { overflow-y: auto; overflow-x: hidden; background: radial-gradient(1100px 650px at 15% -10%, rgba(118, 65, 40, 0.2), transparent 60%), radial-gradient(900px 600px at 100% 100%, rgba(93, 54, 106, 0.18), transparent 62%), var(--ink-2); overscroll-behavior: contain; }
.screen-page.is-active { display: block; }
.page-shell {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: calc(22px + var(--safe-t)) clamp(16px, 4vw, 48px) calc(40px + var(--safe-b));
}
.page-head {
  display: grid;
  grid-template-columns: 120px 1fr 180px;
  align-items: start;
  gap: 20px;
  padding: 12px 0 28px;
  position: relative;
}
.page-head::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 8px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}
.page-head-copy h1 { margin-bottom: 8px; }
.page-sub { margin: 0; color: var(--muted); font-size: 15px; max-width: 620px; }
.page-head-side { display: flex; justify-content: flex-end; }
.btn-back { justify-self: start; margin-top: 4px; }
.page-shell > .hero-select-hint { margin-top: 22px; text-align: center; color: var(--muted-2); font-size: 13px; }

/* ---------- panels ---------- */
.panel {
  position: relative;
  background:
    linear-gradient(160deg, rgba(35, 27, 46, 0.92), rgba(17, 13, 24, 0.96));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel.ornate { border-color: rgba(221, 167, 75, 0.24); }
.ornate::before, .ornate::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  pointer-events: none;
  opacity: 0.75;
}
.ornate::before {
  top: -1px; left: -1px;
  border-top: 2px solid var(--gold);
  border-left: 2px solid var(--gold);
  border-top-left-radius: var(--radius);
}
.ornate::after {
  bottom: -1px; right: -1px;
  border-bottom: 2px solid var(--gold);
  border-right: 2px solid var(--gold);
  border-bottom-right-radius: var(--radius);
}
.panel-title { margin-bottom: 4px; }

/* ============================================================
   TITLE SCREEN
   ============================================================ */
.screen-title {
  display: none;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  background:
    radial-gradient(1100px 700px at 50% 18%, rgba(78, 44, 62, 0.55), transparent 65%),
    linear-gradient(180deg, #0a0710 0%, #120b17 45%, #1c0f13 100%);
  overflow: hidden;
}
.screen-title.is-active { display: flex; }
.title-embers { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.title-backdrop { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.title-moon {
  position: absolute;
  top: 8%; left: 50%;
  width: clamp(150px, 22vw, 300px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 42% 38%, #f6d9a1, #d9a866 40%, #8e5f46 72%, transparent 73%);
  opacity: 0.32;
  filter: blur(1px);
  box-shadow: 0 0 120px 30px rgba(230, 150, 90, 0.12);
}
.title-dragon {
  position: absolute;
  top: 10%;
  right: 4%;
  width: clamp(220px, 26vw, 380px);
  opacity: 0.34;
  filter: brightness(0.4) sepia(0.5) hue-rotate(-28deg) drop-shadow(0 0 36px rgba(226, 103, 44, 0.35));
  transform: rotate(3deg);
  animation: dragon-drift 16s ease-in-out infinite alternate;
  image-rendering: pixelated;
}
@keyframes dragon-drift {
  from { transform: translate3d(0, 0, 0) rotate(3deg); }
  to { transform: translate3d(-22px, 18px, 0) rotate(1deg); }
}
.title-ridge {
  position: absolute;
  left: -5%; right: -5%;
  bottom: 0;
  height: 36%;
}
.title-ridge--far {
  background: #171020;
  opacity: 0.8;
  clip-path: polygon(0 78%, 8% 60%, 15% 68%, 24% 44%, 31% 58%, 40% 34%, 48% 52%, 57% 26%, 66% 46%, 74% 30%, 83% 55%, 91% 38%, 100% 58%, 100% 100%, 0 100%);
}
.title-ridge--near {
  height: 26%;
  background: #0b0710;
  clip-path: polygon(0 70%, 9% 56%, 18% 66%, 27% 48%, 36% 60%, 46% 42%, 55% 62%, 64% 50%, 72% 64%, 82% 52%, 92% 66%, 100% 55%, 100% 100%, 0 100%);
}
.title-castle {
  position: absolute;
  left: 50%;
  bottom: 12%;
  width: min(560px, 62vw);
  height: min(210px, 24vh);
  transform: translateX(-50%);
  background: #08050c;
  opacity: 0.92;
  clip-path: polygon(
    0 100%, 0 62%, 6% 62%, 6% 38%, 10% 38%, 10% 62%, 20% 62%, 20% 48%,
    24% 48%, 24% 20%, 27% 20%, 27% 14%, 30% 14%, 30% 20%, 33% 20%, 33% 48%,
    42% 48%, 42% 34%, 47% 34%, 47% 54%, 53% 54%, 53% 30%, 58% 30%, 58% 44%,
    66% 44%, 66% 16%, 70% 16%, 70% 10%, 74% 10%, 74% 16%, 78% 16%, 78% 44%,
    88% 44%, 88% 36%, 92% 36%, 92% 62%, 100% 62%, 100% 100%
  );
}
.title-fog {
  position: absolute;
  left: -10%; right: -10%; bottom: 0;
  height: 34%;
  background: linear-gradient(180deg, transparent, rgba(56, 37, 47, 0.5) 42%, rgba(9, 7, 13, 0.9));
  filter: blur(8px);
}
.title-top {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(18px + var(--safe-t)) clamp(18px, 4vw, 44px) 0;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  color: var(--gold);
  border: 1px solid rgba(221, 167, 75, 0.38);
  border-radius: 50%;
  background: rgba(12, 8, 16, 0.6);
}
.brand-mark svg { width: 19px; height: 19px; }
.title-top-note {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: var(--muted-2);
  text-transform: uppercase;
}
.title-top .icon-btn { margin-left: auto; }
.title-content {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 10px 20px 0;
  text-align: center;
  min-height: 0;
}
.title-lockup { max-width: 820px; }
.game-title {
  font-family: var(--font-display);
  font-size: clamp(54px, 10.2vw, 132px);
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 0.94;
  margin: 2px 0 0;
  padding-left: 0.14em;
  color: #f4e4c2;
  text-shadow:
    0 1px 0 #fff6df,
    0 2px 0 #c9974d,
    0 3px 0 #7d5120,
    0 14px 34px rgba(0, 0, 0, 0.8),
    0 0 48px rgba(226, 103, 44, 0.22);
  background: linear-gradient(180deg, #fff3d5 0%, #efd19a 42%, #d2a15a 72%, #b77a35 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.title-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 14px auto 16px;
  color: var(--gold);
  opacity: 0.8;
}
.title-rule span { display: block; width: min(160px, 20vw); height: 1px; background: linear-gradient(90deg, transparent, var(--line)); }
.title-rule span:last-child { background: linear-gradient(90deg, var(--line), transparent); }
.title-rule svg { width: 16px; height: 16px; }
.title-lead {
  margin: 0 auto;
  color: var(--parchment-dim);
  font-size: clamp(14px, 1.7vw, 18px);
  letter-spacing: 0.03em;
  line-height: 1.55;
}
.title-lead em { color: var(--muted); font-style: normal; }
.title-menu {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 9px;
  width: min(300px, 84vw);
  margin-top: clamp(20px, 3.4vh, 38px);
}
.title-menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.title-menu-row .btn {
  min-height: 38px;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid rgba(237, 220, 184, 0.18);
  background: rgba(12, 9, 18, 0.55);
  color: var(--parchment-dim);
  box-shadow: none;
}
.title-menu-row .btn:hover { color: var(--parchment); border-color: var(--line); background: rgba(221, 167, 75, 0.08); }
.title-cast {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(20px, 5vw, 58px);
  margin-top: clamp(18px, 3vh, 34px);
  pointer-events: none;
  opacity: 0.95;
}
.cast-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  animation: cast-bob 5s ease-in-out infinite;
}
.cast-figure:nth-child(2) { animation-delay: -1.6s; }
.cast-figure:nth-child(3) { animation-delay: -3.2s; }
.cast-figure img {
  width: clamp(44px, 5vw, 66px);
  height: auto;
  filter: drop-shadow(0 14px 12px rgba(0, 0, 0, 0.65)) drop-shadow(0 0 16px rgba(226, 103, 44, 0.15));
}
@keyframes cast-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.title-footer {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(18px, 4vw, 44px) calc(14px + var(--safe-b));
  font-size: 12px;
  color: var(--muted-2);
  letter-spacing: 0.03em;
}

/* ============================================================
   HERO SELECT
   ============================================================ */
.currency-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(12, 9, 18, 0.55);
  font-size: 14px;
  font-weight: 700;
  color: var(--parchment);
  white-space: nowrap;
}
.currency-pill img { width: 16px; height: 16px; }
.currency-pill b { font-weight: 700; font-variant-numeric: tabular-nums; }
.currency-pill--gold { border-color: rgba(221, 167, 75, 0.28); }
.currency-pill--gold img { filter: drop-shadow(0 0 4px rgba(221, 167, 75, 0.4)); }

.hero-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(14px, 2vw, 24px);
}
.hero-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: linear-gradient(170deg, rgba(34, 26, 44, 0.9), rgba(14, 11, 20, 0.97));
  box-shadow: var(--shadow);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
  min-height: 540px;
}
.hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(440px 260px at 50% 0%, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.hero-card:hover { transform: translateY(-5px); border-color: var(--accent-line); box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6); }
.hero-card.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 24px 70px rgba(0, 0, 0, 0.55); }
.hero-card-top {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px 18px;
  text-align: center;
  border-bottom: 1px solid var(--line-soft);
}
.hero-card-badge {
  position: absolute;
  top: 14px; right: 14px;
  padding: 4px 8px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-soft-2);
  background: rgba(0, 0, 0, 0.22);
}
.hero-portrait-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  margin-bottom: 10px;
}
.hero-portrait-stage::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 66%);
  filter: blur(3px);
}
.hero-portrait-stage::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  opacity: 0.6;
}
.hero-portrait-stage img {
  position: relative;
  width: 86px;
  height: 86px;
  image-rendering: pixelated;
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.55));
  transform: scale(1.15);
}
.hero-role { font-size: 10px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.hero-name { font-family: var(--font-display); font-size: 25px; font-weight: 600; letter-spacing: 0.02em; }
.hero-title { color: var(--muted); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 3px; }
.hero-card-body { display: flex; flex-direction: column; flex: 1; padding: 18px 20px 20px; gap: 14px; }
.hero-blurb { margin: 0; color: var(--parchment-dim); font-size: 14px; min-height: 62px; }
.hero-stats { display: grid; gap: 8px; }
.hero-stat { display: grid; grid-template-columns: 60px 1fr 30px; align-items: center; gap: 9px; font-size: 11px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; }
.hero-stat-bar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.hero-stat-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-soft-2)); }
.hero-stat b { text-align: right; color: var(--parchment-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.hero-kit { display: grid; gap: 7px; padding-top: 2px; }
.hero-kit-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.hero-kit-row img, .hero-kit-row svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--muted); }
.hero-kit-row b { color: var(--parchment-dim); font-weight: 700; }
.hero-card .btn { margin-top: auto; width: 100%; }
.hero-card-foot { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted-2); }
.hero-card-foot .swatches { display: flex; gap: 4px; }
.hero-card-foot .swatch { width: 10px; height: 10px; border-radius: 2px; }

/* ============================================================
   CAMP
   ============================================================ */
.camp-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: calc(14px + var(--safe-t)) clamp(14px, 3vw, 36px) calc(24px + var(--safe-b));
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.camp-top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.camp-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--gold);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: 0.14em;
  font-weight: 600;
}
.camp-brand svg { width: 22px; height: 22px; }
.camp-resources { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: 8px; }
.material-strip { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.material-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 9px 0 6px;
  border: 1px solid rgba(237, 220, 184, 0.12);
  border-radius: 999px;
  background: rgba(10, 8, 15, 0.45);
  font-size: 12px;
  font-weight: 700;
  color: var(--parchment-dim);
  white-space: nowrap;
}
.material-chip img { width: 17px; height: 17px; }
.material-chip--empty { opacity: 0.38; }
.material-chip b { font-variant-numeric: tabular-nums; }
.camp-top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.camp-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: clamp(18px, 2.5vw, 32px);
  padding-top: 22px;
  flex: 1;
}
.hero-panel {
  align-self: start;
  position: sticky;
  top: calc(14px + var(--safe-t));
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: linear-gradient(165deg, rgba(33, 25, 44, 0.9), rgba(13, 10, 19, 0.97));
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero-panel-art {
  position: relative;
  height: 210px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(240px 160px at 50% 45%, var(--accent-soft), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent);
  border-bottom: 1px solid var(--line-soft);
}
.hero-panel-art::before {
  content: "";
  position: absolute;
  inset: 18px 42px;
  border: 1px solid var(--accent-line);
  border-radius: 140px 140px 16px 16px;
  opacity: 0.55;
}
.hero-panel-art img {
  position: relative;
  width: 108px;
  height: 108px;
  image-rendering: pixelated;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.6));
  transform: scale(1.2);
}
.hero-panel-level {
  position: absolute;
  right: 14px; top: 14px;
  padding: 5px 9px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: rgba(7, 5, 11, 0.65);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent-soft-2);
}
.hero-panel-info { padding: 18px 20px 20px; }
.hero-panel-name { font-family: var(--font-display); font-size: 23px; }
.hero-panel-title { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.hero-panel-bars { display: grid; gap: 10px; margin: 18px 0; }
.hero-panel-bars .meter-label { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 5px; }
.meter { position: relative; height: 14px; border-radius: 4px; background: #0b0810; border: 1px solid rgba(237, 220, 184, 0.1); overflow: hidden; }
.meter-fill { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #8f2f2f, #d05b4c); border-radius: 3px; transition: width 260ms ease; }
.meter-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); font-variant-numeric: tabular-nums; }
.meter--xp { height: 8px; }
.meter--xp .meter-fill { background: linear-gradient(90deg, #6b4e9c, #b28be0); }
.hero-panel-gear { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.gear-line { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--muted); }
.gear-line img { width: 20px; height: 20px; flex: 0 0 auto; }
.gear-line svg { width: 20px; height: 20px; flex: 0 0 auto; color: var(--muted); }
.gear-line b { color: var(--parchment-dim); font-weight: 700; }
.gear-line .plus { color: var(--gold); font-size: 11px; margin-left: auto; }
.hero-panel .btn { width: 100%; margin-top: 14px; }

.camp-main { min-width: 0; }
.tab-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 140ms;
}
.tab svg { width: 17px; height: 17px; }
.tab:hover { color: var(--parchment-dim); }
.tab.is-active { color: var(--gold-2); }
.tab.is-active::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.tab-panel { display: none; animation: panel-in 220ms ease both; }
.tab-panel.is-active { display: block; }
@keyframes panel-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.section-head h2 { font-size: 26px; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.section-head .section-note { font-size: 12px; color: var(--muted-2); letter-spacing: 0.04em; }

/* map cards */
.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); gap: 16px; }
.map-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: linear-gradient(170deg, rgba(31, 24, 41, 0.92), rgba(12, 9, 18, 0.97));
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.35);
  transition: border-color 160ms, transform 160ms;
}
.map-card:hover { border-color: rgba(221, 167, 75, 0.4); transform: translateY(-2px); }
.map-card.is-locked { opacity: 0.55; }
.map-card.is-locked:hover { transform: none; border-color: var(--line-soft); }
.map-thumb {
  position: relative;
  height: 148px;
  overflow: hidden;
  background: var(--thumb-bg, linear-gradient(#222, #111));
  border-bottom: 1px solid var(--line-soft);
}
.map-thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(260px 150px at 75% 20%, var(--thumb-glow, transparent), transparent 70%),
    linear-gradient(180deg, transparent 35%, rgba(5, 4, 8, 0.72));
}
.map-thumb-ridge {
  position: absolute;
  left: -5%; right: -5%; bottom: 0;
  height: 60%;
  background: var(--thumb-ridge, #131019);
  clip-path: polygon(0 100%, 0 62%, 12% 38%, 22% 54%, 34% 22%, 47% 48%, 58% 30%, 70% 56%, 82% 34%, 92% 52%, 100% 40%, 100% 100%);
  opacity: 0.9;
}
.map-thumb-sprite {
  position: absolute;
  right: 18px;
  bottom: 12px;
  width: 58px;
  height: 58px;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.65));
}
.map-thumb--keep .map-thumb-sprite { width: 70px; height: 70px; right: 10px; bottom: 4px; }
.map-thumb--peak .map-thumb-sprite {
  width: 112px;
  height: 112px;
  right: -2px;
  bottom: -6px;
  filter: drop-shadow(0 0 22px rgba(226, 103, 44, 0.35)) drop-shadow(0 10px 12px rgba(0, 0, 0, 0.7));
  opacity: 0.92;
}
.map-thumb-numeral {
  position: absolute;
  left: 16px;
  top: 14px;
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.58);
  line-height: 1;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6);
}
.map-thumb-tag {
  position: absolute;
  left: 16px;
  bottom: 14px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--thumb-tag, var(--parchment-dim));
}
.map-thumb-lock {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  background: rgba(5, 4, 9, 0.55);
  color: var(--parchment-dim);
  backdrop-filter: blur(1px);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
}
.map-thumb-lock svg { width: 26px; height: 26px; opacity: 0.8; }
.map-thumb-lock span { opacity: 0.7; }

/* map thumbnail palettes */
.map-thumb--woods {
  --thumb-bg: linear-gradient(180deg, #14262b, #3d6153 55%, #8b6b43);
  --thumb-glow: rgba(232, 201, 138, 0.28);
  --thumb-ridge: #1b332e;
  --thumb-tag: #d8c69e;
}
.map-thumb--keep {
  --thumb-bg: linear-gradient(180deg, #09070d, #1a1220 60%, #2b1a20);
  --thumb-glow: rgba(156, 106, 76, 0.28);
  --thumb-ridge: #100b15;
  --thumb-tag: #b9a7bc;
}
.map-thumb--peak {
  --thumb-bg: linear-gradient(180deg, #0a0d1a, #351a2c 60%, #7e3b28);
  --thumb-glow: rgba(255, 110, 50, 0.32);
  --thumb-ridge: #1b1422;
  --thumb-tag: #f0b28a;
}
.map-body { display: flex; flex-direction: column; flex: 1; padding: 14px 16px 16px; gap: 10px; }
.map-name-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.map-name { font-family: var(--font-display); font-size: 20px; }
.map-level { font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: 0.1em; }
.map-desc { margin: 0; color: var(--muted); font-size: 13px; min-height: 40px; }
.map-rewards { display: flex; gap: 6px; flex-wrap: wrap; }
.reward-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1px solid rgba(237, 220, 184, 0.1);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.025);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.reward-chip img { width: 13px; height: 13px; }
.difficulty-row { display: flex; gap: 4px; flex-wrap: wrap; }
.diff-chip {
  flex: 1;
  min-width: 0;
  padding: 6px 4px;
  border: 1px solid rgba(237, 220, 184, 0.12);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  transition: all 130ms;
}
.diff-chip:hover { color: var(--parchment); border-color: var(--line); }
.diff-chip.is-active { color: #231607; background: linear-gradient(180deg, #ecc97f, #c89442); border-color: #f0d091; }
.diff-chip[disabled] { opacity: 0.35; cursor: not-allowed; }
.map-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }
.map-actions .btn { flex: 1; min-height: 38px; font-size: 13px; padding: 8px 10px; }
.map-cleared {
  position: absolute;
  top: 12px; right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(37, 61, 38, 0.85);
  border: 1px solid rgba(127, 162, 91, 0.5);
  color: #c9e3a9;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  z-index: 2;
}
.map-cleared svg { width: 11px; height: 11px; }

/* forge */
.forge-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 18px; align-items: start; }
.forge-panel { padding: 18px; }
.forge-panel h2 { font-size: 23px; margin-bottom: 3px; }
.forge-panel .panel-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.gear-slot {
  position: relative;
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.022);
  margin-bottom: 10px;
}
.gear-slot:last-child { margin-bottom: 0; }
.gear-icon-box {
  display: grid;
  place-items: center;
  width: 54px; height: 54px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 40%, rgba(221, 167, 75, 0.1), transparent 70%), rgba(8, 6, 12, 0.6);
}
.gear-icon-box img { width: 34px; height: 34px; image-rendering: pixelated; }
.gear-icon-box svg { width: 32px; height: 32px; color: var(--muted); }
.gear-slot-label { font-size: 9px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.gear-slot-name { font-family: var(--font-display); font-size: 17px; margin: 2px 0 4px; }
.gear-slot-stats { font-size: 11px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.gear-slot-stats b { color: var(--parchment-dim); }
.gear-slot-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.plus-badge { color: var(--gold-2); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; }
.upgrade-btn { min-height: 30px; padding: 5px 9px; font-size: 10px; }
.upgrade-note { font-size: 9px; color: var(--muted-2); }
.recipe-list { display: grid; gap: 10px; }
.recipe {
  padding: 13px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 140ms, background 140ms;
}
.recipe.is-craftable { border-color: rgba(127, 162, 91, 0.3); background: rgba(127, 162, 91, 0.035); }
.recipe.is-owned { opacity: 0.6; }
.recipe-top { display: flex; align-items: center; gap: 10px; }
.recipe-top img { width: 26px; height: 26px; image-rendering: pixelated; }
.recipe-top svg { width: 24px; height: 24px; color: var(--muted); flex: 0 0 auto; }
.recipe-name { font-weight: 700; font-size: 14px; }
.recipe-tier { margin-left: auto; font-size: 9px; font-weight: 700; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.recipe-desc { margin: 6px 0 10px; font-size: 12px; color: var(--muted); }
.recipe-costs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.cost-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(237, 220, 184, 0.09);
  font-size: 10px;
  font-weight: 700;
  color: var(--parchment-dim);
}
.cost-chip img { width: 13px; height: 13px; }
.cost-chip.is-missing { color: #e08a7e; border-color: rgba(180, 59, 59, 0.35); }
.recipe .btn { width: 100%; min-height: 34px; font-size: 12px; padding: 7px; }
.forge-footer-note { margin-top: 12px; font-size: 11px; color: var(--muted-2); line-height: 1.5; }

/* hero journal */
.journal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.journal-panel { padding: 18px; }
.stat-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(237, 220, 184, 0.07); font-size: 13px; color: var(--muted); }
.stat-line:last-child { border-bottom: 0; }
.stat-line b { color: var(--parchment); font-size: 15px; font-variant-numeric: tabular-nums; }
.skill-card { border: 1px solid var(--line-soft); border-radius: 10px; padding: 14px; background: rgba(255, 255, 255, 0.02); display: flex; gap: 12px; }
.skill-card-orb { flex: 0 0 46px; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); background: radial-gradient(circle, rgba(226, 103, 44, 0.25), rgba(13, 10, 19, 0.8)); color: var(--gold-2); }
.skill-card-orb svg { width: 24px; height: 24px; }
.skill-card h3 { font-size: 16px; margin-bottom: 3px; }
.skill-card p { margin: 0; font-size: 12px; color: var(--muted); }
.skill-meta { display: flex; gap: 10px; margin-top: 7px; font-size: 10px; color: var(--muted-2); letter-spacing: 0.06em; text-transform: uppercase; }
.key-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-top: 10px; }
.key-list span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.lore-quote { margin: 0; font-size: 15px; line-height: 1.6; color: var(--parchment-dim); font-style: italic; border-left: 2px solid var(--line); padding-left: 14px; }
.lore-source { display: block; margin-top: 8px; font-style: normal; font-size: 10px; letter-spacing: 0.16em; color: var(--muted-2); text-transform: uppercase; }

/* ============================================================
   GAME SCREEN / HUD
   ============================================================ */
.screen-game { display: none; background: #000; overflow: hidden; }
.screen-game.is-active { display: block; }
.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000;
  overflow: hidden;
  touch-action: none;
}
#game-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  background: #050409;
}
.stage-vignette {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(100vw, 177.7778dvh);
  height: min(56.25vw, 100dvh);
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 56%, rgba(2, 2, 6, 0.48) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.28), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.32));
  z-index: 2;
}
.low-hp {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 46%, rgba(152, 21, 21, 0.42) 100%);
  transition: opacity 300ms;
}
.low-hp.is-on { animation: low-pulse 1.6s ease-in-out infinite; }
@keyframes low-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.75; } }

.hud {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(100vw, 177.7778dvh);
  height: min(56.25vw, 100dvh);
  z-index: 4;
  pointer-events: none;
  font-family: var(--font-body);
  padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) calc(10px + var(--safe-b)) calc(12px + var(--safe-l));
  display: flex;
  flex-direction: column;
}
.hud-top {
  display: grid;
  grid-template-columns: minmax(180px, 300px) minmax(160px, 1fr) auto;
  align-items: start;
  gap: clamp(10px, 2vw, 26px);
}
.hud-hero { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-portrait {
  flex: 0 0 auto;
  width: clamp(42px, 5vw, 56px);
  height: clamp(42px, 5vw, 56px);
  border: 1px solid rgba(221, 167, 75, 0.42);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 40%, rgba(221, 167, 75, 0.18), rgba(7, 5, 11, 0.9));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), inset 0 0 0 2px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.hud-portrait img { width: 76%; height: 76%; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.5)); }
.hud-hero-info { min-width: 0; flex: 1; }
.hud-name-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.hud-name-row > span:first-child { font-family: var(--font-display); font-size: clamp(13px, 1.2vw, 16px); font-weight: 600; color: #f3e4c4; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8); letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-level { font-size: 9px; font-weight: 700; letter-spacing: 0.1em; color: var(--gold); opacity: 0.9; }
.hud .meter { height: clamp(11px, 1.3vw, 15px); border-color: rgba(255, 255, 255, 0.16); background: rgba(5, 3, 8, 0.8); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45); }
.hud .meter-fill { background: linear-gradient(90deg, #6e1f23, #c44c45 58%, #e37d5d); box-shadow: 0 0 8px rgba(224, 100, 80, 0.25); }
.hud .meter-text { font-size: 9px; }
.hud-subrow { display: flex; gap: 10px; margin-top: 5px; }
.hud-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--parchment-dim); text-shadow: 0 1px 3px #000; }
.hud-chip img { width: 14px; height: 14px; }
.hud-chip--regen { color: #a9e2a5; }
.hud-chip--regen .regen-cross {
  display: inline-grid;
  place-items: center;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(155, 224, 138, 0.5);
  background: rgba(40, 90, 50, 0.35);
  font-size: 12px;
  line-height: 1;
}
.hud-chip--regen b { font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; }

.hud-objective { text-align: center; padding-top: 2px; min-width: 0; }
.hud-objective-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.hud-objective .eyebrow { margin: 0; font-size: clamp(8px, 0.9vw, 10px); letter-spacing: 0.18em; color: #dcc294; text-shadow: 0 1px 3px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-progress-text { font-size: 10px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-track { height: 4px; background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(237, 220, 184, 0.12); border-radius: 2px; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #a7772d, #f2d18c); box-shadow: 0 0 8px rgba(242, 209, 140, 0.35); transition: width 200ms linear; }
.hud-objective-sub { display: block; margin-top: 5px; font-size: 10px; color: rgba(237, 220, 184, 0.48); letter-spacing: 0.03em; text-shadow: 0 1px 2px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-actions { display: flex; gap: 6px; justify-content: flex-end; pointer-events: auto; }
.hud-round-btn {
  width: clamp(32px, 3.2vw, 38px);
  height: clamp(32px, 3.2vw, 38px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(237, 220, 184, 0.22);
  background: rgba(8, 6, 12, 0.58);
  color: var(--parchment-dim);
  backdrop-filter: blur(4px);
  transition: color 140ms, background 140ms;
}
.hud-round-btn svg { width: 16px; height: 16px; }
.hud-round-btn:hover { color: var(--gold-2); background: rgba(20, 15, 27, 0.8); }
.hud-round-btn.is-muted .sound-wave { opacity: 0.25; }

.boss-hud {
  position: absolute;
  top: clamp(64px, 9vh, 92px);
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 62%);
  text-align: center;
  z-index: 6;
  animation: boss-in 500ms ease both;
}
@keyframes boss-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.boss-hud-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.boss-hud-name { font-family: var(--font-display); font-size: clamp(11px, 1.15vw, 14px); letter-spacing: 0.1em; color: #f6d4ad; text-shadow: 0 2px 6px #000; }
.boss-hud-phase { font-size: 9px; font-weight: 700; letter-spacing: 0.15em; color: var(--ember-2); }
.boss-track { position: relative; height: 11px; border: 1px solid rgba(226, 103, 44, 0.5); border-radius: 3px; background: rgba(5, 3, 8, 0.8); overflow: hidden; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6); }
.boss-track span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #5d1010, #b5301f 55%, #e2672c); box-shadow: 0 0 12px rgba(226, 103, 44, 0.5); transition: width 180ms linear; }
.boss-track i { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255, 220, 180, 0.6); left: 33%; }
.boss-hud-sub { margin: 5px 0 0; font-size: 10px; color: rgba(237, 220, 184, 0.55); letter-spacing: 0.04em; text-shadow: 0 1px 2px #000; }

.skill-widget {
  position: absolute;
  right: calc(14px + var(--safe-r));
  bottom: calc(62px + var(--safe-b));
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.9;
  pointer-events: auto;
}
.skill-orb { cursor: pointer; }
.skill-orb {
  position: relative;
  width: 46px; height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(221, 167, 75, 0.5);
  border-radius: 50%;
  background: radial-gradient(circle at 45% 35%, rgba(221, 167, 75, 0.2), rgba(7, 5, 11, 0.9));
  color: var(--gold-2);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5), inset 0 0 14px rgba(226, 103, 44, 0.12);
}
.skill-orb svg { width: 22px; height: 22px; }
.skill-cd {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: rgba(5, 4, 9, 0.66);
  border-radius: 50%;
  opacity: 0;
}
.skill-widget.is-cooling .skill-cd { opacity: 1; }
.skill-widget.is-cooling .skill-orb { filter: grayscale(0.7) brightness(0.75); }
.skill-label { display: flex; flex-direction: column; gap: 1px; text-shadow: 0 1px 3px #000; }
.skill-label b { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; color: #e9d7b6; }
.skill-label span { font-size: 8px; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted-2); }
.skill-widget.is-ready .skill-label span { color: var(--moss); }

.interact-prompt {
  position: absolute;
  left: 50%;
  bottom: calc(78px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 15px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(9, 7, 14, 0.82);
  backdrop-filter: blur(6px);
  color: var(--parchment);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  animation: prompt-in 180ms ease both;
  z-index: 8;
}
@keyframes prompt-in { from { opacity: 0; transform: translate(-50%, 5px); } to { opacity: 1; transform: translate(-50%, 0); } }
.interact-key { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: linear-gradient(#f2d18c, #bb8333); color: #231607; font-size: 11px; font-weight: 700; }

.toast-stack { position: absolute; top: 23%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 7; pointer-events: none; }
.game-toast {
  padding: 7px 14px;
  border: 1px solid rgba(221, 167, 75, 0.3);
  border-radius: 6px;
  background: rgba(8, 6, 12, 0.82);
  color: #ecd8b2;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px #000;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  animation: toast-life 1.8s ease forwards;
  white-space: nowrap;
}
@keyframes toast-life { 0% { opacity: 0; transform: translateY(6px); } 12%, 78% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-6px); } }

.hotkey-bar {
  position: absolute;
  left: 50%;
  bottom: calc(10px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 14px;
  border: 1px solid rgba(237, 220, 184, 0.12);
  border-radius: 999px;
  background: rgba(7, 5, 11, 0.55);
  backdrop-filter: blur(4px);
  font-size: 10px;
  color: rgba(237, 220, 184, 0.66);
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
}
.hotkey-bar span { display: inline-flex; align-items: center; gap: 3px; }
.hotkey-bar .keycap { height: 18px; min-width: 18px; font-size: 9px; border-radius: 4px; margin: 0; }
.hotkey-bar em { font-style: normal; color: var(--gold); font-size: 8px; }

.touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l));
}
.touch-move { pointer-events: auto; padding: 0 0 4px 2px; }
.stick {
  position: relative;
  width: clamp(104px, 20vh, 138px);
  height: clamp(104px, 20vh, 138px);
  border-radius: 50%;
  border: 1px solid rgba(237, 220, 184, 0.22);
  background: radial-gradient(circle, rgba(20, 15, 27, 0.26), rgba(5, 4, 9, 0.45));
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.35);
  touch-action: none;
}
.stick-ring { position: absolute; inset: 18%; border-radius: 50%; border: 1px dashed rgba(237, 220, 184, 0.16); }
.stick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 40%; height: 40%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 38% 32%, rgba(246, 220, 170, 0.7), rgba(156, 118, 62, 0.4) 60%, rgba(40, 30, 20, 0.5));
  border: 1px solid rgba(250, 229, 187, 0.4);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  transition: transform 60ms linear;
}
.touch-buttons {
  pointer-events: auto;
  display: grid;
  grid-template-columns: repeat(3, auto);
  grid-template-rows: repeat(2, auto);
  gap: clamp(6px, 1.4vh, 10px);
  align-items: end;
  justify-items: end;
}
.touch-btn {
  position: relative;
  width: clamp(48px, 9.4vh, 62px);
  height: clamp(48px, 9.4vh, 62px);
  border-radius: 50%;
  border: 1px solid rgba(237, 220, 184, 0.24);
  background: radial-gradient(circle at 40% 30%, rgba(58, 47, 70, 0.72), rgba(10, 8, 15, 0.7));
  color: rgba(237, 220, 184, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  backdrop-filter: blur(5px);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.touch-btn svg { width: 21px; height: 21px; }
.touch-btn span { font-size: 8px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.72; }
.touch-btn.is-pressed { background: radial-gradient(circle at 40% 30%, rgba(221, 167, 75, 0.5), rgba(36, 24, 15, 0.78)); border-color: rgba(255, 220, 160, 0.7); transform: scale(0.94); }
.touch-btn--jump { width: clamp(60px, 11.5vh, 78px); height: clamp(60px, 11.5vh, 78px); grid-column: 3; grid-row: 2; border-color: rgba(242, 209, 140, 0.4); color: var(--gold-2); }
.touch-btn--attack { grid-column: 2; grid-row: 2; border-color: rgba(226, 103, 44, 0.45); color: #ffc79e; }
.touch-btn--skill { grid-column: 3; grid-row: 1; }
.touch-btn--sm[data-touch="dash"] { grid-column: 1; grid-row: 1; }
.touch-btn--sm[data-touch="potion"] { grid-column: 2; grid-row: 1; }
.touch-btn--sm[data-touch="interact"] { grid-column: 1; grid-row: 2; }
.touch-cd { position: absolute; inset: 0; border-radius: 50%; background: rgba(4, 3, 7, 0.62); display: grid; place-items: center; font-size: 11px; font-style: normal; font-weight: 700; color: #fff; opacity: 0; }
.touch-btn.is-cooling .touch-cd { opacity: 1; }

.map-intro {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 10;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(5, 4, 9, 0.55), rgba(5, 4, 9, 0.86));
  opacity: 0;
  visibility: hidden;
  transition: opacity 600ms ease, visibility 600ms;
}
.map-intro.is-visible { opacity: 1; visibility: visible; }
.map-intro.is-leaving { opacity: 0; }
.map-intro h2 { font-size: clamp(30px, 4.5vw, 58px); color: #f4e4c2; text-shadow: 0 10px 40px #000; }
.map-intro p:not(.eyebrow) { color: var(--muted); font-size: clamp(12px, 1.3vw, 16px); margin: 8px 0 0; letter-spacing: 0.04em; }
.map-intro .eyebrow { color: var(--gold); }
.intro-hint {
  margin-top: 14px !important;
  font-size: 10px !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase;
  color: rgba(237, 220, 184, 0.48) !important;
}
.intro-line { display: block; width: 70px; height: 1px; margin-top: 18px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }

.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 3, 7, 0.72);
  backdrop-filter: blur(7px);
  overflow-y: auto;
}
.pause-card { width: min(520px, 100%); padding: 26px 26px 22px; margin: auto; }
.pause-card .eyebrow { margin-bottom: 4px; }
.pause-stats { display: flex; gap: 18px; flex-wrap: wrap; margin: 14px 0 18px; padding: 10px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); font-size: 11px; color: var(--muted); }
.pause-stats b { display: block; color: var(--parchment); font-size: 14px; margin-top: 2px; }
.pause-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pause-actions .btn-primary { grid-column: 1 / -1; }
#pause-abandon { color: #d9968c; border: 1px solid rgba(180, 59, 59, 0.28); }
#pause-abandon:hover { color: #f1b2a6; border-color: rgba(220, 100, 90, 0.55); background: rgba(120, 30, 30, 0.16); }
.pause-controls { margin-top: 20px; }
.pause-controls h3 { font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.control-grid span { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }

/* In-run inventory / character satchel */
.inventory-overlay {
  position: absolute;
  inset: 0;
  z-index: 31;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 3, 7, 0.74);
  backdrop-filter: blur(7px);
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(214, 177, 105, 0.4) transparent;
}
@media (max-height: 700px) {
  .inventory-overlay { align-items: start; }
}
.inventory-card {
  width: min(820px, 100%);
  margin: auto;
  padding: 24px 26px 20px;
}
.inventory-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.inventory-head .eyebrow { margin-bottom: 3px; }
.inventory-close {
  width: 32px; height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid rgba(237, 220, 184, 0.22);
  background: rgba(8, 6, 12, 0.45);
  color: var(--parchment-dim);
  font-size: 21px;
  line-height: 1;
}
.inventory-close:hover { color: var(--gold-2); background: rgba(20, 15, 27, 0.8); }
.inv-hero {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin: 16px 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: linear-gradient(110deg, var(--accent-soft, rgba(224, 138, 82, 0.12)), rgba(8, 6, 12, 0.22));
}
.inv-portrait {
  width: 54px; height: 54px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 1px solid var(--accent-line, rgba(224, 138, 82, 0.42));
  background: rgba(4, 3, 7, 0.45);
}
.inv-portrait img { width: 38px; height: 38px; image-rendering: pixelated; }
.inv-hero-copy h3 { font-family: var(--display); font-size: 21px; color: var(--parchment); line-height: 1.1; }
.inv-hero-copy p { color: var(--muted); font-size: 11px; margin-top: 3px; }
.inv-hero-stats { display: grid; grid-template-columns: repeat(4, auto); gap: 12px; }
.inv-hero-stats span { display: block; font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.inv-hero-stats b { display: block; font-size: 15px; color: var(--parchment); margin-top: 2px; }
.inv-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.inv-section {
  min-width: 0;
  padding: 13px 14px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: rgba(8, 6, 12, 0.25);
}
.inv-section h3 {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-2);
  margin-bottom: 9px;
}
.inv-section h3:not(:first-child) { margin-top: 16px; }
.inv-mat-head, .inv-mat-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 42px 48px;
  align-items: center;
  gap: 7px;
}
.inv-mat-head {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line-soft);
}
.inv-mat-head span:first-child { grid-column: 1 / 3; }
.inv-mat-head span:not(:first-child) { text-align: right; }
.inv-mat-row { padding: 5px 0; border-bottom: 1px solid rgba(237, 220, 184, 0.06); }
.inv-mat-row:last-child { border-bottom: 0; }
.inv-mat-row img { width: 18px; height: 18px; object-fit: contain; }
.inv-mat-name { font-size: 12px; color: var(--parchment-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-mat-run, .inv-mat-bank { text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.inv-mat-run { color: var(--gold-2); font-weight: 600; }
.inv-mat-run.is-zero { color: var(--muted); font-weight: 400; }
.inv-mat-bank { color: var(--parchment-dim); }
.inv-note { font-size: 10px; line-height: 1.45; color: var(--muted); margin-top: 10px; }
.inv-gear-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  margin-bottom: 8px;
  border: 1px solid rgba(237, 220, 184, 0.1);
  border-radius: 7px;
  background: rgba(16, 12, 20, 0.35);
}
.inv-gear-icon {
  width: 36px; height: 36px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 6px;
  background: rgba(4, 3, 7, 0.5);
  border: 1px solid rgba(237, 220, 184, 0.1);
}
.inv-gear-icon img { width: 26px; height: 26px; image-rendering: pixelated; }
.inv-gear-icon svg { width: 24px; height: 24px; color: var(--gold-2); }
.inv-slot { display: block; font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.inv-gear-card strong { display: block; margin-top: 1px; color: var(--parchment); font-size: 12px; }
.inv-gear-card p { margin: 3px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.inv-supply-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(237, 220, 184, 0.06);
  font-size: 11px;
  color: var(--muted);
}
.inv-supply-row:last-child { border-bottom: 0; }
.inv-supply-row b { color: var(--parchment); font-size: 12px; font-variant-numeric: tabular-nums; }
.inventory-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line-soft);
}
.inventory-hint { font-size: 10px; color: var(--muted); }
.inventory-foot .btn { min-width: 150px; }
@media (max-width: 700px) {
  .inventory-overlay { align-items: start; }
  .inventory-card { padding: 18px 17px 16px; }
  .inv-hero { grid-template-columns: 46px minmax(0, 1fr); }
  .inv-portrait { width: 46px; height: 46px; }
  .inv-portrait img { width: 33px; height: 33px; }
  .inv-hero-stats { grid-column: 1 / -1; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .inv-columns { grid-template-columns: 1fr; }
  .inventory-foot { align-items: stretch; flex-direction: column; }
  .inventory-foot .btn { width: 100%; }
  .inventory-hint { text-align: center; }
}

/* ============================================================
   RESULTS
   ============================================================ */
.screen-results { overflow-y: auto; background: radial-gradient(900px 600px at 50% 0%, rgba(74, 42, 55, 0.5), transparent 70%), #0a0710; }
.results-embers { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: 0.8; }
.results-shell { position: relative; z-index: 1; width: min(1120px, 100%); margin: 0 auto; padding: calc(28px + var(--safe-t)) clamp(16px, 4vw, 36px) calc(36px + var(--safe-b)); }
.results-banner { text-align: center; padding: 16px 0 26px; }
.results-banner .eyebrow { color: var(--gold); }
.results-banner h1 { font-size: clamp(42px, 7vw, 78px); letter-spacing: 0.06em; background: linear-gradient(180deg, #fff2d2, #d9ad61 70%, #a97734); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.4)); }
.results-banner.is-defeat h1 { background: linear-gradient(180deg, #f0cac2, #b75a4d 70%, #6f2d26); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.results-banner p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.results-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr); gap: 18px; align-items: start; }
.results-main { padding: 20px; }
.result-hero { display: flex; align-items: center; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--line-soft); }
.result-hero-img { width: 64px; height: 64px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: radial-gradient(circle, rgba(221, 167, 75, 0.12), rgba(8, 6, 12, 0.7)); }
.result-hero-img img { width: 48px; height: 48px; image-rendering: pixelated; }
.result-hero-name { font-family: var(--font-display); font-size: 22px; }
.result-hero-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.result-hero-badge { margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: 0.12em; color: var(--gold); border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; text-transform: uppercase; }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.result-stat { text-align: center; padding: 8px 4px; border-right: 1px solid rgba(237, 220, 184, 0.07); }
.result-stat:last-child { border-right: 0; }
.result-stat b { display: block; font-family: var(--font-display); font-size: 20px; color: #f1dfbc; font-variant-numeric: tabular-nums; }
.result-stat span { display: block; margin-top: 3px; font-size: 9px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.result-loot { padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.result-loot h3, .result-xp h3 { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.loot-list { display: flex; flex-wrap: wrap; gap: 7px; }
.loot-item { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border: 1px solid var(--line-soft); border-radius: 6px; background: rgba(255, 255, 255, 0.02); font-size: 12px; font-weight: 700; color: var(--parchment-dim); }
.loot-item img { width: 16px; height: 16px; }
.loot-item--gold { color: var(--gold-2); border-color: rgba(221, 167, 75, 0.25); }
.result-xp { padding-top: 16px; }
.result-xp-top { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.results-side { padding: 20px; }
.results-side h3 { font-size: 16px; margin-bottom: 12px; }
.results-side p { color: var(--muted); font-size: 13px; }
.side-list { display: grid; gap: 8px; }
.side-list-item { display: flex; gap: 9px; align-items: flex-start; padding: 9px 10px; border: 1px solid var(--line-soft); border-radius: 7px; background: rgba(255, 255, 255, 0.02); font-size: 12px; color: var(--muted); }
.side-list-item svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; color: var(--gold); }
.side-list-item b { color: var(--parchment); }
.results-actions { display: grid; gap: 8px; margin-top: 18px; }
.results-actions .btn { width: 100%; }
.levelup-burst { display: flex; align-items: center; gap: 8px; padding: 10px; margin-top: 12px; border: 1px solid rgba(221, 167, 75, 0.35); border-radius: 8px; background: rgba(221, 167, 75, 0.06); color: var(--gold-2); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; line-height: 1.35; }
.levelup-burst svg { width: 18px; height: 18px; flex: 0 0 auto; }

/* ============================================================
   CODEX
   ============================================================ */
.codex-shell { max-width: 1180px; }
.codex-tabs { margin-bottom: 18px; }
.codex-body { min-height: 300px; }
.codex-hero-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.codex-card { padding: 16px; }
.codex-card h3 { font-size: 18px; margin-bottom: 3px; }
.codex-card .sub { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.codex-card p { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.codex-card-img { height: 86px; display: grid; place-items: center; margin-bottom: 8px; background: radial-gradient(circle, rgba(221, 167, 75, 0.1), transparent 65%); }
.codex-card-img img { width: 58px; height: 58px; image-rendering: pixelated; }
.bestiary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.beast-card { display: grid; grid-template-columns: 54px 1fr; gap: 11px; padding: 12px; align-items: center; }
.beast-card img { width: 46px; height: 46px; image-rendering: pixelated; margin: 0 auto; }
.beast-card h4 { margin: 0; font-family: var(--font-display); font-size: 15px; }
.beast-card p { margin: 3px 0 0; font-size: 11px; color: var(--muted); }
.threat { font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ember-2); margin-top: 2px; }
.codex-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 26px; padding: 20px; }
.codex-controls .control-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(237, 220, 184, 0.07); font-size: 13px; color: var(--muted); }
.codex-controls .control-row:last-child { border: 0; }
.codex-controls .keys { display: flex; gap: 4px; }
.credits-block { display: grid; gap: 12px; padding: 20px; }
.credit-row { display: grid; grid-template-columns: 150px 1fr; gap: 14px; padding-bottom: 12px; border-bottom: 1px solid rgba(237, 220, 184, 0.07); }
.credit-row:last-child { border: 0; padding-bottom: 0; }
.credit-row h4 { margin: 0; font-size: 13px; color: var(--parchment); }
.credit-row p { margin: 0; font-size: 12px; color: var(--muted); }
.credit-row a { color: var(--gold-2); text-decoration: none; border-bottom: 1px solid rgba(221, 167, 75, 0.3); }

/* ============================================================
   MODALS / BOOT / ROTATE
   ============================================================ */
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal-scrim { position: absolute; inset: 0; background: rgba(3, 2, 6, 0.76); backdrop-filter: blur(7px); }
.modal { position: relative; width: min(620px, 100%); max-height: min(86dvh, 760px); display: flex; flex-direction: column; z-index: 1; animation: modal-in 200ms ease both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { font-size: 23px; }
.modal-body { padding: 18px 20px 22px; overflow-y: auto; }
.modal-note { font-size: 12px; color: var(--muted); margin: 0 0 14px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 0; border-bottom: 1px solid rgba(237, 220, 184, 0.08); }
.setting-row:last-child { border: 0; }
.setting-row-label b { display: block; font-size: 14px; color: var(--parchment); }
.setting-row-label span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.setting-control { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
input[type="range"] { accent-color: var(--gold); width: 140px; }
input[type="checkbox"] { accent-color: var(--gold); width: 18px; height: 18px; }
.segmented { display: inline-flex; border: 1px solid var(--line-soft); border-radius: 7px; overflow: hidden; }
.segmented button { border: 0; background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; padding: 7px 9px; letter-spacing: 0.05em; text-transform: uppercase; }
.segmented button.is-active { background: rgba(221, 167, 75, 0.17); color: var(--gold-2); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.danger-btn { border-color: rgba(180, 59, 59, 0.45); color: #e6a39a; }
.danger-btn:hover { border-color: rgba(220, 100, 90, 0.7); background: rgba(120, 30, 30, 0.18); }

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background:
    radial-gradient(600px 400px at 50% 45%, rgba(90, 45, 30, 0.3), transparent 70%),
    #08060c;
  transition: opacity 500ms ease, visibility 500ms;
}
.boot-screen.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-mark { width: 54px; height: 54px; color: var(--gold); filter: drop-shadow(0 0 22px rgba(226, 103, 44, 0.45)); animation: boot-glow 2s ease-in-out infinite; }
.boot-mark svg { width: 100%; height: 100%; }
@keyframes boot-glow { 0%, 100% { opacity: 0.7; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
.boot-title { font-family: var(--font-display); letter-spacing: 0.3em; font-size: 16px; color: var(--parchment-dim); margin: 0 0 6px; padding-left: 0.3em; }
.boot-bar { width: 180px; height: 3px; border-radius: 2px; background: rgba(237, 220, 184, 0.1); overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold-3), var(--gold-2)); transition: width 200ms ease; }
.boot-status { margin: 2px 0 0; font-size: 11px; letter-spacing: 0.08em; color: var(--muted-2); }

.rotate-hint { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; background: rgba(4, 3, 7, 0.9); backdrop-filter: blur(10px); padding: 22px; }
.rotate-card { width: min(420px, 100%); text-align: center; padding: 26px 22px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(165deg, #1c1625, #0d0a13); box-shadow: var(--shadow); }
.rotate-card svg { width: 54px; height: 54px; margin: 0 auto 12px; color: var(--gold); }
.rotate-card h2 { font-size: 24px; margin-bottom: 8px; }
.rotate-card p { color: var(--muted); font-size: 13px; }
.rotate-actions { margin-top: 16px; }
.rotate-actions .btn { width: 100%; }

/* ---------- app toasts & story ---------- */
.app-toasts {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.app-toasts .game-toast { animation: toast-life 2.2s ease forwards; }
.story-modal { max-width: 560px; }
.story-lead {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--gold-2);
  margin: 0 0 14px;
  letter-spacing: 0.03em;
}
.story-line {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  margin: 0 0 10px;
  color: var(--parchment-dim);
  font-size: 14px;
  line-height: 1.55;
}
.story-line span {
  color: var(--gold-3);
  font-family: var(--font-display);
  font-size: 12px;
  padding-top: 2px;
}
.story-modal .modal-actions { margin-top: 18px; justify-content: flex-end; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .page-head { grid-template-columns: 90px 1fr auto; }
  .hero-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero-card { min-height: 500px; }
  .camp-layout { grid-template-columns: 280px minmax(0, 1fr); }
  .hud-top { grid-template-columns: minmax(160px, 260px) 1fr auto; }
}
@media (max-width: 860px) {
  .page-head { grid-template-columns: 1fr auto; gap: 10px; padding-top: 2px; }
  .page-head-copy { grid-column: 1 / -1; grid-row: 2; }
  .page-head-copy h1 { font-size: clamp(28px, 7vw, 40px); }
  .page-head-side { grid-column: 2; grid-row: 1; }
  .btn-back { grid-column: 1; grid-row: 1; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-card { min-height: 0; }
  .hero-card-top { flex-direction: row; justify-content: flex-start; gap: 16px; text-align: left; padding: 18px; }
  .hero-portrait-stage { width: 92px; height: 92px; margin: 0; flex: 0 0 auto; }
  .hero-portrait-stage img { width: 58px; height: 58px; }
  .hero-card-body { padding: 14px 18px 18px; gap: 10px; }
  .hero-blurb { min-height: 0; }
  .camp-layout { grid-template-columns: 1fr; }
  .hero-panel { position: relative; top: 0; display: grid; grid-template-columns: 150px 1fr; }
  .hero-panel-art { height: auto; min-height: 150px; border-bottom: 0; border-right: 1px solid var(--line-soft); }
  .hero-panel-art::before { inset: 14px 24px; }
  .hero-panel-art img { width: 76px; height: 76px; }
  .hero-panel-info { padding: 15px 18px; }
  .hero-panel-bars { grid-template-columns: 1fr; margin: 12px 0; }
  .forge-grid { grid-template-columns: 1fr; }
  .journal-grid { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: 1fr; }
  .result-stats { grid-template-columns: repeat(2, 1fr); gap: 0; }
  .result-stat:nth-child(2) { border-right: 0; }
  .result-stat:nth-child(3), .result-stat:nth-child(4) { border-top: 1px solid rgba(237, 220, 184, 0.07); padding-top: 12px; }
  .codex-hero-grid { grid-template-columns: 1fr; }
  .codex-controls { grid-template-columns: 1fr; padding: 14px; }
  .hud-top { grid-template-columns: 1fr auto; gap: 8px; }
  .hud-objective { grid-column: 1 / -1; grid-row: 2; padding-top: 5px; }
  .hud-actions { grid-column: 2; grid-row: 1; }
  .hud-hero { grid-column: 1; grid-row: 1; max-width: 56vw; }
  .hud-name-row > span:first-child { font-size: 12px; }
  .hud-objective-sub { display: none; }
  .hotkey-bar { display: none; }
  .skill-widget { bottom: calc(10px + var(--safe-b)); right: calc(14px + var(--safe-r)); }
  .title-cast { gap: 22px; }
}
@media (max-width: 620px) {
  .page-shell { padding-left: 14px; padding-right: 14px; }
  .title-top-note { display: none; }
  .title-footer { font-size: 10px; flex-direction: column; gap: 4px; text-align: center; }
  .title-content { padding-top: 0; }
  .game-title { letter-spacing: 0.1em; padding-left: 0.1em; }
  .title-cast { display: none; }
  .title-menu { margin-top: 24px; }
  .camp-top { gap: 10px; }
  .camp-brand span { display: none; }
  .camp-resources { margin-left: 0; order: 3; width: 100%; }
  .camp-top-actions { margin-left: auto; }
  .material-strip { gap: 4px; }
  .material-chip { height: 26px; font-size: 10px; }
  .hero-panel { grid-template-columns: 110px 1fr; }
  .hero-panel-art { min-height: 132px; }
  .hero-panel-art img { width: 60px; height: 60px; }
  .hero-panel-name { font-size: 19px; }
  .tab { padding: 11px 10px 13px; font-size: 11px; }
  .tab svg { width: 15px; height: 15px; }
  .map-grid { grid-template-columns: 1fr; }
  .map-thumb { height: 128px; }
  .pause-actions { grid-template-columns: 1fr; }
  .pause-actions .btn-primary { grid-column: auto; }
  .modal { max-height: 92dvh; }
  .modal-head { padding: 14px 16px 12px; }
  .modal-body { padding: 14px 16px 18px; }
  .setting-row { align-items: flex-start; flex-direction: column; gap: 8px; }
  input[type="range"] { width: 100%; }
  .setting-control { width: 100%; }
  .results-shell { padding-top: 18px; }
  .result-stats { grid-template-columns: repeat(2, 1fr); }
  .loot-list { gap: 5px; }
  .hud { padding-left: calc(8px + var(--safe-l)); padding-right: calc(8px + var(--safe-r)); }
  .hud-portrait { width: 38px; height: 38px; }
  .hud .meter-text { font-size: 8px; }
  .boss-hud { width: 78%; top: 74px; }
  .map-intro h2 { font-size: 30px; }
  .interact-prompt { bottom: calc(64px + var(--safe-b)); font-size: 10px; }
  .skill-widget { display: none; }
  .title-moon { opacity: 0.24; }
}
@media (max-height: 600px) and (orientation: landscape) {
  .page-shell { padding-top: 10px; padding-bottom: 12px; }
  .page-head { padding-bottom: 14px; }
  .page-head-copy h1 { font-size: 28px; }
  .page-head-copy .page-sub { display: none; }
  .camp-top { padding-bottom: 8px; }
  .camp-layout { padding-top: 12px; gap: 14px; }
  .hero-panel-art { height: 130px; }
  .hero-panel-art img { width: 72px; height: 72px; }
  .hero-panel-info { padding: 12px 14px; }
  .hero-panel-bars { margin: 9px 0; }
  .hero-panel-gear { padding-top: 9px; gap: 5px; }
  .title-content { padding-top: 0; }
  .game-title { font-size: clamp(40px, 9vh, 72px); }
  .title-lead { font-size: 12px; }
  .title-menu { margin-top: 14px; gap: 6px; }
  .btn-hero { min-height: 50px; }
  .title-cast { display: none; }
  .title-footer { padding-top: 4px; padding-bottom: 6px; }
  .tab-bar { margin-bottom: 12px; }
  .results-banner { padding: 6px 0 14px; }
  .results-banner h1 { font-size: 38px; }
}
@media (pointer: coarse) {
  .hotkey-bar { display: none; }
  .skill-widget { display: none; }
  .hud-round-btn { width: 38px; height: 38px; }
}
.touch-mode .hotkey-bar,
.touch-mode .skill-widget { display: none; }

/* Portrait fallback: keep the 16:9 stage, but move HUD and thumbs into
   the letterbox so the world is not buried under the controls. */
@media (orientation: portrait) {
  .touch-mode .hud {
    left: 0; top: 0;
    width: 100vw;
    height: 100dvh;
    transform: none;
    padding-top: calc(10px + var(--safe-t));
  }
  .touch-mode .stage-vignette {
    left: 0; top: 0;
    width: 100vw;
    height: 100dvh;
    transform: none;
    background: radial-gradient(ellipse at center, transparent 42%, rgba(2, 2, 6, 0.35) 100%);
  }
  .touch-mode .touch-controls {
    padding-bottom: calc(12px + var(--safe-b));
  }
  .touch-mode .interact-prompt {
    bottom: calc(50% - 28.125vw + 10px);
  }
  .touch-mode .boss-hud {
    top: 19vh;
    width: min(520px, 92%);
  }
}
@media (hover: none) {
  .btn:hover { transform: none; }
  .hero-card:hover { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* custom scrollbar */
.screen-page::-webkit-scrollbar, .modal-body::-webkit-scrollbar { width: 10px; }
.screen-page::-webkit-scrollbar-track, .modal-body::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.02); }
.screen-page::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb { background: rgba(221, 167, 75, 0.2); border-radius: 6px; border: 2px solid #0d0a12; }
