:root {
  --bg: #0f1117;
  --panel: #1a1d27;
  --panel2: #232735;
  --line: #2e3345;
  --text: #e8eaf0;
  --muted: #8d94a8;
  --accent: #ffcb05;
  --blue: #3b4cca;
  --red: #ed4245;
  --green: #57f287;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", sans-serif;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
small { color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.err { color: var(--red); min-height: 1.2em; }

/* ── 상단바 ── */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; font-size: 1.15rem; color: var(--accent); }
.topbar nav { display: flex; gap: 18px; }
.topbar nav a:hover { color: var(--accent); }
.account { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; }
.uname { font-size: .92rem; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }

.btn {
  display: inline-block; padding: 9px 16px; border-radius: 10px;
  background: var(--blue); color: #fff; border: 0; cursor: pointer;
  font-size: .92rem; font-weight: 600; font-family: inherit;
}
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.big { padding: 13px 26px; font-size: 1rem; }
.btn.tiny { padding: 5px 10px; font-size: .78rem; background: var(--accent); color: #222; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 20px; margin-bottom: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 1.05rem; }

.hero { text-align: center; padding: 40px 20px 26px; }
.hero h1 { font-size: 2rem; margin: 0 0 8px; }
.hero p { color: var(--muted); margin: 0 0 20px; }

/* ── 통계 카드 ── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-label { color: var(--muted); font-size: .82rem; }
.stat-value { font-size: 1.6rem; font-weight: 800; margin: 4px 0; }
.stat-value small { font-size: .85rem; }
.stat-sub { font-size: .8rem; color: var(--muted); }

.bar { background: var(--panel2); border-radius: 99px; height: 7px; overflow: hidden; margin-top: 8px; }
.bar span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.bar.sm { height: 5px; }
.bar.hp span { background: var(--green); }
.bar.hp span.mid { background: var(--accent); }
.bar.hp span.low { background: var(--red); }

/* ── 랭킹 ── */
.ranking { list-style: none; margin: 0; padding: 0; }
.ranking li { display: flex; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.ranking li:last-child { border-bottom: 0; }
.rank { width: 26px; font-weight: 800; color: var(--accent); }
.rname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rdex { color: var(--muted); }
.rtotal { color: var(--muted); width: 70px; text-align: right; }

/* ── 도감 ── */
.filters { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { padding: 5px 12px; border-radius: 99px; background: var(--panel2); font-size: .82rem; }
.chip.on { background: var(--accent); color: #222; font-weight: 700; }

.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 9px; }
.dex-cell {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 4px; text-align: center; position: relative;
}
.dex-cell img { width: 64px; height: 64px; image-rendering: pixelated; }
.dex-cell.locked img { filter: brightness(0) opacity(.28); }
.dex-no { font-size: .68rem; color: var(--muted); }
.dex-name { font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dex-meta { position: absolute; top: 4px; right: 6px; font-size: .7rem; }
.cnt { color: var(--muted); }

/* ── 파티 ── */
.party-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.party-slot { background: var(--panel2); border-radius: 12px; padding: 12px; text-align: center; position: relative; }
.slot-no { position: absolute; top: 7px; left: 10px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.party-slot img { width: 92px; height: 92px; }
.pname { font-weight: 700; font-size: .88rem; }
.plv { color: var(--muted); font-size: .8rem; }
.ptypes { display: flex; gap: 4px; justify-content: center; margin: 6px 0 3px; }
.type { background: var(--panel); padding: 2px 8px; border-radius: 99px; font-size: .7rem; }
.piv { font-size: .74rem; color: var(--muted); margin-bottom: 6px; }

.owned-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.owned-cell { background: var(--panel2); border-radius: 10px; padding: 9px; text-align: center; }
.owned-cell.in-party { outline: 2px solid var(--accent); }
.owned-cell img { width: 56px; height: 56px; image-rendering: pixelated; }
.slot-pick {
  width: 100%; margin-top: 6px; padding: 4px; border-radius: 7px;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); font-family: inherit; font-size: .76rem;
}

/* ── 배틀 ── */
.arena {
  background: linear-gradient(160deg, #1d2333, #141824);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; margin-bottom: 18px;
  display: flex; flex-direction: column; gap: 22px;
}
.fighter { display: flex; flex-direction: column; gap: 4px; }
.fighter.foe { align-items: flex-end; text-align: right; }
.fighter img { width: 130px; height: 130px; }
.fname { font-weight: 700; }
.hptext { font-size: .78rem; color: var(--muted); }
.fighter .bar { width: 190px; }
.team { display: flex; gap: 3px; margin-top: 6px; }
.team img { width: 26px; height: 26px; image-rendering: pixelated; }
.team img.fainted { filter: grayscale(1) opacity(.3); }

.moves { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 9px; margin-bottom: 14px; }
.move {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px; cursor: pointer; color: var(--text); font-family: inherit; text-align: left;
}
.move:hover:not(:disabled) { border-color: var(--accent); }
.move:disabled { opacity: .45; cursor: default; }
.mname { display: block; font-weight: 700; font-size: .9rem; }
.mmeta { display: block; font-size: .74rem; color: var(--muted); }

.log {
  background: #0b0d13; border-radius: 10px; padding: 12px;
  max-height: 230px; overflow-y: auto; font-size: .84rem; line-height: 1.65;
}

footer { text-align: center; padding: 24px; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); }

@media (max-width: 640px) {
  .topbar { gap: 12px; padding: 12px 14px; }
  .uname { display: none; }
  .fighter .bar { width: 140px; }
  .fighter img { width: 100px; height: 100px; }
}
