:root {
  --bg: #0d0a12;
  --bg-2: #16111f;
  --panel: #1c1526;
  --panel-2: #241a30;
  --border: #382a4a;
  --text: #ece6f5;
  --muted: #9585a8;
  --gold: #ffcf5a;
  --soul: #7ce7ff;
  --hp: #ff5d6c;
  --xp: #8b6cff;
  --ember: #ff7a2f;
  --good: #7bffa0;
  --shadow: 0 8px 28px rgba(0,0,0,.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a1730 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 110%, #1a1030 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 16px 24px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.logo {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 3px;
  text-shadow: 0 0 18px rgba(255,122,47,.5);
}
.logo span { color: var(--ember); }
.resources { display: flex; gap: 14px; }
.res {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 120px;
}
.res-icon { font-size: 18px; }
.res-gold .res-icon, .res-gold { color: var(--gold); }
.res-souls .res-icon, .res-souls { color: var(--soul); }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  gap: 14px;
  flex: 1;
}
.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.panel-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* Hero */
.hero-panel { display: flex; flex-direction: column; align-items: center; text-align: center; }
.hero-avatar {
  width: 96px; height: 96px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 40% 30%, #3a2a4f, #1a1226);
  border: 2px solid var(--ember);
  box-shadow: 0 0 24px rgba(255,122,47,.35), inset 0 0 20px rgba(0,0,0,.5);
  margin-bottom: 10px;
}
.hero-avatar.attack { animation: lunge .18s ease; }
@keyframes lunge { 50% { transform: translateX(10px) scale(1.05); } }
.hero-glyph { font-size: 44px; filter: drop-shadow(0 0 6px var(--ember)); }
.hero-name { font-weight: 700; font-size: 17px; }
.hero-level { color: var(--muted); margin-bottom: 12px; font-size: 13px; }
.stat-list { list-style: none; width: 100%; margin-top: 10px; }
.stat-list li {
  display: flex; justify-content: space-between;
  padding: 7px 2px;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}
.stat-list li span { color: var(--muted); }
.stat-list b { color: var(--text); font-variant-numeric: tabular-nums; }

/* Bars */
.bar {
  position: relative;
  height: 20px;
  width: 100%;
  background: #0c0812;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.bar-fill { height: 100%; width: 0%; transition: width .12s linear; }
.xp-bar { margin: 6px 0; }
.xp-bar .bar-fill { background: linear-gradient(90deg, #5a3cff, var(--xp)); }
.hp-bar .bar-fill { background: linear-gradient(90deg, #a01a2a, var(--hp)); transition: width .08s linear; }
.bar-label {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
  font-variant-numeric: tabular-nums;
}

/* Battle */
.battle-panel { display: flex; flex-direction: column; }
.zone-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.zone-info { flex: 1; text-align: center; }
.zone-name { font-weight: 700; font-size: 16px; }
.zone-stage { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.zone-btn {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px; cursor: pointer;
  transition: .15s;
}
.zone-btn:hover:not(:disabled) { background: var(--panel-2); border-color: var(--ember); }
.zone-btn:disabled { opacity: .3; cursor: not-allowed; }

.arena {
  position: relative;
  flex: 1;
  min-height: 240px;
  border-radius: 14px;
  background:
    radial-gradient(500px 240px at 50% 120%, rgba(255,122,47,.14), transparent 70%),
    linear-gradient(180deg, #120c1c, #0a0710);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  overflow: hidden;
  cursor: pointer;
}
.arena::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 40%;
  background: linear-gradient(180deg, transparent, rgba(255,122,47,.06));
}
.enemy { text-align: center; width: 220px; z-index: 2; }
.enemy.hit { animation: shake .12s; }
.enemy.die { animation: die .25s forwards; }
@keyframes shake { 25% { transform: translateX(-6px);} 75% { transform: translateX(6px);} }
@keyframes die { to { transform: scale(.2) rotate(20deg); opacity: 0; } }
.enemy.spawn { animation: spawn .3s ease; }
@keyframes spawn { from { transform: scale(.4); opacity: 0; } }
.enemy-glyph {
  font-size: 78px;
  filter: drop-shadow(0 0 10px rgba(255,93,108,.5));
  margin-bottom: 6px;
}
.enemy.boss .enemy-glyph { font-size: 96px; filter: drop-shadow(0 0 16px rgba(255,207,90,.7)); }
.enemy-name { font-weight: 700; margin-bottom: 8px; }
.enemy.boss .enemy-name { color: var(--gold); }

.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.dmg {
  position: absolute;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  text-shadow: 0 2px 4px #000;
  animation: floatUp .8s ease forwards;
  pointer-events: none;
}
.dmg.crit { color: var(--gold); font-size: 26px; }
.dmg.gold { color: var(--gold); font-size: 15px; }
@keyframes floatUp {
  from { transform: translateY(0) scale(.7); opacity: 0; }
  20% { opacity: 1; transform: translateY(-10px) scale(1.1); }
  to { transform: translateY(-60px) scale(1); opacity: 0; }
}

.battle-log {
  margin-top: 10px;
  height: 78px;
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
}
.battle-log .loot { color: var(--gold); }
.battle-log .up { color: var(--good); }

/* Shop */
.shop-panel { display: flex; flex-direction: column; }
.shop-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  flex: 1;
  padding: 8px 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  transition: .15s;
}
.tab.active { color: var(--text); border-color: var(--ember); background: var(--panel-2); }
.shop-body { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 460px; }

.upg {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
  cursor: pointer;
  transition: .12s;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.upg:hover:not(.locked) { border-color: var(--ember); transform: translateY(-1px); }
.upg.affordable { box-shadow: inset 0 0 0 1px rgba(255,207,90,.25); }
.upg.locked { opacity: .45; cursor: not-allowed; }
.upg-top { display: flex; justify-content: space-between; align-items: center; }
.upg-name { font-weight: 700; font-size: 14px; }
.upg-lvl { font-size: 11px; color: var(--muted); }
.upg-desc { font-size: 12px; color: var(--muted); }
.upg-cost { font-size: 13px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.upg-cost.soul { color: var(--soul); }
.upg-cost.cant { color: var(--muted); }

.prestige-info {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.prestige-info b { color: var(--soul); }
.ascend-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(90deg, #0d5a6e, #16b6d6);
  color: #04141a;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  margin-top: 4px;
}
.ascend-btn:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.6); }

/* Footer */
.game-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  flex-wrap: wrap;
}
.ghost-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 12px;
}
.ghost-btn:hover { border-color: var(--ember); }
.ghost-btn.danger:hover { border-color: var(--hp); color: var(--hp); }
.tip { margin-left: auto; color: var(--good); }

@media (max-width: 940px) {
  .layout { grid-template-columns: 1fr; }
  .shop-body { max-height: none; }
}
