:root {
  --void: #ffffff;
  --deep: #f5f6f8;
  --panel: #ffffff;
  --panel-line: #e5e7eb;
  --gold: #6b7280;
  --gold-bright: #111827;
  --teal: #3b82f6;
  --text: #1f2430;
  --text-dim: #6b7280;
  --danger: #dc2626;
  --medal-silver: #9aa4b2;
  --medal-bronze: #b07548;
  --ace-purple: #8b5cf6;
  --worst-red: #dc2626;

  --tier-iron: #5b5a56;
  --tier-bronze: #a9682f;
  --tier-silver: #64748b;
  --tier-gold: #ca8a04;
  --tier-platinum: #0d9488;
  --tier-emerald: #16a34a;
  --tier-diamond: #2563eb;
  --tier-master: #9333ea;
  --tier-grandmaster: #dc2626;
  --tier-challenger: #d97706;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--void);
  color: var(--text);
  font-family: "Barlow", sans-serif;
  min-height: 100vh;
}

body {
  background-color: var(--deep);
  animation: page-fade-in 0.35s ease both;
}

@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
}

/* Scrollbar con la estética del resto de la app (Firefox + Chromium) */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--teal) var(--deep);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--deep);
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--teal) 55%, var(--panel-line));
  border-radius: 6px;
  border: 2px solid var(--deep);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--teal);
}

.rift-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: none;
  z-index: 0;
}

h1, h2 {
  font-family: "Barlow", sans-serif;
  color: var(--gold-bright);
  letter-spacing: 0.02em;
  margin: 0;
}

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  padding: 40px clamp(20px, 6vw, 64px) 24px;
  border-bottom: 1px solid var(--panel-line);
}

.hero-stats {
  position: relative;
  z-index: 1;
  display: flex;
  gap: clamp(20px, 4vw, 48px);
  padding: 20px clamp(20px, 6vw, 64px);
  border-bottom: 1px solid var(--panel-line);
  background: color-mix(in srgb, var(--teal) 4%, transparent);
}

.hero-stats[hidden] {
  display: none;
}

.hero-stats__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hero-stats__value {
  font-family: "Rajdhani", "Barlow", sans-serif;
  font-weight: 800;
  font-size: 30px;
  color: var(--teal);
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero-stats__icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.hero-stats__live-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2fbf71;
  box-shadow: 0 0 6px rgba(47, 191, 113, 0.8);
  animation: live-pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}

.hero-stats__label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

@media (max-width: 700px) {
  .hero-stats {
    flex-wrap: wrap;
    gap: 20px;
  }
}

.topbar__eyebrow {
  display: block;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 6px;
  font-weight: 600;
}

.topbar h1 {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 900;
}

.topbar__title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.crest {
  display: none;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(10, 200, 185, 0.35));
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.last-updated {
  font-size: 13px;
  color: var(--text-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--panel-line);
  background: var(--panel);
  color: var(--text);
  font-family: "Barlow", sans-serif;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.btn:hover { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal) inset; transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.btn--primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.btn--gold {
  background: #f3f4f6;
  border-color: var(--panel-line);
  color: var(--text);
}

.icon { width: 16px; height: 16px; }
.btn.is-loading .icon--spin { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.layout {
  position: relative;
  z-index: 1;
  max-width: 1680px;
  margin: 0 auto;
  padding: 32px clamp(20px, 3vw, 48px) 80px;
  display: grid;
  grid-template-columns: 240px 1fr;
  align-items: start;
  gap: 24px;
}

.sidebar {
  position: sticky;
  top: 24px;
}

.sidebar__panel h2 {
  font-size: 16px;
  margin-bottom: 14px;
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.queues-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.section-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin: -6px 0 14px;
  line-height: 1.5;
}

.duo-ranking {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.duo-ranking__row {
  display: grid;
  grid-template-columns: 28px auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(243, 244, 246, 0.5);
  border: 1px solid var(--panel-line);
}

.duo-ranking__position {
  font-family: "Rajdhani", "Barlow", sans-serif;
  font-weight: 800;
  color: var(--text-dim);
  font-size: 13px;
}

.duo-ranking__avatars {
  display: flex;
}

.duo-ranking__avatars img,
.duo-ranking__avatar-blank {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  background: var(--panel-line);
}

.duo-ranking__avatars img:last-child,
.duo-ranking__avatar-blank:last-child {
  margin-left: -10px;
}

.duo-ranking__names {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duo-ranking__stats {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stats-empty {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
}

.stat-card {
  background: rgba(243, 244, 246, 0.5);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.stat-card__value-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-card__icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  object-fit: cover;
}

.stat-card__value {
  font-family: "Rajdhani", "Barlow", sans-serif;
  font-weight: 700;
  color: var(--gold-bright);
  font-size: 18px;
  letter-spacing: 0.01em;
}

.stat-card__player {
  font-size: 12px;
  color: var(--text-dim);
}

@media (max-width: 1000px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    order: 2;
  }
  .main-content {
    order: 1;
  }
  .queues-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 20px clamp(14px, 3vw, 24px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  container-type: inline-size;
  container-name: panel;
}

.panel h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

.row-loading {
  list-style: none;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 12px 10px 6px;
}

.row-skeleton {
  list-style: none;
  height: 62px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0.03) 30%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.03) 70%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .row-skeleton { animation: none; }
}

.add-friend__form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field--name { flex: 1 1 160px; }
.field--tag { flex: 0 1 90px; }
.field--label { flex: 1 1 180px; }

.field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.field input {
  background: var(--void);
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-family: "Barlow", sans-serif;
  font-size: 14px;
}

.field input:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

.hash {
  color: var(--text-dim);
  font-size: 18px;
  padding-bottom: 10px;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin: 10px 0 0;
}

.form-success {
  color: var(--teal);
  font-size: 13px;
  margin: 10px 0 0;
}

.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.auto-refresh {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

.empty-state p:first-child {
  color: var(--text);
  font-size: 15px;
  margin: 0 0 6px;
}

.empty-state__hint { font-size: 13px; margin: 0; }

.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.row {
  display: grid;
  grid-template-columns: 28px 36px minmax(0, 1fr) auto auto auto;
  overflow: hidden;
  align-items: center;
  gap: 10px;
  background: rgba(243, 244, 246, 0.5);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 7px 12px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.row:hover {
  border-color: var(--teal);
  background: rgba(10, 200, 185, 0.05);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.row__position {
  font-family: "Barlow", sans-serif;
  font-weight: 700;
  color: var(--text-dim);
  text-align: center;
}

/* --- Podio: los primeros 3 puestos se destacan con medalla --- */
.row--podium {
  padding: 13px 14px;
  position: relative;
}

.row__position--medal {
  font-size: 19px;
  line-height: 1;
}

.row--rank-1 {
  border-color: var(--gold);
  background: linear-gradient(90deg, rgba(240, 224, 173, 0.15), rgba(243, 244, 246, 0.5) 55%);
  box-shadow: 0 0 0 1px var(--gold) inset;
}
.row--rank-1 .row__name { color: var(--gold-bright); }
.row--rank-1:hover { border-color: var(--gold); }

.row--rank-2 {
  border-color: var(--medal-silver);
  background: linear-gradient(90deg, rgba(199, 208, 218, 0.15), rgba(243, 244, 246, 0.5) 55%);
  box-shadow: 0 0 0 1px var(--medal-silver) inset;
}
.row--rank-2:hover { border-color: var(--medal-silver); }

.row--rank-3 {
  border-color: var(--medal-bronze);
  background: linear-gradient(90deg, rgba(205, 133, 90, 0.15), rgba(243, 244, 246, 0.5) 55%);
  box-shadow: 0 0 0 1px var(--medal-bronze) inset;
}
.row--rank-3:hover { border-color: var(--medal-bronze); }

.row__badge {
  display: block;
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--tier-badge, var(--panel-line));
  box-shadow: 0 0 10px color-mix(in srgb, var(--tier-badge, transparent) 45%, transparent);
  overflow: hidden;
  background: var(--void);
  flex-shrink: 0;
}

.row__badge-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.row__identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-decoration: none;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.row__identity:hover .row__name {
  color: var(--teal);
  text-decoration: underline;
}

.row__identity:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.row__name {
  font-weight: 700;
  color: var(--gold-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__riotid {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__rank {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 96px;
}

.row__tier {
  font-family: "Rajdhani", "Barlow", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--tier-badge, var(--text));
  text-transform: capitalize;
}

.row__lp { font-family: "Rajdhani", "Barlow", sans-serif; font-size: 13px; font-weight: 600; color: var(--text-dim); }

.row__record {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 76px;
}

.row__wl { font-family: "Rajdhani", "Barlow", sans-serif; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.row__winrate { font-family: "Rajdhani", "Barlow", sans-serif; font-size: 15px; font-weight: 700; }

.row--error .row__tier { color: var(--danger); }

.row__matches {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.row__matches-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  white-space: nowrap;
}

.row__matches-icons {
  display: flex;
  gap: 6px;
}

.match-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.match-icon__badge {
  visibility: hidden;
  height: 14px;
  line-height: 14px;
  font-family: "Barlow", sans-serif;
  font-style: italic;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.05em;
  padding: 0 4px;
  border-radius: 3px;
}

/* Antes era solo texto de 10px sin fondo — apenas se notaba en el
   celular. El fondo sólido lo hace visible pase lo que pase detrás. */
.match-icon--mvp .match-icon__badge {
  visibility: visible;
  color: #b8860b;
  background: rgba(184, 134, 11, 0.18);
  text-shadow: none;
}

.match-icon--ace .match-icon__badge {
  visibility: visible;
  color: var(--ace-purple);
  background: rgba(162, 89, 217, 0.18);
  text-shadow: 0 0 8px rgba(162, 89, 217, 0.5);
}

.match-icon--worst .match-icon__badge {
  visibility: visible;
  color: var(--worst-red);
  background: rgba(255, 59, 59, 0.18);
  text-shadow: 0 0 8px rgba(255, 59, 59, 0.5);
}

.match-icon__img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--match-color, var(--panel-line));
  box-shadow: 0 0 6px color-mix(in srgb, var(--match-color, transparent) 50%, transparent);
  object-fit: cover;
  background: var(--void);
}

.match-icon--win { --match-color: #2fbf71; }
.match-icon--loss { --match-color: #e05252; }
.match-icon--remake { --match-color: #7a8ba3; }

.match-icon__kda {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
}

.row__matches-empty {
  font-size: 11px;
  color: var(--text-dim);
}

.row--compact {
  grid-template-columns: 24px 32px minmax(0, 1fr) auto auto auto;
}

/* Estos breakpoints reaccionan al ancho real de CADA columna de ranking
   (panel), no al ancho de toda la pantalla — así se ocultan a tiempo
   incluso cuando el panel queda angosto por el sidebar + las 2 columnas.
   Antes la columna del nombre usaba minmax(0, 1fr): sin piso, así que en
   pantallas de celular terminaba en 0px real (nombre invisible) apenas el
   resto de las columnas (con sus min-width fijos) no entraba. Ahora tiene
   un piso garantizado, y en vez de esconder las últimas partidas para
   ganar lugar, las bajamos a una segunda línea propia — así en el celular
   se ve el mismo icono de campeón + KDA que en la versión de escritorio,
   solo que abajo del nombre en vez de al costado. */
@container panel (max-width: 620px) {
  .row__matches-label { display: none; }
}

@container panel (max-width: 460px) {
  .row__record { display: none; }
  .row__rank { min-width: 60px; }
  .row,
  .row--compact {
    grid-template-columns: 24px 32px minmax(64px, 1fr) auto;
    grid-template-areas:
      "pos badge identity rank"
      "matches matches matches matches";
    row-gap: 6px;
  }
  .row__position { grid-area: pos; }
  .row__badge-wrap { grid-area: badge; }
  .row__identity { grid-area: identity; }
  .row__rank { grid-area: rank; }
  .row__matches {
    grid-area: matches;
    flex-direction: row;
    align-items: center;
    padding-left: 62px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn.is-loading .icon--spin { animation: none; }
}

/* ============================================
   Tema alternativo (oscuro, el viejo "Invictus") — toggle en el header
   ============================================ */

.btn--icon {
  padding: 10px 12px;
  font-size: 16px;
  line-height: 1;
}

/* ============================================
   Buscador de la clasificación
   ============================================ */
.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.search-input {
  flex: 1 1 220px;
  max-width: 320px;
  background: var(--void);
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-family: "Barlow", sans-serif;
  font-size: 13px;
}

.search-input:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

.row--search-hidden {
  display: none !important;
}

/* ============================================
   Indicador de "en partida ahora"
   ============================================ */
.row__badge-wrap {
  position: relative;
  flex-shrink: 0;
}

.row__live-text {
  font-size: 11px;
  font-weight: 700;
  color: #2fbf71;
  display: flex;
  align-items: center;
  gap: 4px;
}

.row__live-text[hidden] {
  display: none;
}

.row__live-text::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2fbf71;
  box-shadow: 0 0 5px rgba(47, 191, 113, 0.8);
  animation: live-pulse 1.6s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}

.row__live-text {
  cursor: default;
}

.row__live-text--clickable {
  cursor: pointer;
  text-decoration: underline dotted;
}

/* ============================================
   Tarjeta de estadística de dupla
   ============================================ */
.stat-card__value-row--duo {
  gap: 4px;
}

.stat-card__value-row--duo .stat-card__icon:nth-child(2) {
  margin-left: -10px;
  border-color: var(--teal);
}

/* ============================================
   Confeti al subir de posición
   ============================================ */
.confetti-piece {
  position: fixed;
  top: 0;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 999;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(140px) rotate(360deg);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .row__live-text::before { animation: none; }
  .confetti-piece { display: none; }
}
