:root {
  --bg: #12171a; --panel: #1b2327; --panel-2: #243036; --line: #33444c;
  --text: #f1e9d8; --muted: #9aa7a4; --accent: #e0a23c; --accent-ink: #2a1c05;
  --good: #7fc77a; --bad: #e0705c;
  --q-common: #a7b0ae; --q-uncommon: #7fc77a; --q-rare: #62a8e8; --q-epic: #b98cf0; --q-legendary: #f0b445;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#app { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; }
h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: .01em; }
h2 { font-size: 13px; margin: 20px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
.btn {
  display: block; width: 100%; padding: 14px 16px; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 16px;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: var(--panel-2); color: var(--text); font-weight: 600; }
.btn.slim { width: auto; padding: 10px 14px; font-size: 14px; }
input[type=text] {
  width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; margin: 12px 0;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--panel);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
#tabs[hidden] { display: none; }
#tabs button { flex: 1; padding: 16px 4px; background: none; color: var(--muted); font-size: 14px; font-weight: 600; }
#tabs button.on { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }

.idol { width: 84px; height: 84px; flex: none; border-radius: 16px; background: var(--panel-2); }
.idol.sm { width: 52px; height: 52px; border-radius: 12px; }
.bar { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .35s ease; }
.bar.hp > i { background: var(--good); }
.bar.hp.low > i { background: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--panel-2); border-radius: 10px; padding: 8px 4px; text-align: center; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--panel-2); border-radius: 999px; padding: 5px 10px; font-size: 13px; }
.pips { display: flex; gap: 5px; }
.pips i { width: 14px; height: 14px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); }
.pips i.on { background: var(--accent); border-color: var(--accent); }

.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 10px 4px; border-radius: 9px; background: none; color: var(--muted); font-size: 14px; font-weight: 600; }
.seg button.on { background: var(--panel-2); color: var(--text); }
.list { display: grid; gap: 8px; }

.item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.item.on { border-color: var(--accent); background: var(--panel-2); }
.item .dot { width: 12px; height: 12px; border-radius: 3px; flex: none; transform: rotate(45deg); }
.q-common { color: var(--q-common); } .q-uncommon { color: var(--q-uncommon); } .q-rare { color: var(--q-rare); }
.q-epic { color: var(--q-epic); } .q-legendary { color: var(--q-legendary); }
.dot.q-common { background: var(--q-common); } .dot.q-uncommon { background: var(--q-uncommon); } .dot.q-rare { background: var(--q-rare); }
.dot.q-epic { background: var(--q-epic); } .dot.q-legendary { background: var(--q-legendary); }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot { min-height: 76px; border-radius: 12px; border: 1px dashed var(--line); padding: 10px 8px; font-size: 13px; text-align: center; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.slot.full { border-style: solid; background: var(--panel); }

.overlay { position: fixed; inset: 0; background: rgba(8, 11, 13, .88); display: flex; align-items: flex-end; padding: 16px; z-index: 5; }
.sheet { width: 100%; max-width: 520px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px; min-height: 130px; text-align: center; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.card b { font-size: 16px; }
.card .kind { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.card.rare { border-color: var(--q-legendary); }

.duel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.duel .side b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.duel .side.right { text-align: right; }
.hpnum { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.log { margin: 14px 0; height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.log div { padding: 7px 10px; border-radius: 10px; background: var(--panel); font-size: 14px; max-width: 88%; }
.log div.b { align-self: flex-end; text-align: right; }
.log div.crit { border: 1px solid var(--accent); }
.log div.sys { align-self: center; background: none; color: var(--muted); }
.verdict { font-size: 28px; font-weight: 800; margin: 0; }
.verdict.win { color: var(--good); } .verdict.lose { color: var(--bad); }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 488px; background: var(--bad); color: #1c0905; font-weight: 600; padding: 12px 14px; border-radius: 12px; z-index: 9; }
#toast[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .bar > i { transition: none; } }
