/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ---- Theme variables (mirrors ShiroNexus portal) ---- */
[data-theme="dark"] {
  --bg:          #0c0c15;
  --surface:     #13131f;
  --surface-hov: #18182a;
  --inset:       rgba(255, 255, 255, 0.04);
  --border:      rgba(255, 255, 255, 0.07);
  --border-hov:  rgba(255, 255, 255, 0.14);
  --text:        #eeeef5;
  --muted:       #7878a0;
  --accent:      #a78bfa;
  --shadow:      rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
  --bg:          #f0ece8;
  --surface:     #ffffff;
  --surface-hov: #f7f5ff;
  --inset:       rgba(0, 0, 0, 0.03);
  --border:      rgba(0, 0, 0, 0.08);
  --border-hov:  rgba(0, 0, 0, 0.18);
  --text:        #1b1020;
  --muted:       #706080;
  --accent:      #7c3aed;
  --shadow:      rgba(0, 0, 0, 0.12);
}

:root {
  --xp:    #3b82f6;
  --mon:   #ef4444;
  --gold:  #f59e0b;
  --boss:  #fbbf24;
  --souls: #c084fc;
  --green: #22c55e;
  --header-h: 54px;
}

/* ---- Base ---- */
html { font-family: 'Cabin', -apple-system, sans-serif; font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.25s, color 0.25s;
}

/* ---- Header ---- */
.header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 1rem;
  flex-shrink: 0;
}

.header-left  { display: flex; align-items: center; gap: 0.875rem; }
.header-right { display: flex; align-items: center; gap: 0.5rem; }

.back-btn {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.back-btn:hover { color: var(--text); border-color: var(--border-hov); }

.game-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; }

.hbadge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.28rem 0.8rem;
  border-radius: 99px;
  white-space: nowrap;
}
.gold-badge { color: var(--gold); background: rgba(245,158,11,0.1);  border: 1px solid rgba(245,158,11,0.25); }
.dps-badge  { color: #f87171;    background: rgba(239,68,68,0.1);    border: 1px solid rgba(239,68,68,0.22); }

.theme-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s, transform 0.2s;
  flex-shrink: 0;
}
.theme-btn:hover { border-color: var(--border-hov); transform: rotate(18deg); }

/* ---- Layout ---- */
.game-layout {
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  gap: 0.875rem;
  padding: 0.875rem;
  flex: 1;
  height: calc(100vh - var(--header-h));
  min-height: 0;
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow-y: auto;
  min-height: 0;
}

.panel-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.divider { height: 1px; background: var(--border); }

/* ---- Bars ---- */
.bar-track { height: 7px; background: var(--inset); border-radius: 99px; overflow: hidden; }
.bar-track.big-bar { height: 14px; }
.bar-fill { height: 100%; border-radius: 99px; transition: width 0.1s linear; }
.mon-fill { background: linear-gradient(90deg, #ef4444, #f87171); }

/* ════════ STATS PANEL ════════ */
.big-stats { display: flex; flex-direction: column; gap: 0.5rem; }

.bstat {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}
.bstat-ico { font-size: 1.4rem; line-height: 1; }
.bstat-lbl { display: block; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.bstat-val { display: block; font-size: 1.05rem; font-weight: 700; }

.souls-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid rgba(192,132,252,0.3);
  background: rgba(192,132,252,0.08);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}
.souls-ico { font-size: 1.35rem; }
.souls-val   { display: block; font-size: 0.9rem; font-weight: 700; color: var(--souls); }
.souls-bonus { display: block; font-size: 0.68rem; color: var(--muted); }

.ascend-btn {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.55rem;
  border: 1px solid rgba(192,132,252,0.4);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(192,132,252,0.18), rgba(124,58,237,0.12));
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s;
}
.ascend-btn:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(124,58,237,0.3); }
.ascend-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ascend-top { font-size: 0.85rem; font-weight: 700; }
.ascend-sub { font-size: 0.66rem; color: var(--muted); }

.info-rows { display: flex; flex-direction: column; gap: 0.35rem; }
.info-row {
  display: flex; justify-content: space-between;
  font-size: 0.75rem; color: var(--muted);
}
.info-row span:last-child { color: var(--text); font-weight: 600; }

.reset-btn {
  margin-top: auto;
  padding: 0.38rem 0.6rem;
  font-size: 0.7rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  font-family: inherit;
  align-self: flex-start;
}
.reset-btn:hover { color: #ef4444; border-color: rgba(239,68,68,0.5); }

/* ════════ COMBAT PANEL ════════ */
.combat-panel {
  align-items: center;
  background:
    radial-gradient(circle at 50% 38%, var(--inset) 0%, transparent 60%),
    var(--surface);
}

.zone-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
}
.znav-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--inset);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, opacity 0.2s;
  flex-shrink: 0;
}
.znav-btn:not(:disabled):hover { border-color: var(--border-hov); background: var(--surface-hov); }
.znav-btn:disabled { opacity: 0.25; cursor: not-allowed; }

.zone-title { text-align: center; min-width: 160px; }
.zone-name { display: block; font-size: 1.05rem; font-weight: 700; color: var(--accent); }
.zone-num  { display: block; font-size: 0.72rem; color: var(--muted); }

.auto-toggle {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.8rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--inset);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s, border-color 0.2s;
}
.auto-toggle.on { color: var(--green); border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.08); }

/* Boss timer */
.boss-timer { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.boss-timer-bar-track { width: 100%; height: 8px; background: var(--inset); border-radius: 99px; overflow: hidden; }
.boss-timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #fbbf24, #f59e0b); transition: width 0.1s linear; }
.boss-timer-text { font-size: 0.75rem; font-weight: 700; color: var(--boss); }

/* Monster stage */
.monster-stage {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  min-height: 0;
  padding: 0.5rem 0;
}

.float-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }

.monster-name { font-size: 1.15rem; font-weight: 700; text-align: center; }

.monster-emoji {
  font-size: 5.5rem;
  line-height: 1;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.55));
  transition: transform 0.07s ease;
  will-change: transform;
}
.monster-emoji.bounce { transform: scale(0.9); }
[data-theme="light"] .monster-emoji { filter: drop-shadow(0 8px 18px rgba(0,0,0,0.25)); }

.monster-hp { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 0.25rem; align-items: center; }
.monster-hp-text { font-size: 0.78rem; font-weight: 600; color: var(--muted); }

.click-hint { font-size: 0.7rem; color: var(--muted); opacity: 0.7; animation: hint-pulse 2s ease-in-out infinite; }
@keyframes hint-pulse { 0%,100% { opacity: 0.35; } 50% { opacity: 0.8; } }

/* Floating damage numbers */
.float-num {
  position: absolute;
  font-weight: 700;
  font-size: 1rem;
  color: #fde68a;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  pointer-events: none;
  animation: floatUp 0.8s ease-out forwards;
  white-space: nowrap;
}
.float-num.crit { font-size: 1.5rem; color: #fca5a5; }
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, 0) scale(0.7); }
  15%  { opacity: 1; transform: translate(-50%, -8px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -55px) scale(1); }
}

/* Progress pips */
.progress-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.progress-lbl { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.pips { display: flex; gap: 0.3rem; }
.pip { width: 14px; height: 8px; border-radius: 99px; background: var(--inset); border: 1px solid var(--border); transition: background 0.15s; }
.pip.filled { background: var(--green); border-color: var(--green); }

/* ════════ HEROES PANEL ════════ */
.heroes-hdr { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-shrink: 0; }

.buy-amount { display: flex; gap: 0.2rem; }
.buy-amount button {
  font-size: 0.66rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border);
  background: var(--inset);
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.buy-amount button.active { color: #fff; background: var(--accent); border-color: var(--accent); }

.hero-list { display: flex; flex-direction: column; gap: 0.45rem; }

.hero-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--inset);
}
.hero-row.locked { opacity: 0.5; }
.hero-row.owned  { opacity: 0.5; }

.hero-icon { font-size: 1.6rem; line-height: 1; flex-shrink: 0; width: 1.8rem; text-align: center; }

.hero-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.12rem; }
.hero-top { display: flex; align-items: baseline; justify-content: space-between; gap: 0.4rem; }
.hero-name { font-size: 0.82rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-lvl  { font-size: 0.68rem; font-weight: 700; color: var(--accent); flex-shrink: 0; }
.hero-sub  { font-size: 0.66rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hero-buy {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
  min-width: 78px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.1s, opacity 0.15s;
}
.hero-buy:not(:disabled):hover { border-color: var(--accent); background: var(--surface-hov); transform: translateY(-1px); }
.hero-buy:disabled { opacity: 0.4; cursor: not-allowed; }
.buy-label { font-size: 0.68rem; font-weight: 700; }
.buy-cost  { font-size: 0.66rem; font-weight: 700; color: var(--gold); }

/* ════════ TOAST ════════ */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border-hov);
  color: var(--text);
  padding: 0.6rem 1.1rem;
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 10px 30px var(--shadow);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}
@keyframes toastIn  { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(14px); } }

/* ════════ HERO SKILLS ════════ */
.skill-strip { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.3rem; }

.skill-pip {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--inset);
  white-space: nowrap;
  color: var(--muted);
  cursor: default;
  font-family: inherit;
}
.skill-buy {
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.skill-buy:not(:disabled):hover { border-color: var(--accent); background: var(--surface-hov); }
.skill-buy:disabled { opacity: 0.45; cursor: not-allowed; }
.skill-owned { border-color: rgba(192,132,252,0.5); background: rgba(192,132,252,0.12); color: var(--souls); }
.skill-locked { opacity: 0.38; }

/* ════════ SOUL SHOP ════════ */
.soul-shop-list { display: flex; flex-direction: column; gap: 0.38rem; }

.soul-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(192,132,252,0.2);
  border-radius: 9px;
  background: rgba(192,132,252,0.05);
}
.soul-row-icon { font-size: 1.1rem; line-height: 1; width: 1.4rem; text-align: center; flex-shrink: 0; }
.soul-row-main { flex: 1; min-width: 0; }
.soul-row-name { font-size: 0.72rem; font-weight: 700; }
.soul-row-rank { font-weight: 400; color: var(--souls); font-size: 0.66rem; margin-left: 0.25rem; }
.soul-row-desc { font-size: 0.62rem; color: var(--muted); }
.soul-row-btn {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border: 1px solid rgba(192,132,252,0.35);
  border-radius: 7px;
  background: rgba(192,132,252,0.12);
  color: var(--souls);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
}
.soul-row-btn:not(:disabled):hover { border-color: rgba(192,132,252,0.6); background: rgba(192,132,252,0.22); }
.soul-row-btn:disabled { opacity: 0.38; cursor: not-allowed; }

/* ════════ ASCEND MODAL ════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  padding: 1rem;
}

.modal-box {
  background: var(--surface);
  border: 1px solid rgba(192,132,252,0.4);
  border-radius: 20px;
  padding: 2rem 2.25rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 28px 64px rgba(0,0,0,0.65), 0 0 0 1px rgba(192,132,252,0.1);
  animation: modalIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.86) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

.modal-glow  { font-size: 2.4rem; line-height: 1; }
.modal-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin-top: -0.3rem; }

.modal-souls-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(192,132,252,0.3);
  background: rgba(192,132,252,0.08);
}
.modal-big   { font-size: 2.8rem; font-weight: 700; color: var(--souls); line-height: 1; }
.modal-label { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

.modal-gain {
  font-size: 1rem;
  font-weight: 700;
  color: var(--green);
  background: rgba(34,197,94,0.1);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
}

.modal-lines { display: flex; flex-direction: column; gap: 0.35rem; text-align: left; }
.modal-line {
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 7px;
}
.modal-warn { background: rgba(239,68,68,0.08); color: #f87171; }
.modal-keep { background: rgba(163,230,53,0.07); color: #a3e635; }

.modal-tip {
  font-size: 0.7rem;
  color: var(--muted);
  font-style: italic;
  margin-top: -0.2rem;
}

.modal-actions { display: flex; gap: 0.65rem; margin-top: 0.25rem; }

.modal-cancel {
  flex: 1;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--inset);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  transition: border-color 0.15s, color 0.15s;
}
.modal-cancel:hover { border-color: var(--border-hov); color: var(--text); }

.modal-confirm {
  flex: 1.6;
  padding: 0.6rem;
  border: 1px solid rgba(192,132,252,0.55);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(192,132,252,0.28), rgba(124,58,237,0.2));
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  transition: transform 0.12s, box-shadow 0.2s;
}
.modal-confirm:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(124,58,237,0.4); }

/* ════════ RESPONSIVE ════════ */
@media (max-width: 980px) {
  .game-layout { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .panel { min-height: unset; }
  .combat-panel { min-height: 460px; order: -1; }
  .monster-emoji { font-size: 4.5rem; }
}
@media (max-width: 520px) {
  .back-btn { display: none; }
  .dps-badge { display: none; }
  .game-layout { padding: 0.6rem; gap: 0.6rem; }
}
