/* ==========================================================================
   Tap Or Trap - Estilos principales (Cartoon Minimalista 9:16)
   ========================================================================== */

:root {
  --bg-desktop: #12172a;
  --bg-surface: #f4f7fd;
  --bg-card: #ffffff;
  --ink-dark: #1d2744;
  --ink-muted: #6e7a99;

  --blue-main: #5ea8f2;
  --blue-light: #96cbff;
  --blue-dark: #3b7ec4;

  --red-main: #ee7480;
  --red-light: #ffa3ac;
  --red-dark: #bf4b58;

  --amber-main: #ffb800;
  --amber-dark: #cc8a00;

  --green-main: #20c96b;
  --green-dark: #14964d;

  --oro-main: #ffc41f;
  --oro-dark: #d99100;
  --plata-main: #c7d2e0;
  --plata-dark: #8797ad;
  --bronce-main: #e48f56;
  --bronce-dark: #b05c27;

  --radius-shell: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;

  --font-display: "Fredoka", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -ms-touch-action: none;
  font-family: var(--font-display);
  color: var(--ink-dark);
  background: radial-gradient(circle at 20% 15%, #232d52 0%, var(--bg-desktop) 65%, #0a0d19 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  color: inherit;
  touch-action: none;
}

button:focus-visible {
  outline: 3px solid var(--amber-main);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* ==================== CONTENEDOR 9:16 ==================== */
.app-shell {
  position: relative;
  width: min(100vw, calc(94dvh * 9 / 16));
  height: min(94dvh, calc(100vw * 16 / 9));
  max-width: 450px;
  max-height: 800px;
  background: var(--bg-surface);
  border-radius: var(--radius-shell);
  overflow: hidden;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.55),
    0 0 0 6px rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
}

@media (max-width: 520px), (max-height: 620px) and (pointer: coarse) {
  body {
    background: var(--bg-surface);
  }
  .app-shell {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }
}

/* ==================== PANTALLAS ==================== */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--bg-surface);
}

.screen--active {
  display: flex;
}

/* ==================== MENÚ PRINCIPAL ==================== */
#screen-menu {
  justify-content: space-between;
  align-items: center;
  padding: max(28px, env(safe-area-inset-top)) 24px max(26px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 85% 12%, rgba(34, 148, 255, 0.14), transparent 44%),
    radial-gradient(circle at 12% 78%, rgba(255, 59, 78, 0.12), transparent 44%),
    var(--bg-surface);
  overflow: hidden;
}

.menu-bg-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.decor-dot {
  position: absolute;
  border-radius: 50%;
  opacity: 0.14;
}

.decor-dot--blue {
  width: 160px;
  height: 160px;
  background: var(--blue-main);
  top: -45px;
  right: -45px;
}

.decor-dot--red {
  width: 120px;
  height: 120px;
  background: var(--red-main);
  bottom: 90px;
  left: -40px;
}

.decor-dot--yellow {
  width: 72px;
  height: 72px;
  background: var(--amber-main);
  top: 44%;
  right: -22px;
}

.menu-header {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 0;
}

.menu-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.profile-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 7px;
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--ink-dark);
  box-shadow: 0 4px 12px rgba(29, 39, 68, 0.08), 0 2px 0 #dce5f4;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  max-width: 72%;
}

.profile-pill:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #dce5f4;
}

.profile-pill-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #edf4ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.96rem;
  line-height: 1;
  flex-shrink: 0;
}

.profile-pill-nick {
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-pill-edit {
  width: 14px;
  height: 14px;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.logo-wrap {
  animation: titleBreathe 3.2s ease-in-out infinite;
}

@keyframes titleBreathe {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-5px) scale(1.035);
  }
}

.game-title {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  font-size: clamp(2.15rem, 9vw, 2.75rem);
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1;
}

.title-tap {
  color: var(--blue-main);
  text-shadow: 0 4px 0 rgba(17, 104, 199, 0.22);
}

.title-or {
  font-size: 0.58em;
  font-weight: 700;
  color: var(--ink-muted);
  background: #e7eef9;
  padding: 5px 9px;
  border-radius: 999px;
  transform: translateY(-3px);
}

.title-trap {
  color: var(--red-main);
  text-shadow: 0 4px 0 rgba(192, 26, 44, 0.2);
}

.level-indicator-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--ink-dark);
  box-shadow: 0 5px 14px rgba(29, 39, 68, 0.08), 0 2px 0 #dce5f4;
}

.level-indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue-main);
  box-shadow: 0 0 0 3px rgba(34, 148, 255, 0.22);
}

.menu-center {
  position: relative;
  z-index: 2;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
}

.play-hero-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* Botón gigante redondo "JUGAR" con latido */
.play-orb-btn {
  position: relative;
  width: clamp(156px, 42vw, 190px);
  height: clamp(156px, 42vw, 190px);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, var(--blue-light) 0%, var(--blue-main) 58%, #4b95e0 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 12px 0 var(--blue-dark),
    0 20px 36px rgba(94, 168, 242, 0.36),
    inset 0 4px 10px rgba(255, 255, 255, 0.45);
  animation: heartbeatOrb 1.85s ease-in-out infinite;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.play-orb-btn:hover {
  filter: brightness(1.04);
}

.play-orb-btn:active {
  animation: none;
  transform: translateY(8px) scale(0.96);
  box-shadow:
    0 4px 0 var(--blue-dark),
    0 10px 20px rgba(34, 148, 255, 0.35),
    inset 0 4px 10px rgba(255, 255, 255, 0.35);
}

.play-orb-ring {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 4px solid rgba(34, 148, 255, 0.28);
  pointer-events: none;
  animation: ringPulse 1.85s ease-out infinite;
}

.play-orb-shine {
  position: absolute;
  top: 16px;
  left: 26px;
  width: 56px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.36);
  transform: rotate(-24deg);
  pointer-events: none;
}

.play-orb-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.play-orb-icon {
  width: 52px;
  height: 52px;
  margin-left: 5px;
  filter: drop-shadow(0 3px 0 rgba(17, 104, 199, 0.45));
}

.play-orb-label {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-shadow: 0 3px 0 rgba(17, 104, 199, 0.45);
}

@keyframes heartbeatOrb {
  0%, 100% {
    transform: scale(1);
  }
  18% {
    transform: scale(1.06);
  }
  32% {
    transform: scale(0.99);
  }
  46% {
    transform: scale(1.04);
  }
  65% {
    transform: scale(1);
  }
}

@keyframes ringPulse {
  0% {
    transform: scale(0.94);
    opacity: 0.7;
  }
  70% {
    transform: scale(1.13);
    opacity: 0;
  }
  100% {
    transform: scale(1.13);
    opacity: 0;
  }
}

.menu-hint {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink-muted);
  text-align: center;
}

.hint-blue {
  color: var(--blue-main);
  font-weight: 700;
}

.hint-red {
  color: var(--red-main);
  font-weight: 700;
}

.menu-footer {
  position: relative;
  z-index: 2;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.menu-footer--triple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.menu-footer--triple .menu-action-btn {
  flex-direction: column;
  gap: 4px;
  padding: 12px 8px 11px;
  font-size: 0.86rem;
  border-radius: 18px;
}

.menu-footer--triple .menu-action-btn svg {
  width: 22px;
  height: 22px;
}

.menu-action-btn--gold svg {
  color: #e6a100;
}

.menu-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  color: var(--ink-dark);
  font-size: 1.02rem;
  font-weight: 700;
  box-shadow: 0 5px 0 #d5dff0, 0 10px 20px rgba(29, 39, 68, 0.08);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.menu-action-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--ink-muted);
}

.menu-action-btn--primary svg {
  color: var(--blue-main);
}

.menu-action-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #d5dff0, 0 4px 10px rgba(29, 39, 68, 0.08);
}

/* ==================== SELECTOR DE NIVELES ==================== */
#screen-levels {
  padding: max(18px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  gap: 14px;
}

.subscreen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.icon-circle-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--bg-card);
  color: var(--ink-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #d5dff0;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.icon-circle-btn svg {
  width: 24px;
  height: 24px;
}

.icon-circle-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #d5dff0;
}

.subscreen-title-group {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.subscreen-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.1;
}

.subscreen-subtitle {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.header-spacer {
  width: 44px;
  height: 44px;
}

.levels-grid {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(106px, auto);
  gap: 12px;
  padding: 4px 2px 12px;
  align-content: start;
}

.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: 13px 14px 12px;
  border-radius: 18px;
  background: var(--bg-card);
  box-shadow: 0 5px 0 #d5dff0, 0 8px 16px rgba(29, 39, 68, 0.06);
  text-align: left;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  border: 2.5px solid transparent;
}

.level-card:not(.level-card--locked):active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #d5dff0;
}

.level-card--current {
  border-color: var(--blue-main);
  background: linear-gradient(180deg, #ffffff 0%, #eef7ff 100%);
  box-shadow: 0 5px 0 #9bccff, 0 8px 18px rgba(34, 148, 255, 0.2);
}

.level-card--locked {
  background: #e4e9f2;
  color: #8f9bb3;
  box-shadow: 0 4px 0 #cfd6e3;
  cursor: not-allowed;
}

.level-card-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.level-num-badge {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  background: #e9f3ff;
  color: var(--blue-main);
}

.level-card--current .level-num-badge {
  background: var(--blue-main);
  color: #ffffff;
}

.level-card--locked .level-num-badge {
  background: #d4dce8;
  color: #7d89a1;
}

.level-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.level-lock-icon {
  width: 20px;
  height: 20px;
  color: #8f9bb3;
}

.level-current-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--blue-main);
  color: #ffffff;
}

.level-medal-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.level-medal-chip svg {
  width: 13px;
  height: 13px;
}

.level-medal-chip--oro {
  background: #fff3c4;
  color: #a66a00;
}

.level-medal-chip--plata {
  background: #eaf0f7;
  color: #54657d;
}

.level-medal-chip--bronce {
  background: #fde8da;
  color: #9c4d1e;
}

.level-card-mid {
  margin-top: 8px;
  width: 100%;
}

.level-card-name {
  display: block;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level-card-footer {
  width: 100%;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.level-card-record {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-dark);
}

.level-card--locked .level-card-footer {
  color: #8f9bb3;
}

/* ==================== PANTALLA DE JUEGO (HUD + CANVAS) ==================== */
.screen--game {
  background: #eef3fb;
  touch-action: none;
}

.game-hud {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: var(--bg-card);
  box-shadow: 0 4px 16px rgba(29, 39, 68, 0.08);
  flex-shrink: 0;
  touch-action: none;
}

.hud-top-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
}

.hud-level-banner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5fc;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.45px;
  color: var(--ink-dark);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 68%;
}

.hud-level-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue-main);
  flex-shrink: 0;
}

.hud-level-dot--basico { background: #52c997; }
.hud-level-dot--normal { background: var(--blue-main); }
.hud-level-dot--dificil { background: #f2b441; }
.hud-level-dot--avanzado { background: #967df2; }
.hud-level-dot--infernal { background: var(--red-main); }
.hud-level-dot--infinito { background: #7662e6; }
.hud-level-dot--tutorial { background: #38b2ac; }

.hud-lives {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

.heart-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--red-main);
  filter: drop-shadow(0 2px 0 rgba(191, 75, 88, 0.25));
  transition: transform 0.22s ease, color 0.22s ease, opacity 0.22s ease;
}

.heart-icon svg {
  width: 100%;
  height: 100%;
}

.heart-icon--lost {
  color: #cfd8e8;
  filter: none;
  transform: scale(0.84);
  opacity: 0.65;
}

.heart-icon--just-lost {
  animation: heartBreak 0.42s ease-out;
}

@keyframes heartBreak {
  0% {
    transform: scale(1.3);
    color: var(--red-main);
    opacity: 1;
  }
  35% {
    transform: scale(1.15) rotate(-16deg);
    color: var(--red-dark);
  }
  65% {
    transform: scale(0.75) rotate(14deg);
    opacity: 0.7;
  }
  100% {
    transform: scale(0.84) rotate(0deg);
    color: #cfd8e8;
    opacity: 0.65;
  }
}

.hud-main-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
}

.hud-taps-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.hud-taps-top {
  display: flex;
  align-items: center;
  gap: 7px;
}

.hud-tap-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--blue-main);
  box-shadow: 0 2px 0 var(--blue-dark);
  flex-shrink: 0;
}

.hud-taps-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink-dark);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: transform 0.1s ease;
}

.hud-taps-value.pop {
  transform: scale(1.16);
  color: var(--blue-main);
}

.hud-progress-track {
  width: 100%;
  max-width: 132px;
  height: 8px;
  border-radius: 999px;
  background: #e4ecf8;
  overflow: hidden;
}

.hud-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-main), #38d39f);
  transition: width 0.14s ease-out;
}

.hud-timer-box {
  background: #f1f5fc;
  border: 2px solid #dfe7f5;
  border-radius: 14px;
  padding: 7px 12px;
  min-width: 98px;
  text-align: center;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.hud-timer-box--warn {
  background: #fff6db;
  border-color: var(--amber-main);
  color: #a66500;
}

.hud-timer-box--danger {
  background: #ffe6e9;
  border-color: var(--red-main);
  color: var(--red-dark);
  animation: timerPulse 0.55s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.045);
  }
}

.hud-timer-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: inline-block;
}

.hud-pause-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #f1f5fc;
  color: var(--ink-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #d5dff0;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.hud-pause-btn svg {
  width: 22px;
  height: 22px;
}

.hud-pause-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #d5dff0;
}

.canvas-stage {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Aviso breve de nivel al empezar */
.level-toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(16px);
  background: rgba(29, 39, 68, 0.88);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 16px;
  text-align: center;
  max-width: 88%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 10px 24px rgba(15, 22, 42, 0.25);
  z-index: 4;
}

.level-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.level-toast-title {
  display: block;
  font-size: 0.96rem;
  font-weight: 700;
}

.level-toast-desc {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.84);
  margin-top: 2px;
}

/* ==================== MODALES ==================== */
.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(15, 22, 42, 0.58);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeInBackdrop 0.18s ease-out;
}

@keyframes fadeInBackdrop {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-card {
  width: 100%;
  max-width: 340px;
  background: var(--bg-card);
  border-radius: 26px;
  padding: 24px 22px 22px;
  text-align: center;
  box-shadow:
    0 22px 48px rgba(10, 15, 35, 0.34),
    0 6px 0 rgba(213, 223, 240, 0.95);
  animation: popInModal 0.24s cubic-bezier(0.22, 1.28, 0.36, 1);
}

@keyframes popInModal {
  from {
    opacity: 0;
    transform: scale(0.86) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-title {
  margin: 0 0 6px;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--ink-dark);
}

.modal-title--victory {
  color: var(--green-dark);
}

.modal-title--defeat {
  color: var(--red-dark);
}

.modal-subtitle {
  margin: 0 0 18px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-muted);
}

/* Ajustes switches */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 18px 0 22px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 16px;
  background: #f4f7fd;
  cursor: pointer;
}

.setting-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setting-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.setting-icon svg {
  width: 20px;
  height: 20px;
}

.setting-icon--blue {
  background: var(--blue-main);
}

.setting-icon--purple {
  background: #7950f2;
}

.setting-label {
  font-size: 1.05rem;
  font-weight: 600;
}

.switch-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 54px;
  height: 30px;
  border-radius: 999px;
  background: #cad5e6;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s cubic-bezier(0.22, 1.28, 0.36, 1);
}

.switch-input:checked + .switch-track {
  background: var(--green-main);
}

.switch-input:checked + .switch-track .switch-thumb {
  transform: translateX(24px);
}

/* Victoria */
.result-badge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.medal-emblem {
  width: 82px;
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 8px 14px rgba(29, 39, 68, 0.16));
  animation: medalPop 0.45s cubic-bezier(0.22, 1.4, 0.36, 1);
}

.medal-emblem svg {
  width: 100%;
  height: 100%;
}

.medal-emblem--oro {
  color: var(--oro-main);
}

.medal-emblem--plata {
  color: var(--plata-main);
}

.medal-emblem--bronce {
  color: var(--bronce-main);
}

@keyframes medalPop {
  0% {
    transform: scale(0.4) rotate(-18deg);
  }
  70% {
    transform: scale(1.1) rotate(5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

.medal-pill {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 5px 12px;
  border-radius: 999px;
}

.medal-pill--oro {
  background: #fff3c4;
  color: #a66a00;
}

.medal-pill--plata {
  background: #eaf0f7;
  color: #4f6078;
}

.medal-pill--bronce {
  background: #fde8da;
  color: #9c4d1e;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 18px;
}

.stat-box {
  position: relative;
  background: #f4f7fd;
  border-radius: 16px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.stat-value {
  font-size: 1.24rem;
  font-weight: 700;
  color: var(--ink-dark);
}

.stat-value--mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.new-record-tag {
  position: absolute;
  top: -9px;
  right: 8px;
  background: var(--amber-main);
  color: #5c3900;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(255, 184, 0, 0.4);
}

/* Derrota */
.defeat-icon-wrap {
  width: 72px;
  height: 72px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: #ffe6e9;
  color: var(--red-main);
  display: flex;
  align-items: center;
  justify-content: center;
}

.defeat-icon-wrap svg {
  width: 44px;
  height: 44px;
}

.defeat-reason {
  margin: 0 0 14px;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--ink-dark);
}

.defeat-progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f4f7fd;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin-bottom: 18px;
}

.defeat-progress-pill strong {
  color: var(--ink-dark);
}

/* Botones cartoon 3D */
.modal-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-cartoon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 1.04rem;
  font-weight: 700;
  color: #ffffff;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.1s ease;
}

.btn-full {
  width: 100%;
}

.btn-cartoon:hover {
  filter: brightness(1.04);
}

.btn-cartoon--blue {
  background: var(--blue-main);
  box-shadow: 0 5px 0 var(--blue-dark);
}
.btn-cartoon--blue:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--blue-dark);
}

.btn-cartoon--green {
  background: var(--green-main);
  box-shadow: 0 5px 0 var(--green-dark);
}
.btn-cartoon--green:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--green-dark);
}

.btn-cartoon--red {
  background: var(--red-main);
  box-shadow: 0 5px 0 var(--red-dark);
}
.btn-cartoon--red:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--red-dark);
}

.btn-cartoon--amber {
  background: var(--amber-main);
  color: #4f3100;
  box-shadow: 0 5px 0 var(--amber-dark);
}
.btn-cartoon--amber:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--amber-dark);
}

.btn-cartoon--neutral {
  background: #edf2fa;
  color: var(--ink-dark);
  box-shadow: 0 5px 0 #cfd9ea;
}
.btn-cartoon--neutral:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #cfd9ea;
}

.btn-cartoon--purple {
  background: linear-gradient(135deg, #8e7cf6 0%, #6f5be0 100%);
  box-shadow: 0 5px 0 #4f3db5;
}
.btn-cartoon--purple:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #4f3db5;
}

/* ==================== MODO INFINITO EN MENÚ ==================== */
.infinite-cta-wrap {
  width: 100%;
  max-width: 264px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: clamp(26px, 5vh, 44px);
}

.infinite-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, #9886fa 0%, #7662e6 100%);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  box-shadow:
    0 6px 0 #5441bd,
    0 12px 24px rgba(118, 98, 230, 0.28),
    inset 0 2px 6px rgba(255, 255, 255, 0.34);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.12s ease;
}

.infinite-btn:hover {
  filter: brightness(1.04);
}

.infinite-btn:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #5441bd,
    0 6px 14px rgba(118, 98, 230, 0.22);
}

.infinite-btn-icon {
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.22);
  padding: 2px 9px 4px;
  border-radius: 999px;
}

.infinite-record-text {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ==================== BLOQUES DE DIFICULTAD (SELECTOR 1-20) ==================== */
.tier-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin-top: 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  border: 1.5px solid #e2eaf6;
}

.tier-header:first-child {
  margin-top: 0;
}

.tier-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tier-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tier-title {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.tier-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* Colores suaves por bloque de dificultad */
.tier-header--basico .tier-dot { background: #52c997; }
.tier-header--basico .tier-title { color: #248a60; }

.tier-header--normal .tier-dot { background: var(--blue-main); }
.tier-header--normal .tier-title { color: var(--blue-dark); }

.tier-header--dificil .tier-dot { background: #f2b441; }
.tier-header--dificil .tier-title { color: #ad7207; }

.tier-header--avanzado .tier-dot { background: #967df2; }
.tier-header--avanzado .tier-title { color: #5b43b8; }

.tier-header--infernal .tier-dot { background: var(--red-main); }
.tier-header--infernal .tier-title { color: var(--red-dark); }

/* Acento sutil en tarjetas desbloqueadas por tier */
.level-card--tier-basico:not(.level-card--locked):not(.level-card--current) .level-num-badge {
  background: #e5f8f0;
  color: #248a60;
}
.level-card--tier-normal:not(.level-card--locked):not(.level-card--current) .level-num-badge {
  background: #e9f3ff;
  color: var(--blue-dark);
}
.level-card--tier-dificil:not(.level-card--locked):not(.level-card--current) .level-num-badge {
  background: #fff4dd;
  color: #ad7207;
}
.level-card--tier-avanzado:not(.level-card--locked):not(.level-card--current) .level-num-badge {
  background: #f0ecff;
  color: #5b43b8;
}
.level-card--tier-infernal:not(.level-card--locked):not(.level-card--current) .level-num-badge {
  background: #fdebec;
  color: var(--red-dark);
}

/* ==================== HUD & BARRA DE SUPERVIVENCIA (MODO INFINITO) ==================== */
.hud-intensity-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: #efeaff;
  color: #5b43b8;
  line-height: 1.1;
  flex-shrink: 0;
}

.survival-bar-wrap {
  position: relative;
  z-index: 4;
  width: 100%;
  height: 9px;
  background: #dde6f5;
  overflow: hidden;
  flex-shrink: 0;
}

.survival-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #5ea8f2 0%, #4ed199 100%);
  transition: background-color 0.2s ease;
  transform-origin: left center;
}

.survival-bar-fill--warn {
  background: linear-gradient(90deg, #f5b83d 0%, #ffd45c 100%);
}

.survival-bar-fill--danger {
  background: linear-gradient(90deg, #d95562 0%, #ee7480 100%);
}

.hud-timer-box--gain {
  border-color: #4ed199;
  background: #e8fbf2;
}

/* Aviso breve de subida de intensidad */
.intensity-callout {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  z-index: 6;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(118, 98, 230, 0.94), rgba(94, 168, 242, 0.94));
  color: #ffffff;
  padding: 9px 20px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 24px rgba(84, 65, 189, 0.34);
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.22, 1.32, 0.36, 1);
  white-space: nowrap;
}

.intensity-callout--visible {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.intensity-callout-title {
  font-size: 0.9rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.22);
  padding: 2px 9px;
  border-radius: 999px;
}

.intensity-callout-sub {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.infinite-over-badge {
  display: inline-block;
  margin-bottom: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #efeaff;
  color: #5b43b8;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ==================== RETRASO DE SEGURIDAD (1s ANTI-PULSACIÓN) ==================== */
.result-actions-guard {
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.22, 1.28, 0.36, 1);
}

.result-actions-guard--locked {
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  pointer-events: none;
}

/* ==================== VICTORIA VIDAS Y AJUSTES TUTORIAL ==================== */
.victory-lives-summary {
  margin: -10px 0 14px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink-dark);
  background: #f4f7fd;
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
}

.setting-row--action {
  width: 100%;
  text-align: left;
  transition: transform 0.08s ease, filter 0.1s ease;
}

.setting-row--action:active {
  transform: scale(0.98);
}

.setting-icon--teal {
  background: #38b2ac;
  font-size: 1.25rem;
  font-weight: 700;
}

.setting-action-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: #e5f6f5;
  color: #227974;
  font-size: 0.84rem;
  font-weight: 700;
}

.tutorial-done-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  animation: medalPop 0.42s cubic-bezier(0.22, 1.35, 0.36, 1);
}

.tutorial-done-icon svg {
  width: 100%;
  height: 100%;
}

/* ==================== TUTORIAL GUIADO CON FOCO ==================== */
.tutorial-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  touch-action: none;
}

.tutorial-overlay--passthrough {
  pointer-events: none;
}

.tutorial-spotlight-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.tutorial-focus-ring {
  stroke: #ffd45c;
  stroke-width: 3.5;
  filter: drop-shadow(0 0 8px rgba(255, 212, 92, 0.75));
  animation: tutorialRingPulse 1.4s ease-in-out infinite;
}

@keyframes tutorialRingPulse {
  0%, 100% {
    stroke-opacity: 1;
    stroke-width: 3.5;
  }
  50% {
    stroke-opacity: 0.55;
    stroke-width: 5.5;
  }
}

.tutorial-bubble {
  position: absolute;
  left: 12px;
  right: 12px;
  margin: 0 auto;
  max-width: 364px;
  background: #ffffff;
  border-radius: 22px;
  padding: 15px 16px 14px;
  box-shadow:
    0 18px 40px rgba(10, 16, 36, 0.42),
    0 5px 0 #dce5f4;
  pointer-events: auto;
  animation: popInModal 0.22s cubic-bezier(0.22, 1.28, 0.36, 1);
}

.tutorial-bubble--compact {
  padding: 13px 14px 13px;
}

.tutorial-bubble--compact .tutorial-bubble-text {
  font-size: clamp(0.75rem, 3.45vw, 0.92rem);
  white-space: nowrap;
  text-align: center;
  margin-bottom: 12px;
}

.tutorial-bubble-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tutorial-step-badge {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e9f3ff;
  color: var(--blue-dark);
}

.tutorial-skip-btn {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-muted);
  padding: 4px 8px;
  border-radius: 8px;
}

.tutorial-skip-btn:active {
  background: #eef2fa;
}

.tutorial-bubble-text {
  margin: 0 0 14px;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink-dark);
  text-align: left;
}

.tutorial-bubble-footer {
  display: flex;
  justify-content: flex-end;
}

.tutorial-next-btn {
  padding: 10px 20px;
  font-size: 0.95rem;
  border-radius: 14px;
}

/* ==================== PANTALLA BIENVENIDA / PERFIL ==================== */
#screen-welcome {
  background:
    radial-gradient(circle at 85% 12%, rgba(94, 168, 242, 0.16), transparent 45%),
    radial-gradient(circle at 12% 82%, rgba(238, 116, 128, 0.14), transparent 45%),
    var(--bg-surface);
  overflow: hidden;
}

.welcome-scroll {
  position: relative;
  z-index: 2;
  flex: 1;
  width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: max(22px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}

.welcome-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.welcome-subtitle {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.profile-card {
  width: 100%;
  max-width: 344px;
  background: var(--bg-card);
  border-radius: 26px;
  padding: 20px 18px 20px;
  box-shadow:
    0 18px 40px rgba(29, 39, 68, 0.1),
    0 5px 0 #dce5f4;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.avatar-preview-wrap {
  display: flex;
  justify-content: center;
  margin-top: -4px;
}

.avatar-preview-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(145deg, #eef6ff 0%, #dcebff 100%);
  border: 3px solid #ffffff;
  box-shadow: 0 6px 16px rgba(94, 168, 242, 0.22), 0 0 0 3px rgba(94, 168, 242, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
  line-height: 1;
  transition: transform 0.18s cubic-bezier(0.22, 1.38, 0.36, 1);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
}

.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-dark);
}

.form-char-count {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.nick-input {
  width: 100%;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-dark);
  background: #f4f7fd;
  border: 2.5px solid #dce5f4;
  border-radius: 15px;
  padding: 12px 14px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.nick-input:focus {
  background: #ffffff;
  border-color: var(--blue-main);
  box-shadow: 0 0 0 4px rgba(94, 168, 242, 0.2);
}

.nick-input::placeholder {
  color: #9ba7bf;
  font-weight: 500;
}

.form-error-hint {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
  transition: color 0.15s ease;
}

.form-error-hint--warn {
  color: var(--red-dark);
}

.form-error-hint--ok {
  color: var(--green-dark);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.avatar-option {
  height: 50px;
  border-radius: 15px;
  background: #f4f7fd;
  border: 2.5px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  line-height: 1;
  transition: transform 0.1s ease, border-color 0.14s ease, background-color 0.14s ease, box-shadow 0.14s ease;
}

.avatar-option:active {
  transform: scale(0.92);
}

.avatar-option--selected {
  background: #e9f4ff;
  border-color: var(--blue-main);
  box-shadow: 0 4px 10px rgba(94, 168, 242, 0.24);
  transform: scale(1.04);
}

.btn-cartoon:disabled {
  opacity: 0.5;
  filter: grayscale(0.25);
  cursor: not-allowed;
  transform: none;
}

.welcome-start-btn {
  margin-top: 2px;
  letter-spacing: 0.5px;
}

/* ==================== MODAL INTRO TUTORIAL & EDITAR PERFIL ==================== */
.tutorial-intro-avatar {
  width: 68px;
  height: 68px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: #eef6ff;
  border: 3px solid var(--blue-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1rem;
  line-height: 1;
  animation: medalPop 0.4s cubic-bezier(0.22, 1.35, 0.36, 1);
}

.tutorial-intro-greeting {
  display: inline-block;
  margin-bottom: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #e9f4ff;
  color: var(--blue-dark);
  font-size: 0.82rem;
  font-weight: 700;
}

.tutorial-intro-title {
  font-size: 1.42rem;
  line-height: 1.2;
}

.profile-modal-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 12px;
}

/* ==================== BOTÓN TROFEO EN VICTORIA ==================== */
.modal-actions-row--victory {
  grid-template-columns: 1fr 1fr 54px;
}

.btn-icon-only {
  padding: 0;
  width: 54px;
  height: 100%;
  min-height: 48px;
}

.btn-icon-only svg {
  width: 24px;
  height: 24px;
}

/* ==================== PANTALLA: RANKING GLOBAL ==================== */
#screen-ranking {
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  gap: 12px;
}

.ranking-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border-radius: 18px;
  background: #e6edf8;
  flex-shrink: 0;
}

.ranking-tab {
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink-muted);
  transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.ranking-tab--active {
  background: var(--bg-card);
  color: var(--ink-dark);
  box-shadow: 0 3px 10px rgba(29, 39, 68, 0.08);
}

.ranking-level-bar {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ranking-lvl-step {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: var(--bg-card);
  color: var(--ink-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 #d5dff0;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.ranking-lvl-step svg {
  width: 20px;
  height: 20px;
}

.ranking-lvl-step:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #d5dff0;
}

.ranking-lvl-step:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ranking-level-select {
  width: 100%;
  height: 40px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-dark);
  background: var(--bg-card);
  border: 2px solid #dce5f4;
  border-radius: 13px;
  padding: 0 12px;
  outline: none;
  cursor: pointer;
  touch-action: manipulation;
}

.ranking-level-select:focus {
  border-color: var(--blue-main);
}

.ranking-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 2px 2px 12px;
}

.ranking-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: 0 4px 0 #dde6f4, 0 6px 14px rgba(29, 39, 68, 0.05);
  border: 2px solid transparent;
}

.ranking-row--me {
  background: linear-gradient(180deg, #ffffff 0%, #edf6ff 100%);
  border-color: var(--blue-main);
  box-shadow: 0 4px 0 #9cc9f7, 0 8px 16px rgba(94, 168, 242, 0.18);
}

.ranking-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.ranking-pos {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 700;
  background: #f0f4fb;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.ranking-pos--1 {
  background: #fff3c4;
  color: #a66a00;
  font-size: 1.15rem;
}

.ranking-pos--2 {
  background: #e9eff7;
  color: #4f6078;
  font-size: 1.15rem;
}

.ranking-pos--3 {
  background: #fde8da;
  color: #9c4d1e;
  font-size: 1.15rem;
}

.ranking-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f1f6ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
}

.ranking-player-info {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ranking-nick {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--ink-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranking-me-tag {
  font-size: 0.64rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--blue-main);
  color: #ffffff;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

.ranking-row-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.ranking-score-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-dark);
}

.ranking-score-unit {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.ranking-medal-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.ranking-medal-dot svg {
  width: 16px;
  height: 16px;
}

.ranking-medal-dot--oro {
  background: #fff3c4;
  color: #d99100;
}

.ranking-medal-dot--plata {
  background: #eaf0f7;
  color: #7c8da6;
}

.ranking-medal-dot--bronce {
  background: #fde8da;
  color: #c26a33;
}

.ranking-state-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 20px;
  text-align: center;
  color: var(--ink-muted);
}

.ranking-state-icon {
  font-size: 2.6rem;
  line-height: 1;
}

.ranking-state-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-dark);
}

.ranking-state-desc {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-muted);
  max-width: 250px;
}

.ranking-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 4px solid #dce6f5;
  border-top-color: var(--blue-main);
  animation: rankingSpin 0.75s linear infinite;
}

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