:root {
  --bg: #101418;
  --bg2: #1a2129;
  --bg3: #242e39;
  --line: #2f3b48;
  --text: #dfe6ee;
  --muted: #8b9bab;
  --accent: #e03a3a;
  --gold: #f0b23c;
  --green: #4caf6d;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
}
h1 { font-size: 1.2rem; }
h2 { font-size: 1.05rem; margin-bottom: .6rem; color: var(--gold); }
button { font-family: inherit; }

#topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .7rem 1.2rem; background: var(--bg2);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-actions { display: flex; gap: .5rem; }

.view { max-width: 1200px; margin: 0 auto; padding: 1.2rem; }
.home-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1rem; }
@media (max-width: 800px) { .home-cols { grid-template-columns: 1fr; } }
.feed-tl-icon {
  width: 40px; height: 40px; border-radius: 4px; flex-shrink: 0;
  background: var(--bg3); border: 1px solid var(--gold); color: var(--gold);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem;
}
h2.mt { margin-top: 1.2rem; }

.btn {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: .45rem .9rem; cursor: pointer; font-size: .9rem;
  display: inline-block;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.15); }
.btn.danger { color: #ff8a8a; }

/* ---- hero picker ---- */
.hero-filters { display: flex; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
#hero-search, #item-search {
  background: var(--bg3); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: .45rem .8rem; width: 260px; font-size: .9rem;
}
#attr-filters { display: flex; gap: .4rem; }
#hero-sort {
  background: var(--bg3); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: .45rem .7rem; font-size: .88rem;
}
.attr-btn {
  background: var(--bg3); border: 1px solid var(--line); color: var(--muted);
  border-radius: 6px; padding: .4rem .7rem; cursor: pointer; font-size: .85rem;
}
.attr-btn.active { color: var(--text); border-color: var(--gold); }

#hero-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .6rem;
}
.hero-card {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; cursor: pointer; text-align: center;
}
.hero-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.hero-card img { width: 100%; aspect-ratio: 256/144; object-fit: cover; display: block; }
.hero-card .hname { padding: .35rem; font-size: .85rem; }

/* ---- build lists ---- */
.build-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .8rem; }
.build-row {
  display: flex; align-items: center; gap: .7rem;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
  padding: .5rem .8rem; cursor: pointer;
}
.build-row:hover { border-color: var(--gold); }
.build-row img { width: 40px; border-radius: 4px; }
.build-row .b-name { font-weight: 600; }
.b-meta { color: var(--muted); font-size: .82rem; }
.spacer { flex: 1; }
.empty-note { color: var(--muted); font-size: .88rem; padding: .4rem 0; }

/* ---- hero page ---- */
#hero-page-head {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem;
}
#hero-page-head img.portrait { width: 190px; border-radius: 8px; }
#hero-page-head .hp-name { font-size: 1.5rem; font-weight: 700; }
#hero-page-head .hp-meta { color: var(--muted); margin-top: .3rem; }
.hero-page-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 800px) { .hero-page-cols { grid-template-columns: 1fr; } }

/* ---- editor head ---- */
#editor-head, #guide-head {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: .9rem 1rem; margin-bottom: 1.2rem;
}
#editor-head img.portrait { width: 130px; border-radius: 6px; }
#editor-head .eh-fields { display: flex; flex-direction: column; gap: .45rem; flex: 1; min-width: 220px; }
#editor-head input[type=text], #editor-head select {
  background: var(--bg3); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: .45rem .7rem; font-size: .95rem; max-width: 340px;
}
#editor-head .eh-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.editor-section {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem; margin-bottom: 1.2rem;
}
.section-head { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: .8rem; }

/* ---- skill grid ---- */
#skill-grid-wrap { overflow-x: auto; margin-top: .6rem; }
#skill-grid { border-collapse: collapse; }
#skill-grid th, #skill-grid td {
  border: 1px solid var(--line); text-align: center; min-width: 34px;
  padding: 2px; font-size: .78rem;
}
#skill-grid th.lvl-talent { color: var(--gold); }
#skill-grid td.ability-label {
  text-align: left; padding: 3px 8px 3px 3px; white-space: nowrap;
  position: sticky; left: 0; background: var(--bg2); z-index: 2;
}
#skill-grid td.ability-label img { width: 30px; vertical-align: middle; border-radius: 4px; margin-right: 6px; }
#skill-grid td.skill-cell { cursor: pointer; height: 34px; }
#skill-grid td.skill-cell:hover { background: var(--bg3); }
#skill-grid td.skill-cell.on { background: var(--gold); color: #1c1c1c; font-weight: 700; }
#skill-grid td.count { color: var(--muted); }
#skill-grid td.count.over { color: var(--accent); font-weight: 700; }

/* ---- talents ---- */
#talent-picker { display: flex; flex-direction: column; gap: .5rem; }
.talent-tier { display: flex; align-items: center; gap: .6rem; }
.talent-lvl {
  width: 44px; height: 44px; border-radius: 50%; background: var(--bg3);
  border: 1px solid var(--gold); color: var(--gold);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  flex-shrink: 0;
}
.talent-opt {
  flex: 1; background: var(--bg3); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; padding: .55rem .7rem;
  cursor: pointer; font-size: .85rem; text-align: center;
}
.talent-opt.on { border-color: var(--gold); background: #3a3323; color: var(--gold); }

/* ---- phases ---- */
.phase {
  background: var(--bg3); border: 1px solid var(--line); border-radius: 8px;
  padding: .7rem; margin-bottom: .7rem;
}
.phase-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.phase-head input {
  background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: .35rem .6rem; font-size: .88rem;
}
.phase-head input.p-title { width: 220px; font-weight: 600; }
.phase-head input.p-time { width: 130px; color: var(--gold); }
.phase-head .spacer { flex: 1; }
.icon-btn {
  background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 6px; width: 30px; height: 30px; cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.phase-items { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.p-item { position: relative; text-align: center; width: 72px; }
.p-item img { width: 68px; border-radius: 5px; display: block; margin: 0 auto; }
.p-item .i-name { font-size: .68rem; color: var(--muted); line-height: 1.15; display: block; margin-top: 2px; }
.p-item .i-del {
  position: absolute; top: -7px; right: -1px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--accent); color: #fff; border: none;
  cursor: pointer; font-size: .7rem; line-height: 1; display: none;
}
.p-item:hover .i-del { display: block; }
.add-item-btn {
  width: 68px; height: 50px; border: 1px dashed var(--muted); border-radius: 5px;
  background: none; color: var(--muted); font-size: 1.3rem; cursor: pointer;
}
.add-item-btn:hover { color: var(--gold); border-color: var(--gold); }
.phase-note {
  width: 100%; margin-top: .5rem; background: var(--bg2);
  border: 1px solid var(--line); color: var(--text); border-radius: 6px;
  padding: .4rem .6rem; font-size: .85rem; resize: vertical;
}
.phase-cost { color: var(--gold); font-size: .8rem; margin-top: .4rem; }

#build-notes {
  width: 100%; background: var(--bg3); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; padding: .5rem .7rem; resize: vertical;
}

/* ---- item modal ---- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  width: min(860px, 94vw); max-height: 86vh; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; gap: .7rem; align-items: center; padding: .8rem;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.modal-tabs { display: flex; gap: .4rem; }
.tab-btn {
  background: var(--bg3); border: 1px solid var(--line); color: var(--muted);
  border-radius: 6px; padding: .4rem .8rem; cursor: pointer;
}
.tab-btn.active { color: var(--text); border-color: var(--gold); }
#item-modal-grid {
  overflow-y: auto; padding: .8rem;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .5rem;
}
.pick-item {
  display: flex; gap: .5rem; align-items: center;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 6px;
  padding: .35rem; cursor: pointer;
}
.pick-item:hover { border-color: var(--gold); }
.pick-item img { width: 44px; border-radius: 4px; }
.pick-item .pi-name { font-size: .78rem; line-height: 1.2; }
.pick-item .pi-cost { font-size: .72rem; color: var(--gold); }

/* ---- guide (view mode) ---- */
#guide-head .g-title { font-size: 1.4rem; font-weight: 700; }
.guide-section {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem; margin-bottom: 1.2rem;
}
.skill-seq { display: flex; flex-wrap: wrap; gap: .35rem; }
.seq-cell { text-align: center; width: 46px; }
.seq-cell img { width: 42px; border-radius: 5px; display: block; }
.seq-cell .seq-lvl { font-size: .72rem; color: var(--muted); }
.seq-cell.talent-cell .seq-box {
  width: 42px; height: 42px; border-radius: 50%; background: var(--bg3);
  border: 1px solid var(--gold); color: var(--gold); font-size: .65rem;
  display: flex; align-items: center; justify-content: center;
}
.guide-talents { display: flex; flex-direction: column; gap: .3rem; }
.guide-talents .gt-row { display: flex; gap: .6rem; align-items: center; }
.gt-lvl { color: var(--gold); font-weight: 700; width: 30px; }
.guide-phase { margin-bottom: 1rem; }
.guide-phase .gp-title { font-weight: 700; }
.guide-phase .gp-time { color: var(--gold); margin-left: .5rem; font-size: .85rem; }
.guide-phase .gp-note { color: var(--muted); font-size: .85rem; margin-top: .3rem; white-space: pre-wrap; }
.guide-notes { white-space: pre-wrap; }

/* ---- hero popularity ---- */
.pop-row { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: .7rem; }
.pop-stage { width: 90px; flex-shrink: 0; color: var(--gold); font-size: .85rem; padding-top: .6rem; }

/* ---- match viewer ---- */
.match-input-row { display: flex; gap: .5rem; margin: .6rem 0 .8rem; }
#match-id-input {
  background: var(--bg3); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: .45rem .8rem; width: 240px; font-size: .95rem;
}
.mv-recent-heroes { display: flex; gap: 2px; flex-wrap: wrap; max-width: 260px; }
.mv-recent-heroes img { width: 24px; border-radius: 3px; }
.mv-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.mv-winner { font-size: 1.2rem; font-weight: 700; padding: .4rem .9rem; border-radius: 8px; }
.mv-winner.radiant { background: #1d3323; color: #7ed99a; }
.mv-winner.dire { background: #3a2020; color: #ff9a8a; }
.mv-score { font-size: 1.6rem; font-weight: 700; color: var(--gold); }
.mv-team-title.radiant { color: #7ed99a; }
.mv-team-title.dire { color: #ff9a8a; }
.mv-table-wrap { overflow-x: auto; }
.mv-table { border-collapse: collapse; width: 100%; font-size: .85rem; }
.mv-table th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem;
  padding: .3rem .5rem; border-bottom: 1px solid var(--line);
}
.mv-table td { padding: .35rem .5rem; border-bottom: 1px solid var(--line); }
.mv-player-row { cursor: pointer; }
.mv-player-row:hover td { background: var(--bg3); }
.mv-hero-cell { white-space: nowrap; }
.mv-hero-cell img { width: 30px; border-radius: 4px; vertical-align: middle; margin-right: 6px; }
.mv-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-items { white-space: nowrap; }
.mv-items img { width: 30px; border-radius: 3px; margin-right: 2px; vertical-align: middle; }
.mv-items img.mv-neutral { border-radius: 50%; border: 1px solid var(--gold); }
.mv-detail-row td { background: var(--bg3); padding: .8rem; }
.mv-detail-row h2 { margin-top: .5rem; }

/* ---- advantage chart ---- */
.adv-chart-wrap { position: relative; }
.adv-chart { width: 100%; height: auto; display: block; }
.adv-tip {
  position: absolute; top: 4px; background: var(--bg3);
  border: 1px solid var(--line); border-radius: 6px; padding: .25rem .6rem;
  font-size: .8rem; pointer-events: none; white-space: nowrap;
}
.adv-legend { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-bottom: .4rem; font-size: .82rem; color: var(--muted); }
.adv-legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.adv-chip { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
details summary { cursor: pointer; color: var(--muted); font-size: .85rem; margin-top: .5rem; }
.adv-table { border-collapse: collapse; margin-top: .5rem; font-size: .8rem; }
.adv-table th, .adv-table td {
  border: 1px solid var(--line); padding: .2rem .6rem; text-align: right;
}
.adv-table th { color: var(--muted); }

/* ---- tier list ---- */
.tier-controls { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; }
#tier-roles { display: flex; gap: .4rem; flex-wrap: wrap; }
#tier-bracket {
  background: var(--bg3); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: .4rem .7rem; font-size: .88rem;
}
#tier-bracket:disabled { opacity: .45; cursor: not-allowed; }
.tier-band {
  display: flex; gap: .8rem; align-items: stretch;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: .7rem; margin-bottom: .7rem;
}
.tier-label {
  width: 56px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 800; border-radius: 8px; color: #14181d;
}
.tier-S { background: #e03a3a; color: #fff; }
.tier-A { background: #f0b23c; }
.tier-B { background: #4caf6d; }
.tier-C { background: #3684c8; color: #fff; }
.tier-D { background: #8b9bab; }
.tier-cards { display: flex; flex-wrap: wrap; gap: .5rem; }
.tier-card {
  display: flex; gap: .5rem; align-items: center;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 8px;
  padding: .35rem .55rem .35rem .35rem; cursor: pointer; width: 215px;
}
.tier-card:hover { border-color: var(--gold); }
.tier-card > img { width: 58px; border-radius: 5px; }
.tc-name { font-size: .82rem; font-weight: 600; line-height: 1.15; }
.tc-meta { font-size: .75rem; color: var(--muted); }
.tc-bar { height: 4px; background: var(--bg); border-radius: 2px; margin-top: 3px; width: 110px; }
.tc-bar-fill { height: 100%; background: var(--gold); border-radius: 2px; }

/* ---- custom tier list editor ---- */
.tl-head { display: flex; gap: .5rem; align-items: center; margin-bottom: .8rem; }
#tl-name {
  background: var(--bg3); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: .45rem .7rem; font-size: 1rem; font-weight: 600;
  flex: 1; max-width: 380px;
}
#tl-search {
  background: var(--bg3); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: .35rem .7rem; width: 200px; font-size: .88rem;
}
#tl-role-filter { display: flex; gap: .35rem; flex-wrap: wrap; }
.tl-drop { min-height: 76px; cursor: pointer; }
.tl-drop.dragover { border-color: var(--gold); background: #262f24; }
.tl-card { width: 168px; cursor: grab; }
.tl-card:active { cursor: grabbing; }
.tl-card.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
#tl-pool { min-height: 60px; }

/* ---- versus ---- */
#vs-search {
  background: var(--bg3); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: .45rem .8rem; width: 240px; font-size: .9rem;
  margin-bottom: .6rem;
}
#vs-picker { display: flex; flex-wrap: wrap; gap: 4px; }
.vs-pick { border: 2px solid transparent; border-radius: 6px; cursor: pointer; line-height: 0; }
.vs-pick img { width: 46px; border-radius: 4px; }
.vs-pick:hover { border-color: var(--muted); }
.vs-pick.active { border-color: var(--gold); }
.vs-head { display: flex; gap: 1rem; align-items: center; }
.vs-head img.portrait { width: 150px; border-radius: 8px; }
.vs-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 800px) { .vs-cols { grid-template-columns: 1fr; } }
.vs-adv { font-weight: 700; font-size: .95rem; }
.vs-adv.good { color: #7ed99a; }
.vs-adv.bad { color: #ff9a8a; }
.hint a { color: var(--gold); }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); border: 1px solid var(--gold); color: var(--text);
  padding: .6rem 1.2rem; border-radius: 8px; z-index: 100;
}

/* ---------- draft page ---------- */
#draft-controls { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
#draft-prob { margin-bottom: 1rem; }
.prob-labels { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .3rem; }
.prob-name { font-weight: 700; }
.prob-name.a, .prob-pct.a { color: #7ed99a; }
.prob-name.b, .prob-pct.b { color: #ff9a8a; }
.prob-pct { font-size: 1.3rem; font-weight: 700; }
.prob-bar { height: 14px; border-radius: 7px; background: #7a3a34; overflow: hidden; border: 1px solid var(--line); }
.prob-fill { height: 100%; background: #3f8b5c; border-right: 2px solid var(--bg); transition: width .3s; }
#draft-seq { display: flex; flex-wrap: wrap; gap: .8rem; }
.seq-phase { display: flex; flex-direction: column; gap: .25rem; }
.seq-label { font-size: .72rem; color: var(--muted); }
.seq-cells { display: flex; gap: 4px; }
.seq-cell {
  width: 40px; height: 40px; border-radius: 6px; display: flex;
  align-items: center; justify-content: center; overflow: hidden;
  border: 2px solid var(--line); background: var(--bg3);
}
.seq-cell.ta { border-color: #3f8b5c; }
.seq-cell.tb { border-color: #a04a42; }
.seq-cell.ban { opacity: .75; }
.seq-cell.ban.done img { filter: grayscale(1); }
.seq-cell.current { box-shadow: 0 0 0 2px var(--gold); opacity: 1; }
.seq-cell.done { cursor: pointer; }
.seq-cell img { width: 100%; height: 100%; object-fit: cover; }
.seq-act { font-size: .62rem; color: var(--muted); }
.draft-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .draft-cols { grid-template-columns: 1fr; } }
#draft-grid { display: flex; flex-wrap: wrap; gap: 4px; margin-top: .5rem; }
#draft-grid .vs-pick.used { opacity: .22; cursor: default; }
.draft-team.ta h2 { color: #7ed99a; }
.draft-team.tb h2 { color: #ff9a8a; }
.draft-slots { display: flex; gap: 6px; }
.draft-slot { width: 82px; height: 46px; border-radius: 6px; background: var(--bg3); border: 1px solid var(--line); overflow: hidden; }
.draft-slot img { width: 100%; height: 100%; object-fit: cover; }
.draft-bans { display: flex; align-items: center; gap: 4px; margin-top: .5rem; flex-wrap: wrap; }
.draft-bans img { width: 30px; border-radius: 4px; filter: grayscale(1); }
#rank-side, #rank-faction { display: inline-flex; align-items: center; gap: 4px; }
#rank-pos { display: inline-flex; align-items: center; gap: 4px; }
#rank-account { display: flex; align-items: center; gap: .5rem; margin-bottom: .8rem; flex-wrap: wrap; }
#rank-account input { background: var(--bg3); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: .35rem .6rem; width: 190px; }
select.btn { appearance: auto; }
