/* ============================================================
   LOBBY — PNG asset-based ROOKIE level select
   ============================================================ */

/* ---------- Lobby screen stage ---------- */
#lobby-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #080312;
  overflow: hidden;
}

.lobby-root {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lobby-stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  container-type: size;
  font-family: var(--font-body);
}

.lobby-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  z-index: 0;
}

.lobby-stage img:not(.lobby-bg) {
  background: transparent;
}

.lobby-stage > *:not(.lobby-bg) {
  position: absolute;
  z-index: 1;
}

/* ---------- Lobby brand mark ---------- */
.lobby-brand {
  top: 7.2%;
  left: 50%;
  transform: translateX(-50%);
  width: 19cqi;
  pointer-events: none;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.45));
}

.lobby-brand__logo {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

/* ---------- Header ---------- */
.lobby-header {
  top: 1.5%;
  left: 1.5%;
  right: 1.5%;
  display: grid;
  grid-template-columns: 4.5cqi 1fr auto;
  align-items: center;
  gap: 1cqi;
}

.lobby-icon-btn {
  width: 4.2cqi;
  height: 4.2cqi;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  justify-self: start;
}
.lobby-icon-btn__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

.lobby-xp {
  display: flex;
  align-items: center;
  gap: 0.8cqi;
  justify-self: center;
}

.lobby-avatar {
  width: 4.5cqi;
  height: 4.5cqi;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.lobby-xp-info {
  min-width: 14cqi;
  position: relative;
}

.lobby-xp-label {
  font-size: 1.15cqi;
  font-weight: 700;
  color: #fff;
  display: block;
  line-height: 1.1;
}

.lobby-xp-track {
  height: 0.75cqi;
  border-radius: 1cqi;
  background: rgba(0,0,0,0.55);
  margin-top: 0.35cqi;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  width: 11cqi;
}

.lobby-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, #43a047, #aed581);
  border-radius: 1cqi;
}

.lobby-xp-text {
  position: absolute;
  right: 0;
  top: 0;
  font-size: 0.9cqi;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
}

.lobby-coins-wrap {
  display: flex;
  align-items: stretch;
  justify-self: end;
}

.lobby-coins {
  display: flex;
  align-items: center;
  gap: 0.5cqi;
  padding: 0.55cqi 1cqi 0.55cqi 0.7cqi;
  border-radius: 2cqi 0 0 2cqi;
  background: rgba(15, 6, 30, 0.88);
  border: 2px solid #f5c842;
  border-right: none;
  font-weight: 800;
  font-size: 1.35cqi;
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

.lobby-coin-icon {
  width: 1.8cqi;
  height: 1.8cqi;
  object-fit: contain;
  flex-shrink: 0;
}

.lobby-coins-add {
  width: 3cqi;
  border-radius: 0 0.8cqi 0.8cqi 0;
  background: linear-gradient(180deg, #7e57c2, #5e35b1);
  border: 2px solid #f5c842;
  border-left: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1.6cqi;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

/* ---------- ROOKIE title ---------- */
.lobby-tier {
  top: 27.3%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75cqi;
  padding: 0.2cqi 1cqi 0.35cqi;
  min-width: 25cqi;
  border-bottom: 1px solid rgba(231, 190, 73, 0.55);
  background: radial-gradient(ellipse at center, rgba(45, 10, 76, 0.78), rgba(15, 3, 31, 0) 72%);
}

.lobby-wing {
  width: 5.8cqi;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.45));
}
.lobby-wing--right { transform: scaleX(-1); }

.lobby-tier-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2cqi;
}

.lobby-tier-name {
  font-size: 2.1cqi;
  font-weight: 800;
  font-style: italic;
  margin: 0;
  line-height: 1;
  letter-spacing: 0.05em;
  background: linear-gradient(180deg, #ffffff 0%, #c8c8d8 55%, #9090a8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.5)) drop-shadow(0 0 12px rgba(180,140,255,0.35));
}

.lobby-tier-stars {
  display: flex;
  gap: 0.45cqi;
  align-items: center;
}

.tier-star-img {
  width: 1.1cqi;
  height: 1.1cqi;
  object-fit: contain;
  opacity: 0.35;
}
.tier-star-img--on {
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.7));
}

/* ---------- Main row ---------- */
.lobby-main {
  top: 35%;
  left: 2%;
  right: 2%;
  bottom: 17%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1cqi;
}

.lobby-sidebar {
  flex: 0 0 10.5cqi;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6cqi;
  align-self: center;
}

.free-coins-pig {
  width: 9.2cqi;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.45));
}

.free-coins-btn {
  background: linear-gradient(180deg, rgba(40, 15, 60, 0.92), rgba(20, 8, 40, 0.98));
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 0.8cqi;
  cursor: pointer;
  padding: 0.45cqi 0.7cqi;
  font-size: 0.85cqi;
  font-weight: 800;
  color: #ffd740;
  letter-spacing: 0.05em;
  box-shadow: 0 3px 10px rgba(0,0,0,0.35);
  white-space: nowrap;
}

.level-carousel {
  flex: 1;
  min-width: 0;
  height: 100%;
  position: relative;
  overflow: hidden;
  border-top: 1px solid rgba(231, 190, 73, 0.2);
  border-bottom: 1px solid rgba(231, 190, 73, 0.2);
  background: linear-gradient(90deg, rgba(10, 2, 23, 0.48), rgba(45, 12, 70, 0.18) 50%, rgba(10, 2, 23, 0.48));
  box-shadow: inset 0 1.2cqi 2cqi rgba(7, 1, 16, 0.22), inset 0 -1.2cqi 2cqi rgba(7, 1, 16, 0.22);
}

.level-carousel::before,
.level-carousel::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 6;
  width: 2.3cqi;
  pointer-events: none;
}
.level-carousel::before { left: 0; background: linear-gradient(90deg, rgba(15, 4, 31, 0.96), transparent); }
.level-carousel::after { right: 0; background: linear-gradient(-90deg, rgba(15, 4, 31, 0.96), transparent); }

.level-track {
  width: 100%;
  display: flex;
  gap: 0.9cqi;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  box-sizing: border-box;
  padding: 1cqi 2.4cqi;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: pan-y;
  cursor: grab;
  overscroll-behavior-x: contain;
}
.level-track::-webkit-scrollbar { display: none; }
.level-track:focus-visible { outline: 2px solid rgba(255, 220, 103, 0.9); outline-offset: -3px; }
.level-track.is-grabbing,
.level-track.is-grabbing * { cursor: grabbing !important; }

/* ---------- Level cards ---------- */
.level-card {
  flex: 0 0 11.5cqi;
  width: 11.5cqi;
  height: 19.5cqi;
  border: none;
  border-radius: 1.4cqi;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  position: relative;
  overflow: visible;
  font-family: var(--font-body);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  scroll-snap-align: center;
}

.level-card--unlocked {
  background: linear-gradient(165deg, #72248f 0%, #43105f 46%, #220735 100%);
  border: 0.18cqi solid #dcb94e;
  box-shadow:
    0 0 1.5cqi rgba(227, 181, 56, 0.24),
    0 0.6cqi 1.4cqi rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.25);
  color: #fff;
}

.level-card--unlocked:hover { transform: translateY(-0.3cqi); }

.level-card--featured {
  flex: 0 0 12.2cqi;
  width: 12.2cqi;
  height: 20.5cqi;
  border-width: 0.28cqi;
  border-color: #ffe07b;
  box-shadow:
    0 0 2.2cqi rgba(255, 208, 71, 0.65),
    0 0 3.5cqi rgba(161, 67, 201, 0.36),
    0 0.8cqi 1.8cqi rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.3);
  z-index: 2;
}

.level-card--locked {
  background: linear-gradient(180deg, rgba(55, 48, 72, 0.95) 0%, rgba(35, 28, 52, 0.98) 50%, rgba(22, 16, 38, 1) 100%);
  border: 0.15cqi solid rgba(255,255,255,0.18);
  box-shadow: 0 0.6cqi 1.2cqi rgba(0,0,0,0.45);
  color: rgba(255,255,255,0.88);
  cursor: not-allowed;
}

.level-card__ribbon {
  position: absolute;
  top: 0.6cqi;
  right: -0.3cqi;
  z-index: 4;
  background: linear-gradient(160deg, #bd8e21, #70500e);
  color: #fff;
  font-size: 0.58cqi;
  font-weight: 800;
  padding: 0.25cqi 0.65cqi 0.25cqi 0.5cqi;
  border-radius: 0.3cqi 0.7cqi 0.7cqi 0.3cqi;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  transform: rotate(6deg);
}
.level-card--completed .level-card__ribbon { background: linear-gradient(160deg, #3d9b72, #17573f); }

.level-card__badge {
  position: absolute;
  top: -1.1cqi;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: 2.6cqi;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.45));
}

.level-card__badge--lock.level-card__badge--l2 { filter: hue-rotate(195deg) saturate(0.85) drop-shadow(0 3px 8px rgba(0,0,0,0.45)); }
.level-card__badge--lock.level-card__badge--l3 { filter: sepia(0.45) hue-rotate(5deg) saturate(1.1) drop-shadow(0 3px 8px rgba(0,0,0,0.45)); }
.level-card__badge--lock.level-card__badge--l4 { filter: hue-rotate(255deg) saturate(1.15) drop-shadow(0 3px 8px rgba(0,0,0,0.45)); }
.level-card__badge--lock.level-card__badge--l5 { filter: hue-rotate(25deg) saturate(1.25) brightness(1.08) drop-shadow(0 3px 8px rgba(0,0,0,0.45)); }

.level-card__heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2cqi;
  padding: 1.8cqi .4cqi .25cqi;
  flex-shrink: 0;
  z-index: 2;
  color: #fff;
  text-shadow: 0 2px 5px rgba(0,0,0,.55);
}
.level-card__heading strong { font-size: 1.15cqi; line-height: 1; }
.level-card__heading span { font-size: .72cqi; font-weight: 800; color: #ffe47a; }
.level-card__facts { display: flex; justify-content: center; gap: .35cqi; z-index: 2; font-size: .62cqi; font-weight: 800; }
.level-card__facts span { padding: .22cqi .35cqi; border-radius: .3cqi; background: rgba(20,3,38,.42); white-space: nowrap; }

.level-card__stars {
  display: flex;
  gap: 0.35cqi;
  justify-content: center;
  margin-bottom: 0.35cqi;
  z-index: 2;
  flex-shrink: 0;
}

.level-card__star {
  width: 1.15cqi;
  height: 1.15cqi;
  object-fit: contain;
}

.level-card__art {
  flex: 1;
  margin: 0 0.45cqi;
  border-radius: 0.6cqi 0.6cqi 0 0;
  overflow: hidden;
  position: relative;
  min-height: 5cqi;
  z-index: 1;
  border: 1px solid rgba(245, 206, 93, 0.52);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45);
}
.level-card__environment { position: absolute; left: 0; right: 0; bottom: 0; padding: .3cqi .2cqi; background: rgba(8,2,20,.78); color: #fff5c4; font-size: .58cqi; font-weight: 800; text-align: center; }
.level-card--completed { border-color: #ffd95d; box-shadow: 0 0 2cqi rgba(255,205,56,.44), 0 .6cqi 1.4cqi rgba(0,0,0,.4); }

.level-card__art-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
  display: block;
}

.level-card--locked .level-card__art::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 18, 0.42);
  pointer-events: none;
}

.level-card__cost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35cqi;
  margin: 0 0.65cqi 0.75cqi;
  font-weight: 800;
  font-size: .82cqi;
  padding: 0.55cqi 1cqi;
  border-radius: 1.4cqi;
  flex-shrink: 0;
  z-index: 2;
}

.setup-level-details { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: -4px auto 10px; }
.setup-level-details span { padding: 5px 9px; border: 1px solid rgba(231,190,73,.48); border-radius: 5px; background: rgba(31,4,54,.56); color: #ffe587; font-size: 10px; font-weight: 800; }

.level-card__cost-coin {
  width: 1.35cqi;
  height: 1.35cqi;
  object-fit: contain;
}

.level-card--unlocked .level-card__cost,
.level-card--featured .level-card__cost {
  background: linear-gradient(180deg, #ffe082 0%, #ffb300 50%, #ff8f00 100%);
  color: #4e342e;
  border: 1px solid #ff8f00;
  box-shadow: 0 3px 10px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.35);
}

.level-card--locked .level-card__cost {
  background: linear-gradient(180deg, #4a3560 0%, #2a1848 100%);
  color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 3px 8px rgba(0,0,0,0.35);
}

/* ---------- Bottom ad CTA ---------- */
.lobby-bottom {
  bottom: 1.8%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
}

.lobby-ad-btn {
  display: flex;
  align-items: center;
  gap: 1.2cqi;
  padding: 0.9cqi 3.5cqi 0.9cqi 1.2cqi;
  border: none;
  border-radius: 1.4cqi;
  background: linear-gradient(180deg, #ffe082 0%, #ffb300 45%, #ff8f00 100%);
  color: #fff;
  cursor: pointer;
  box-shadow:
    0 0 1.8cqi rgba(255, 179, 0, 0.45),
    0 0.6cqi 1.5cqi rgba(0,0,0,0.4),
    inset 0 2px 0 rgba(255,255,255,0.35);
  min-width: 36cqi;
}
.lobby-ad-btn:active { transform: scale(0.98); }

.lobby-ad-play {
  width: 4cqi;
  height: auto;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.25));
}

.lobby-ad-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15cqi;
}

.lobby-ad-title {
  font-size: 1.85cqi;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.25);
  line-height: 1.1;
}

.lobby-ad-sub {
  font-size: 0.85cqi;
  font-weight: 700;
  letter-spacing: 0.07em;
  opacity: 0.92;
}

/* ---------- Modals ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 4, 24, 0.82);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.22s;
}
.overlay.is-open { opacity: 1; }

.coins-panel {
  position: relative;
  box-sizing: border-box;
  width: min(400px, 78vw);
  height: auto;
  max-height: 86dvh;
  padding: 26px 22px 22px;
  border-radius: 22px;
  background: linear-gradient(180deg, #6a3d9a 0%, #4a2578 50%, #3a1868 100%);
  border: 3px solid #f5c842;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

#coins-overlay .setup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 2px solid #f5c842;
  background: transparent;
  color: #f5c842;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.setup-brand {
  margin: 0 0 10px;
  padding-right: 36px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
  color: #e8c874;
  opacity: 0.92;
}

.coins-panel__title {
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.06em;
  margin: 0 0 6px;
}
.coins-panel__sub {
  text-align: center;
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  margin: 0 0 14px;
  line-height: 1.5;
}
.coins-panel__pig-img {
  display: block;
  width: 100px;
  height: auto;
  margin: 4px auto;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.35));
}
.coins-panel__amount {
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  color: #ffd740;
  margin-bottom: 10px;
}
.coins-panel__status {
  text-align: center;
  padding: 7px 16px;
  border-radius: 20px;
  background: rgba(0,0,0,0.3);
  color: rgba(255,255,255,0.55);
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 14px;
  display: inline-block;
  width: 100%;
  box-sizing: border-box;
}
.coins-panel__status.is-ready {
  background: rgba(67,160,71,0.3);
  color: #a5d6a7;
}
.coins-panel__actions { display: flex; gap: 8px; }

.btn-collect {
  flex: 1;
  padding: 13px 8px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #66bb6a, #388e3c);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-collect.is-disabled { opacity: 0.4; cursor: not-allowed; }
.btn-collect__ad { width: 22px; height: auto; object-fit: contain; }

@keyframes loadSpin { to { transform: rotate(360deg); } }
@keyframes sparkle { from { opacity: 0.45; } to { opacity: 1; } }
@keyframes floatCard {
  0%, 100% { transform: translateY(0) rotate(var(--r, 0deg)); }
  50% { transform: translateY(-10px) rotate(var(--r, 0deg)); }
}

@media (max-width: 768px) {
  .lobby-xp-text { position: static; display: block; margin-top: 0.2cqi; font-size: 0.75cqi; }
  .level-track { padding-inline: 2.4cqi; }
}

@media (max-width: 430px) {
  .lobby-ad-btn { min-width: 42cqi; padding-right: 2cqi; }
}
