:root {
  --bg: #0d0f13;
  --panel: #141821;
  --panel-2: #0f1219;
  --text: #e9f0ff;
  --muted: #99a3b8;
  --accent: #f1b432; /* golden */
  --accent-2: #ffd36e;
  --danger: #e05d5d;
  --success: #3bd27f;
  /* pickaxe tip position inside the Kirka image (percent of its width/height) */
  /* --kirka-tip-x: 75%;
  --kirka-tip-y: 55%; */
  /* spine spark anchor as normalized (0..1) inside #spine-player */
/*  --spark-tip-x: 0.64;
  --spark-tip-y: 0.62; */
  --spark-tip-x: 0.90;
  --spark-tip-y: 0.55;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg) url('./background.png?v=dev7') center / cover no-repeat;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

/* Mobile: prevent text selection, callout, overscroll, and unintended gestures */
html, body, #app {
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

/* Disable scroll/gesture on main interactive area */
.game-area, .mine-center, .digger, #spine-player {
  touch-action: none;
}

#app { overflow: hidden; min-height: 100vh; display: flex; flex-direction: column; }

#loading-screen { position: fixed; inset: 0; background: rgb(13,15,19); display: grid; place-items: center; z-index: 1000; }
.loader { width: 48px; height: 48px; border-radius: 50%; border: 4px solid rgba(255,255,255,.15); border-top-color: var(--accent-2); animation: spin 0.9s linear infinite; }
/* spin keyframes are also inlined in index.html so the loading-screen
   spinner spins before styles.css has finished loading. Duplicating here
   is fine — browsers de-dupe identical @keyframes definitions. */
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Topbar (Figma-aligned) ─────────────────────────────────────────────
   Three groups, separated by `justify-content: space-between`:
     [avatar-pill]   [Roulette + coin]   [settings-square]
   Each group is its own dark card with a subtle gold border so the layout
   reads as three balanced chips, matching the reference. */
/* ── Top bar (Figma-accurate, Jun 2026) ────────────────────────────────
   The Figma source uses THREE separate translucent-black "glass" pieces
   (avatar pill | center pill housing Roulette+Balance | settings square)
   over the cave background. Each piece: rgba(0,0,0,0.75) + 4.5px
   backdrop-blur, rounded 10px (NOT pill-shaped). All chrome buttons
   inside the bar are 36px tall pills with rounded 10px corners, and
   the gold gradient uses the exact -13deg axis from Figma so the
   highlight sits on the upper-left edge. */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 10px 10px 10px;
  font-family: 'Montserrat', ui-sans-serif, system-ui, sans-serif;
  background: linear-gradient(180deg, rgba(10,12,18,.65), rgba(10,12,18,.30) 70%, transparent);
  position: sticky;
  top: 0;
  z-index: 10;
}
.tb-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,0.75);
  -webkit-backdrop-filter: blur(4.5px);
  backdrop-filter: blur(4.5px);
  border: 0;
  border-radius: 10px;
  height: 52px;
  padding: 0 10px 0 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.45);
}
.tb-avatar-pill {
  /* Avatar (36×36) + chevron, with tight 8px left padding. The chevron
   * is intentionally tucked BEHIND the avatar's right edge (Figma
   * stacking order: avatar tile sits on top of the gold chevron card),
   * so we kill the flex gap here and add a negative margin on the
   * chevron below to pull it under the avatar. */
  gap: 0;
  padding-right: 6px;
}
.tb-avatar-pill .avatar-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: #2b2b2b;
  border: 0; padding: 0;
  overflow: hidden;
  display: grid; place-items: center;
  cursor: pointer;
  position: relative;
  z-index: 2;          /* sits on top of the chevron */
}
.tb-avatar-pill .avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
/* Chevron next to the avatar — Figma uses a small gold-cream rounded
 * rect (39×36, r=10, fill #D8AD71) with a dark arrow inside (7×12,
 * #03080B). We reuse the existing SVGs verbatim so the proportions
 * and the rounded "10px on a 39px box" radius land exactly as in
 * the design. */
.tb-avatar-chev {
  display: inline-grid;
  place-items: center;
  width: 39px;
  height: 36px;
  background: url("./assets/navicons/Rectangle%2079.svg?v=dev8") center / 100% 100% no-repeat;
  padding: 0;
  /* Pull the chevron LEFT so its left edge slides under the avatar
   * tile (~14px overlap, matching the Figma reference). The arrow
   * itself stays right-aligned within the gold rect so it visually
   * sticks out past the avatar. */
  margin-left: -14px;
  padding-left: 18px;          /* re-centres the arrow within the visible (non-overlapped) area */
  box-sizing: border-box;
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.35));
}
.tb-avatar-chev-arrow {
  display: block;
  width: 7px;
  height: 12px;
  pointer-events: none;
}

.tb-center {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.75);
  -webkit-backdrop-filter: blur(4.5px);
  backdrop-filter: blur(4.5px);
  border: 0;
  border-radius: 10px;
  height: 52px;
  padding: 0 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,.45);
  min-width: 0;
}
/* "Roulette" CTA: solid gold gradient pill with crisp white-gold border
   and BLACK text (Figma: Montserrat Medium 12). */
.roulette-btn {
  background: linear-gradient(-13.23deg, #e9bf7d 19.72%, #91603c 91.38%);
  color: #1a1004;
  border: 1px solid #f8e6a2;
  border-radius: 10px;
  height: 36px;
  padding: 0 16px;
  font-family: inherit;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: .1px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.30), 0 1px 2px rgba(0,0,0,.35);
}
.roulette-btn.hidden { display: none; }
/* Coin balance pill (the "0" next to the Roulette CTA): transparent fill
   over the dark glass, thin gold hairline border, white Regular 12. */
.gb-balance {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit;
  font-weight: 400; font-size: 12px;
  height: 36px;
  padding: 0 12px 0 8px;
  background: transparent;
  border-radius: 10px;
  border: 0.5px solid #e0b577;
  cursor: pointer;
  white-space: nowrap;
  color: #fff;
}
.gb-balance .icon { width: 22px; height: 22px; }

/* Settings: 52×52 square glass tile matching the avatar pill height. */
.settings-btn {
  width: 52px; height: 52px;
  display: inline-grid; place-items: center;
  background: rgba(0,0,0,0.75);
  -webkit-backdrop-filter: blur(4.5px);
  backdrop-filter: blur(4.5px);
  border: 0;
  border-radius: 10px;
  color: #d6aa66;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.45);
}

/* legacy helpers kept for code that may still reference them */
.left-group, .right-group { display: none; }
.username { display: none; }

/* ── Resource row (Figma-accurate, Jun 2026) ──────────────────────────
   Layout in the Figma reference (375px frame):
     Balance card: left 20, w=194, h=82, dark glass
     Boost card  : left 222, w=43, h=82, dark glass (vertical, with
                   character at the bottom and a 6px-wide thermometer
                   spanning the right edge)
     Level ring  : left 273, w=82, h=82, NO card chrome — just the ring
   All cards: rgba(0,0,0,0.75) + 4.5px backdrop-blur, rounded 10px,
   NO border, soft drop-shadow. Typography: Montserrat. */
.resource-row {
  display: flex;
  gap: 8px;
  padding: 6px 10px 8px;
  align-items: stretch;
  font-family: 'Montserrat', ui-sans-serif, system-ui, sans-serif;
}
.rc-card {
  background: rgba(0, 0, 0, 0.75);
  -webkit-backdrop-filter: blur(4.5px);
  backdrop-filter: blur(4.5px);
  border: none;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.45);
  min-width: 0;
  position: relative;
  overflow: hidden;
}

/* ── Balance card (Figma: 194×82) ──────────────────────────────────
   Single inline row: nugget icon | big white "100" | muted "(+0 GN/hr)"
   The number is Montserrat Regular 30 in Figma (not bold). */
.rc-balance {
  flex: 1 1 0;
  height: 82px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
}
.rc-balance-icon {
  width: 36px; height: 36px;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
}
.rc-balance-value {
  font-family: inherit;
  font-weight: 400;
  font-size: clamp(24px, 7.6vw, 30px);
  color: #fff;
  line-height: 1;
  letter-spacing: -0.2px;
}
.rc-balance-sub {
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  color: rgba(255,255,255,0.35);
  white-space: nowrap;
  line-height: 1;
}

/* ── Boost card (Figma: 43×82) ─────────────────────────────────────
   Vertical: BOOST + 100% stacked at the top, character image fills the
   lower half, and a thin vertical thermometer track sits on the right
   inner edge (6px wide). */
.rc-boost {
  flex: 0 0 56px;
  height: 82px;
  padding: 6px 12px 0 6px;        /* right padding reserves the thermo lane */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.rc-boost-head {
  display: flex; flex-direction: column;
  align-items: flex-start;
  line-height: 1;
  gap: 2px;
  z-index: 2;
}
.rc-boost-label {
  font-family: inherit;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: .4px;
  color: #f5d99a;
  text-shadow: 0 1px 1px rgba(0,0,0,.6);
}
.rc-boost-value {
  font-family: inherit;
  font-size: 8px;
  font-weight: 500;
  color: #fff;
}
.rc-boost-portrait {
  position: absolute;
  left: 0;
  right: 6px;                     /* reserve the thermo lane on the right */
  bottom: 0;
  width: auto;
  max-width: calc(100% - 6px);
  height: 60%;
  object-fit: cover;
  object-position: center top;
  pointer-events: none;
  border-bottom-left-radius: 10px;
}
.rc-boost-thermo {
  position: absolute;
  top: 6px;
  right: 4px;
  bottom: 6px;
  width: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  border: 0.5px solid rgba(214,170,102,.6);
  overflow: hidden;
  z-index: 3;
}
.rc-boost-thermo-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 100%;
  /* Figma exact gradient: 73° axis, light gold → bronze. */
  background: linear-gradient(73.45deg, #d6aa66 0%, #91603c 100%);
  border-radius: 999px;
  transition: height .35s ease;
}

/* ── Level ring (Figma: 82×82, ring only) ─────────────────────────
   No card background — pure ring on the cave bg. Stroke uses the warm
   gold gradient; XP text is gold (#d3a764), the "Level N" line is
   white. */
.rc-level {
  flex: 0 0 auto;
  width: 82px;
  height: 82px;
  align-self: center;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 50%;
  overflow: visible;
}
.rc-level-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.rc-level-ring-track,
.rc-level-ring-fill {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
}
.rc-level-ring-track { stroke: rgba(214,170,102,.22); }
.rc-level-ring-fill  {
  stroke: url(#rcLevelGradient);
  stroke-dasharray: 169.65;       /* 2 * π * 27 — matches the SVG circle radius */
  stroke-dashoffset: 169.65;
  transition: stroke-dashoffset .35s ease;
  filter: drop-shadow(0 0 4px rgba(232,178,90,.45));
}
@supports not (stroke: url(#x)) { .rc-level-ring-fill { stroke: #d6aa66; } }
.rc-level-text {
  position: relative;
  text-align: center;
  line-height: 1.05;
  font-family: 'Montserrat', ui-sans-serif, system-ui, sans-serif;
}
.rc-level-xp {
  font-weight: 400;
  font-size: 12px;
  color: #d3a764;                 /* Figma exact */
  letter-spacing: 0;
}
.rc-level-title {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 400;
  color: #fff;
  letter-spacing: 0;
}

.game-area { overflow: hidden; flex: 1; display: block; padding: 4px 10px 84px 10px; }

.mine-center { position: relative; display: flex; align-items: center; justify-content: center; overflow: visible; z-index: 2; }
.digger { position: relative; width: clamp(360px, 72vw, 820px); max-width: 96vw; aspect-ratio: 1/1; display: grid; place-items: end center; z-index: 1; }
.mine-center { padding-right: 10px; }

/* Spine player container sits where dwarf was */
/* Spine host. Mobile-first: the game targets phones only, so these are the
   primary values (no desktop breakpoint).
   - 100svh: the stable "small viewport" height. Safari 15.4+, Chrome 108+
     and Firefox 110+ support it; it doesn't fluctuate when iOS Safari shows
     or hides the toolbar, so the SpinePlayer canvas keeps a constant size
     and the character never visibly resizes mid-tap.
   - 100vh: fallback for ancient browsers (only kicks in if svh isn't
     supported — caveat: iOS Safari < 15.4 measures 100vh as the LARGEST
     viewport, including the hidden toolbar, which is why we prefer svh).
   - transform-origin: 50% 100% pivots the scale on the character's feet so
     they stay glued to the same ground line as we scale.
   - --spine-offset-y is positive → translateY pushes the host DOWN
     (further grounds the character). Bigger value = character sits lower
     on screen. */
#spine-player {
  position: fixed; left: 0; right: 0; top: 0; bottom: 0;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  transform-origin: 50% 100%;
  -webkit-transform-origin: 50% 100%;
  /* Default values target Android Chrome — Android viewports are taller
     than iOS at the same physical width, so the same `vh` values land
     differently. We tune for Android here and override for iOS Safari
     below via @supports.
     Bigger --spine-scale = bigger character.
     Smaller positive --spine-offset-y = character sits higher (less
     downward translate). */
  --spine-scale: 1.4;
  --spine-shift: 0;
  --spine-offset-y: 4vh;
  transform: translateX(var(--spine-shift)) translateY(var(--spine-offset-y)) scale(var(--spine-scale));
  -webkit-transform: translateX(var(--spine-shift)) translateY(var(--spine-offset-y)) scale(var(--spine-scale));
  will-change: transform;
  z-index: 1; pointer-events: none;
}
/* Android. Mind the CSS width of each device class — Android viewports are
   typically taller and slightly narrower than iOS, so we need more granular
   breakpoints to keep framing consistent across the ecosystem:
     >480px  : large phones / phablets / Android tablets (rare for this game)
     ≤480px : Pixel 6/7 Pro, Galaxy S22 Ultra, large Mi (≈411-440px)
     ≤420px : the "compact flagship" tier — Xiaomi Mi 11, Pixel 7, Galaxy
              S22, OnePlus 9, Nothing Phone (all 393-414px wide). Same
              physical size class as iPhone 14/15/16, so we tone down the
              scale and push further down to look right.
     ≤380px : older / mini Androids (Galaxy S20, Pixel 4a — ≤360px) */
@media (max-width: 480px) { #spine-player { --spine-scale: 1.2;  --spine-offset-y: 4vh; } }
@media (max-width: 420px) { #spine-player { --spine-scale: 1.0;  --spine-offset-y: 9vh; } }
@media (max-width: 380px) { #spine-player { --spine-scale: 0.9;  --spine-offset-y: 8vh; } }

/* iOS Safari override. `@supports (-webkit-touch-callout: none)` is a
   reliable iOS-only feature query (no other browser ships that property).
   iOS viewports are shorter & more square, so the character needs less
   upscaling and more downward push to ground correctly.
   Breakpoints (mind the CSS width of each device):
     >480px   : iPhone XS Max-class (no longer common, fallback)
     ≤480px  : iPhone 14/15/16 Plus & Pro Max (430px)
     ≤420px  : iPhone 14/15/16 (393–402px), iPhone 16 Pro (402px) — shorter
              viewports, so needs less downward push to look right
     ≤380px  : iPhone SE / mini-class (375px) — even tighter framing */
@supports (-webkit-touch-callout: none) {
  #spine-player { --spine-scale: 0.95; --spine-offset-y: 14vh; }
  @media (max-width: 480px) { #spine-player { --spine-scale: 0.85; --spine-offset-y: 12vh; } }
  @media (max-width: 420px) { #spine-player { --spine-scale: 0.85; --spine-offset-y: 8vh;  } }
  @media (max-width: 380px) { #spine-player { --spine-scale: 0.75; --spine-offset-y: 10vh; } }
}

/* Hide legacy balance pill — value is now rendered inside the new resource row. */
.balance-over { display: none !important; }

/* removed separate rotor-compress to avoid transform override */

.gold-mound { position: fixed; top: max(20px, env(safe-area-inset-top)); right: 0; height: calc(100svh - max(20px, env(safe-area-inset-top))); width: min(52vw, 640px); background: url('./Stone.png?v=dev7') right center / cover no-repeat; filter: drop-shadow(0 10px 20px rgba(0,0,0,.55)); pointer-events: none; z-index: 0; }
.tap-helper { position: absolute; bottom: -6px; font-size: 12px; color: var(--muted); }

/* ── Bottom HUD bar (Figma-accurate, Jun 2026) ────────────────────────
   Layout: glass-black Energy card on the left (230×38) with a thin
   #be925b track + #be925b solid fill, and a gold-gradient Upgrades
   pill on the right (97×38) with a 1px #f8e6a2 border and BLACK
   Montserrat Medium 12 text. */
.hud-bar {
  position: fixed;
  left: 10px; right: 10px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 5;
  display: flex; align-items: center; gap: 10px;
  font-family: 'Montserrat', ui-sans-serif, system-ui, sans-serif;
}
.hud-bar .energy {
  flex: 1 1 auto;
  height: 38px;
  background: rgba(0, 0, 0, 0.75);
  -webkit-backdrop-filter: blur(4.5px);
  backdrop-filter: blur(4.5px);
  border: none;
  border-radius: 10px;
  padding: 6px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.45);
}
.hud-bar .fab {
  flex: 0 0 auto;
}
.energy-row {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 300; font-size: 12px;
  margin-bottom: 0;
  color: #fff;
}
.energy-label {
  display: inline-flex; align-items: center; gap: 8px;
  color: #fff;
  font-family: inherit;
  font-weight: 300;
  font-size: 12px;
}
.energy-bolt {
  color: #be925b;
  width: 15px; height: 13px;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 2px rgba(190,146,91,.5));
}
.energy-count {
  color: #fff;
  font-family: inherit;
  font-weight: 300;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.energy-bar {
  height: 6px;
  background: transparent;
  border: 0.5px solid #be925b;
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}
.energy-fill {
  height: 100%;
  background: #be925b;
  transition: width .25s ease;
  position: relative;
  border-radius: 5px;
}
/* subtle glow at the decreasing edge */
.energy-fill::after { content: ""; position: absolute; top: 0; bottom: 0; right: -3px; width: 36px; pointer-events: none; opacity: 0; background: radial-gradient(closest-side, rgba(255,255,240,1) 0%, rgba(255,242,200,.95) 50%, rgba(255,230,150,0) 78%); filter: blur(4px); mix-blend-mode: screen; box-shadow: 0 0 16px rgba(255,242,200,.85), 0 0 28px rgba(255,236,170,.55); }
.energy-fill.flicker::after { animation: energyFlicker 560ms ease-out forwards; }
@keyframes energyFlicker { 0% { opacity: 1; transform: translateX(0) scaleX(1.05); } 18% { opacity: .9; transform: translateX(2px) scaleX(1.15); } 44% { opacity: .65; transform: translateX(0) scaleX(1.04); } 76% { opacity: .4; transform: translateX(0) scaleX(1); } 100% { opacity: 0; transform: translateX(0) scaleX(1); } }

/* sharp white spike for extra visibility */
.energy-fill::before { content: ""; position: absolute; top: 0; bottom: 0; right: -1px; width: 8px; background: linear-gradient(90deg, rgba(255,255,255,1), rgba(255,255,255,0)); opacity: 0; pointer-events: none; mix-blend-mode: screen; filter: blur(0.5px); }
.energy-fill.flicker::before { animation: energySpike 220ms ease-out forwards; }
@keyframes energySpike { 0% { opacity: 1; transform: translateX(0); } 60% { opacity: .12; transform: translateX(1px); } 100% { opacity: 0; transform: translateX(0); } }

/* New approach: overlay glow positioned at the edge of the bar (parent) */
.energy-bar::after { content: ""; position: absolute; top: -6px; bottom: -6px; left: var(--energy-pct, 0%); transform: translateX(-50%); width: 42px; pointer-events: none; opacity: 0; background: radial-gradient(circle, rgba(255,255,255,1) 0%, rgba(255,246,210,.95) 38%, rgba(255,236,170,.6) 52%, rgba(255,220,120,0) 76%); filter: blur(4px); mix-blend-mode: screen; box-shadow: 0 0 18px rgba(255,246,210,.9), 0 0 34px rgba(255,236,170,.6); }
.energy-bar.flicker::after { animation: energyEdgePulse 580ms ease-out forwards; }
@keyframes energyEdgePulse { 0% { opacity: 1; transform: translateX(-50%) scaleX(1.1); } 22% { opacity: .9; transform: translateX(calc(-50% + 2px)) scaleX(1.2); } 48% { opacity: .7; transform: translateX(-50%) scaleX(1.06); } 76% { opacity: .42; transform: translateX(-50%) scaleX(1); } 100% { opacity: 0; transform: translateX(-50%) scaleX(1); }
}

/* legacy wrapper hidden — .fab now lives inside .hud-bar */
.hud-bottom-right, .hud-bottom-left { display: none !important; }
/* "Upgrades" CTA — mirrors the Roulette pill (gold gradient with the
   exact -11.71° axis from Figma, 1px #f8e6a2 border, BLACK text). */
.fab {
  background: linear-gradient(-11.71deg, #e9bf7d 19.72%, #91603c 91.38%);
  color: #1a1004;
  border: 1px solid #f8e6a2;
  border-radius: 10px;
  height: 38px;
  padding: 0 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.30), 0 2px 6px rgba(0,0,0,.35);
  font-family: 'Montserrat', ui-sans-serif, system-ui, sans-serif;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: .1px;
  cursor: pointer;
  text-shadow: none;
}
.fab:active {
  transform: translateY(1px);
  box-shadow:
    0 1px 4px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.35);
}

/* ── Bottom navigation (Figma-accurate, Jun 2026) ─────────────────────
   Container: 335×52 glass-black pill (rgba(0,0,0,0.75) + 4.5px blur,
   10px corner radius). Five tabs separated by hair-thin 0.5px #281e13
   vertical dividers. Icons are flat #be925b (~16px tall) sitting near
   the top edge; labels are Montserrat Light 11px white sitting near
   the bottom edge. */
.bottom-nav {
  position: fixed;
  left: 10px; right: 10px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  height: 52px;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(0, 0, 0, 0.75);
  -webkit-backdrop-filter: blur(4.5px);
  backdrop-filter: blur(4.5px);
  border: 0;
  border-radius: 10px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,.55);
  overflow: hidden;
  font-family: 'Montserrat', ui-sans-serif, system-ui, sans-serif;
}
.nav-btn {
  position: relative;
  background: transparent;
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 11px;
  font-weight: 300;
  display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  text-align: center;
  cursor: pointer;
  transition: background .15s ease;
  padding: 7px 2px 8px;
}
/* Hair-thin dividers between tabs, matching Figma's 0.5px #281e13
 * lines at x = 80, 146, 217, 283 (relative to the bar's interior). */
.nav-btn + .nav-btn::before {
  content: "";
  position: absolute;
  left: 0; top: 7px; bottom: 7px;
  width: 0.5px;
  background: #281e13;
}
.nav-btn:active { background: rgba(190,146,91,.10); }
.nav-icon {
  /* Each SVG ships with its own #BE925B fill baked in and a Figma-
   * matched intrinsic aspect ratio (≈12×16 for most, ≈18×16 for
   * battles, ≈10×14 for friends). We constrain the box height so
   * every icon lines up on the same baseline and let width auto-
   * scale to the SVG's aspect ratio. */
  width: auto; height: 16px;
  max-width: 22px;
  flex: 0 0 auto;
  display: block;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.5));
}
.nav-label {
  line-height: 1;
  letter-spacing: 0;
  font-weight: 300;
  font-size: 11px;
  color: #fff;
}

.overlay { position: fixed; inset: 0; backdrop-filter: blur(6px); background: rgba(5,7,10,.55); display: grid; place-items: end center; padding: 12px; z-index: 30; }
.overlay.hidden { display: none; }
.panel { width: 100%; max-width: 520px; background: #141a24; border: 1px solid rgba(255,255,255,0.08); border-radius: 16px 16px 0 0; padding: 12px; max-height: 86vh; overflow: auto; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 8px; position: sticky; top: 0; background: linear-gradient(180deg, rgba(20,26,36,1), rgba(20,26,36,.75)); z-index: 1; }
.panel h3 { margin: 0; }
.close { background: transparent; color: var(--text); border: 0; font-size: 18px; cursor: pointer; }
.panel-body { padding: 10px 4px 18px; }
.mb-8 { margin-bottom: 8px; }
.result { margin-top: 10px; font-weight: 800; }

/* Cards */
.cards-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.cards-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(160px, 44vw); gap: 12px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; scroll-snap-type: x mandatory; }
.cards-row .card-wrap { scroll-snap-align: start; display: grid; gap: 6px; }
.card { position: relative; background: #181f2b; border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; overflow: hidden; }
.card img { width: 100%; height: auto; display: block; }
.card .title-overlay { position: absolute; left: 50%; bottom: 5vh; transform: translateX(-50%); color: #c7a248; padding: 4px 8px; border-radius: 999px; font-weight: 900; font-size: 12px; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }

/* Framed cards: gold ornamental backdrop (empty.png) holds the artwork. */
.card.framed { background: #0c0f15 url('./assets/cards/empty.png') center / 100% 100% no-repeat; border: 0; aspect-ratio: 727 / 1010; }
.card.framed img { position: absolute; left: 14%; top: 11%; width: 72%; height: 78%; object-fit: contain; background: transparent; filter: drop-shadow(0 6px 14px rgba(0,0,0,.55)); }
.card.framed .title-overlay { bottom: 4%; background: rgba(0,0,0,.55); color: #ffd36e; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
.cards-row .desc { color: var(--muted); font-size: 12px; text-align: center; }

/* Stage sections — one per progression tier inside the Cards panel.
   Each section has its own header strip with the stage number/name and
   an "unlocked / unlocks at Lvl N" status pill, and a horizontally
   scrolling row of cards underneath. */
.cards-stage { margin: 0 0 20px; }
.cards-stage + .cards-stage { margin-top: 16px; padding-top: 14px; border-top: 1px dashed rgba(255,211,110,0.18); }
.cards-stage.locked { opacity: 0.78; }
.cards-stage-head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin: 0 0 8px;
  padding: 0 2px;
}
.cards-stage-num {
  font-size: 11px; font-weight: 900; letter-spacing: 0.6px;
  color: #ffd36e; text-transform: uppercase;
  background: rgba(255,211,110,0.10);
  border: 1px solid rgba(255,211,110,0.32);
  padding: 3px 8px; border-radius: 999px;
}
.cards-stage-name { font-size: 14px; font-weight: 800; color: #fff; letter-spacing: 0.2px; }
.cards-stage-req {
  margin-left: auto;
  font-size: 11px; font-weight: 700;
  color: rgba(255,255,255,0.55);
}
.cards-stage.locked .cards-stage-req { color: #ffa44a; }

/* Locked card tile state — desaturated artwork with a lock badge overlay. */
.card-wrap.locked .card img { filter: grayscale(0.85) brightness(0.65); }
.card-wrap.locked .card .title-overlay { color: rgba(255,255,255,0.55); }
.card-lock {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  background: rgba(8,12,20,0.55);
  color: #ffd36e;
  font-weight: 900; font-size: 12px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  pointer-events: none;
}
.card-lock svg { filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6)); }

/* Owned-level chip in the top-right corner of the card thumb. */
.card-owned-tag {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.65);
  color: #6bff8e;
  border: 1px solid rgba(107,255,142,0.35);
  border-radius: 999px;
  padding: 2px 7px;
  font-weight: 900; font-size: 10px;
  letter-spacing: 0.4px;
  pointer-events: none;
}

/* Card detail locked notice — replaces the buy/upgrade controls. */
.card-detail .hero.locked img { filter: grayscale(0.85) brightness(0.65); }
.card-locked-notice {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: rgba(255,211,110,0.08);
  border: 1px solid rgba(255,211,110,0.32);
  border-radius: 14px;
  color: #ffd36e;
}
.card-locked-title { font-weight: 900; font-size: 16px; color: #fff; }
.card-locked-sub   { font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.75); margin-top: 2px; }
.card-locked-sub small { color: rgba(255,211,110,0.85); }

/* Card detail fullscreen panel */
.panel.card-full { width: 94vw; max-width: 94vw; height: 88vh; max-height: 88vh; display: grid; grid-template-rows: auto 1fr; }
.card-detail { height: 100%; display: grid; grid-template-rows: 1fr auto; gap: 12px; perspective: 1000px; }
.card-detail .hero { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid rgba(255,255,255,0.08); transform-style: preserve-3d; animation: flipIn .5s cubic-bezier(.2,.7,.2,1) both; }
.card-detail .hero img { width: 100%; height: 100%; object-fit: contain; background: #0f1219; }
.card-detail .hero.framed { background: #0c0f15 url('./assets/cards/empty.png') center / contain no-repeat; border: 0; }
.card-detail .hero.framed img { background: transparent; padding: 7% 12% 11%; box-sizing: border-box; }
.card-stats { display: flex; justify-content: space-between; gap: 10px; font-weight: 800; }
.card-detail .hero .title-overlay-detail { position: absolute; left: 50%; bottom: 20vh; transform: translateX(-50%); color: #c7a248; padding: 6px 10px; border-radius: 999px; font-weight: 900; font-size: 20pt; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }
.card-detail .hero .overlay-stats { position: absolute; left: 50%; bottom: 10vh; transform: translateX(-50%); display: grid; gap: 6px; text-align: center; width: auto; max-width: 90%; }
.card-detail .hero .overlay-stats .chip { background: #141a24; color: #c7a248; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 800; }
.card-detail .hero .level-badge { position: absolute; left: 10px; top: 10px; background: rgba(0,0,0,.6); color: #ffd36e; border: 1px solid rgba(255,255,255,0.18); border-radius: 999px; padding: 4px 8px; font-weight: 900; font-size: 12px; }
.card-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-items: stretch; }
.card-actions .btn { padding: 10px 8px; border-radius: 12px; font-weight: 900; font-size: 12px; border: 1px solid rgba(255,255,255,0.12); cursor: pointer; text-align: center; }
.card-actions .btn.primary { background: var(--success); color: #05140e; border: 0; }
.card-actions .btn.secondary { background: var(--accent); color: #272211; border: 0; }
.card-actions .btn.outline { background: transparent; color: var(--text); }

@keyframes flipIn {
  0% { transform: rotateY(90deg); opacity: 0; }
  60% { transform: rotateY(-8deg); opacity: 1; }
  100% { transform: rotateY(0deg); opacity: 1; }
}

.upgrade-list { display: grid; gap: 10px; padding: 10px 4px 18px; }
.upgrade-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #181f2b; border: 1px solid rgba(255,255,255,0.06); border-radius: 12px; padding: 12px; }
.upgrade-item .meta { display: grid; }
.upgrade-item .title { font-weight: 800; }
.upgrade-item .desc { color: var(--muted); font-size: 12px; }
.upgrade-item button { background: var(--accent); color: #222; border: 0; border-radius: 12px; padding: 8px 12px; font-weight: 900; }
.upgrade-item button:disabled { opacity: .5; }

.primary { background: var(--success); color: #05140e; border: 0; border-radius: 12px; padding: 10px 14px; font-weight: 900; }
.secondary { background: var(--accent); color: #272211; border: 0; border-radius: 12px; padding: 10px 14px; font-weight: 900; }

.floating-text { position: absolute; color: var(--accent-2); font-weight: 900; font-size: 25pt; text-shadow: 0 2px 8px rgba(0,0,0,.65); pointer-events: none; animation: floatUp 800ms ease-out forwards; z-index: 7; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(8px) scale(.9);} 15% { opacity: 1;} 100% { opacity: 0; transform: translateY(-32px) scale(1);} }

/* legacy dot sparks kept for fallback (unused now) */
.spark { position: absolute; width: 6px; height: 6px; background: radial-gradient(circle at 30% 30%, #fff0c2, #f1b432 60%, #9c6b19); border-radius: 50%; opacity: 0; animation: spark .7s ease-out forwards; box-shadow: 0 0 10px 2px rgba(241,180,50,.6); }
@keyframes spark { 0% { opacity: 0; transform: translate(0, 0) scale(.6);} 20% { opacity: 1;} 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0); } }

/* image-based sparks */
.spark-img { position: absolute; width: 26px; height: 26px; object-fit: contain; pointer-events: none; opacity: 0; transform: translate(-50%, -50%) scale(var(--s, .95)) rotate(var(--rot, 0deg)); animation-name: sparkImg; animation-timing-function: cubic-bezier(.2,.7,.2,1); animation-fill-mode: forwards; z-index: 8; filter: drop-shadow(0 0 14px rgba(241,180,50,.95)) brightness(1.25) saturate(1.3); mix-blend-mode: screen; will-change: transform, opacity; }
@keyframes sparkImg {
  0% { opacity: 0; transform: translate(calc(-50% + 0px), calc(-50% + 0px)) scale(var(--s, .95)) rotate(var(--rot, 0deg)); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.22) rotate(var(--rot, 0deg)); }
}

/* brief additive flash at impact */
.spark-flash { position: absolute; width: 132px; height: 132px; pointer-events: none; transform: translate(-50%, -50%); background: radial-gradient(circle, rgba(255,235,170,.98) 0%, rgba(255,218,130,.78) 26%, rgba(255,210,120,.42) 52%, rgba(255,210,120,0) 72%); border-radius: 50%; opacity: 0; mix-blend-mode: screen; z-index: 7; animation: sparkFlash 300ms ease-out forwards; filter: blur(0.25px); }

/* mobile-only app: mobile-friendly defaults are applied globally */
@keyframes sparkFlash { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6);} 25% { opacity: .9;} 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.4);} }

.reset { position: fixed; top: 10px; right: 10px; background: #2a3345; color: #fff; border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 6px 10px; font-size: 12px; z-index: 50; }

/* Tiny phones (iPhone SE, Pixel 4a) — tighten the resource row so the
   three cards still fit comfortably on a 320–360px viewport. The
   layout, gaps and corner radii stay Figma-spec; only the inner
   spacing/glyph sizes are eased down. */
@media (max-width: 360px) {
  .rc-balance-icon  { width: 30px; height: 30px; }
  .rc-balance-value { font-size: 24px; }
  .rc-balance-sub   { font-size: 11px; }
  .rc-balance       { gap: 10px; padding: 0 14px; height: 76px; }
  .rc-boost         { flex-basis: 50px; height: 76px; padding: 5px 10px 0 5px; }
  .rc-boost-label   { font-size: 6px; }
  .rc-boost-value   { font-size: 7px; }
  .rc-level         { width: 76px; height: 76px; }
  .rc-level-xp, .rc-level-title { font-size: 11px; }
}

/* ── "Open in Telegram" gate (api.js, production-only) ───────────────────── */
#lhm-telegram-gate {
  position: fixed; inset: 0; z-index: 4000;
  background: radial-gradient(ellipse at 50% 30%, #1a2030 0%, #0a0c12 70%);
  display: grid; place-items: center;
  padding: 20px;
  animation: lhmFade 220ms ease both;
}
#lhm-telegram-gate .tg-gate-card {
  width: min(360px, 100%);
  background: linear-gradient(180deg, #1c2230, #11151e);
  border: 1px solid rgba(199,162,72,0.32);
  border-radius: 20px;
  padding: 28px 22px 24px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.65), inset 0 1px 0 rgba(255,255,255,.04);
  color: var(--text);
}
#lhm-telegram-gate .tg-gate-logo { font-size: 48px; margin-bottom: 8px; line-height: 1; }
#lhm-telegram-gate h2 { margin: 6px 0 10px; font-size: 22px; color: var(--accent-2); }
#lhm-telegram-gate p  { margin: 0 0 18px; font-size: 14px; color: var(--muted); line-height: 1.5; }
#lhm-telegram-gate .tg-gate-btn {
  display: inline-block;
  padding: 12px 22px;
  background: linear-gradient(180deg, #ffd36e, #c7a248 60%, #8a6b21);
  color: #1a1303; text-decoration: none; font-weight: 900;
  border-radius: 14px; border: 1px solid #c7a248;
  box-shadow: 0 6px 14px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.45);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
/* Secondary "Continue in browser" debug button — neutral slate so it's
   clearly distinct from the gold primary "Open Telegram" CTA. */
#lhm-telegram-gate .tg-gate-btn--debug {
  display: block;
  width: 100%;
  background: rgba(255,255,255,0.06);
  color: #cfd6e5;
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  text-shadow: none;
  font-weight: 700;
}
#lhm-telegram-gate .tg-gate-btn--debug:hover {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,211,110,0.45);
}
/* "or" divider between the two buttons. */
#lhm-telegram-gate .tg-gate-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
#lhm-telegram-gate .tg-gate-divider::before,
#lhm-telegram-gate .tg-gate-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.10);
}
#lhm-telegram-gate .tg-gate-warn {
  display: block;
  margin-top: 12px;
  font-size: 11px;
  color: rgba(255,180,80,0.85);
  line-height: 1.4;
}
@keyframes lhmFade { from { opacity: 0; } to { opacity: 1; } }

/* ── Character (pers) chooser — fullscreen slider ────────────────────────── */
.avatar-btn {
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden;
  transition: transform 120ms ease, border-color 120ms ease;
}
.avatar-btn:hover { transform: scale(1.06); border-color: rgba(255,211,110,0.65); }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

#pers-chooser-overlay {
  position: fixed; inset: 0; z-index: 2500;
  background: radial-gradient(ellipse at center, #1a1208 0%, #060a10 75%);
  display: flex; align-items: stretch; justify-content: center;
  animation: lhmFade 200ms ease;
}
#pers-chooser-overlay.hidden { display: none; }

.pers-slider-screen {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  width: 100%; height: 100%;
  padding: 18px 12px max(20px, env(safe-area-inset-bottom)) 12px;
  box-sizing: border-box; color: var(--text);
}

.pers-slider-close {
  position: absolute; top: max(12px, env(safe-area-inset-top)); right: 14px;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(0,0,0,0.45); color: #fff; font-size: 18px; line-height: 1;
  border: 1px solid rgba(255,255,255,0.18); cursor: pointer; z-index: 3;
}
.pers-slider-close:hover { background: rgba(255, 80, 80, 0.65); }

.pers-slider-title {
  margin: 4px 0 10px; font-size: 18px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--accent-2, #f1b432); text-transform: uppercase;
}

.pers-slider-stage {
  position: relative; width: 100%; flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
}

.pers-slider-viewport {
  position: relative; overflow: hidden;
  width: min(560px, 92vw); height: 100%;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.0));
  box-shadow: 0 18px 50px rgba(0,0,0,0.55);
}
.pers-slider-track {
  display: flex; height: 100%;
  transition: transform 280ms cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
  touch-action: pan-y;
}
.pers-slide {
  position: relative;
  flex: 0 0 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 12px; box-sizing: border-box;
  user-select: none; -webkit-user-drag: none;
}
.pers-slide img,
.pers-slide .pers-slide-spine {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 16px 28px rgba(0,0,0,0.55));
  pointer-events: none;
  transform: scale(0.92); opacity: 0.55;
  transition: transform 320ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 320ms ease;
}
.pers-slide.is-active img,
.pers-slide.is-active .pers-slide-spine { transform: scale(1); opacity: 1; }

/* Spine-player host inside a chooser slide. Reserves a square-ish region
   so the spine canvas has a stable size to fit into. */
.pers-slide .pers-slide-spine {
  position: relative;
  width: min(420px, 92%);
  height: 100%;
  background: radial-gradient(ellipse at 50% 70%, rgba(255, 200, 80, 0.10) 0%, rgba(0,0,0,0) 60%);
  border-radius: 18px;
  overflow: hidden;
}
.pers-slide .pers-slide-spine canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.pers-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #ffd36e;
  border: 1px solid rgba(255,211,110,0.35);
  font-size: 28px; line-height: 0.9; cursor: pointer; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  transition: background 120ms ease, transform 120ms ease;
}
.pers-nav.prev { left: 6px; }
.pers-nav.next { right: 6px; }
.pers-nav:hover { background: rgba(255,211,110,0.18); transform: translateY(-50%) scale(1.05); }
.pers-nav:disabled { opacity: 0.3; cursor: not-allowed; }

.pers-slider-meta {
  text-align: center; margin: 12px 0 6px; min-height: 44px;
}
.pers-slider-name {
  font-size: 22px; font-weight: 800; letter-spacing: 0.06em;
  color: var(--accent-2, #f1b432); text-transform: uppercase;
}
.pers-slider-tag {
  margin-top: 4px; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}

.pers-dots {
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
  padding: 4px 12px 12px; max-width: 92vw;
}
.pers-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: none; padding: 0; cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}
.pers-dot.is-active { background: #ffd36e; transform: scale(1.35); }
.pers-dot.is-disabled { background: rgba(255,80,80,0.35); }

.pers-slider-confirm {
  width: min(360px, 92vw);
  padding: 14px 16px; border-radius: 12px;
  font-weight: 800; font-size: 15px; letter-spacing: 0.06em;
  text-transform: uppercase; cursor: pointer;
  background: linear-gradient(180deg, #f1b432, #c98e1c);
  color: #1a1206; border: 1px solid rgba(255,211,110,0.6);
  box-shadow: 0 10px 26px rgba(241,180,50,0.28);
  transition: transform 120ms ease, opacity 120ms ease;
}
.pers-slider-confirm:hover:not(:disabled) { transform: translateY(-1px); }
.pers-slider-confirm:disabled {
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.45);
  border-color: rgba(255,255,255,0.10); box-shadow: none; cursor: not-allowed;
}

/* Static-pers host inherits #spine-player's position:fixed + 100vw/100svh
   bounding box. Non-animated characters are sized larger and lifted up so
   they sit roughly centred over the mine instead of being squashed against
   the bottom HUD. Bottom-anchored so taller portraits still ground naturally. */
.pers-static-host {
  width: 100%; height: 100%;
  display: flex; align-items: flex-end; justify-content: center;
  background: transparent;
  padding-bottom: clamp(180px, 32vh, 360px);
  box-sizing: border-box;
  pointer-events: none;
}
.pers-static-host img {
  max-width: clamp(300px, 70vw, 680px);
  max-height: clamp(380px, 68vh, 820px);
  object-fit: contain;
  filter: drop-shadow(0 22px 28px rgba(0,0,0,0.55));
}

/* ── Wheel of Fortune ───────────────────────────────────────────────────── */
.wheel-panel { width: min(420px, 96vw); max-height: 92vh; overflow: auto; }
.wheel-body  { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 14px 16px; }

.wheel-status {
  font-size: 12px; letter-spacing: 0.04em; color: var(--muted);
  text-align: center; min-height: 16px;
}

.wheel-stage {
  position: relative; width: 100%;
  display: flex; align-items: center; justify-content: center;
}

/* Lady Luck mascot. Sits to the right of the wheel and in front (higher
   z-index than .wheel-frame) so she appears to lean on the roulette. Anchors
   to the bottom of the stage so she "stands" on the same ground line. */
.wheel-ladyluck {
  position: absolute;
  right: -2%;
  bottom: -6%;
  height: 102%;
  z-index: 5;
  pointer-events: none;
  user-select: none; -webkit-user-drag: none;
  filter: drop-shadow(0 16px 22px rgba(0,0,0,0.55));
  transition: transform 0.4s ease, opacity 0.2s ease;
  transform-origin: 80% 100%;
}
/* When the wheel is mid-spin, lean Lady Luck slightly away and dim her so
   the prize popup remains the focal point. */
.wheel-spinner.spinning ~ .wheel-ladyluck,
.wheel-stage:has(.wheel-spinner.spinning) .wheel-ladyluck {
  opacity: 0.55;
  transform: translateX(8%) scale(0.96);
}
@media (max-width: 540px) {
  .wheel-ladyluck { right: -8%; bottom: -8%; height: 95%; }
}
@media (max-width: 380px) {
  .wheel-ladyluck { right: -14%; height: 86%; opacity: 0.9; }
}
.wheel-stack {
  position: relative; width: 86%; max-width: 320px;
  filter: drop-shadow(0 12px 28px rgba(212, 168, 83, 0.28));
  user-select: none; -webkit-user-drag: none;
}
.wheel-frame {
  position: relative; z-index: 2;
  width: 100%; display: block; pointer-events: none;
}
.wheel-spinner {
  position: absolute; z-index: 1;
  top: 8%; left: 4%;
  height: 73%; border-radius: 50%;
  transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99);
  pointer-events: none;
}
.wheel-spinner.spinning { will-change: transform; }

.wheel-popup {
  position: absolute; top: 45%; left: 50%;
  transform: translate(-50%, -50%) scale(0); opacity: 0;
  z-index: 10;
  background: rgba(10, 10, 11, 0.92);
  backdrop-filter: blur(8px);
  border: 2px solid #ffd36e;
  border-radius: 16px;
  padding: 18px 22px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
  box-shadow: 0 0 30px rgba(212,168,83,0.35), 0 0 60px rgba(212,168,83,0.12);
  transition: transform 420ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 220ms ease;
  min-width: 60%;
}
.wheel-popup.is-visible {
  transform: translate(-50%, -50%) scale(1); opacity: 1;
}
.wheel-popup-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--muted);
}
.wheel-popup-icon { width: 52px; height: 52px; }
.wheel-popup-icon img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(212,168,83,0.55));
  animation: wheelPopBounce 0.6s ease;
}
.wheel-popup-name {
  font-size: 18px; font-weight: 800;
  color: #ffd36e; letter-spacing: 0.04em;
}
.wheel-popup-amount {
  font-size: 13px; color: var(--text); font-weight: 600;
  margin-top: 2px;
}
@keyframes wheelPopBounce {
  0%   { transform: scale(0.3) rotate(-20deg); }
  50%  { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1)   rotate(0deg); }
}

.wheel-rewards {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; width: 100%; margin-top: 4px;
}
.wheel-reward {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,211,110,0.18);
  border-radius: 10px;
  transition: border-color 200ms ease, background 200ms ease, transform 200ms ease;
}
.wheel-reward.is-winner {
  border-color: #ffd36e;
  background: linear-gradient(135deg, rgba(212,168,83,0.20), rgba(186,108,44,0.10));
  transform: scale(1.04);
  box-shadow: 0 0 18px rgba(212,168,83,0.30);
}
.wheel-reward-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.wheel-reward-icon img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(212,168,83,0.30));
}
.wheel-reward-name {
  font-weight: 700; font-size: 13px;
  color: var(--accent-2, #f1b432); letter-spacing: 0.03em;
}

.wheel-actions {
  display: flex; gap: 8px; width: 100%; flex-wrap: wrap; margin-top: 4px;
}
.wheel-actions button {
  flex: 1 1 140px; padding: 10px 12px; border-radius: 10px;
  font-weight: 800; font-size: 13px; letter-spacing: 0.03em;
  cursor: pointer; border: 1px solid rgba(255,255,255,0.14);
}
.wheel-actions .primary {
  background: linear-gradient(180deg, #f1b432, #c98e1c);
  color: #1a1206; border-color: rgba(255,211,110,0.6);
}
.wheel-actions .secondary {
  background: rgba(255,255,255,0.05); color: var(--text);
}
.wheel-actions button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.wheel-result {
  min-height: 18px; font-size: 13px; font-weight: 600;
  color: var(--accent-2, #f1b432); text-align: center;
}

/* ── Settings button: panel-only refinements (the visual base is set in
 * the topbar section above; keep these as light-touch hover/active
 * states so the Figma-spec sizing/colors aren't overridden). */
.settings-btn {
  transition: transform 200ms ease, background 120ms ease, border-color 120ms ease;
  flex: 0 0 auto;
}
.settings-btn:hover { background: rgba(0,0,0,0.85); }
.settings-btn:active svg { transform: rotate(60deg); }
.settings-btn svg { transition: transform 200ms ease; display: block; }

#settings-panel .panel { width: min(380px, 92vw); }
#settings-panel .panel-body {
  display: flex; flex-direction: column; gap: 10px; padding: 12px 16px 16px;
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
}
.settings-row-label { font-size: 13px; color: var(--muted); letter-spacing: 0.02em; }
.settings-value { font-size: 13px; color: var(--text); font-weight: 600; }
.settings-status {
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.06); color: var(--muted);
}
.settings-status.is-online  { background: rgba(70, 200, 130, 0.18); color: #6fe2a4; }
.settings-status.is-offline { background: rgba(224, 93, 93, 0.20); color: #ff8a8a; }
.settings-divider {
  height: 1px; background: rgba(255,255,255,0.08); margin: 6px 0;
}
.settings-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.settings-btn-inline {
  flex: 1 1 auto;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  background: linear-gradient(180deg, #f1b432, #c98e1c);
  color: #1a1206; border: 1px solid rgba(255,211,110,0.6);
  font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
}
.settings-btn-inline:hover { transform: translateY(-1px); }
.settings-btn-inline.danger {
  background: rgba(224, 93, 93, 0.16); color: #ff8a8a;
  border-color: rgba(224, 93, 93, 0.45);
}
.settings-btn-inline.danger:hover { background: rgba(224, 93, 93, 0.30); color: #fff; }
.settings-version {
  margin-top: 4px; text-align: center;
  font-size: 11px; color: var(--muted); opacity: 0.7;
}

/* Settings sliders / multi-line rows */
.settings-row.settings-row--column {
  flex-direction: column; align-items: stretch; gap: 8px;
}
.settings-row-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.settings-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; background: rgba(255,255,255,0.10);
  border-radius: 999px; outline: none; cursor: pointer; padding: 0;
}
.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(180deg, #f1b432, #c98e1c);
  border: 2px solid #5a3e10; cursor: grab;
  box-shadow: 0 2px 6px rgba(0,0,0,0.45);
}
.settings-slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(180deg, #f1b432, #c98e1c);
  border: 2px solid #5a3e10; cursor: grab;
}
.settings-hint { font-size: 11px; color: var(--muted); line-height: 1.45; }

/* ── Bank panel (Staking + Airdrop) ─────────────────────────────────────── */
.bank-panel { width: min(440px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.bank-hero {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 14px 12px;
}
.bank-hero-img {
  width: 110px; height: auto; flex-shrink: 0;
  filter: drop-shadow(0 8px 20px rgba(212,168,83,0.35));
}
/* Portrait variant for the Lucky Larry hero — the source is a tall
   full-body painting, so we clip to a rounded square thumbnail so it
   sits nicely next to the title block instead of dominating the panel. */
.bank-hero-img--portrait {
  width: 96px; height: 96px;
  border-radius: 16px;
  object-fit: cover;
  object-position: 50% 18%;
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 8px 20px rgba(0,0,0,0.45);
}
.bank-hero-meta { min-width: 0; }
.bank-hero-title {
  font-size: 16px; font-weight: 800; letter-spacing: 0.04em;
  color: var(--accent-2, #f1b432);
}
.bank-hero-sub {
  margin-top: 4px; font-size: 12px; color: var(--muted); line-height: 1.45;
}
.bank-tabs {
  display: flex; gap: 6px; padding: 0 14px;
}
.bank-tab {
  flex: 1; padding: 10px 8px; border-radius: 10px 10px 0 0;
  background: rgba(255,255,255,0.04); color: var(--muted);
  border: none; cursor: pointer;
  font-weight: 800; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  border-bottom: 2px solid transparent;
}
.bank-tab.is-active {
  color: var(--accent-2, #f1b432);
  background: rgba(255,211,110,0.08);
  border-bottom-color: #ffd36e;
}
.bank-body { padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 10px; overflow: auto; flex: 1 1 auto; }

.bank-stat-row {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.bank-stat {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px; padding: 10px 12px;
}
.bank-stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.bank-stat-value { font-size: 18px; font-weight: 800; color: var(--accent-2, #f1b432); margin-top: 2px; }
.bank-stat-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }

.bank-form {
  display: flex; gap: 8px; align-items: center;
  background: rgba(0,0,0,0.32);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; padding: 8px 10px;
}
.bank-form input {
  flex: 1 1 auto; min-width: 0;
  background: transparent; border: none; color: var(--text);
  font-size: 14px; font-weight: 700; outline: none;
}
.bank-form .pct {
  display: flex; gap: 4px;
}
.bank-form .pct button {
  padding: 4px 8px; border-radius: 6px; cursor: pointer;
  background: rgba(255,255,255,0.05); color: var(--muted);
  border: 1px solid rgba(255,255,255,0.10);
  font-size: 11px; font-weight: 700;
}
.bank-form .pct button:hover { background: rgba(255,211,110,0.18); color: #ffd36e; }

.bank-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bank-btn {
  flex: 1 1 140px; padding: 10px 12px; border-radius: 10px;
  font-weight: 800; font-size: 13px; letter-spacing: 0.03em; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.14);
}
.bank-btn.primary {
  background: linear-gradient(180deg, #f1b432, #c98e1c);
  color: #1a1206; border-color: rgba(255,211,110,0.6);
}
.bank-btn.secondary { background: rgba(255,255,255,0.06); color: var(--text); }
.bank-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.bank-note {
  font-size: 11px; color: var(--muted); line-height: 1.45;
  padding: 6px 0 0;
}
.bank-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 4px 0; }

.airdrop-progress {
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px; padding: 12px;
}
.airdrop-bar { height: 8px; background: rgba(0,0,0,0.40); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.airdrop-bar-fill { height: 100%; background: linear-gradient(90deg, #f1b432, #ffd36e); width: 0%; transition: width 250ms ease; }
.airdrop-snapshot { font-size: 11px; color: var(--muted); margin-top: 6px; }

.airdrop-tasks { display: flex; flex-direction: column; gap: 6px; }
.airdrop-task {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06); border-radius: 10px;
}
.airdrop-task.is-done { border-color: rgba(255,211,110,0.55); background: rgba(255,211,110,0.06); }
.airdrop-task-label { font-size: 13px; }
.airdrop-task-status {
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.06); color: var(--muted);
}
.airdrop-task-status.is-done { background: rgba(255,211,110,0.18); color: #ffd36e; }

/* ── Tasks panel ─────────────────────────────────────────────────────────── */
.tasks-panel { width: min(440px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.tasks-tabs {
  display: flex; gap: 6px; padding: 6px 14px 0;
}
.tasks-tab {
  flex: 1; padding: 10px 8px; border-radius: 10px 10px 0 0;
  background: rgba(255,255,255,0.04); color: var(--muted);
  border: none; cursor: pointer;
  font-weight: 800; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-bottom: 2px solid transparent;
}
.tasks-tab.is-active {
  color: var(--accent-2, #f1b432);
  background: rgba(255,211,110,0.08);
  border-bottom-color: #ffd36e;
}
.tasks-tab-pill {
  background: rgba(0,0,0,0.45); color: #ffd36e;
  font-size: 10px; padding: 2px 6px; border-radius: 999px; letter-spacing: 0.04em;
  min-width: 18px; text-align: center;
}
.tasks-tab.is-active .tasks-tab-pill { background: #ffd36e; color: #1a1206; }

.tasks-resets {
  padding: 6px 14px 0; font-size: 11px; color: var(--muted); letter-spacing: 0.04em;
  text-align: right;
}
.tasks-body {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 14px 14px; overflow: auto; flex: 1 1 auto;
}
.task-card {
  display: grid; grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  transition: border-color 200ms ease, background 200ms ease;
}
.task-card.is-complete { border-color: rgba(255,211,110,0.55); background: rgba(255,211,110,0.06); }
.task-card.is-claimed  { opacity: 0.55; }
.task-info { min-width: 0; }
.task-title { font-weight: 700; font-size: 13px; color: var(--text); margin: 0 0 2px; }
.task-desc  { font-size: 11px; color: var(--muted); margin: 0 0 6px; line-height: 1.4; }
.task-progress {
  height: 6px; background: rgba(0,0,0,0.35); border-radius: 999px; overflow: hidden;
}
.task-progress-bar {
  height: 100%; background: linear-gradient(90deg, #f1b432, #ffd36e);
  width: 0%; border-radius: inherit; transition: width 250ms ease;
}
.task-progress-text {
  margin-top: 4px; font-size: 11px; color: var(--muted); letter-spacing: 0.02em;
}
.task-action {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center;
  gap: 4px; min-width: 90px;
}
.task-reward {
  font-size: 12px; font-weight: 700; color: var(--accent-2, #f1b432); white-space: nowrap;
}
.task-claim {
  padding: 6px 10px; border-radius: 8px; cursor: pointer;
  font-weight: 800; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase;
  background: linear-gradient(180deg, #f1b432, #c98e1c);
  color: #1a1206; border: 1px solid rgba(255,211,110,0.6);
  white-space: nowrap;
}
.task-claim:disabled {
  background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.45);
  border-color: rgba(255,255,255,0.10); cursor: not-allowed;
}
.task-empty {
  text-align: center; color: var(--muted); padding: 24px 8px;
  font-size: 13px;
}

@media (max-height: 560px) {
  .pers-slider-title { display: none; }
  .pers-slider-meta  { margin: 6px 0 2px; min-height: 32px; }
  .pers-slider-name  { font-size: 18px; }
}

/* ── Friends panel ──────────────────────────────────────────────────── */
.friends-panel { max-height: 92vh; }
.friends-tabs {
  display: flex; gap: 8px;
  padding: 0 14px 6px; margin-top: -4px;
}
.friends-tab {
  flex: 1; padding: 8px 10px; cursor: pointer;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.75);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px; font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.friends-tab.is-active {
  background: linear-gradient(180deg, rgba(255,211,110,0.20), rgba(255,211,110,0.08));
  color: #ffe7a8; border-color: rgba(255,211,110,0.45);
}
.friends-body { padding-top: 4px; }

.friends-hero {
  display: flex; gap: 14px; align-items: center;
  padding: 10px 4px 12px;
}
.friends-qr {
  width: 110px; height: 110px; flex: 0 0 110px;
  border-radius: 14px; overflow: hidden;
  background: #fff; padding: 6px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.4);
}
.friends-qr img { width: 100%; height: 100%; display: block; }
.friends-hero-meta { flex: 1; min-width: 0; }
.friends-hero-title {
  font-size: 16px; font-weight: 800; color: #fff; margin-bottom: 4px;
}
.friends-hero-sub { color: var(--muted); font-size: 13px; line-height: 1.35; }
.friends-code-row {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 8px; padding: 4px 8px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
}
.friends-code-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.friends-code { font-size: 13px; font-weight: 800; color: #ffe7a8; }

.friends-link {
  display: flex; gap: 8px; align-items: stretch;
  margin: 4px 0 6px;
}
.friends-link input {
  flex: 1; min-width: 0;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px; padding: 10px 12px; color: #fff;
  font-size: 12px; font-family: monospace;
}
.friends-link input:focus { outline: none; border-color: rgba(255,211,110,0.55); }
.friends-actions-row { display: flex; gap: 8px; }
.friends-actions-row .bank-btn { flex: 1; }

.friends-stat-row {
  display: grid; grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 8px; margin: 6px 0 6px;
}

.friends-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 4px;
}
.friend-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px; align-items: center;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
}
.friend-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #4a3a1f, #ffd56e);
  color: #1a1206; font-weight: 900; font-size: 18px;
  display: grid; place-items: center;
}
.friend-info { min-width: 0; }
.friend-name { font-weight: 800; color: #fff; font-size: 14px; }
.friend-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.friend-earn { text-align: right; }
.friend-earn-value { font-weight: 800; color: #ffd56e; font-size: 14px; }
.friend-earn-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.friends-empty {
  text-align: center; padding: 30px 12px;
  color: var(--muted); font-size: 13px;
}
.friends-empty .bank-btn { margin-top: 12px; min-width: 180px; }

/* ── Battle arena ──────────────────────────────────────────────────── */
.battle-panel { max-height: 92vh; }
.battle-body {
  display: flex; flex-direction: column; gap: 12px;
  padding-top: 6px;
}

.battle-stage {
  position: relative;
  border-radius: 16px;
  background: radial-gradient(ellipse at 50% 70%, rgba(255,211,110,0.12), transparent 65%);
  height: 220px;
  display: grid; place-items: center;
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.battle-stage--intro { height: 200px; }
.battle-stage--fight {
  height: 240px; cursor: pointer;
  background: radial-gradient(ellipse at 50% 70%, rgba(255,211,110,0.18), transparent 60%);
  border: 1px solid rgba(255,211,110,0.20);
}
.battle-stage--fight:active { transform: scale(0.995); }

.battle-vein {
  position: absolute;
  right: 8%; bottom: 4%;
  height: 70%; width: auto; max-width: 55%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.5));
}
.battle-pers {
  position: relative;
  height: 92%; width: auto; max-width: 60%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.55));
  margin-right: 18%;
}

/* Host for the animated character inside battle stages. The
 * SpinePlayer fills the host element via a <canvas>, so we just have
 * to give it the right dimensions and clear pointer-events so taps
 * still register on the surrounding .battle-stage. */
.battle-pers-host {
  position: relative;
  height: 92%; width: 60%; max-width: 60%;
  margin-right: 18%;
  pointer-events: none;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.55));
}
.battle-pers-host canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  background: transparent !important;
}
.battle-pers-host .spine-player,
.battle-pers-host .spine-player-controls { background: transparent !important; }
.battle-pers-host .spine-player-controls { display: none !important; }
.battle-pers-static {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}

.battle-tap-fx { position: absolute; inset: 0; pointer-events: none; }
.battle-tap-pop {
  position: absolute; transform: translate(-50%, -50%);
  font-weight: 900; color: #ffd56e; font-size: 22px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  animation: battlePop .7s ease-out forwards;
  pointer-events: none;
}
@keyframes battlePop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  20%  { opacity: 1; transform: translate(-50%, -70%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1.0); }
}

.battle-meta { text-align: center; }
.battle-stake { font-size: 14px; color: #fff; }
.battle-stake b { color: #ffd56e; }
.battle-rules { font-size: 12px; color: var(--muted); margin-top: 4px; }

.battle-record {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px; padding: 10px;
  text-align: center;
}
.battle-record > div {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.battle-record > div span { font-size: 18px; color: #fff; font-weight: 800; letter-spacing: 0; }
.battle-record-earn {
  grid-column: 1 / -1;
  border-top: 1px dashed rgba(255,255,255,0.10);
  padding-top: 6px; color: #ffd56e !important; font-weight: 700;
  font-size: 12px !important; text-transform: none !important; letter-spacing: 0 !important;
}

.battle-last {
  text-align: center; color: var(--muted); font-size: 12px;
}
.battle-last-win  { color: #6dffb0; }
.battle-last-loss { color: #ff6d6d; }
.battle-last-tie  { color: #d0c9bf; }

.battle-actions { display: flex; gap: 8px; }
.battle-actions .bank-btn { flex: 1; }

.battle-vs {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 12px; padding: 10px 6px;
}
.battle-side { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.battle-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, #4a3a1f, #ffd56e);
  color: #1a1206; font-weight: 900; font-size: 28px;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.battle-avatar--opp { background: linear-gradient(135deg, #2c3144, #6f7faf); color: #fff; }
.battle-handle { font-weight: 800; color: #fff; font-size: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.battle-handle-sub { color: var(--muted); font-size: 11px; }
.battle-vs-mark { font-size: 18px; font-weight: 900; color: #ffd56e; letter-spacing: 0.06em; }
.battle-countdown {
  text-align: center;
  font-size: 56px; font-weight: 900;
  color: #ffd56e; text-shadow: 0 4px 14px rgba(0,0,0,0.5);
  margin: 6px 0 0;
}
.battle-countdown.pulse { animation: battlePulse .55s ease-out; }
@keyframes battlePulse {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.0); opacity: 1; }
}

.battle-hud {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px;
}
.battle-timer, .battle-counter {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px; padding: 8px 6px;
  text-align: center;
  min-width: 0;
}
.battle-timer span { font-size: 24px; font-weight: 900; color: #ffd56e; }
.battle-timer small,
.battle-counter small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }
.battle-counter span { font-size: 24px; font-weight: 900; color: #fff; }
.battle-counter--opp span { color: #ff8a8a; }
.battle-counter--opp { border-color: rgba(255,138,138,0.25); }

.battle-result-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; padding: 16px;
  text-align: center;
}
.battle-result--win  { border-color: rgba(109,255,176,0.4); background: linear-gradient(180deg, rgba(109,255,176,0.10), rgba(109,255,176,0.02)); }
.battle-result--loss { border-color: rgba(255,109,109,0.35); background: linear-gradient(180deg, rgba(255,109,109,0.10), rgba(255,109,109,0.02)); }
.battle-result--tie  { border-color: rgba(255,255,255,0.12); }
.battle-result-title { font-size: 22px; font-weight: 900; color: #fff; }
.battle-result-sub   { font-size: 16px; font-weight: 800; color: #ffd56e; margin-top: 2px; }
.battle-result-score {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 10px; margin-top: 14px;
}
.battle-result-score > div { display: flex; flex-direction: column; align-items: center; }
.battle-result-score span { font-size: 32px; font-weight: 900; color: #fff; }
.battle-result-score small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.battle-result-vs { font-weight: 900; color: var(--muted); font-size: 14px; }
.battle-result-meta { color: var(--muted); font-size: 12px; margin-top: 12px; }

/* ── Registration wizard ───────────────────────────────────────────────── */
/* Nickname (step 1) and gender (step 2) overlays share the same shell. The
   character chooser (step 3) reuses the existing pers-chooser styles plus
   the wizard step indicator. */
#reg-nickname-overlay,
#reg-gender-overlay {
  position: fixed; inset: 0; z-index: 2500;
  background: radial-gradient(ellipse at top, rgba(40,52,82,0.85), rgba(8,11,17,0.96));
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(6px);
}
#reg-nickname-overlay.hidden,
#reg-gender-overlay.hidden { display: none; }

.reg-wizard-screen {
  width: min(440px, 100%);
  background: linear-gradient(180deg, rgba(22,28,42,0.96), rgba(15,19,28,0.96));
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 22px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.55);
  padding: 28px 24px 24px;
  text-align: center;
  display: flex; flex-direction: column; gap: 14px;
}

.reg-wizard-steps {
  display: flex; justify-content: center; align-items: center; gap: 10px;
  margin: 0 auto 4px;
}
.reg-wizard-steps.hidden { display: none; }
.reg-step {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  color: var(--muted, #94a3b8); font-weight: 800; font-size: 12px;
}
.reg-step.is-active {
  background: var(--accent-2, #facc15); color: #1a1300; border-color: transparent;
}
.reg-step.is-done {
  background: rgba(34,197,94,0.18); color: #4ade80; border-color: rgba(74,222,128,0.4);
}

.reg-wizard-title {
  margin: 4px 0 0; font-size: clamp(20px, 5vw, 26px); font-weight: 900; color: #fff;
}
.reg-wizard-sub {
  margin: 0 0 6px; font-size: 13px; line-height: 1.45; color: var(--muted, #94a3b8);
}
.reg-wizard-label {
  text-align: left; font-size: 12px; font-weight: 700; color: var(--muted, #94a3b8);
  text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px;
}
.reg-wizard-input {
  width: 100%; padding: 14px 16px; font-size: 16px; font-weight: 600;
  background: rgba(0,0,0,0.35); color: #fff;
  border: 1px solid rgba(255,255,255,0.16); border-radius: 12px;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.reg-wizard-input:focus {
  border-color: var(--accent-2, #facc15);
  box-shadow: 0 0 0 3px rgba(250,204,21,0.18);
}
.reg-wizard-error {
  min-height: 18px; font-size: 12px; text-align: left;
  color: #fca5a5; font-weight: 600;
}
.reg-wizard-next {
  width: 100%; padding: 14px 18px; font-size: 15px; font-weight: 800;
  border-radius: 14px; border: none; cursor: pointer; margin-top: 4px;
  background: linear-gradient(180deg, var(--accent-2, #facc15), #d97706);
  color: #1a1300;
  transition: transform 0.1s, opacity 0.15s, filter 0.15s;
}
.reg-wizard-next:disabled {
  opacity: 0.45; cursor: not-allowed; filter: grayscale(0.4);
}
.reg-wizard-next:not(:disabled):hover { transform: translateY(-1px); }
.reg-wizard-back {
  align-self: center; background: transparent; border: none; color: var(--muted, #94a3b8);
  font-size: 13px; font-weight: 600; cursor: pointer; padding: 8px 12px;
  margin-top: 2px; transition: color 0.15s;
}
.reg-wizard-back:hover { color: #fff; }

.reg-gender-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px;
}
.reg-gender-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 10px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 18px;
  color: #fff; font-weight: 800; cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.reg-gender-card:hover {
  border-color: var(--accent-2, #facc15);
  background: rgba(250,204,21,0.06);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.4);
}
.reg-gender-card:active { transform: translateY(0); }
.reg-gender-art {
  position: relative;
  width: 100%; aspect-ratio: 3 / 4; max-height: 220px;
  display: flex; align-items: flex-end; justify-content: center;
  overflow: hidden; border-radius: 14px;
  background: radial-gradient(ellipse at bottom, rgba(255,255,255,0.08), transparent 60%);
}
.reg-gender-art img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 12px 18px rgba(0,0,0,0.5));
}
/* SpinePlayer host inside the gender card. Fills the .reg-gender-art box
   so the live character renders at the same size as the static fallback
   would have. */
.reg-gender-spine {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  filter: drop-shadow(0 12px 18px rgba(0,0,0,0.5));
}
/* Centred loading spinner shown while the spine assets fetch. */
.reg-gender-loader {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  transition: opacity 0.25s;
}
.reg-gender-loader.is-done { opacity: 0; }
.reg-gender-loader-spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.14);
  border-top-color: var(--accent-2, #facc15);
  animation: spin 0.85s linear infinite;
}
/* Fallback when spine fails to load — keeps the card from being blank. */
.reg-gender-fallback {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  font-size: 48px; font-weight: 900;
  color: rgba(255,255,255,0.25);
}
.reg-gender-name {
  font-size: 16px; letter-spacing: 0.02em;
}

/* Gender toggle inside the character chooser. Two segmented pills; only
   shown when allowGenderSwitch is enabled (change-character flow). */
.pers-gender-toggle {
  display: inline-flex; gap: 4px;
  margin: 0 auto 10px;
  padding: 4px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  align-self: center;
}
.pers-gender-toggle.hidden { display: none; }
.pers-gender-toggle .pgt-btn {
  appearance: none; background: transparent;
  border: none; color: var(--muted, #94a3b8);
  font-size: 13px; font-weight: 800;
  padding: 8px 18px; border-radius: 999px;
  cursor: pointer; transition: background 0.15s, color 0.15s;
  min-width: 84px;
}
.pers-gender-toggle .pgt-btn:hover { color: #fff; }
.pers-gender-toggle .pgt-btn.is-active {
  background: linear-gradient(180deg, var(--accent-2, #facc15), #d97706);
  color: #1a1300;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

/* Lazy-loaded chooser slide: while the spine canvas is loading we show a
   centred spinner. Pers.png is the spine atlas (all body parts on one
   sheet) so it can't be used as a portrait placeholder; the spinner is
   the only correct loading state. */
.pers-slide-spine { position: relative; }
.pers-slide-loader {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  transition: opacity 0.25s;
}
.pers-slide-loader.is-done { opacity: 0; }
.pers-slide-loader-spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.14);
  border-top-color: var(--accent-2, #facc15);
  animation: spin 0.85s linear infinite;
}

/* Loading spinner for the in-game spine player. Sibling of #spine-player
   (lives directly under <body>) because SpinePlayer wipes its host's
   innerHTML during init. Positioned over the same fixed bbox so it lands
   roughly where the character will appear, then fades out on success. */
.spine-main-loader {
  position: fixed; left: 0; right: 0; top: 0; bottom: 0;
  width: 100vw; height: 100svh;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 5;
  transition: opacity 0.2s;
}
.spine-main-loader.is-done { opacity: 0; }
.spine-main-loader-spinner {
  width: 56px; height: 56px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.16);
  border-top-color: var(--accent-2, #facc15);
  animation: spin 0.85s linear infinite;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

