@font-face {
  font-family: "Luckiest Guy";
  src: url("/fonts/luckiest.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #0d0a1f;
  --surface: #181a2e;
  --surface-2: #20233b;
  --border: #2c3050;
  --text: #eceefd;
  --muted: #9aa0c3;
  --accent: #8f7bff;
  --accent-soft: rgba(143, 123, 255, 0.16);
  --gold: #ffd84a;
  --bar: #3499f0;
  --grid: rgba(236, 238, 253, 0.08);
  --ok: #2ecc71;
  --bad: #ff5c5c;
  --warn: #f5a623;
  --radius: 16px;
  --hero-a: #120c2b;
  --hero-b: #1b1446;
  --hero-c: #0b1b3d;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f3fb;
    --surface: #ffffff;
    --surface-2: #eeedf8;
    --border: #dddbee;
    --text: #17162b;
    --muted: #5d5b80;
    --accent: #5b45e0;
    --accent-soft: rgba(91, 69, 224, 0.1);
    --gold: #b88700;
    --bar: #1f6fd1;
    --grid: rgba(23, 22, 43, 0.08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

img { max-width: 100%; display: block; }

/* `hidden` tiene que ganar a los display de las secciones. */
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

h1, h2, h3, .brand__name, .tile__value, .tab {
  font-family: "Luckiest Guy", system-ui, sans-serif;
  font-weight: 400;
  letter-spacing: 0.02em;
}

h2 { font-size: 1.25rem; margin: 0; }
h3 { font-size: 1.05rem; margin: 0; }

/* ── Cabecera ── */

.hero {
  background:
    radial-gradient(circle at 85% 0%, rgba(123, 77, 255, 0.55), transparent 55%),
    radial-gradient(circle at 5% 100%, rgba(47, 139, 255, 0.4), transparent 60%),
    linear-gradient(135deg, var(--hero-a), var(--hero-b) 55%, var(--hero-c));
  color: #fff;
  padding: 22px 16px 0;
}

.hero__inner, .tabs, main, .foot {
  max-width: 1100px;
  margin: 0 auto;
}

.hero__inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.1); color: #ffd84a;
}
.brand__mark svg { width: 28px; height: 28px; }
.brand__name { font-size: 1.9rem; margin: 0; line-height: 1; }
.brand__sub { margin: 4px 0 0; color: #c9c0ff; font-size: 0.9rem; }

.tabs { display: flex; gap: 6px; margin-top: 18px; overflow-x: auto; }
.tab {
  color: #d8d2ff; text-decoration: none; padding: 10px 16px 12px;
  border-radius: 12px 12px 0 0; font-size: 1.05rem; white-space: nowrap;
}
.tab:hover { background: rgba(255, 255, 255, 0.08); }
.tab[aria-current="page"] { background: var(--bg); color: var(--text); }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  background: rgba(255, 255, 255, 0.12); color: #fff; white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill--ok::before { background: var(--ok); }
.pill--bad::before { background: var(--bad); }
.pill--unknown::before { background: var(--warn); }

/* ── Contenido ── */

main { padding: 20px 16px 40px; }
.view { display: grid; gap: 18px; }
.view > *, .tiles > *, .boards > * { min-width: 0; }

.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tile, .panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.tile__label { margin: 0; color: var(--muted); font-size: 0.85rem; }
.tile__value { margin: 6px 0 2px; font-size: 2rem; line-height: 1.1; }
.tile__value--md { font-size: 1.5rem; }
.tile__meta { margin: 0; color: var(--muted); font-size: 0.85rem; }
.tile--hero { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); }
.tile--hero .tile__value { color: var(--gold); font-size: 2.6rem; }

.card-img { margin: 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.card-img img { width: 100%; height: auto; }
.card-img img:not([src]) { display: none; }
.card-img--flat { border: 0; }
.stack { display: grid; gap: 12px; }
.stack img { border-radius: 12px; }

.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.meta { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* Filas de alertas */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.row {
  display: grid; grid-template-columns: 32px auto auto minmax(0, 1fr); align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 12px; background: var(--surface-2);
}
.row img { width: 32px; height: 32px; object-fit: contain; }
.row__where { color: var(--muted); font-size: 0.9rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__name { font-weight: 600; }
.chip {
  font: 600 0.85rem ui-monospace, "Cascadia Mono", Consolas, monospace;
  padding: 2px 8px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border);
  white-space: nowrap; text-align: right;
}
.chip--gold { color: var(--gold); }
.empty { color: var(--muted); padding: 8px 0; }

/* Grupos (subtipos) */
.group { display: grid; gap: 8px; }
.group + .group { margin-top: 18px; }
.group__head { display: flex; align-items: center; gap: 10px; }
.group__head img { width: 36px; height: 36px; object-fit: contain; }
.group__total { color: var(--gold); font-family: "Luckiest Guy", system-ui, sans-serif; margin-left: auto; font-size: 1.05rem; }

.rarity-uc { box-shadow: inset 3px 0 0 #5bd35b; }
.rarity-r { box-shadow: inset 3px 0 0 #3ea6ff; }
.rarity-vr { box-shadow: inset 3px 0 0 #b45cff; }
.rarity-sr { box-shadow: inset 3px 0 0 #ffab2e; }
.rarity-ur { box-shadow: inset 3px 0 0 #ffd84a; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font: inherit;
}
.chips button img { width: 22px; height: 22px; }
.chips button[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); }
.chips button:focus-visible, .tab:focus-visible, .link-btn:focus-visible, .search button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Buscador */
.search { display: flex; gap: 8px; margin: 10px 0; }
.search input {
  flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
}
.search button, .link-btn {
  font: inherit; cursor: pointer; border-radius: 12px; border: 1px solid var(--accent);
  background: var(--accent-soft); color: var(--text); padding: 10px 16px;
}
.link-btn { padding: 4px 10px; font-size: 0.85rem; }

/* Rankings */
.boards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.rank { margin: 10px 0 0; padding: 0; list-style: none; counter-reset: pos; display: grid; gap: 6px; }
.rank li {
  counter-increment: pos; display: flex; gap: 10px; align-items: baseline;
  padding: 8px 10px; border-radius: 10px; background: var(--surface-2);
}
.rank li::before { content: counter(pos); font-family: "Luckiest Guy", system-ui, sans-serif; color: var(--muted); min-width: 1.4em; }
.rank li:nth-child(1)::before { color: var(--gold); }
.rank .value { margin-left: auto; font-weight: 600; white-space: nowrap; }

/* Gráfica */
.chart { position: relative; height: 220px; margin-top: 8px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--bar); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.is-active { opacity: 0.8; }
.table-wrap { margin-top: 10px; max-height: 260px; overflow: auto; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table-wrap th, .table-wrap td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.table-wrap td:last-child, .table-wrap th:last-child { text-align: right; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 10px; font-size: 0.85rem; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 0 16px 28px; color: var(--muted); font-size: 0.8rem;
}

@media (max-width: 560px) {
  /* En el móvil el nivel de poder se queda y el texto baja de línea en vez de cortarse. */
  .row { grid-template-columns: 28px auto auto minmax(0, 1fr); gap: 8px; }
  .row__where { white-space: normal; }
  .tab { padding: 10px 10px 12px; font-size: 0.95rem; }
  .brand__name { font-size: 1.5rem; }
  .tile--hero .tile__value { font-size: 2.1rem; }
}
