:root {
  --bg: #0d1017;
  --bg2: #141924;
  --bg3: #1c2331;
  --line: #2a3444;
  --txt: #e6ebf2;
  --txt2: #93a0b3;
  --acc: #f0b429;
  --acc2: #38bdf8;
  --good: #4ade80;
  --bad: #f87171;
  --crit: #fbbf24;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1b2436 0%, transparent 60%),
    var(--bg);
  color: var(--txt);
  font: 15px/1.5 'Segoe UI', system-ui, -apple-system, 'Noto Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

h1, h2, h3 { margin: 0 0 10px; line-height: 1.25; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }

.muted { color: var(--txt2); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.acc { color: var(--acc); }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

#app { max-width: 1080px; margin: 0 auto; padding: 0 12px 60px; }

/* ---------- Topbar ---------- */
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; flex-wrap: wrap;
}
.tb-portrait { font-size: 30px; line-height: 1; }
.tb-name { font-weight: 700; }
.tb-exp {
  width: 160px; height: 7px; background: var(--bg3);
  border-radius: 99px; overflow: hidden; margin-top: 4px;
}
.tb-exp > i { display: block; height: 100%; background: linear-gradient(90deg, var(--acc2), #818cf8); }
.tb-gold {
  margin-left: auto; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 99px; padding: 7px 14px; font-weight: 700; color: var(--acc);
  font-variant-numeric: tabular-nums;
}
.tb-power {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 99px; padding: 7px 14px; font-weight: 700;
}

/* ---------- Tabs ---------- */
#tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 10px;
  scrollbar-width: none;
}
#tabs::-webkit-scrollbar { display: none; }
#tabs button {
  background: var(--bg2); border: 1px solid var(--line); color: var(--txt2);
  padding: 9px 14px; border-radius: 10px; white-space: nowrap; transition: .15s;
}
#tabs button:hover { color: var(--txt); border-color: #3b4759; }
#tabs button.on { background: var(--acc); border-color: var(--acc); color: #1a1405; font-weight: 700; }
#tabs .dot { display: inline-block; width: 7px; height: 7px; border-radius: 99px; background: var(--bad); margin-left: 5px; vertical-align: middle; }

/* ---------- Card / panel ---------- */
.card {
  background: linear-gradient(180deg, var(--bg2), #11151e);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card > h3:first-child { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 780px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.btn {
  background: var(--bg3); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 16px; transition: .15s;
}
.btn:hover { border-color: #4b5a70; background: #26303f; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #1a1405; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: #7f2d2d; color: #fca5a5; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.on { background: var(--acc2); border-color: var(--acc2); color: #04202b; font-weight: 700; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  background: var(--bg3); border: 1px solid var(--line); font-size: 12px;
}

/* ---------- Stat table ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
@media (max-width: 560px) { .stat-grid { grid-template-columns: 1fr; } }
.stat-row {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 5px 0; border-bottom: 1px dashed #222b39; font-size: 14px;
}
.stat-name { color: var(--txt2); }
.stat-val { font-weight: 700; font-variant-numeric: tabular-nums; }

.cmp-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cmp-table th { color: var(--txt2); font-size: 12px; padding-bottom: 6px; }
.cmp-table td { padding: 4px 6px; border-bottom: 1px dashed #222b39; }
.cmp-a, .cmp-b { font-weight: 700; font-variant-numeric: tabular-nums; width: 30%; }
.cmp-a { text-align: right; }
.cmp-b { text-align: left; }
.cmp-mid { text-align: center; color: var(--txt2); font-size: 12.5px; }
.better { color: var(--good); }
.worse { color: #6b7787; }

.chip {
  display: inline-block; font-size: 12px; padding: 2px 7px; border-radius: 6px;
  background: #17202c; border: 1px solid var(--line); margin: 2px 3px 2px 0;
}
.chip.pos { color: #a7f3d0; }
.chip.neg { color: #fca5a5; }

.portrait { display: inline-block; line-height: 1; }
.portrait.big { font-size: 46px; }
.portrait img { width: 1em; height: 1em; object-fit: contain; vertical-align: middle; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: #1e2735; border: 1px solid var(--line); color: var(--txt);
  padding: 11px 20px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: .2s; z-index: 300; max-width: 90vw; text-align: center;
  box-shadow: 0 10px 30px #0008;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.ok { border-color: #2f6b45; }
#toast.err { border-color: #7f2d2d; }

/* ---------- Modal ---------- */
.modal-wrap {
  position: fixed; inset: 0; background: #05070bcc; backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 200; padding: 16px;
  opacity: 0; transition: .18s;
}
.modal-wrap.in { opacity: 1; }
.modal {
  background: linear-gradient(180deg, #18202c, #10151d);
  border: 1px solid var(--line); border-radius: 16px; padding: 20px;
  max-width: 520px; width: 100%; max-height: 88vh; overflow: auto;
  box-shadow: 0 24px 70px #000a;
  transform: scale(.97); transition: .18s;
}
.modal-wrap.in .modal { transform: scale(1); }
