:root {
  --bg: #0b0d12;
  --panel: #121621;
  --panel2: #171c29;
  --line: #262d3d;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #f472b6;
  --gold: #facc15;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; overflow: hidden; }
canvas#game { position: fixed; inset: 0; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.gold { color: var(--gold); font-weight: 700; }
.win { color: #fbbf24; }
.lose { color: #ef4444; }

/* ---------- menú ---------- */
.menu { position: absolute; inset: 0; overflow: auto; padding: 24px 32px; background: radial-gradient(1200px 600px at 20% 0%, #1e1533 0%, var(--bg) 60%); }
.menu-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.menu h1 { margin: 0; font-size: 40px; letter-spacing: 4px; color: var(--accent); }
.menu h1 span { font-size: 16px; letter-spacing: 0; color: var(--muted); font-weight: 500; }
.menu h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); margin: 18px 0 8px; }
.menu-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; margin-top: 8px; }
@media (max-width: 900px) { .menu-body { grid-template-columns: 1fr; } }
.champ-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.champ-card { background: var(--panel); border: 2px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; transition: transform .1s, border-color .1s; }
.champ-card:hover { transform: translateY(-2px); border-color: var(--c); }
.champ-card.sel { border-color: var(--c); box-shadow: 0 0 0 1px var(--c), 0 0 24px -6px var(--c); }
.champ-dot { width: 44px; height: 44px; margin: 0 auto 6px; border-radius: 50%; background: var(--c); color: #0b0b0f; font-weight: 800; font-size: 22px; display: grid; place-items: center; border: 3px solid #fff; }
.champ-name { font-weight: 700; }
.champ-sub { font-size: 11px; color: var(--muted); }
.champ-detail { margin-top: 14px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 10px; padding: 12px 16px; }
.champ-detail h3 { margin: 0 0 4px; color: var(--c); }
.champ-detail p { margin: 8px 0; line-height: 1.4; font-size: 14px; }
.champ-detail .kv { font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.col { flex-direction: column; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; text-align: left; }
.chip.sel { border-color: var(--accent); background: #2a1730; }
.chip small { color: var(--muted); }
.toggle { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 6px 0; cursor: pointer; }
.menu-actions { display: flex; gap: 10px; margin-top: 18px; }
.menu footer { margin-top: 24px; color: var(--muted); font-size: 13px; }
.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 8px; padding: 10px 16px; font-weight: 700; }
.btn.primary { background: var(--accent); color: #1b0b16; border-color: transparent; flex: 1; font-size: 16px; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }

/* ---------- modales ---------- */
.modal, .stats-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(4, 6, 10, 0.62); padding: 16px; }
.stats-overlay { pointer-events: none; background: rgba(4, 6, 10, 0.4); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px 24px; max-width: min(1000px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.panel.wide { width: 760px; }
.panel h2 { margin: 0 0 6px; }
.cards { display: flex; gap: 14px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
.card { position: relative; width: 250px; min-height: 200px; text-align: left; background: var(--panel2); border: 2px solid var(--line); border-top: 6px solid var(--c); border-radius: 12px; padding: 14px; transition: transform .1s, border-color .1s; }
.card:hover { transform: translateY(-3px); border-color: var(--c); }
.card.evo { box-shadow: 0 0 30px -6px #fbbf24; }
.card-key { position: absolute; top: 8px; right: 10px; color: var(--muted); font-weight: 700; }
.card-tag { font-size: 11px; letter-spacing: 1px; color: var(--c); font-weight: 800; }
.card-title { font-size: 18px; font-weight: 800; margin: 4px 0 8px; }
.card-line { font-size: 13px; line-height: 1.4; color: #cbd5e1; margin: 4px 0; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; justify-content: flex-end; }
.debug { margin-top: 10px; border-top: 1px solid var(--line); }
.debug h3 { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.debug .row-btns { justify-content: flex-start; }
.stats-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; margin-top: 8px; }
table.stats { border-collapse: collapse; font-size: 13px; }
table.stats td, table.stats th { padding: 3px 10px 3px 0; text-align: left; border-bottom: 1px solid #1e2433; }
table.stats td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.shop { display: grid; gap: 6px; margin-top: 10px; }
.shop-row { display: grid; grid-template-columns: minmax(0, 1fr) 60px 110px; gap: 10px; align-items: center; background: var(--panel2); border-radius: 8px; padding: 8px 12px; }
.shop-row .lvl { text-align: center; color: var(--muted); }

/* ---------- tooltip ---------- */
.tip { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; max-width: 440px; background: #0d111a; border: 1px solid #2c3550; border-radius: 10px; padding: 10px 12px; box-shadow: 0 12px 40px rgba(0,0,0,.6); font-size: 12.5px; line-height: 1.35; }
.tip.wide { max-width: 620px; }
.tip-tag { font-size: 10.5px; font-weight: 800; letter-spacing: 1px; }
.tip-title { font-size: 15px; font-weight: 800; margin: 2px 0 4px; color: #f8fafc; }
.tip-desc { color: #cbd5e1; margin-bottom: 6px; }
.tip-rows { display: grid; gap: 5px; border-top: 1px solid #1f2738; padding-top: 6px; }
.tip-row { display: grid; gap: 1px; }
.tip-l1 { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.tip-label { font-weight: 700; color: #e2e8f0; }
.tip-f { color: #93c5fd; font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }
.tip-note { color: #64748b; font-size: 11px; }
.tip-note::before { content: '— '; }
.tip-l2 { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; color: #94a3b8; padding-left: 10px; }
.tip-eq { color: #475569; }
.tip-res { color: #fde68a; }
.tip-more { border-top: 1px solid #1f2738; margin-top: 8px; padding-top: 6px; display: grid; gap: 8px; }
.tip-sec-title { font-size: 11px; font-weight: 800; letter-spacing: .8px; color: #94a3b8; text-transform: uppercase; margin-bottom: 3px; }
.tip-sec ul { margin: 0; padding-left: 16px; color: #cbd5e1; }
.tip-table { border-collapse: collapse; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tip-table th, .tip-table td { padding: 2px 7px; border-bottom: 1px solid #1f2738; text-align: right; color: #cbd5e1; }
.tip-table th:first-child, .tip-table td:first-child { text-align: left; color: #94a3b8; }
.tip-table .hl { background: #1e293b; color: #fde68a; }
.tip-hint { margin-top: 6px; color: #64748b; font-size: 10.5px; }
kbd { background: #1e293b; border: 1px solid #334155; border-radius: 4px; padding: 0 4px; font-size: 10px; color: #e2e8f0; }
.hoverable { cursor: help; border-radius: 6px; padding: 2px 4px; margin-left: -4px; }
.hoverable:hover { background: #1a2030; }

/* ---------- KPIs y gráficos ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 8px 0 12px; }
.kpi { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.kpi-value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11px; color: var(--muted); }
.charts2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin: 8px 0; }
.chart { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.chart-title { font-size: 12px; font-weight: 700; color: #cbd5e1; margin-bottom: 4px; }
.chart-svg { display: block; overflow: visible; }
.chart-svg .grid { stroke: #1f2738; stroke-width: 1; }
.chart-svg .tick { fill: #64748b; font-size: 10px; font-family: system-ui; }
.chart-svg .endlabel { fill: #cbd5e1; font-size: 10.5px; font-family: system-ui; }
.chart-svg .cross { stroke: #475569; stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: #cbd5e1; margin-top: 4px; }
.legend i, .hbar-label i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbars { display: grid; gap: 5px; }
.hbar-row { display: grid; grid-template-columns: minmax(110px, 190px) minmax(0, 1fr) 96px; gap: 8px; align-items: center; font-size: 12px; cursor: help; }
.hbar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #e2e8f0; }
.hbar-track { height: 12px; background: #161b28; border-radius: 0 4px 4px 0; }
.hbar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-val { text-align: right; font-variant-numeric: tabular-nums; color: #e2e8f0; }
.hbar-val small { color: var(--muted); margin-left: 4px; }
.cmp { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.cmp-track { position: relative; height: 10px; background: #161b28; border-radius: 0 4px 4px 0; }
.cmp-a { position: absolute; left: 0; top: 0; height: 4px; background: #475569; border-radius: 0 3px 3px 0; }
.cmp-b { position: absolute; left: 0; bottom: 0; height: 5px; border-radius: 0 3px 3px 0; }
.cmp-b.up { background: #0ca30c; }
.cmp-b.down { background: #d03b3b; }
.cmp-txt { font-size: 11.5px; font-variant-numeric: tabular-nums; color: #cbd5e1; white-space: nowrap; }
.cmp-txt small.up { color: #4ade80; }
.cmp-txt small.down { color: #f87171; }
.cmp-label { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.cmp-list { display: grid; gap: 6px; }
.cmp-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; align-items: center; cursor: help; }
.card-cmp { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 4px; }
.card-foot { margin-top: 8px; font-size: 11.5px; color: #fde68a; }
.card-hint { margin-top: 8px; font-size: 10px; color: #475569; }
.card { min-height: 230px; }
.stat-chips, .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-stat { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; font-size: 12px; cursor: help; }
.chip-stat b { color: #fde68a; }
.stats tr { cursor: help; }
.stats tr:hover td { background: #1a2030; }
table.stats.full { width: 100%; margin-top: 10px; }
table.stats.full td:last-child { text-align: left; }
.inline-bar { display: inline-block; width: 50px; height: 6px; margin-right: 6px; background: linear-gradient(90deg, #3987e5 var(--w), #1f2738 var(--w)); border-radius: 3px; vertical-align: 1px; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 12px 0 6px; }
.panel.wide { width: min(1100px, 100%); }
.stats-wrap { grid-template-columns: 300px minmax(0, 1fr); }
@media (max-width: 800px) { .stats-wrap { grid-template-columns: 1fr; } }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.codex { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.codex-item { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 8px; padding: 8px 10px; cursor: help; display: grid; }
.codex-item:hover { border-color: var(--c); }
.codex-item small { color: var(--muted); font-size: 11px; }
.mini-hist { margin-top: 10px; }
.mini-hist .chart { padding: 4px 6px; }
.champ-portrait { width: 64px; height: 64px; display: block; margin: 0 auto 4px; }
.pips { display: inline-flex; gap: 2px; vertical-align: middle; }
.pips i { width: 5px; height: 8px; background: #1f2738; border-radius: 1px; }
.pips i.on { background: #facc15; }
.shop-row { cursor: help; grid-template-columns: minmax(0, 1fr) 120px 110px; }
.cmp-b.same { background: #64748b; }
.cmp-txt small.same { color: #94a3b8; }

/* ---------- cartas de mejora (v2) ---------- */
.panel.choices { width: min(1060px, 100%); }
.cards { align-items: stretch; }
.card { width: 312px; min-height: 360px; display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden; position: relative;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 16%, #151a26), #121621 42%);
  border: 1px solid #263044; border-top: 0; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35), inset 0 3px 0 var(--c);
  animation: cardIn .35s backwards; transition: transform .12s, box-shadow .12s; }
.card:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(0,0,0,.45), 0 0 0 1px var(--c), inset 0 3px 0 var(--c); }
.card-key { position: absolute; top: 10px; right: 12px; background: #0b0f18; border: 1px solid #263044; border-radius: 6px; padding: 0 7px; color: #cbd5e1; font-size: 12px; }
.card-top { display: flex; gap: 12px; padding: 16px 14px 10px; align-items: center; }
.card-icon { width: 58px; height: 58px; flex: none; filter: drop-shadow(0 6px 12px rgba(0,0,0,.45)); }
.card-head { min-width: 0; padding-right: 22px; }
.card-tag { font-size: 10.5px; letter-spacing: 1px; color: var(--c); font-weight: 800; }
.card-title { font-size: 19px; font-weight: 800; margin: 2px 0 0; line-height: 1.15; }
.card-sub { font-size: 11px; color: var(--muted); }
.lvl-pips { display: flex; gap: 3px; align-items: center; margin-top: 6px; font-size: 11px; color: var(--muted); }
.lvl-pips i { width: 15px; height: 6px; border-radius: 3px; background: #263044; }
.lvl-pips i.on { background: var(--c); }
.lvl-pips i.next { background: #fde68a; box-shadow: 0 0 8px #fde68a; animation: pulse 1s infinite; }
.lvl-pips span { margin-left: 6px; }
.evo-star { margin-left: 6px; color: #fbbf24; }
.card-body { padding: 0 14px 14px; display: grid; gap: 8px; align-content: start; }
.card-desc { font-size: 13px; color: #cbd5e1; line-height: 1.4; }
.card-desc.big { font-size: 14px; color: #fef3c7; }
.card-line { font-size: 12px; color: #94a3b8; line-height: 1.35; }
.card-line b { color: #cbd5e1; }
.card-cmp { margin: 0; border-top: 1px solid #1f2738; padding-top: 6px; display: grid; gap: 2px; }
.evo-box { border: 1px solid #5b4a1a; background: linear-gradient(135deg, rgba(251,191,36,.12), rgba(251,191,36,.02)); border-radius: 10px; padding: 8px 10px; cursor: help; }
.evo-box.ready { border-color: #fbbf24; box-shadow: 0 0 18px -4px #fbbf24; }
.evo-box.compact { padding: 6px 8px; }
.evo-head { display: flex; gap: 8px; align-items: center; }
.evo-icon { width: 36px; height: 36px; flex: none; }
.evo-label { font-size: 9.5px; font-weight: 800; letter-spacing: .8px; color: #fbbf24; }
.evo-name { font-size: 15px; font-weight: 800; color: #fef3c7; }
.evo-desc { font-size: 12px; color: #e7dcc0; margin: 6px 0 2px; line-height: 1.35; }
.evo-box .card-cmp { border-top-color: #3b3117; }
.evo-req { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 3px; font-size: 12px; }
.evo-req li { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.evo-req .mark { width: 16px; text-align: center; font-weight: 800; }
.evo-req li.ok .mark { color: #4ade80; }
.evo-req li.no .mark { color: #f87171; }
.evo-req li.neutral .mark { color: #38bdf8; }
.evo-req small { color: #94a3b8; }
.req-bar { display: inline-block; width: 58px; height: 5px; background: #263044; border-radius: 3px; overflow: hidden; }
.req-bar i { display: block; height: 100%; background: #fbbf24; }
.card.kind-evo { background: linear-gradient(180deg, rgba(251,191,36,.22), #121621 46%); animation: cardIn .35s backwards, evoGlow 1.6s ease-in-out infinite alternate; }
.card.kind-aug { background: linear-gradient(180deg, rgba(249,168,212,.16), #121621 42%); }
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes evoGlow { from { box-shadow: 0 0 10px -2px #fbbf24, inset 0 3px 0 #fbbf24; } to { box-shadow: 0 0 34px 2px #fbbf24, inset 0 3px 0 #fbbf24; } }
@keyframes pulse { 50% { opacity: .45; } }
.center { text-align: center; }
.panel.choices { max-width: min(1080px, 100%); }
.card { width: 304px; }
