:root {
  --bg: #0b0e14; --surface: #141922; --surface-2: #1c2331; --line: #2a3444;
  --text: #e6edf7; --muted: #8b9bb4; --accent: #ff7a2f; --accent-2: #4aa3ff;
  --good: #43d17c; --warn: #ffcc4d; --bad: #ff5f6b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI", system-ui, sans-serif; display: flex; flex-direction: column; }
h1, h2, h3, h4 { margin: 0; }
.muted { color: var(--muted); font-size: 12px; margin: 0; }
.hidden { display: none !important; }

/* topo */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { font-size: 17px; }
.mark { width: 38px; height: 38px; display: grid; place-items: center; font-size: 21px; background: linear-gradient(145deg, var(--accent), #b93d00); border-radius: 10px; color: #fff; }
.counters { display: flex; gap: 20px; }
.counters div { text-align: right; }
.counters strong { display: block; font-size: 18px; color: var(--accent); }
.counters span { font-size: 10.5px; color: var(--muted); }

/* abas */
.tabs { display: flex; gap: 2px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 9px 14px; font-size: 12.5px; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.banner { padding: 9px 20px; font-size: 12.5px; background: #4a1d22; color: #ffb3b9; border-bottom: 1px solid var(--bad); }
.banner.ok { background: #10331f; color: #9be7bd; border-bottom-color: var(--good); }

/* atualização automática */
.upd { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); padding: 5px 9px; align-self: center; }
.upd .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.upd .dot.novo { background: var(--accent); box-shadow: 0 0 0 3px #ff7a2f33; }
.upd .dot.erro { background: var(--bad); }
.upd .dot.rodando { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.news { padding: 10px 20px; background: #2a1f10; border-bottom: 1px solid var(--accent); font-size: 12.5px; }
.news h4 { color: var(--accent); font-size: 12px; margin-bottom: 4px; }
.news ul { margin: 4px 0; padding-left: 18px; color: var(--muted); }
.news li { margin: 2px 0; }
.news .acts { margin-top: 7px; display: flex; gap: 7px; }

main { flex: 1; min-height: 0; display: flex; }
.page { display: none; flex: 1; min-height: 0; flex-direction: column; }
.page.active { display: flex; }

.toolbar { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.toolbar.sub { background: var(--bg); }

input, select, button, textarea { font: inherit; color: var(--text); }
input[type=search], input[type=number], input[type=text], select, textarea { background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; }
input[type=search] { flex: 1; min-width: 150px; }
select { max-width: 200px; }
select[multiple] { max-width: none; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 11px; color: var(--muted); }
.field select, .field input { width: 100%; max-width: none; }
.field.small { flex: 0 0 96px; }
.row { display: flex; gap: 8px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }

button { cursor: pointer; border-radius: 7px; padding: 7px 12px; border: 1px solid var(--line); background: var(--surface-2); }
button:hover { border-color: var(--accent); }
button.primary { background: linear-gradient(145deg, var(--accent), #d1550f); border: none; color: #fff; font-weight: 600; padding: 10px; }
button:disabled { opacity: .5; cursor: wait; }
button.ghost { font-size: 12px; color: var(--muted); }

/* grade virtualizada */
.grid-scroll { flex: 1; overflow: auto; padding: 12px; }
#gridSizer { position: relative; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(144px, 1fr)); gap: 8px; align-content: start; }
.card { position: relative; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 7px; cursor: pointer; transition: .1s; }
.card:hover { border-color: var(--accent-2); }
.card.owned { border-color: var(--accent); background: #241a12; }
.card .thumb { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 6px; background: var(--surface-2); display: block; }
.card .nm { font-size: 11px; margin-top: 5px; line-height: 1.25; height: 2.5em; overflow: hidden; }
.card .tags { display: flex; gap: 3px; margin-top: 4px; flex-wrap: wrap; }
.pill { font-size: 9px; padding: 1px 5px; border-radius: 20px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.r-SS { background: #4b2360; color: #e3b6ff; border-color: #7a3ba0; }
.pill.r-S { background: #5a3a10; color: #ffcf8f; border-color: #8a5a1a; }
.pill.r-A { background: #123a4d; color: #9fd9f2; border-color: #1d5c78; }
.pill.main { background: var(--accent); color: #fff; border-color: var(--accent); }
.pill.star { background: #3a2d10; color: var(--warn); border-color: #6b5320; }
.card .info { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%; background: #000a; display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.card .info:hover { color: #fff; background: var(--accent-2); }

/* páginas com painel + resultado */
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: 310px 1fr; gap: 1px; background: var(--line); }
.config { background: var(--surface); padding: 14px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.config h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); }
.results { background: var(--bg); overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.empty { color: var(--muted); text-align: center; padding: 40px 20px; font-size: 13px; }

details summary { cursor: pointer; font-size: 12px; color: var(--muted); padding: 4px 0; }
.weight { display: grid; grid-template-columns: 88px 1fr 28px; gap: 7px; align-items: center; font-size: 11px; color: var(--muted); margin: 4px 0; }
.weight input { width: 100%; }

.progress { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; position: relative; }
.progress-bar { height: 100%; width: 30%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

/* times */
.team { border: 1px solid var(--line); border-radius: 11px; background: var(--surface); overflow: hidden; }
.team-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 13px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.team-head .rank { font-size: 12px; color: var(--muted); }
.team-head .right { display: flex; align-items: center; gap: 10px; }
.team-head .score { font-size: 20px; font-weight: 700; color: var(--accent); }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 11px; }
.slot { text-align: center; }
.slot img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 7px; background: var(--surface-2); }
.slot .pos { font-size: 10px; color: var(--accent-2); font-weight: 700; }
.slot .nm { font-size: 10.5px; line-height: 1.25; margin-top: 3px; }
.bars { padding: 0 13px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.bar { display: grid; grid-template-columns: 84px 1fr 30px; gap: 7px; align-items: center; font-size: 11px; color: var(--muted); }
.bar .track { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar .fill { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.chain { padding: 0 13px 12px; }
.chain h4 { margin: 8px 0 6px; font-size: 12px; }
.step { display: flex; gap: 8px; align-items: baseline; font-size: 11.5px; padding: 3px 0; border-bottom: 1px dashed #ffffff10; }
.step .p { color: var(--accent-2); font-weight: 700; min-width: 22px; }
.step .arrow { color: var(--muted); font-size: 10px; margin-left: auto; }
.notes { padding: 0 13px 12px; display: flex; flex-direction: column; gap: 4px; }
.note { font-size: 11.5px; color: var(--muted); padding-left: 12px; position: relative; }
.note::before { content: "▸"; position: absolute; left: 0; color: var(--accent); }
.timeline { padding: 0 13px 12px; display: flex; gap: 6px; overflow-x: auto; }
.round { flex: 0 0 auto; min-width: 132px; border: 1px solid var(--line); border-radius: 8px; padding: 7px; background: var(--surface-2); }
.round h5 { margin: 0 0 5px; font-size: 10px; color: var(--accent-2); }
.round div { font-size: 10.5px; color: var(--muted); }
.tradeoff { padding: 0 13px 10px; font-size: 11.5px; color: var(--warn); }
.matchup { margin: 0 13px 10px; padding: 9px 11px; border-radius: 9px; background: #10231a; border: 1px solid #1e5c3c; display: flex; gap: 14px; align-items: center; }
.matchup .wr { text-align: center; flex: 0 0 108px; }
.matchup .wr b { display: block; font-size: 24px; color: var(--good); line-height: 1.1; }
.matchup .wr small { font-size: 9.5px; color: var(--muted); }
.matchup .mu-det { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.matchup .mu-det b { color: var(--text); }
.counterbox { padding: 0 13px 10px; font-size: 11.5px; }
.counterbox b { color: var(--accent-2); }

/* gráfico radar dos oito critérios */
.radar { display: block; margin: 4px auto 8px; }
.radar .grid-line { fill: none; stroke: var(--line); stroke-width: 1; }
.radar .shape { fill: rgba(255,122,47,.22); stroke: var(--accent); stroke-width: 2; }
.radar .shape.b { fill: rgba(74,163,255,.18); stroke: var(--accent-2); }
.radar text { fill: var(--muted); font-size: 9px; }

.analise { margin: 0 13px 12px; padding: 9px 11px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.analise b { color: var(--text); }
.analise .solido { color: var(--good); }
.analise .fragil { color: var(--warn); }

.troca { display: grid; grid-template-columns: 1fr 34px 1fr 74px; gap: 9px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 9px; background: var(--surface); font-size: 12px; }
.troca .sai { color: var(--bad); }
.troca .entra { color: var(--good); }
.troca .seta { text-align: center; color: var(--muted); }
.troca .g { text-align: right; font-size: 16px; font-weight: 700; color: var(--good); }
.troca .g small { display: block; font-size: 9.5px; color: var(--muted); font-weight: 400; }
.troca .deltas { grid-column: 1/-1; font-size: 10.5px; color: var(--muted); }

.acq { display: grid; grid-template-columns: 54px 1fr 90px; gap: 11px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 9px; background: var(--surface); }
.acq img { width: 54px; height: 54px; object-fit: cover; border-radius: 7px; background: var(--surface-2); }
.acq .gain { text-align: right; font-size: 18px; font-weight: 700; color: var(--good); }
.acq .gain small { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }

.manual-slots { display: flex; flex-direction: column; gap: 5px; }
.manual-slot { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 7px; padding: 5px 7px; font-size: 11.5px; background: var(--surface-2); }
.manual-slot img { width: 32px; height: 32px; border-radius: 5px; object-fit: cover; }
.manual-slot .x { margin-left: auto; color: var(--muted); cursor: pointer; padding: 0 4px; }
.manual-slot .x:hover { color: var(--bad); }

.modal { position: fixed; inset: 0; background: #000b; display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-inner { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; max-width: 680px; width: 100%; max-height: 86vh; overflow: auto; padding: 20px; position: relative; }
.modal-close { position: absolute; top: 10px; right: 10px; background: none; border: none; font-size: 22px; color: var(--muted); }
.skill { border-top: 1px solid var(--line); padding: 9px 0; }
.skill .h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.skill .t { font-size: 9px; padding: 1px 6px; border-radius: 20px; background: var(--surface-2); color: var(--accent-2); border: 1px solid var(--line); }
.skill p { margin: 5px 0 0; font-size: 12px; color: var(--muted); }

@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } .bars { grid-template-columns: 1fr; } }

/* ============================================================ tema claro
   O tema escuro combina com o jogo, mas quem usa de dia num monitor claro sofre.
   Só as variáveis mudam: nenhum componente precisa saber qual tema está ativo. */
body[data-tema="claro"] {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #eaeef5; --line: #d3dae6;
  --text: #1a2230; --muted: #5b6b82; --accent: #d1550f; --accent-2: #1a6fd4;
  --good: #17864a; --warn: #a06c00; --bad: #c62234;
}
body[data-tema="claro"] .card.owned { background: #fff3e8; }
body[data-tema="claro"] .matchup { background: #e8f7ee; border-color: #9fd9b6; }
body[data-tema="claro"] .news { background: #fff5e6; }
body[data-tema="claro"] .banner { background: #fdeaec; color: #8d1626; }
body[data-tema="claro"] .banner.ok { background: #e6f6ec; color: #14663a; }

/* ============================================================ diagrama do combo */
.diagrama { overflow-x: auto; padding: 4px 0 10px; }
.dg-caixa { fill: var(--surface-2); stroke: var(--line); }
.dg-estado { fill: var(--accent); font-size: 11px; font-weight: 700; }
.dg-quem { fill: var(--muted); font-size: 9px; }
.dg-seta { stroke: var(--accent); stroke-width: 1.6; fill: none; }

/* ============================================================ comparação */
table.cmp { width: 100%; border-collapse: collapse; font-size: 12px; }
table.cmp th, table.cmp td { border: 1px solid var(--line); padding: 5px 8px; text-align: center; }
table.cmp th { background: var(--surface-2); color: var(--muted); font-weight: 600; }
table.cmp td:first-child, table.cmp th:first-child { text-align: left; color: var(--muted); }
table.cmp tr.total td { font-size: 16px; font-weight: 700; color: var(--accent); }
table.cmp td.melhor { background: #43d17c22; color: var(--good); font-weight: 700; }
table.cmp td.nomes { font-size: 10.5px; line-height: 1.35; }

/* ============================================================ lista de desejos */
.card.desejado::after {
  content: "★"; position: absolute; top: 5px; left: 6px;
  color: var(--warn); font-size: 13px; text-shadow: 0 0 3px #000a;
}

/* ============================================================ arrastar */
.manual-slot { cursor: grab; }
.manual-slot.arrastando { opacity: .45; cursor: grabbing; }

/* ============================================================ toque e telas pequenas
   Responsivo não basta: no celular os alvos precisam ser grandes o suficiente
   para o dedo, e o painel lateral não cabe ao lado do resultado. */
@media (max-width: 760px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .counters { width: 100%; justify-content: space-between; gap: 10px; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { flex: 0 0 auto; padding: 11px 13px; }
  .split { grid-template-columns: 1fr; }
  .config { max-height: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  .slots { grid-template-columns: repeat(2, 1fr); }
  .bars { grid-template-columns: 1fr; }
  .matchup { flex-direction: column; align-items: flex-start; }
  button, .card, .tab { min-height: 40px; }
  .toolbar { gap: 6px; }
  select, input[type=search] { min-height: 38px; }
}

/* dificuldade de conseguir um ninja */
.custo-facil { color: var(--good); }
.custo-medio { color: var(--warn); }
.custo-dificil { color: var(--bad); }
.custo-incerto { color: var(--muted); }
