/* ═══════════════════════════════════════════════════════
   LEVEL SELECT — Gamified Redesign
═══════════════════════════════════════════════════════ */

.level-select {
  min-height: 100dvh;
  max-width: var(--app-max-width);
  margin: 0 auto;
  padding: 0 0 60px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  background: var(--bg-primary);
}

/* ── Ambient section background ─────────────────────── */
.ls-section-bg {
  position: fixed;
  inset: 0;
  max-width: var(--app-max-width);
  left: 50%;
  transform: translateX(-50%);
  opacity: 0.18;
  z-index: 0;
  pointer-events: none;
  width: 100%;
}

/* ── Floating ambient orbs ──────────────────────────── */
.ls-particles {
  position: fixed;
  inset: 0;
  max-width: var(--app-max-width);
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
  width: 100%;
}
.ls-orb {
  position: absolute;
  border-radius: 50%;
  background: var(--section-glow, rgba(99,102,241,0.25));
  filter: blur(55px);
  animation: orbFloat ease-in-out infinite;
}
.ls-orb-0 { width: 260px; height: 260px; top: -8%;   left: -20%; opacity: 0.30; animation-duration: 18s; animation-delay:   0s; }
.ls-orb-1 { width: 180px; height: 180px; top:  35%;  right:-15%; opacity: 0.22; animation-duration: 23s; animation-delay:  -7s; }
.ls-orb-2 { width: 150px; height: 150px; bottom:20%; left:   8%; opacity: 0.18; animation-duration: 28s; animation-delay: -12s; }
.ls-orb-3 { width: 130px; height: 130px; top:  65%;  right:  5%; opacity: 0.20; animation-duration: 21s; animation-delay:  -4s; }
.ls-orb-4 { width: 220px; height: 220px; bottom:-10%;right: -18%;opacity: 0.22; animation-duration: 25s; animation-delay: -16s; }

@keyframes orbFloat {
  0%,100% { transform: translateY(0px)   scale(1);    }
  33%      { transform: translateY(-28px) scale(1.06); }
  66%      { transform: translateY(18px)  scale(0.96); }
}

/* ── Sticky top bar ─────────────────────────────────── */
.ls-top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  padding-top: max(12px, env(safe-area-inset-top, 12px));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  background: rgba(10,10,26,0.72);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.ls-back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s, transform 0.15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.ls-back-btn:active { transform: scale(0.88); background: rgba(255,255,255,0.1); }
.ls-top-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--section-accent, var(--text-primary));
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ls-top-stars {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #FBBF24;
  background: rgba(251,191,36,0.1);
  border: 1px solid rgba(251,191,36,0.2);
  padding: 4px 11px;
  border-radius: 20px;
  flex-shrink: 0;
}

/* ── Hero section ───────────────────────────────────── */
.ls-hero {
  position: relative;
  z-index: 1;
  padding: 22px 16px 18px;
  text-align: center;
}
.ls-hero-emoji {
  font-size: 58px;
  display: block;
  line-height: 1;
  margin-bottom: 12px;
  animation: heroFloat 3.5s ease-in-out infinite;
  filter: drop-shadow(0 0 26px var(--section-glow, rgba(99,102,241,0.65)));
}
@keyframes heroFloat {
  0%,100% { transform: translateY(0);    }
  50%      { transform: translateY(-9px); }
}
.ls-hero-name {
  font-family: 'Outfit', sans-serif;
  font-size: 30px;
  font-weight: 900;
  color: rgba(210,220,240,0.9);
  margin: 0 0 5px;
  letter-spacing: -0.5px;
  text-shadow: 0 0 40px var(--section-glow, rgba(99,102,241,0.5));
}
.ls-hero-tagline {
  font-size: 12px;
  color: rgba(140,158,185,0.6);
  font-style: italic;
  margin: 0 0 18px;
}

/* Stats row */
.ls-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 14px;
}
.ls-stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}
.ls-stat-num {
  font-family: 'Outfit', sans-serif;
  font-size: 19px;
  font-weight: 800;
  color: var(--section-accent, var(--text-primary));
  line-height: 1;
}
.ls-stat-lbl {
  font-size: 9px;
  font-weight: 600;
  color: rgba(130,148,175,0.55);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ls-stat-sep {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,0.09);
  flex-shrink: 0;
}

/* XP progress track */
.ls-xp-track {
  position: relative;
  height: 8px;
  background: rgba(255,255,255,0.07);
  border-radius: 4px;
  overflow: visible;
}
.ls-xp-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  border-radius: 4px;
  background: linear-gradient(90deg,
    var(--section-accent, #6366f1),
    color-mix(in srgb, var(--section-accent, #6366f1) 60%, white)
  );
  box-shadow: 0 0 14px var(--section-glow, rgba(99,102,241,0.5));
  transition: width 0.9s cubic-bezier(0.22,0.61,0.36,1);
  overflow: hidden;
}
.ls-xp-fill::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 30%, rgba(255,255,255,0.28) 60%, transparent);
  animation: xpShimmer 2.2s ease-in-out infinite;
}
@keyframes xpShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%);  }
}
.ls-xp-tip {
  position: absolute;
  right: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 14px;
  background: white;
  border-radius: 3px;
  opacity: 0.85;
  box-shadow: 0 0 8px white, 0 0 16px var(--section-glow, rgba(99,102,241,0.6));
}
.ls-xp-tick {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 14px;
  background: rgba(255,255,255,0.18);
  border-radius: 1px;
  z-index: 2;
}

/* ── No-anim mode ───────────────────────────────────── */
.ls-no-anim .level-card { animation: none !important; }

/* ── Grid: 2 columns ────────────────────────────────── */
.levels-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 4px 12px 40px;
}

/* ── Stage dividers ─────────────────────────────────── */
.stage-divider {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 2px 4px;
}
.stage-line  { flex: 1; height: 1px; background: rgba(255,255,255,0.08); }
.stage-label {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: rgba(255,255,255,0.28);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════
   LEVEL CARD
══════════════════════════════════════════════════════ */

.level-card {
  position: relative;
  border-radius: 16px;
  border: 1.5px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* Left-aligned column layout */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 190px;
  padding: 14px;
  text-align: left;
  gap: 0;
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.18s ease;
  animation: cardPop 0.42s cubic-bezier(0.22,0.61,0.36,1) both;
  animation-delay: var(--anim-delay, 0s);
}
@keyframes cardPop {
  from { opacity: 0; transform: translateY(22px) scale(0.88); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}
.level-card:active:not(:disabled) {
  transform: scale(0.93) translateY(1px);
}

/* ── Unlocked ───────────────────────────────────────── */
.level-card.unlocked {
  background: var(--section-card-bg, rgba(255,255,255,0.04));
  border-color: color-mix(in srgb, var(--section-accent, #6366f1) 22%, transparent);
  box-shadow:
    0 4px 18px rgba(0,0,0,0.38),
    inset 0 1px 0 rgba(255,255,255,0.07);
}
.level-card.unlocked::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(ellipse at 85% 10%,
    var(--section-glow, rgba(99,102,241,0.22)) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}
.level-card.unlocked:not(.completed) {
  box-shadow:
    0 4px 18px rgba(0,0,0,0.38),
    0 0 0 1px color-mix(in srgb, var(--section-accent, #6366f1) 16%, transparent),
    inset 0 1px 0 rgba(255,255,255,0.07);
}

/* ── Completed ──────────────────────────────────────── */
.level-card.completed {
  border-color: color-mix(in srgb, #FBBF24 38%, var(--section-accent, #6366f1) 62%);
  box-shadow:
    0 4px 22px rgba(0,0,0,0.42),
    0 0 20px rgba(251,191,36,0.1),
    inset 0 1px 0 rgba(255,255,255,0.09);
}
.level-card.completed::before {
  background: radial-gradient(ellipse at 85% 10%, rgba(251,191,36,0.14) 0%, transparent 55%);
}

/* ── Locked ─────────────────────────────────────────── */
.level-card.locked {
  cursor: default;
  border-color: rgba(255,255,255,0.04);
  background: rgba(255,255,255,0.015);
  box-shadow: none;
}

/* Override every text element to flat, dim gray on locked cards */
.level-card.locked .card-lv-label {
  color: rgba(80,88,105,0.55);
}
.level-card.locked .card-num {
  color: rgba(75,85,100,0.55);
  text-shadow: none;
}
.level-card.locked .card-name {
  color: rgba(70,80,95,0.5);
}
.level-card.locked .card-diff {
  color: rgba(80,88,105,0.45) !important;
}
.level-card.locked .card-grid {
  color: rgba(70,80,95,0.38);
}

/* ── Boss (full width) ──────────────────────────────── */
.level-card.boss {
  grid-column: 1 / -1;
  min-height: 160px;
}
.level-card.boss.unlocked {
  border-color: var(--section-accent, #6366f1);
  box-shadow:
    0 0 32px var(--section-glow, rgba(99,102,241,0.38)),
    0 0 70px color-mix(in srgb, var(--section-glow, rgba(99,102,241,0.2)) 50%, transparent),
    inset 0 1px 0 rgba(255,255,255,0.12);
}

/* ── Timed top strip ────────────────────────────────── */
.level-card.timed.unlocked::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2.5px;
  background: linear-gradient(90deg, #FBBF24, #F97316);
  border-radius: 16px 16px 0 0;
  z-index: 5;
}

/* ── Daily glow ─────────────────────────────────────── */
.level-card.daily.unlocked:not(.completed) {
  border-color: rgba(16,185,129,0.4);
  box-shadow: 0 0 18px rgba(16,185,129,0.13);
}

/* ── Badges — absolute top-right ────────────────────── */
.card-badges {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  gap: 4px;
  align-items: center;
}
.badge-boss {
  font-size: 16px;
  animation: bossWiggle 6s ease-in-out infinite;
}
@keyframes bossWiggle {
  0%,85%,100% { transform: rotate(0deg);  }
  88%          { transform: rotate(-14deg); }
  92%          { transform: rotate(14deg);  }
  96%          { transform: rotate(-7deg);  }
}
.badge-timed {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 700;
  color: #FBBF24;
  background: rgba(251,191,36,0.14);
  border: 1px solid rgba(251,191,36,0.28);
  border-radius: 5px;
  padding: 2px 5px;
}
.badge-daily {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 700;
  color: #10B981;
  background: rgba(16,185,129,0.14);
  border: 1px solid rgba(16,185,129,0.28);
  border-radius: 5px;
  padding: 2px 5px;
  animation: dailyPulse 2.2s ease-in-out infinite;
}
@keyframes dailyPulse {
  0%,100% { box-shadow: 0 0 0 0 transparent;          }
  50%      { box-shadow: 0 0 8px rgba(16,185,129,0.5); }
}

/* ── Card body: level number + name ─────────────────── */
.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
  padding-right: 32px; /* avoid overlapping badge */
}
.card-lv-label {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2.5px;
  color: rgba(160,175,200,0.45);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.card-num {
  font-family: 'Outfit', sans-serif;
  font-size: 52px;
  font-weight: 900;
  color: rgba(205,215,235,0.88);
  line-height: 1;
  letter-spacing: -2px;
  text-shadow: 0 0 30px var(--section-glow, rgba(99,102,241,0.6));
  margin-bottom: 6px;
}
.card-name {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: rgba(165,180,210,0.68);
  text-transform: uppercase;
  letter-spacing: 2px;
  line-height: 1;
}
.boss-stage-name {
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: 500;
  font-style: italic;
  color: var(--section-accent, rgba(255,255,255,0.5));
  opacity: 0.75;
  margin-top: 5px;
}

/* ── Card bottom row ─────────────────────────────────── */
.card-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  position: relative;
  z-index: 2;
  margin-top: 14px;
}
.card-bottom-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Difficulty text label */
.card-diff {
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.card-diff.diff-easy   { color: #10B981; }
.card-diff.diff-medium { color: #FBBF24; }
.card-diff.diff-hard   { color: #F97316; }
.card-diff.diff-expert { color: #EF4444; }

/* Grid size */
.card-grid {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: rgba(140,158,185,0.5);
}

/* Stars */
.level-stars {
  display: flex;
  gap: 2px;
}
.star-filled {
  color: #FBBF24;
  filter: drop-shadow(0 0 5px rgba(251,191,36,0.75));
}
.star-empty { color: rgba(255,255,255,0.12); }

/* ── Circular play button — bottom right ─────────────── */
.card-play {
  position: relative;
  z-index: 2;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(
    145deg,
    var(--section-accent, #6366f1),
    color-mix(in srgb, var(--section-accent, #6366f1) 55%, #000)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 4px;
  color: #fff;
  box-shadow:
    0 4px 18px color-mix(in srgb, var(--section-glow, rgba(99,102,241,0.5)) 80%, transparent),
    inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform 0.15s ease;
}

/* Sonar rings on uncompleted unlocked cards */
.level-card.unlocked:not(.completed) .card-play::before,
.level-card.unlocked:not(.completed) .card-play::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--section-accent, #6366f1) 65%, transparent);
  animation: playRing 2.2s ease-out infinite;
  pointer-events: none;
}
.level-card.unlocked:not(.completed) .card-play::after {
  inset: -11px;
  border-width: 1.5px;
  animation-delay: 0.6s;
}
@keyframes playRing {
  0%   { transform: scale(0.78); opacity: 0.75; }
  100% { transform: scale(1.55); opacity: 0;    }
}

/* Lock button for locked cards */
.card-lock-btn {
  position: relative;
  z-index: 2;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.3);
}

/* Boss play button — larger */
.card-play-boss {
  width: 52px;
  height: 52px;
  padding-left: 4px;
}

/* Active press */
.level-card:active:not(:disabled) .card-play {
  transform: scale(0.88);
}

/* Completed — muted, no rings */
.level-card.completed .card-play {
  background: rgba(255,255,255,0.09);
  box-shadow: none;
  opacity: 0.45;
}
.level-card.completed .card-play::before,
.level-card.completed .card-play::after { display: none; }

/* ── Boss card aura ─────────────────────────────────── */
.card-boss-aura {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 60%,
    var(--section-glow, rgba(99,102,241,0.45)) 0%, transparent 65%);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
  animation: bossAura 3s ease-in-out infinite;
}
@keyframes bossAura {
  0%,100% { opacity: 0.3; }
  50%      { opacity: 0.7; }
}

/* ── Shimmer — light sweep on uncompleted ────────────── */
.card-shimmer {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
.card-shimmer::after {
  content: '';
  position: absolute;
  top: -40%;
  left: -60%;
  width: 36%;
  height: 180%;
  background: linear-gradient(
    105deg,
    transparent,
    rgba(255,255,255,0.05)  44%,
    rgba(255,255,255,0.09)  50%,
    rgba(255,255,255,0.05)  56%,
    transparent
  );
  animation: shimmerPass 5.5s ease-in-out infinite;
  animation-delay: var(--anim-delay, 0s);
}
@keyframes shimmerPass {
  0%   { transform: translateX(0);    opacity: 0; }
  8%   { opacity: 1; }
  58%  { transform: translateX(500%); opacity: 1; }
  65%  { opacity: 0; }
  100% { transform: translateX(500%); opacity: 0; }
}


/* ── Scroll highlight ───────────────────────────────── */
.level-card.scroll-highlight {
  animation: scrollPop 1.5s ease forwards;
}
@keyframes scrollPop {
  0%   { box-shadow: 0 0 0 0 var(--section-glow, rgba(99,102,241,0.5)); }
  30%  { box-shadow: 0 0 32px 8px var(--section-glow, rgba(99,102,241,0.55)); transform: scale(1.05); }
  100% { box-shadow: none; transform: scale(1); }
}

/* ── Tablet ─────────────────────────────────────────── */
@media (min-width: 600px) and (max-width: 1023px) {
  .level-select { max-width: none; }
  .ls-top-bar   { padding: 14px clamp(20px,4vw,40px); }
  .ls-hero      { padding: 24px clamp(20px,4vw,40px) 20px; }
  .levels-grid  {
    grid-template-columns: repeat(3, 1fr);
    padding: 4px clamp(20px,4vw,40px) 40px;
  }
}
