:root {
  --bg: #0f1020;
  --panel: #181a36;
  --panel-2: #232552;
  --accent: #e94560;
  --gold: #f4c430;
  --text: #ececf4;
  --dim: #8a8ab0;
  --good: #4db84d;
  --bad: #b84d4d;

  --scene-h: 400px;
  --hero-x: 60px;
  --hero-slot-w: 58px;
  --hero-slot-h: 72px;
  --hero-slot-gap: 6px;
  --ground-y: 42px; /* bottom offset for entities */
}

/* Shrink scene + party on narrow / portrait so the enemy stays in frame */
@media (max-width: 700px) {
  :root {
    --scene-h: 260px;
    --hero-x: 18px;
    --hero-slot-w: 40px;
    --hero-slot-h: 54px;
    --hero-slot-gap: 3px;
    --ground-y: 32px;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background:
    radial-gradient(ellipse at top, #25285a 0%, #0f1020 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

#app {
  max-width: 1150px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  zoom: 1.47;
}

/* Walk zoom down as viewport narrows so the app fits without horizontal scroll */
@media (max-width: 1500px) { #app { zoom: 1.27; } }
@media (max-width: 1200px) { #app { zoom: 1.08; } }
@media (max-width: 1000px) { #app { zoom: 1.0; } }
@media (max-width: 700px)  { #app { zoom: 1.0; padding: 8px; } }

/* Short viewports (landscape tablets, small laptops): compress vertically so
   the game fits under the browser chrome without scrolling. Doesn't touch
   wider-and-tall desktops or narrow-portrait phones. */
@media (max-height: 780px) {
  #app { zoom: 1.0; padding: 8px; gap: 8px; }
  :root {
    --scene-h: 300px;
    --hero-slot-h: 64px;
  }
  header { padding: 8px 12px; }
  #roster { padding: 8px; }
  #roster h2 { margin-bottom: 4px; }
  .hero-card { padding: 4px 6px; margin-bottom: 4px; gap: 2px; }
  .hero-card .icon { width: 28px; height: 28px; }
  .hero-card .name { font-size: 11px; }
  footer { padding: 2px 6px; }
}

/* ---------- header ---------- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.05);
  flex-wrap: wrap;
}
h1 { font-size: 18px; color: var(--accent); letter-spacing: 0.5px; }
h1 .subtitle { color: var(--dim); font-weight: 500; font-size: 14px; letter-spacing: 0.3px; }
#stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; }
#stats .stat { font-variant-numeric: tabular-nums; }
#stats .dim { color: var(--dim); font-size: 12px; }
#gold { color: var(--gold); font-weight: 600; }
#dps { color: var(--accent); font-weight: 600; }

.stat-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-variant-numeric: tabular-nums;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.stat-btn:hover { background: rgba(255,255,255,0.12); }
.stat-btn:active { transform: scale(0.97); }
.stat-btn.active {
  background: rgba(244,196,48,0.18);
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 600;
}

/* ---------- layout ---------- */
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 14px;
}
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
}

/* ---------- battlefield / scene ---------- */
#battlefield {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  overflow: hidden;
  min-height: var(--scene-h);
  height: 100%; /* grid cell stretches to match the taller sibling (roster) */
  padding: 0;
}

#scene {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: var(--scene-h);
  overflow: hidden;
  isolation: isolate;
  cursor: default;
}

.bg {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  will-change: background-position;
}

/* ---- Theme vars (default: Mossy Woods) ---- */
#scene {
  --sky-grad:    linear-gradient(180deg, #181a3a 0%, #2c2f5a 55%, #4a3f5a 90%, #6a4a4a 100%);
  --hills-far:   #202345;
  --hills-near:  #2b2e5c;
  --ground-grad: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.35) 100%),
                 linear-gradient(180deg, #1e3d2c 0%, #0f2318 100%);
  --grass-color: #2d5a2d;
}

.bg-sky {
  top: 0;
  height: 72%;
  background: var(--sky-grad);
}

.bg-hills-far {
  top: 32%;
  height: 46%;
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="600" height="160" viewBox="0 0 600 160" preserveAspectRatio="none"><path d="M0 160 L0 110 Q60 55 140 90 T280 80 T440 95 T600 75 L600 160 Z" fill="black"/></svg>');
          mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="600" height="160" viewBox="0 0 600 160" preserveAspectRatio="none"><path d="M0 160 L0 110 Q60 55 140 90 T280 80 T440 95 T600 75 L600 160 Z" fill="black"/></svg>');
  -webkit-mask-repeat: repeat-x;  mask-repeat: repeat-x;
  -webkit-mask-size: 600px 100%;  mask-size: 600px 100%;
  -webkit-mask-position-y: bottom; mask-position-y: bottom;
  -webkit-mask-position-x: calc(var(--scroll, 0px) * -0.25);
          mask-position-x: calc(var(--scroll, 0px) * -0.25);
  background-color: var(--hills-far);
  opacity: 0.95;
}

.bg-hills-near {
  top: 46%;
  height: 34%;
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="500" height="140" viewBox="0 0 500 140" preserveAspectRatio="none"><path d="M0 140 L0 80 Q50 25 120 55 T220 45 T360 65 T500 45 L500 140 Z" fill="black"/></svg>');
          mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="500" height="140" viewBox="0 0 500 140" preserveAspectRatio="none"><path d="M0 140 L0 80 Q50 25 120 55 T220 45 T360 65 T500 45 L500 140 Z" fill="black"/></svg>');
  -webkit-mask-repeat: repeat-x;  mask-repeat: repeat-x;
  -webkit-mask-size: 500px 100%;  mask-size: 500px 100%;
  -webkit-mask-position-y: bottom; mask-position-y: bottom;
  -webkit-mask-position-x: calc(var(--scroll, 0px) * -0.55);
          mask-position-x: calc(var(--scroll, 0px) * -0.55);
  background-color: var(--hills-near);
}

.bg-ground {
  bottom: 0;
  height: 28%;
  background: var(--ground-grad);
}

.bg-grass {
  bottom: 0;
  height: 28%;
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="260" height="80" viewBox="0 0 260 80"><g fill="black"><rect x="10" y="68" width="2" height="10"/><rect x="30" y="70" width="2" height="8"/><rect x="55" y="66" width="2" height="12"/><rect x="78" y="72" width="2" height="6"/><rect x="100" y="68" width="2" height="10"/><rect x="130" y="72" width="2" height="6"/><rect x="160" y="66" width="2" height="12"/><rect x="190" y="70" width="2" height="8"/><rect x="220" y="68" width="2" height="10"/></g><g fill="black" opacity="0.7"><path d="M45 76 l-4 -5 4 5 l4 -5"/><path d="M120 76 l-4 -5 4 5 l4 -5"/><path d="M200 76 l-4 -5 4 5 l4 -5"/></g></svg>');
          mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="260" height="80" viewBox="0 0 260 80"><g fill="black"><rect x="10" y="68" width="2" height="10"/><rect x="30" y="70" width="2" height="8"/><rect x="55" y="66" width="2" height="12"/><rect x="78" y="72" width="2" height="6"/><rect x="100" y="68" width="2" height="10"/><rect x="130" y="72" width="2" height="6"/><rect x="160" y="66" width="2" height="12"/><rect x="190" y="70" width="2" height="8"/><rect x="220" y="68" width="2" height="10"/></g><g fill="black" opacity="0.7"><path d="M45 76 l-4 -5 4 5 l4 -5"/><path d="M120 76 l-4 -5 4 5 l4 -5"/><path d="M200 76 l-4 -5 4 5 l4 -5"/></g></svg>');
  -webkit-mask-repeat: repeat-x;  mask-repeat: repeat-x;
  -webkit-mask-size: 260px 100%;  mask-size: 260px 100%;
  -webkit-mask-position-y: bottom; mask-position-y: bottom;
  -webkit-mask-position-x: calc(var(--scroll, 0px) * -1);
          mask-position-x: calc(var(--scroll, 0px) * -1);
  background-color: var(--grass-color);
}

/* ---- Per-zone theme overrides ---- */
#scene[data-zone-theme="cursed-swamp"] {
  --sky-grad: linear-gradient(180deg, #3a3a15 0%, #5a5520 55%, #6a5820 90%, #3a3215 100%);
  --hills-far: #1a2210;
  --hills-near: #2d3820;
  --ground-grad: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.35) 100%),
                 linear-gradient(180deg, #2e2a1a 0%, #181410 100%);
  --grass-color: #4a5530;
}
#scene[data-zone-theme="bandit-pass"] {
  --sky-grad: linear-gradient(180deg, #5a2a15 0%, #7a3820 45%, #a04a20 80%, #6a2a15 100%);
  --hills-far: #3a2018;
  --hills-near: #4a2b1e;
  --ground-grad: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.25) 100%),
                 linear-gradient(180deg, #5a3a20 0%, #2a1a10 100%);
  --grass-color: #8a5a30;
}
#scene[data-zone-theme="frozen-peaks"] {
  --sky-grad: linear-gradient(180deg, #5a7090 0%, #8aa0c0 50%, #b0c8e0 90%, #e0f0ff 100%);
  --hills-far: #a0b0c8;
  --hills-near: #8090a8;
  --ground-grad: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.3) 100%),
                 linear-gradient(180deg, #c0d0e0 0%, #8090a8 100%);
  --grass-color: #d5e0ee;
}
#scene[data-zone-theme="dragon-caldera"] {
  --sky-grad: linear-gradient(180deg, #3a0a10 0%, #8a2010 40%, #c04a15 75%, #802015 100%);
  --hills-far: #1a0a08;
  --hills-near: #2a1510;
  --ground-grad: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(180,60,20,0.4) 100%),
                 linear-gradient(180deg, #3a1a15 0%, #1a0a08 100%);
  --grass-color: #6a2a1a;
}
#scene[data-zone-theme="shattered-ruins"] {
  --sky-grad: linear-gradient(180deg, #3a3a3a 0%, #5a5a5a 55%, #707070 90%, #606060 100%);
  --hills-far: #30323a;
  --hills-near: #40424a;
  --ground-grad: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.4) 100%),
                 linear-gradient(180deg, #6a6a6a 0%, #3a3a3a 100%);
  --grass-color: #808080;
}
#scene[data-zone-theme="obsidian-depths"] {
  --sky-grad: linear-gradient(180deg, #100a2a 0%, #1a1540 55%, #2a205a 90%, #1a1030 100%);
  --hills-far: #0a0a1a;
  --hills-near: #15152a;
  --ground-grad: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(80,40,140,0.3) 100%),
                 linear-gradient(180deg, #1a1028 0%, #05020a 100%);
  --grass-color: #2a1a4a;
}
#scene[data-zone-theme="blighted-plains"] {
  --sky-grad: linear-gradient(180deg, #6a5020 0%, #8a6820 55%, #a07a28 90%, #706028 100%);
  --hills-far: #3a2a18;
  --hills-near: #4a3820;
  --ground-grad: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.3) 100%),
                 linear-gradient(180deg, #5a4820 0%, #2a2010 100%);
  --grass-color: #6a5020;
}
#scene[data-zone-theme="sunken-city"] {
  --sky-grad: linear-gradient(180deg, #10384a 0%, #205a70 50%, #308898 90%, #40a0b0 100%);
  --hills-far: #0a2430;
  --hills-near: #15384a;
  --ground-grad: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(20,80,100,0.35) 100%),
                 linear-gradient(180deg, #204058 0%, #0a1a28 100%);
  --grass-color: #3a708a;
}
#scene[data-zone-theme="skyreach-spires"] {
  --sky-grad: linear-gradient(180deg, #78a0d0 0%, #a0c0e0 40%, #d0e0f0 75%, #f0f5ff 100%);
  --hills-far: #d0d8e8;
  --hills-near: #a8b8c8;
  --ground-grad: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(255,255,255,0.3) 100%),
                 linear-gradient(180deg, #e0e8f0 0%, #b0c0d0 100%);
  --grass-color: #e0e8f0;
}

/* ---------- entities ---------- */
.entity {
  position: absolute;
  bottom: var(--ground-y);
  z-index: 2;
  will-change: transform, left;
}

#formation {
  left: var(--hero-x);
  display: flex;
  gap: var(--hero-slot-gap);
  align-items: flex-end;
}

.hero-slot {
  position: relative;
  width: var(--hero-slot-w);
  height: var(--hero-slot-h);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.hero-slot.locked { opacity: 0.3; filter: grayscale(1); }

.hero-body {
  width: 100%;
  height: calc(100% - 6px);
  transform-origin: bottom center;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,0.55));
  will-change: transform;
  user-select: none;
  display: block;
}
.hero-body svg.hamster-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.hero-slot .shadow {
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 80%;
  height: 9px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse closest-side, rgba(0,0,0,0.7) 0%, transparent 100%);
  pointer-events: none;
  will-change: transform, opacity;
  z-index: -1;
}
.hero-slot.locked .shadow { opacity: 0.25; }

.hero-slot .level {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  z-index: 3;
}
.hero-slot .buff-ring {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(244,196,48,0.75) 0%, transparent 70%);
  animation: pulse 1.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

/* phase-driven animations — target .hero-body so shadow stays put */
[data-phase="walking"] .hero-slot:not(.locked) .hero-body {
  animation: walk 0.48s ease-in-out infinite;
}
[data-phase="walking"] .hero-slot:not(.locked):nth-child(2n) .hero-body { animation-delay: -0.24s; }
[data-phase="walking"] .hero-slot:not(.locked):nth-child(3n) .hero-body { animation-delay: -0.16s; }

[data-phase="walking"] .hero-slot:not(.locked) .shadow {
  animation: shadow-pulse 0.48s ease-in-out infinite;
}
[data-phase="walking"] .hero-slot:not(.locked):nth-child(2n) .shadow { animation-delay: -0.24s; }
[data-phase="walking"] .hero-slot:not(.locked):nth-child(3n) .shadow { animation-delay: -0.16s; }

[data-phase="fighting"] .hero-slot:not(.locked) .hero-body {
  animation: idle 1.6s ease-in-out infinite;
}

@keyframes walk {
  0%   { transform: translateY(0) rotate(-3deg); }
  50%  { transform: translateY(-10px) rotate(3deg); }
  100% { transform: translateY(0) rotate(-3deg); }
}
@keyframes idle {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-2px); }
}
@keyframes shadow-pulse {
  0%,100% { transform: translateX(-50%) scaleX(1); opacity: 0.85; }
  50%     { transform: translateX(-50%) scaleX(0.55); opacity: 0.3; }
}

.hero-slot.swinging .hero-body {
  animation: swing 0.28s ease !important;
}
@keyframes swing {
  0%   { transform: translate(0, 0) rotate(0); }
  18%  { transform: translate(-5px, -2px) rotate(-14deg); }
  55%  { transform: translate(24px, -12px) rotate(22deg); }
  78%  { transform: translate(14px, -4px) rotate(14deg); }
  100% { transform: translate(0, 0) rotate(0); }
}

/* ---------- enemy ---------- */
#enemy {
  left: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
#enemy.hidden { display: none; }

#enemy-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.6));
}

#enemy-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,0,0,0.55);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  color: var(--text);
}

#enemy-hp {
  width: 120px;
  height: 9px;
  background: rgba(0,0,0,0.65);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
#enemy-hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #2d7a2d, #4db84d);
  transition: width 0.12s linear;
}
#enemy.boss #enemy-hp {
  width: 180px;
  height: 11px;
}
#enemy.boss #enemy-hp-fill {
  background: linear-gradient(90deg, #7a2d2d, #e94560);
}
#enemy.miniboss #enemy-hp {
  width: 150px;
  height: 10px;
}
#enemy.miniboss #enemy-hp-fill {
  background: linear-gradient(90deg, #8a5a2a, #e09a3e);
}
#enemy.miniboss #enemy-sprite { font-size: 82px; }
#enemy.miniboss .enemy-shadow { width: 82px; height: 12px; }
.badge.miniboss-badge { background: #d0882e; }
#enemy-hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
  font-variant-numeric: tabular-nums;
}

#enemy-sprite {
  --facing: 1; /* Most Apple emojis already face left; flip only the ones tagged 'right' */
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 5px 5px rgba(0,0,0,0.55));
  transform: scaleX(var(--facing));
  transition: filter 0.1s;
  will-change: transform;
  user-select: none;
}
#enemy[data-facing="right"] #enemy-sprite { --facing: -1; }

.enemy-shadow {
  position: absolute;
  bottom: -8px;
  left: 50%;
  width: 72px;
  height: 12px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse closest-side, rgba(0,0,0,0.7) 0%, transparent 100%);
  pointer-events: none;
  z-index: -1;
}
#enemy.boss .enemy-shadow { width: 92px; height: 14px; }

#enemy.approaching #enemy-sprite {
  animation: enemy-walk 0.28s ease-in-out infinite alternate;
}
#enemy.approaching .enemy-shadow {
  animation: enemy-shadow-pulse 0.28s ease-in-out infinite alternate;
}
#enemy.fighting #enemy-sprite {
  animation: enemy-idle 0.9s ease-in-out infinite;
}
#enemy.dying #enemy-sprite {
  animation: enemy-die 0.4s ease-out forwards;
}
#enemy.hit #enemy-sprite {
  animation: enemy-hit 0.2s ease !important;
  filter: drop-shadow(0 5px 5px rgba(0,0,0,0.55)) brightness(1.9) saturate(1.4);
}
#enemy.boss #enemy-sprite { font-size: 92px; }

@media (max-width: 700px) {
  #enemy-sprite          { font-size: 54px; }
  #enemy.boss #enemy-sprite     { font-size: 68px; }
  #enemy.miniboss #enemy-sprite { font-size: 60px; }
  .enemy-shadow          { width: 52px; height: 10px; }
  #enemy.boss .enemy-shadow     { width: 66px; }
  #enemy.miniboss .enemy-shadow { width: 58px; }
  #enemy-hp     { width: 100px; }
  #enemy.boss #enemy-hp     { width: 130px; }
  #enemy.miniboss #enemy-hp { width: 110px; }
}

@keyframes enemy-walk {
  from { transform: translateY(0) scaleX(var(--facing)); }
  to   { transform: translateY(-5px) scaleX(var(--facing)); }
}
@keyframes enemy-idle {
  0%,100% { transform: translateY(0) scaleX(var(--facing)); }
  50%     { transform: translateY(-3px) scaleX(var(--facing)); }
}
@keyframes enemy-die {
  0%   { opacity: 1; transform: translateY(0) scaleX(var(--facing)) rotate(0); }
  100% { opacity: 0; transform: translate(-18px, 22px) scaleX(var(--facing)) rotate(-45deg); }
}
@keyframes enemy-hit {
  0%   { transform: translateX(0) scaleX(var(--facing)); }
  25%  { transform: translateX(-12px) scaleX(var(--facing)); }
  55%  { transform: translateX(6px) scaleX(var(--facing)); }
  100% { transform: translateX(0) scaleX(var(--facing)); }
}
@keyframes enemy-shadow-pulse {
  from { transform: translateX(-50%) scaleX(1); opacity: 0.75; }
  to   { transform: translateX(-50%) scaleX(0.7); opacity: 0.5; }
}

.badge {
  background: var(--accent);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

#boss-timer-panel {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(233,69,96,0.92);
  color: white;
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  z-index: 5;
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
  letter-spacing: 0.5px;
}

.dmg-pop {
  position: absolute;
  font-weight: 700;
  font-size: 18px;
  color: var(--gold);
  animation: dmgFloat 0.9s ease-out forwards;
  pointer-events: none;
  text-shadow: 0 0 4px #000, 0 0 3px #000;
  font-variant-numeric: tabular-nums;
  z-index: 6;
  white-space: nowrap;
}
.dmg-pop.crit { color: #fff; font-size: 24px; }
@keyframes dmgFloat {
  0%   { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -50px) scale(1); }
}

.gold-pop {
  position: absolute;
  font-weight: 700;
  font-size: 14px;
  color: var(--gold);
  animation: goldFloat 1s ease-out forwards;
  pointer-events: none;
  text-shadow: 0 0 3px #000;
  z-index: 6;
  white-space: nowrap;
}
@keyframes goldFloat {
  0%   { opacity: 0; transform: translate(-50%, 0) scale(0.9); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -30px) scale(1.1); }
}

#toast {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.82);
  color: var(--gold);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 10;
  max-width: 80%;
  text-align: center;
}
#toast.show { opacity: 1; }

/* ---------- roster ---------- */
#roster {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 14px;
}
#roster h2 {
  font-size: 12px;
  margin-bottom: 10px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.hero-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 8px;
  margin-bottom: 6px;
  transition: border-color 0.15s ease;
}
.hero-card.locked { opacity: 0.72; }
.hero-card.affordable { border-color: rgba(244,196,48,0.45); }
.hero-card .card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.hero-card .icon { width: 34px; height: 34px; flex-shrink: 0; }
.hero-card .icon svg.hamster-svg { width: 100%; height: 100%; display: block; }
.hero-card .info { flex: 1; min-width: 0; }
.hero-card .name { font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-card .name .role { color: var(--dim); font-weight: 400; font-size: 11px; margin-left: 3px; }
.hero-card .stats {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 10px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.hero-card .stats .stat-lv,
.hero-card .stats .stat-dps {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.hero-card .stats .stat-lv { color: var(--text); font-weight: 600; }
.hero-card .buff-note {
  font-size: 10px;
  text-align: center;
  padding: 3px 4px 1px;
  border-top: 1px dashed rgba(255,255,255,0.08);
  margin-top: 1px;
  color: var(--dim);
}
.hero-card .buff-note.active {
  color: var(--gold);
  font-weight: 600;
  border-top-color: rgba(244,196,48,0.25);
}
.hero-card button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  min-width: 72px;
  font-size: 11px;
  text-align: center;
  line-height: 1.2;
  transition: filter 0.1s ease, transform 0.05s ease;
}
.hero-card button:hover:not(:disabled) { filter: brightness(1.15); }
.hero-card button:active:not(:disabled) { transform: scale(0.97); }
.hero-card button:disabled { background: #44476a; color: #8a8ab0; cursor: not-allowed; }
.hero-card button .cost { font-size: 9px; opacity: 0.9; display: block; font-weight: 400; }
.hero-card .actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}
.hero-card .btn-max {
  min-width: unset;
  padding: 2px 10px;
  font-size: 10px;
  letter-spacing: 0.5px;
  background: transparent;
  color: var(--gold);
  border: 1px solid rgba(244,196,48,0.5);
}
.hero-card .btn-max:hover:not(:disabled) {
  background: rgba(244,196,48,0.15);
  filter: none;
}
.hero-card .btn-max:disabled {
  color: #666a80;
  border-color: rgba(255,255,255,0.08);
  background: transparent;
}

/* ---------- footer ---------- */
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--dim);
}
#save-indicator { min-height: 14px; }
#save-indicator.visible { animation: fadeOut 1.5s ease forwards; }
@keyframes fadeOut { 0% { opacity: 1; } 100% { opacity: 0; } }

#reset-btn {
  background: transparent;
  color: var(--dim);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  transition: color 0.12s, border-color 0.12s;
}
#reset-btn:hover { color: var(--accent); border-color: var(--accent); }
