/* =========================================================
   OVERLAYS
========================================================= */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(10, 22, 36, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 1;
}
/* No animation on overlay — React mounts/unmounts it, no fade needed */
.overlay--countdown { background: rgba(10, 22, 36, 0.55); }

/* Intro */
.intro {
  background: linear-gradient(180deg, #0e2238, #0a1b2c);
  border: 1px solid rgba(208, 224, 16, 0.25);
  border-radius: 18px;
  padding: var(--space-7) var(--space-7);
  max-width: 640px;
  width: calc(100% - 48px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  color: var(--white);
  box-shadow: 0 40px 100px rgba(0,0,0,0.6);
  position: relative;
}
.intro::before {
  content: ""; position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: var(--brand-lime);
  border-radius: 18px 18px 0 0;
}
.intro__kicker { display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-4); }
.intro__dot { width: 8px; height: 8px; background: var(--brand-lime); border-radius: 50%; box-shadow: 0 0 12px var(--brand-lime); }
.intro__title {
  font-family: var(--font-display); font-size: 42px; font-weight: 600;
  line-height: 1.05; letter-spacing: -0.02em;
  margin: 0 0 var(--space-4); color: var(--white);
}
.intro__num { color: var(--brand-lime); font-variant-numeric: tabular-nums; }
.intro__lead { font-size: 16px; line-height: 1.55; color: rgba(255,255,255,0.8); margin: 0 0 var(--space-5); max-width: 52ch; }
.intro__lead em { color: var(--brand-teal-bright); font-style: normal; }
.intro__rules {
  list-style: none; padding: 0; margin: 0 0 var(--space-6);
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.intro__rules li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px; font-size: 13px; color: rgba(255,255,255,0.9);
}
.intro__rule-ico { color: var(--brand-lime); font-family: var(--font-display); font-weight: 600; font-size: 15px; }

.intro__form { margin-bottom: var(--space-5); }
.intro__label {
  display: block; font-family: var(--font-display); font-size: 11px;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(255,255,255,0.55); margin-bottom: 8px;
}
.intro__row { display: flex; gap: 10px; }
.intro__input {
  flex: 1; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.18); border-radius: 8px;
  padding: 12px 14px; color: var(--white);
  font-family: var(--font-display); font-size: 16px; outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.intro__input:focus { border-color: var(--brand-lime); box-shadow: 0 0 0 3px rgba(208, 224, 16, 0.2); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; font-family: var(--font-display); font-weight: 600; font-size: 15px;
  padding: 12px 20px; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer;
  transition: all var(--dur-fast) var(--ease-standard); letter-spacing: -0.005em;
}
.btn--sm { padding: 8px 14px; font-size: 13px; }
.btn--big { padding: 14px 26px; font-size: 16px; }
.btn--primary { background: var(--brand-lime); color: #0a1b2c; }
.btn--primary:hover { background: #e8f830; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(208, 224, 16, 0.35); }
.btn--primary:active { transform: translateY(0) scale(0.98); }
.btn--ghost { background: transparent; border-color: rgba(255,255,255,0.2); color: var(--white); }
.btn--ghost:hover { background: rgba(255,255,255,0.06); border-color: var(--brand-lime); color: var(--brand-lime); }

/* Leaderboard */
.intro__leaderboard { margin-top: var(--space-5); }
.leaderboard {
  list-style: none; padding: 0; margin: var(--space-3) 0 0;
  display: flex; flex-direction: column; gap: 3px;
}
.leaderboard__row {
  display: grid; grid-template-columns: 36px 1fr auto auto;
  align-items: center; gap: 12px;
  padding: 8px 12px; background: rgba(255,255,255,0.03);
  border-radius: 6px; font-size: 13px; color: rgba(255,255,255,0.85);
  border: 1px solid transparent;
  transition: background var(--dur-fast);
}
.leaderboard__rank { font-family: var(--font-mono); font-size: 13px; color: rgba(255,255,255,0.5); text-align: center; }
.leaderboard__name { font-family: var(--font-display); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.leaderboard__me-tag {
  display: inline-block; font-family: var(--font-display); font-size: 9px;
  letter-spacing: 0.2em; font-weight: 700;
  padding: 2px 6px; background: var(--brand-lime); color: #0a1b2c;
  border-radius: 3px;
}
.leaderboard__hits { font-family: var(--font-display); font-weight: 600; color: var(--brand-lime); font-variant-numeric: tabular-nums; }
.leaderboard__time { font-family: var(--font-mono); font-size: 12px; color: rgba(255,255,255,0.5); font-variant-numeric: tabular-nums; }
.leaderboard__row.is-me {
  background: rgba(208, 224, 16, 0.16);
  border-color: rgba(208, 224, 16, 0.5);
  box-shadow: 0 0 0 3px rgba(208, 224, 16, 0.08);
}
.leaderboard__row.is-me .leaderboard__name { color: var(--white); }
.leaderboard__row.is-first .leaderboard__rank { font-size: 18px; }
.leaderboard--big .leaderboard__row { padding: 12px 14px; font-size: 14px; }

/* Cabecera del ranking con el toggle móvil/desktop */
.leaderboard-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-bottom: 2px;
}

/* Toggle de dispositivo (móvil / desktop) */
.device-toggle {
  display: inline-flex; align-items: stretch;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.device-toggle__btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: rgba(255,255,255,0.55);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast);
  white-space: nowrap;
}
.device-toggle__btn svg { opacity: 0.7; transition: opacity var(--dur-fast); }
.device-toggle__btn:hover { color: rgba(255,255,255,0.9); }
.device-toggle__btn:hover svg { opacity: 1; }
.device-toggle__btn.is-active {
  background: var(--brand-lime);
  color: #0a1b2c;
}
.device-toggle__btn.is-active svg { opacity: 1; }

/* Tabla vacía */
.leaderboard__empty {
  margin-top: var(--space-3);
  padding: 14px 16px;
  font-family: var(--font-display);
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.03);
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 6px;
  text-align: center;
}

/* Aviso en EndOverlay cuando miras el ranking del otro dispositivo */
.end__leaderboard-cross {
  color: var(--brand-lime);
  font-style: italic;
}

/* Countdown */
.countdown { text-align: center; }
.countdown__num {
  font-family: var(--font-display); font-weight: 700; font-size: 220px;
  line-height: 1; color: var(--brand-lime);
  text-shadow: 0 0 60px rgba(208, 224, 16, 0.6);
  letter-spacing: -0.05em;
}
@keyframes countdown-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  30%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ==============================================
   END SCREEN — redesigned, competitive
   ============================================== */
.end {
  background: linear-gradient(180deg, #0e2238, #0a1b2c);
  border: 1px solid rgba(208, 224, 16, 0.25);
  border-radius: 18px;
  padding: var(--space-6) var(--space-7);
  max-width: 760px;
  width: calc(100% - 48px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  color: var(--white);
  box-shadow: 0 40px 100px rgba(0,0,0,0.6);
  position: relative;
}
.end::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--brand-lime); border-radius: 18px 18px 0 0;
}
.end__top {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--space-4);
}
.end__tier {
  font-family: var(--font-display); font-weight: 600;
  font-size: 14px; letter-spacing: -0.005em;
}

.end__hero {
  display: grid; grid-template-columns: 1fr auto; gap: var(--space-5);
  align-items: center;
  padding: var(--space-5) var(--space-5);
  background: linear-gradient(135deg, rgba(208, 224, 16, 0.08), rgba(32, 176, 208, 0.04));
  border: 1px solid rgba(208, 224, 16, 0.25);
  border-radius: 14px;
  margin-bottom: var(--space-4);
  position: relative;
  overflow: hidden;
}
.end__hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 20% 50%, rgba(208, 224, 16, 0.15), transparent 50%);
  pointer-events: none;
}
.end__hero-left { position: relative; z-index: 1; }
.end__hero-num {
  font-family: var(--font-display); font-weight: 700;
  font-size: 96px; line-height: 0.9;
  letter-spacing: -0.04em; font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 4px;
}
.end__hero-hits { color: var(--brand-lime); }
.end__hero-sep { color: rgba(255,255,255,0.25); font-size: 56px; font-weight: 400; margin: 0 2px; }
.end__hero-total { color: rgba(255,255,255,0.55); font-size: 56px; font-weight: 500; }
.end__hero-label {
  font-family: var(--font-display); font-size: 13px;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: rgba(255,255,255,0.65); margin-top: 4px;
}
.end__hero-meta {
  margin-top: 10px; display: flex; gap: 12px;
  font-size: 14px; color: rgba(255,255,255,0.8);
}
.end__hero-meta strong { color: var(--white); font-weight: 600; }
.end__sep { color: rgba(255,255,255,0.3); }

/* Ocultos globalmente (desktop + móvil): la etiqueta secundaria, la línea
   "Xs usados · Nombre" y el subtítulo de la tabla. */
.end__hero-label,
.end__hero-meta,
.end__leaderboard-sub { display: none !important; }

.end__rank-badge {
  background: var(--brand-lime);
  color: #0a1b2c;
  border-radius: 14px;
  padding: 18px 22px;
  text-align: center;
  min-width: 110px;
  position: relative; z-index: 1;
  box-shadow: 0 8px 24px rgba(208, 224, 16, 0.3);
}
.end__rank-lbl {
  font-family: var(--font-display); font-size: 10px;
  letter-spacing: 0.24em; text-transform: uppercase;
  font-weight: 600; opacity: 0.7;
}
.end__rank-num {
  font-family: var(--font-display); font-weight: 800;
  font-size: 48px; line-height: 1; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  margin: 4px 0 2px;
}
.end__rank-of {
  font-family: var(--font-display); font-size: 11px;
  opacity: 0.7; font-weight: 500;
}

.end__nudge {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: var(--space-4);
}
.end__nudge-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  font-size: 14px;
  color: rgba(255,255,255,0.88);
}
.end__nudge-row strong { color: var(--brand-lime); font-weight: 600; }
.end__nudge-row--win {
  background: rgba(208, 224, 16, 0.14);
  border-color: rgba(208, 224, 16, 0.4);
}
.end__nudge-row--win strong { color: var(--white); }
.end__nudge-ico { font-size: 20px; flex-shrink: 0; }

.end__missed {
  margin-bottom: var(--space-4);
  padding: 12px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
}
.end__missed-list {
  list-style: none; padding: 0; margin: 8px 0 0;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.end__missed-list li {
  font-size: 13px; padding: 4px 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  color: rgba(255,255,255,0.8);
}
.end__leaderboard { margin-bottom: var(--space-4); }
.end__leaderboard-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 4px;
}
.end__leaderboard-sub {
  font-family: var(--font-mono); font-size: 11px;
  color: rgba(255,255,255,0.4);
}
.end__actions {
  display: flex; gap: 10px; justify-content: flex-end;
  padding-top: var(--space-3);
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ==============================================
   PERFECT SCORE CELEBRATION
   ============================================== */
.overlay--perfect {
  background: radial-gradient(ellipse at center, rgba(8, 30, 50, 0.95), rgba(5, 15, 25, 0.98));
}
.perfect {
  position: relative;
  background: linear-gradient(180deg, #0e2238, #0a1b2c);
  border: 2px solid var(--brand-lime);
  border-radius: 20px;
  padding: var(--space-7) var(--space-7) var(--space-6);
  max-width: 560px;
  width: calc(100% - 48px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  color: var(--white);
  box-shadow:
    0 0 120px rgba(208, 224, 16, 0.4),
    0 40px 100px rgba(0,0,0,0.6);
  text-align: center;
  z-index: 2;
  opacity: 1;
}
@keyframes perfect-in {
  from { opacity: 0; transform: scale(0.8) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.perfect__glow {
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle, rgba(208, 224, 16, 0.15), transparent 60%);
  pointer-events: none;
  z-index: -1;
  animation: perfect-pulse 2.5s ease-in-out infinite;
}
@keyframes perfect-pulse { 50% { opacity: 0.5; } }
.perfect__crest {
  display: flex; justify-content: center;
  margin-bottom: var(--space-3);
  animation: crest-spin 0.9s var(--ease-out) both;
}
@keyframes crest-spin {
  from { transform: rotate(-180deg) scale(0); opacity: 0; }
  to   { transform: rotate(0) scale(1); opacity: 1; }
}
.perfect__title {
  font-family: var(--font-display); font-weight: 800;
  font-size: 64px; line-height: 1;
  letter-spacing: -0.04em;
  margin: var(--space-2) 0 var(--space-4);
  color: var(--white);
  text-shadow: 0 0 40px rgba(208, 224, 16, 0.6);
}
.perfect__lead {
  font-size: 16px; line-height: 1.55;
  color: rgba(255,255,255,0.85);
  margin: 0 auto var(--space-5);
  max-width: 40ch;
}
.perfect__lead strong { color: var(--brand-lime); }
.perfect__form {
  display: flex; flex-direction: column; gap: var(--space-3);
  text-align: left;
}
.perfect__field { display: flex; flex-direction: column; gap: 6px; }
.perfect__field label {
  font-family: var(--font-display); font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: rgba(255,255,255,0.6);
}
.perfect__field input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--white);
  font-family: var(--font-display); font-size: 16px;
  outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.perfect__field input:focus {
  border-color: var(--brand-lime);
  box-shadow: 0 0 0 3px rgba(208, 224, 16, 0.2);
}
.perfect__err {
  background: rgba(255, 96, 96, 0.15);
  border: 1px solid rgba(255, 96, 96, 0.4);
  color: #ff8a8a;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.perfect__actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: var(--space-2);
}
.perfect__legal {
  font-size: 11px; color: rgba(255,255,255,0.4);
  text-align: center; line-height: 1.5;
  margin-top: var(--space-3);
}
.perfect__sent { text-align: center; padding: var(--space-4) 0; }
.perfect__sent h3 {
  font-family: var(--font-display); font-size: 28px;
  font-weight: 600; margin: var(--space-3) 0 var(--space-2);
  color: var(--white);
}
.perfect__sent p {
  color: rgba(255,255,255,0.8); margin: 0 0 var(--space-4);
  font-size: 15px;
}
.perfect__sent strong { color: var(--brand-lime); }

/* Confetti */
.confetti {
  position: fixed; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}
.confetti__piece {
  position: absolute;
  top: -20px;
  display: block;
  border-radius: 2px;
  animation: confetti-fall linear infinite;
  opacity: 0.9;
}
@keyframes confetti-fall {
  0%   { transform: translateY(-20px) rotate(0deg); }
  100% { transform: translateY(105vh) rotate(720deg); }
}

/* Editor panel */
.editor-panel {
  position: fixed; bottom: 20px; left: 20px;
  width: 300px;
  background: rgba(10, 22, 36, 0.96);
  border: 1px solid rgba(208, 224, 16, 0.35);
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--white);
  z-index: 50;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
.editor-panel__head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.editor-panel__count { font-family: var(--font-mono); font-size: 11px; color: rgba(255,255,255,0.5); }
.editor-panel__text { font-size: 12px; line-height: 1.5; color: rgba(255,255,255,0.7); margin: 0 0 12px; }
.editor-panel__actions { display: flex; gap: 8px; justify-content: flex-end; }


/* ---- Editor panel v2 ---- */
.editor-panel {
  width: 340px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 16px;
}
.editor-panel__head { margin-bottom: 12px; }

.editor-tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
}
.editor-tool {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  color: rgba(255,255,255,0.65);
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.editor-tool:hover { background: rgba(255,255,255,0.06); color: #fff; }
.editor-tool.is-active {
  background: rgba(208, 224, 16, 0.14);
  color: var(--brand-lime);
  border-color: rgba(208, 224, 16, 0.4);
}
.editor-tool__icon { font-size: 18px; line-height: 1; }
.editor-tool__label { font-size: 12px; font-weight: 600; }
.editor-tool__hint { font-size: 9.5px; opacity: 0.7; letter-spacing: 0.02em; text-transform: uppercase; }

.editor-current {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.editor-current__nav {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  gap: 8px;
}
.editor-nav-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 120ms ease;
}
.editor-nav-btn:hover { background: rgba(208, 224, 16, 0.25); }
.editor-current__info { text-align: center; min-width: 0; }
.editor-current__eyebrow {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.editor-current__name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-lime);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.editor-current__help {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  line-height: 1.45;
  color: rgba(255,255,255,0.7);
}
.editor-current__help strong { color: var(--brand-lime); font-weight: 600; }

.editor-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 12px;
  padding: 2px;
}
.editor-list__item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  border-radius: 6px;
  color: rgba(255,255,255,0.75);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease, border-color 100ms ease;
}
.editor-list__item:hover {
  background: rgba(32, 176, 208, 0.12);
  color: #fff;
}
.editor-list__item.is-selected {
  background: rgba(208, 224, 16, 0.18);
  color: var(--brand-lime);
  border-color: rgba(208, 224, 16, 0.4);
  font-weight: 600;
}
.editor-list__num {
  font-family: var(--font-mono);
  font-size: 9.5px;
  opacity: 0.6;
  min-width: 18px;
}
.editor-list__item.is-selected .editor-list__num { opacity: 1; color: var(--brand-lime); }
.editor-list__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* Editor panel v3: draggable + collapsible */
.editor-panel {
  position: fixed;
  width: 320px;
  max-height: calc(100vh - 40px);
  overflow: hidden; /* body handles its own scroll */
  display: flex;
  flex-direction: column;
  z-index: 90;
  user-select: none;
}
.editor-panel__drag {
  cursor: grab;
  padding: 10px 14px;
  margin: -16px -16px 12px -16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.03);
  border-radius: 14px 14px 0 0;
}
.editor-panel__drag:active { cursor: grabbing; }
.editor-panel__head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.editor-panel__grip {
  font-size: 14px;
  color: rgba(255,255,255,0.35);
  letter-spacing: -2px;
}
.editor-panel__head-right { display: flex; align-items: center; gap: 8px; }
.editor-panel__collapse {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  font-size: 12px;
  display: grid; place-items: center;
  transition: background 120ms ease;
}
.editor-panel__collapse:hover { background: rgba(208, 224, 16, 0.2); color: var(--brand-lime); }
.editor-panel__body {
  overflow-y: auto;
  max-height: calc(100vh - 100px);
  padding-right: 2px;
}
.editor-panel.is-collapsed {
  max-height: none;
  overflow: visible;
}
.editor-panel.is-collapsed .editor-panel__drag {
  margin-bottom: -16px;
  border-bottom: none;
  border-radius: 14px;
}

/* Keep the landmark list compact so everything fits */
.editor-list {
  max-height: 180px;
}


/* Edit mode: give the board the full width (hide side bingo area) */
.app:has(.board.is-edit) {
  grid-template-columns: 1fr 0;
}
.app:has(.board.is-edit) .bingo { display: none; }

/* Editor panel — tight minimized mode (just a floating chip) */
.editor-panel.is-collapsed {
  width: auto;
  min-width: 0;
}
.editor-panel.is-collapsed .editor-panel__head-left .eyebrow {
  font-size: 10px;
}

/* Intro name error */
.intro__input.is-error {
  border-color: #ff6060;
  box-shadow: 0 0 0 3px rgba(255, 96, 96, 0.2);
}
.intro__name-err {
  margin-top: 8px;
  font-size: 13px;
  color: #ff8a8a;
  font-family: var(--font-display);
  display: flex;
  align-items: center;
  gap: 6px;
}
.intro__name-err::before {
  content: "⚠";
}


/* =============================================
   SHARE BAR
   ============================================= */
.share-bar {
  margin-bottom: var(--space-4);
  padding: 14px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
}
.share-bar__label {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  margin-bottom: 10px;
}
.share-bar__btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 140ms ease;
  white-space: nowrap;
}
.share-btn--x {
  background: #000;
  color: #fff;
  border-color: rgba(255,255,255,0.15);
}
.share-btn--x:hover { background: #1a1a1a; border-color: rgba(255,255,255,0.3); }

.share-btn--wa {
  background: #25D366;
  color: #fff;
}
.share-btn--wa:hover { background: #20bb5a; }

.share-btn--li {
  background: #0A66C2;
  color: #fff;
}
.share-btn--li:hover { background: #0854a0; }

.share-btn--fb {
  background: #1877F2;
  color: #fff;
}
.share-btn--fb:hover { background: #1560cc; }

/* Botón único de compartir (móvil) — ocupa todo el ancho y usa la
   identidad del juego para que destaque sobre las filas. */
.share-bar__btns--single { flex-wrap: nowrap; }
.share-btn--single {
  flex: 1 1 100%;
  justify-content: center;
  padding: 14px 16px;
  font-size: 15px;
  letter-spacing: 0.02em;
  border-radius: 10px;
  background: var(--brand-lime);
  color: #0a1b2c;
  border-color: transparent;
}
.share-btn--single:hover  { filter: brightness(0.95); }
.share-btn--single:active { transform: scale(0.99); }
.share-btn--single svg    { color: #0a1b2c; }

/* Toast informativo del share-bar — explica al usuario que la imagen
   se ha descargado y debe adjuntarla manualmente. */
.share-bar__toast {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 1.35;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.92);
  animation: shareToastIn 180ms ease-out both;
}
.share-bar__toast--ok   { border-color: rgba(208,224,16,0.45); background: rgba(208,224,16,0.10); color: #d0e010; }
.share-bar__toast--warn { border-color: rgba(255,200,80,0.45); background: rgba(255,200,80,0.10); color: #ffd47a; }
@keyframes shareToastIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Compat: ocultamos cualquier resto del antiguo botón "Copiar" si quedase
   en alguna versión cacheada. */
.share-btn--copy {
  display: none !important;
  border-color: rgba(208, 224, 16, 0.4);
}

/* Editor pause button */
.editor-pause-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.85);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 140ms ease;
}
.editor-pause-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: var(--brand-lime);
  color: var(--brand-lime);
}
.editor-pause-btn.is-paused {
  background: rgba(208, 224, 16, 0.18);
  border-color: rgba(208, 224, 16, 0.6);
  color: var(--brand-lime);
  box-shadow: 0 0 12px rgba(208,224,16,0.2);
}

/* Editor mode toggle (desktop/mobile switch) */
.editor-mode-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.75);
  font-family: var(--font-display);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 140ms ease;
  line-height: 1.4;
}
.editor-mode-toggle strong { color: var(--white); }
.editor-mode-toggle:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.25);
}
.editor-mode-toggle.is-mobile {
  background: rgba(32, 176, 208, 0.12);
  border-color: rgba(32, 176, 208, 0.45);
  color: var(--brand-teal-bright);
}
.editor-mode-toggle.is-mobile strong { color: var(--white); }
.editor-mode-toggle.is-desktop {
  background: rgba(208, 224, 16, 0.08);
  border-color: rgba(208, 224, 16, 0.3);
  color: rgba(208,224,16,0.85);
}
.editor-mode-toggle.is-desktop strong { color: var(--brand-lime); }


/* ============================================================
   MOBILE INTRO — title + name input visible above fold
   ============================================================ */
@media (max-width: 767px) {
  .overlay--intro { align-items: flex-start; padding: 0; }
  .intro {
    display: flex;
    flex-direction: column;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
    max-width: 100%;
    width: 100%;
    border-radius: 0;
    min-height: 100dvh;
  }
  /* Re-order: kicker → title → form → lead → rules → leaderboard */
  .intro__kicker     { order: 1; margin-bottom: 10px; }
  .intro__title      { order: 2; font-size: 28px; line-height: 1.05; margin: 0 0 14px; }
  .intro__form       { order: 3; margin: 0 0 18px; }
  .intro__lead       { order: 4; font-size: 14px; line-height: 1.5; margin: 0 0 14px; }
  .intro__rules      { order: 5; grid-template-columns: 1fr; gap: 6px; margin: 0 0 16px; }
  .intro__rules li   { padding: 8px 12px; font-size: 13px; }
  .intro__leaderboard{ order: 6; margin-top: 0; }

  .intro__input { font-size: 16px; padding: 12px 14px; } /* 16px = no iOS zoom */
  .btn--primary { padding: 12px 18px; font-size: 14px; }
}


/* ============================================================
   MOBILE END OVERLAY — fits in 100dvh, scrollable, rank prominent
   ============================================================ */
@media (max-width: 767px) {
  .overlay--end { align-items: flex-start; padding: 0; overflow-y: auto; }
  .end {
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    border-radius: 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  .end::before { border-radius: 0; }

  .end__top {
    margin-bottom: 0;
    align-items: center;
    gap: 10px;
  }
  .end__tier { font-size: 16px; }

  /* Hero mobile defaults — overridden by the side-by-side block below.
     Kept minimal to avoid cascade fights. */
  .end__hero-label { font-size: 11px; }
  .end__hero-meta { flex-wrap: wrap; gap: 6px 10px; font-size: 13px; }

  .end__nudge { gap: 6px; margin-bottom: 0; }
  .end__nudge-row {
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.4;
    align-items: flex-start;
  }
  .end__nudge-ico { font-size: 18px; line-height: 1.3; }

  .end__leaderboard { margin-bottom: 0; }
  .end__leaderboard-head { flex-wrap: wrap; gap: 4px; }

  /* Share + actions stack full-width and flow naturally */
  .share-bar { flex-wrap: wrap; gap: 8px; }
  .share-bar__btn { flex: 1 1 auto; min-width: 64px; }

  .end__actions {
    flex-direction: column-reverse;
    gap: 10px;
    padding-top: 6px;
  }
  .end__actions .btn { width: 100%; justify-content: center; }
}


/* ============================================================
   MOBILE END — rank prominent + compact leaderboard
   ============================================================ */
/* ============================================================
   MOBILE END — hero score + rank badge lado a lado, ambos visibles
   ============================================================ */
@media (max-width: 767px) {
  /* Más aire entre los bloques principales del fin de partida */
  .overlay--end .end {
    padding: 20px 14px 24px !important;
    gap: 22px !important;
  }
  .end__top { margin-bottom: 14px !important; }
  .end__hero { margin-bottom: 18px !important; }
  .end__leaderboard { margin: 18px 0 !important; }
  .share-bar { margin: 18px 0 !important; padding: 14px 14px !important; }
  .end__actions { margin-top: 18px !important; gap: 12px !important; }

  /* Hero móvil: flexbox simple. La badge tiene tamaño FIJO (~108px en estrechos,
     hasta 128px). El número 1/20 ocupa el resto del espacio y se reduce con
     clamp si hace falta. Padding interno menor en pantallas <380px. */
  .end__hero {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding: 14px 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    /* No clipping: si la badge fuese ligeramente más alta que la columna izq.,
       preferimos que crezca el hero a que se recorte el contenido. */
    overflow: visible !important;
    min-height: 108px !important;
  }

  /* Columna izquierda: número 1/20 — flexible, no se sale */
  .end__hero-left {
    order: 0 !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    overflow: hidden !important;
  }
  .end__hero-num {
    font-size: clamp(38px, 12vw, 60px) !important;
    line-height: 0.95 !important;
    display: flex !important;
    align-items: baseline !important;
    flex-wrap: nowrap !important;
    margin: 0 !important;
    white-space: nowrap !important;
  }
  .end__hero-sep, .end__hero-total {
    font-size: clamp(22px, 7vw, 34px) !important;
  }

  /* Badge POSICIÓN: layout en 2 filas (etiqueta arriba, "#N de M" abajo)
     para reducir la altura y evitar cualquier recorte en móviles. */
  .end__rank-badge {
    order: 1 !important;
    flex: 0 0 auto !important;
    align-self: center !important;
    display: grid !important;
    grid-template-columns: auto auto !important;
    grid-template-rows: auto auto !important;
    column-gap: 6px !important;
    row-gap: 2px !important;
    justify-content: center !important;
    align-items: baseline !important;
    width: clamp(132px, 36vw, 148px) !important;
    min-width: 132px !important;
    max-width: 148px !important;
    padding: 10px 12px !important;
    border-radius: 14px !important;
    box-sizing: border-box !important;
    text-align: center !important;
    overflow: visible !important;
  }
  .end__rank-lbl {
    grid-column: 1 / -1 !important;
    display: block !important;
    font-size: 10px !important;
    letter-spacing: 0.16em !important;
    margin: 0 !important;
    opacity: 0.75 !important;
    white-space: nowrap !important;
    text-align: center !important;
  }
  .end__rank-num {
    grid-column: 1 !important;
    display: block !important;
    font-size: clamp(28px, 8.2vw, 36px) !important;
    line-height: 1 !important;
    margin: 0 !important;
    white-space: nowrap !important;
    justify-self: end !important;
  }
  .end__rank-of {
    grid-column: 2 !important;
    display: block !important;
    font-size: 11px !important;
    margin: 0 !important;
    white-space: nowrap !important;
    opacity: 0.85 !important;
    align-self: baseline !important;
    justify-self: start !important;
  }

  /* Leaderboard móvil: TODAS las filas (#1–#10) idénticas y nunca recortadas */
  .end__leaderboard {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .leaderboard--big {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .leaderboard--big .leaderboard__row,
  .leaderboard--big .leaderboard__row.is-first,
  .leaderboard--big .leaderboard__row.is-me {
    padding: 10px 12px !important;
    font-size: 13px !important;
    grid-template-columns: 30px minmax(0, 1fr) auto auto !important;
    gap: 8px !important;
    align-items: center !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .leaderboard--big .leaderboard__rank,
  .leaderboard--big .leaderboard__row.is-first .leaderboard__rank {
    font-size: 13px !important;
    line-height: 1 !important;
  }
  .leaderboard--big .leaderboard__hits { font-size: 13px !important; white-space: nowrap; }
  .leaderboard--big .leaderboard__time { font-size: 12px !important; white-space: nowrap; }
  .leaderboard--big .leaderboard__name {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
}


/* "Cómo se juega" — visible solo en móvil; oculto por defecto en desktop */
.intro__howto,
.intro__teaser,
.intro__record { display: none; }

.intro__hook {
  font-size: 24px;
  line-height: 1.4;
  color: rgba(255,255,255,0.9);
  margin: 0 0 var(--space-5);
  font-weight: 500;
}

/* "Top mejores vigueses" — eyebrow más grande para más presencia */
.intro__leaderboard .leaderboard-head .eyebrow {
  font-size: 16px;
  letter-spacing: 0.18em;
}

/* ============================================================
   MOBILE — minimalismo: solo lo esencial
   ============================================================ */
@media (max-width: 767px) {
  /* Intro: fuera explicaciones largas y preview/récord */
  .intro__lead,
  .intro__rules,
  .intro__teaser,
  .intro__record { display: none !important; }

  .intro {
    padding: 32px 22px calc(28px + env(safe-area-inset-bottom));
    gap: 0;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
  }

  /* Orden vertical: kicker → title → howto → hook → form → leaderboard */
  .intro__kicker      { order: 0; margin-bottom: 16px !important; }
  .intro__title       { order: 1; }
  .intro__howto       { order: 2; }
  .intro__hook        { order: 3; }
  .intro__form        { order: 4; }
  .intro__leaderboard { order: 5; }

  .intro__title {
    margin: 0 0 24px !important;
    font-size: 34px !important;
    line-height: 1.05 !important;
    letter-spacing: -0.02em;
    text-wrap: pretty;
  }
  .intro__hook {
    display: block !important;
    margin: 0 0 24px !important;
    font-size: clamp(16px, 4.6vw, 20px);
    line-height: 1.35;
    color: rgba(255,255,255,0.9);
    font-weight: 500;
  }

  /* Form: input + botón en una sola fila ocupando todo el ancho */
  .intro__form { margin: 0 0 28px !important; }
  .intro__row {
    flex-direction: row !important;
    gap: 10px !important;
    width: 100%;
  }
  .intro__row .intro__input {
    flex: 1 1 auto;
    min-width: 0;
  }
  .intro__row .btn--primary {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  /* Leaderboard móvil — solo top 5 visible */
  .intro__leaderboard { display: block !important; margin-top: 0 !important; }
  .intro__leaderboard .leaderboard__row:nth-child(n+6) { display: none !important; }
  .intro__leaderboard .leaderboard-head .eyebrow {
    font-size: clamp(13px, 3.6vw, 15px) !important;
    letter-spacing: 0.16em !important;
  }

  /* Bloques de instrucciones */
  .intro__howto {
    display: flex !important;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 24px !important;
  }
  .intro__howto-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px;
    background: rgba(208, 224, 16, 0.06);
    border: 1px solid rgba(208, 224, 16, 0.16);
    border-radius: 10px;
  }
  .intro__howto-ico { flex: 0 0 auto; color: #d0e010; }
  .intro__howto-txt {
    font-size: 14px;
    line-height: 1.3;
    color: rgba(255,255,255,0.85);
  }
  .intro__howto-txt strong { color: #ffffff; font-weight: 600; }

  /* Preview difuminada de la lámina — llena el espacio central */
  .intro__teaser {
    display: block !important;
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: 100px;
    max-height: 220px;
    margin: 0 0 10px !important;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
  }
  .intro__teaser-img {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    filter: blur(4px) saturate(1.05) brightness(0.55);
    transform: scale(1.08);
  }
  .intro__teaser-fade {
    position: absolute; inset: 0;
    background:
      radial-gradient(120% 80% at 50% 50%, transparent 0%, rgba(10,27,44,0.55) 80%),
      linear-gradient(180deg, rgba(10,27,44,0) 40%, rgba(10,27,44,0.85) 100%);
  }
  .intro__teaser-stamp {
    position: absolute;
    left: 12px; bottom: 10px;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(208,224,16,0.85);
  }

  /* Récord — chip de una línea */
  .intro__record {
    display: flex !important;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin: 0 0 14px !important;
    font-size: 12px;
    line-height: 1.3;
    color: rgba(255,255,255,0.7);
  }
  .intro__record strong { color: #ffffff; font-weight: 600; }
  .intro__record-trophy { font-size: 14px; }
  .intro__record-dot { opacity: 0.5; }

  /* End: fuera eyebrow/tier y "Copiar resultado".
     Se queda la puntuación, el nudge informativo, la tabla compacta,
     el compartir y el botón primario. */
  .end__top,
  .end__actions .btn--ghost { display: none !important; }

  /* Nudge informativo — visible en móvil con el mismo estilo del juego */
  .end__nudge {
    display: flex !important;
    margin: 0 !important;
  }
  .end__nudge-row {
    padding: 12px 14px !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
  }

  .end { gap: 16px !important; }
  .end__actions { padding-top: 4px !important; }

  /* Leaderboard compacto en móvil: cabecera apilada, toggle visible,
     scroll interno y top-10 a la vista de un vistazo. */
  .end__leaderboard {
    display: block !important;
    margin: 0 !important;
  }
  .end__leaderboard-head {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    margin-bottom: 10px !important;
  }
  .end__leaderboard-head .device-toggle {
    align-self: stretch;
    width: 100%;
  }
  .end__leaderboard-head .device-toggle button {
    flex: 1 1 0;
  }
  .end__leaderboard .leaderboard--big {
    /* Altura para ~5 filas visibles; el resto en scroll interno */
    max-height: 230px;
    overflow-y: auto;
    padding-right: 4px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(208,224,16,0.4) transparent;
  }
  /* Filas idénticas #1–#10: mismo grid, padding, fuente, color, alineación.
     Sin tratos especiales para #1 ni medallas con tamaño distinto. */
  .end__leaderboard .leaderboard--big .leaderboard__row,
  .end__leaderboard .leaderboard--big .leaderboard__row.is-first,
  .end__leaderboard .leaderboard--big .leaderboard__row.is-me {
    width: 100%;
    max-width: 100% !important;
    box-sizing: border-box;
    grid-template-columns: 32px minmax(0, 1fr) auto auto !important;
    padding: 10px 12px !important;
    font-size: 13px !important;
    gap: 10px !important;
    background: rgba(255,255,255,0.03) !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
    box-shadow: none !important;
    margin: 0 !important;
  }
  .end__leaderboard .leaderboard--big .leaderboard__rank,
  .end__leaderboard .leaderboard--big .leaderboard__row.is-first .leaderboard__rank {
    font-size: 13px !important;
    line-height: 1 !important;
    color: rgba(255,255,255,0.5) !important;
    text-align: center;
  }
  .end__leaderboard .leaderboard--big .leaderboard__name {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  .end__leaderboard .leaderboard--big .leaderboard__hits,
  .end__leaderboard .leaderboard--big .leaderboard__time {
    white-space: nowrap !important;
  }
  /* Fila del jugador: misma caja, solo color/borde lima para identificar */
  .end__leaderboard .leaderboard--big .leaderboard__row.is-me {
    background: rgba(208, 224, 16, 0.16) !important;
    border-color: rgba(208, 224, 16, 0.5) !important;
  }
  .end__leaderboard .leaderboard--big::-webkit-scrollbar { width: 4px; }
  .end__leaderboard .leaderboard--big::-webkit-scrollbar-thumb {
    background: rgba(208,224,16,0.4); border-radius: 2px;
  }
  /* Fila del jugador siempre visible y resaltada */
  .end__leaderboard .leaderboard__row.is-me {
    position: sticky;
    bottom: 0;
    z-index: 2;
    box-shadow: 0 -8px 14px -8px rgba(10,27,44,0.9);
  }
  /* Revertimos el "ocultar a partir de la 6ª" del bloque anterior:
     ahora queremos top-10 con scroll. Forzamos display: grid para que
     conserven el MISMO layout horizontal que las filas #1–#5. */
  .end__leaderboard ol > li:nth-child(n+6),
  .end__leaderboard ol > li:nth-child(n+6):not(.is-me) {
    display: grid !important;
    grid-template-columns: 32px 1fr auto auto !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 10px 12px !important;
    font-size: 13px !important;
  }
}
