/* ==========================================================================
   Backgammon Lobby — premium reference layout
   ========================================================================== */

.language-picker { display:flex; align-items:center; gap:.35rem; margin-inline:.35rem; color:#fff; font: .75rem Tahoma,sans-serif; }
.language-picker select { max-width:6.5rem; padding:.3rem; border-radius:7px; }

:root {
  --lobby-gold: #e8c547;
  --lobby-gold-bright: #ffe566;
  --lobby-gold-dark: #8b6914;
  --lobby-gold-mid: #c9a227;
  --lobby-gold-light: #fff3b0;
  --lobby-green: #3dcc5a;
  --lobby-text: #f4f0e6;
  --lobby-muted: #9aa3b8;
  --lobby-bar-top: linear-gradient(
    180deg,
    #4a5168 0%,
    #323848 12%,
    #252a36 45%,
    #1a1e28 78%,
    #12151c 100%
  );
  --lobby-bar-bottom: linear-gradient(
    0deg,
    #4a5168 0%,
    #323848 10%,
    #252a36 40%,
    #1a1e28 75%,
    #12151c 100%
  );
  --lobby-bar-gloss: inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35);
  --lobby-bar-border: linear-gradient(
    90deg,
    transparent 0%,
    rgba(212, 175, 55, 0.35) 15%,
    rgba(245, 230, 168, 0.95) 50%,
    rgba(212, 175, 55, 0.35) 85%,
    transparent 100%
  );
  --font: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
  /* Desktop caps preserved; scale down on short/narrow via vmin */
  --topbar-h: clamp(52px, 10vmin, 88px);
  --bottombar-h: clamp(64px, 13vmin, 112px);
  --rooms-per-page: 3;
  --lobby-avatar: clamp(36px, 7.5vmin, 64px);
  --lobby-icon: clamp(34px, 6.5vmin, 52px);
  --lobby-case-h: min(95vmin, 92vh, 1200px);
  --lobby-case-w: min(75vmin, 58vw, 980px);
  --lobby-pedestal-h: clamp(48px, 12vmin, 180px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

.lobby-body {
  font-family: var(--font);
  color: var(--lobby-text);
  background: #0a1628;
}

.lobby-app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

/* ---- Top bar ---- */
.lobby-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 1rem 1.25rem;
  padding: 0 1.25rem;
  padding-top: env(safe-area-inset-top, 0);
  background: var(--lobby-bar-top);
  box-shadow: var(--lobby-bar-gloss), 0 6px 20px rgba(0, 0, 0, 0.55);
  z-index: 30;
  min-height: var(--topbar-h);
  max-height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  position: relative;
  overflow: hidden;
}

.lobby-topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--lobby-bar-border);
  pointer-events: none;
}

.lobby-topbar__profile {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.lobby-avatar-wrap {
  flex-shrink: 0;
}

.lobby-avatar {
  width: var(--lobby-avatar);
  height: var(--lobby-avatar);
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--lobby-gold);
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.45),
    0 0 18px rgba(232, 197, 71, 0.45),
    inset 0 2px 6px rgba(255, 255, 255, 0.2);
}

.lobby-xp-block {
  flex: 1;
  min-width: 0;
  max-width: 420px;
}

.lobby-level-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.lobby-level-badge {
  flex-shrink: 0;
  min-width: 36px;
  height: 32px;
  padding: 0 6px;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 32px;
  text-align: center;
  color: #1a1200;
  background: linear-gradient(180deg, #fff0a0 0%, #e8c547 45%, #a67c00 100%);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  box-shadow:
    0 2px 0 #5c4200,
    0 0 12px rgba(232, 197, 71, 0.5);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.lobby-xp-bar {
  flex: 1;
  height: 22px;
  border-radius: 11px;
  background: linear-gradient(180deg, #0a0c10 0%, #1a1e28 100%);
  border: 2px solid var(--lobby-gold-mid);
  overflow: hidden;
  box-shadow:
    inset 0 3px 6px rgba(0, 0, 0, 0.65),
    0 1px 0 rgba(255, 255, 255, 0.08);
}

.lobby-xp-bar__fill {
  height: 100%;
  background: linear-gradient(180deg, #fff8c8 0%, #e8c547 35%, #a67c00 100%);
  border-radius: 8px;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.2);
  transition: width 0.4s ease;
}

.lobby-xp-text {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--lobby-gold-light);
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.lobby-guest-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0.35rem 0.9rem;
  border: 1px solid rgba(232, 197, 71, 0.7);
  border-radius: 999px;
  color: var(--lobby-gold-light);
  background: rgba(10, 14, 24, 0.78);
  font-weight: 800;
}

.lobby-topbar__economy {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.lobby-topbar__coins {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem 0.4rem 0.65rem;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.55) 100%);
  border-radius: 999px;
  border: 2px solid rgba(232, 197, 71, 0.55);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}

.lobby-coin-stack {
  position: relative;
  width: 44px;
  height: 32px;
  flex-shrink: 0;
}

.lobby-coin-icon {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #fffce0, #ffe566 40%, #c9a227 72%, #7a5a10 100%);
  border: 2px solid #fff8d0;
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.45),
    inset 0 -3px 5px rgba(0, 0, 0, 0.25);
  left: 0;
  top: 0;
}

.lobby-coin-icon--back {
  left: 10px;
  top: 2px;
  opacity: 0.85;
  z-index: -1;
  filter: brightness(0.92);
}

.lobby-coin-icon::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid rgba(74, 56, 0, 0.35);
}

.lobby-coins-value {
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--lobby-gold-light);
  letter-spacing: 0.03em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.65);
}

.lobby-btn-buy {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.35rem;
  line-height: 1;
  color: #1a1200;
  cursor: pointer;
  background: linear-gradient(180deg, #7dff96 0%, #2db84a 50%, #1a8a32 100%);
  border: 2px solid #b8ffc8;
  box-shadow:
    0 0 16px rgba(61, 204, 90, 0.5),
    0 3px 0 #145a22,
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.lobby-btn-buy:hover {
  filter: brightness(1.08);
  transform: scale(1.06);
}

.lobby-topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.lobby-auth-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0.4rem 0.85rem;
  border: 1px solid rgba(232, 197, 71, 0.75);
  border-radius: 999px;
  color: var(--lobby-gold-light);
  background: rgba(20, 24, 34, 0.92);
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.lobby-auth-link--register {
  color: #1a1200;
  background: linear-gradient(180deg, #fff8c8 0%, #e8c547 55%, #a67c00 100%);
}

.lobby-auth-link:hover {
  filter: brightness(1.08);
}

.lobby-icon-btn {
  width: var(--lobby-icon);
  height: var(--lobby-icon);
  border-radius: 50%;
  border: 2px solid rgba(232, 197, 71, 0.65);
  background: linear-gradient(180deg, #454c5e 0%, #2e3442 45%, #1e222c 100%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  text-decoration: none;
  box-shadow:
    var(--lobby-bar-gloss),
    0 4px 10px rgba(0, 0, 0, 0.5);
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}

.lobby-logout-form {
  margin: 0;
}

.lobby-logout-form .lobby-icon-btn {
  appearance: none;
  font: inherit;
}

.lobby-icon-btn:hover {
  border-color: var(--lobby-gold-bright);
  transform: translateY(-2px);
  box-shadow:
    var(--lobby-bar-gloss),
    0 6px 16px rgba(0, 0, 0, 0.55),
    0 0 14px rgba(232, 197, 71, 0.25);
}

.lobby-icon {
  width: 50%;
  height: 50%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.lobby-icon--vault {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f5e6a8'%3E%3Cpath d='M4 8v12h16V8H4zm2 2h12v8H6v-8zm2-6h8l1 4H7l1-4z'/%3E%3C/svg%3E");
}

.lobby-icon--dice {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f5e6a8'%3E%3Crect x='3' y='3' width='8' height='8' rx='1.5'/%3E%3Crect x='13' y='13' width='8' height='8' rx='1.5'/%3E%3Ccircle cx='7' cy='7' r='1.2' fill='%23141'/%3E%3Ccircle cx='17' cy='17' r='1.2' fill='%23141'/%3E%3C/svg%3E");
}

.lobby-icon--vs {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f5e6a8'%3E%3Ctext x='3' y='17' font-size='11' font-weight='bold' font-family='sans-serif'%3EVS%3C/text%3E%3C/svg%3E");
}

.lobby-icon--friends {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f5e6a8'%3E%3Ccircle cx='9' cy='8' r='3'/%3E%3Cpath d='M2 20c0-3.3 3.1-5 7-5s7 1.7 7 5v1H2v-1z'/%3E%3Cpath d='M17 10h5v2h-5zM19 8v6' stroke='%23f5e6a8' stroke-width='2'/%3E%3C/svg%3E");
}

.lobby-icon--settings {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f5e6a8'%3E%3Cpath d='M12 15.5A3.5 3.5 0 1112 8.5a3.5 3.5 0 010 7zm8.94-2.06a1.3 1.3 0 00.26-1.43l-1.12-1.94a1.3 1.3 0 00-1.2-.65h-.14a7.05 7.05 0 00-.6-.35l-.2-2.12a1.3 1.3 0 00-1.28-1.18h-2.24a1.3 1.3 0 00-1.28 1.18l-.2 2.12c-.2.12-.4.23-.6.35h-.14a1.3 1.3 0 00-1.2.65L4.8 11.01a1.3 1.3 0 00.26 1.43l1.12 1.94c.2.35.2.78 0 1.13l-1.12 1.94a1.3 1.3 0 00-.26 1.43l1.12 1.94c.35.6 1.05.85 1.68.6l.14-.06c.2.12.4.23.6.35l.2 2.12c.1.65.65 1.18 1.28 1.18h2.24c.63 0 1.18-.53 1.28-1.18l.2-2.12c.2-.12.4-.23.6-.35h.14c.63.25 1.33 0 1.68-.6l1.12-1.94a1.3 1.3 0 00-.26-1.43l-1.12-1.94a1.3 1.3 0 010-1.13l1.12-1.94z'/%3E%3C/svg%3E");
}

.lobby-icon--logout {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f5e6a8'%3E%3Cpath d='M10 3H5v18h5v-2H7V5h3V3zm10 9l-4-4v3H9v2h7v3l4-4z'/%3E%3C/svg%3E");
}

/* ---- Main scene ---- */
.lobby-main {
  position: relative;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

.lobby-scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("../img/backcover.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}

/* Side promos */
.lobby-side {
  position: absolute;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lobby-side--left {
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
}

.lobby-promo {
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  position: relative;
  transition: transform 0.15s ease;
}

.lobby-promo:hover {
  transform: scale(1.05);
}

.lobby-promo--portal {
  width: 96px;
  padding: 0.55rem 0.4rem 0.65rem;
  border-radius: 14px;
  background: linear-gradient(180deg, #5a48a8 0%, #3a2e70 55%, #2a2050 100%);
  border: 2px solid #b89aff;
  color: #f0e8ff;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.lobby-promo__portal-icon {
  display: block;
  width: 52px;
  height: 52px;
  margin: 0.15rem auto 0.35rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 35%, #e8d4ff, #9b7aff 55%, #5a3a9a 100%);
  box-shadow:
    0 0 20px rgba(155, 122, 255, 0.65),
    inset 0 -4px 8px rgba(0, 0, 0, 0.35);
}

.lobby-promo__portal-icon::after {
  content: "⚒";
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 1.4rem;
}

.lobby-promo__badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff6b6b, #c62828);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 22px;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.lobby-promo__timer {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.lobby-promo__label {
  font-size: 0.7rem;
  font-weight: 800;
}

.lobby-ribbon {
  position: absolute;
  top: 0.65rem;
  right: 1rem;
  z-index: 9;
  padding: 0.45rem 1rem 0.45rem 0.85rem;
  border: none;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: #1a1200;
  cursor: pointer;
  background: linear-gradient(180deg, #fff8c8 0%, #ffe566 40%, #e8c547 100%);
  box-shadow:
    2px 4px 10px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  clip-path: polygon(0 0, 100% 0, 96% 50%, 100% 100%, 0 100%, 3% 50%);
}

/* ---- Carousel (3 cities per page) ---- */
.lobby-carousel-wrap {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: stretch;
  padding: 0 4.5rem;
  box-sizing: border-box;
  pointer-events: none;
}

.lobby-carousel-wrap > * {
  pointer-events: auto;
}

.lobby-carousel {
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  direction: ltr;
  touch-action: pan-x;
  -ms-overflow-style: none;
  scrollbar-width: none;
  padding: 0.5rem 0 1.25rem;
}

.lobby-carousel::-webkit-scrollbar {
  display: none;
}

.lobby-carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 12;
  width: 56px;
  height: 88px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: linear-gradient(
    90deg,
    rgba(30, 35, 45, 0.15),
    rgba(20, 24, 32, 0.55) 40%,
    rgba(20, 24, 32, 0.55) 60%,
    rgba(30, 35, 45, 0.15)
  );
  backdrop-filter: blur(2px);
  transition: background 0.15s, opacity 0.15s;
}

.lobby-carousel-nav:hover:not(:disabled) {
  background: linear-gradient(
    90deg,
    rgba(30, 35, 45, 0.25),
    rgba(20, 24, 32, 0.72) 40%,
    rgba(20, 24, 32, 0.72) 60%,
    rgba(30, 35, 45, 0.25)
  );
}

.lobby-carousel-nav:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.lobby-carousel-nav span {
  display: block;
  width: 18px;
  height: 18px;
  margin: auto;
  border-top: 5px solid rgba(255, 255, 255, 0.75);
  border-right: 5px solid rgba(255, 255, 255, 0.75);
}

.lobby-carousel-nav--prev {
  right: 0.25rem;
}

.lobby-carousel-nav--prev span {
  transform: rotate(-135deg);
  margin-right: 8px;
}

.lobby-carousel-nav--next {
  left: 0.25rem;
}

.lobby-carousel-nav--next span {
  transform: rotate(45deg);
  margin-left: 8px;
}

/* Room card — large, 3 per viewport */
.lobby-room {
  flex: 0 0 calc(100% / var(--rooms-per-page));
  width: calc(100% / var(--rooms-per-page));
  max-width: calc(100% / var(--rooms-per-page));
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  padding: 0 0.75rem 0.25rem;
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  color: inherit;
  transition: transform 0.22s ease, filter 0.22s ease;
}

.lobby-room:hover:not(.lobby-room--disabled) {
  transform: translateY(-10px);
  filter: brightness(1.06);
}

.lobby-room--disabled {
  cursor: not-allowed;
  opacity: 0.5;
  filter: grayscale(0.45) brightness(0.85);
}

.lobby-room__label {
  text-align: center;
  margin: 0 0 0.2rem;
  z-index: 2;
  flex-shrink: 0;
  pointer-events: none;
}

.lobby-room__name {
  display: block;
  font-size: clamp(1.1rem, 2.2vw, 1.65rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.8),
    0 0 24px rgba(232, 197, 71, 0.45);
}

.lobby-room__bet {
  display: block;
  font-size: clamp(0.75rem, 1.4vw, 0.95rem);
  font-weight: 700;
  color: var(--lobby-gold-light);
  margin-top: 0.15rem;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
}

.lobby-room__case {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: min(var(--lobby-case-w), 94%);
  height: var(--lobby-case-h);
  max-height: calc(100% - var(--lobby-pedestal-h) - 0.5rem);
  margin-bottom: 0.15rem;
  transform: perspective(720px) rotateX(9deg);
  filter: drop-shadow(0 28px 32px rgba(0, 0, 0, 0.65));
  transition: filter 0.25s ease, transform 0.25s ease;
}

.lobby-room:hover:not(.lobby-room--disabled) .lobby-room__case {
  transform: perspective(720px) rotateX(7deg) translateY(-6px) scale(1.03);
  filter: drop-shadow(0 36px 42px rgba(0, 0, 0, 0.7))
    drop-shadow(0 0 28px rgba(232, 197, 71, 0.28));
}

.lobby-room__board-art {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100% - 3.25rem);
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  image-rendering: auto;
  flex-shrink: 1;
  min-height: 0;
}

/* The Shiraz 3D render is a portrait canvas; normalize its visible case to the
   landscape city thumbnails while keeping its base aligned with the pedestal. */
.lobby-room--shiraz .lobby-room__board-art {
  transform: scale(0.84);
  transform-origin: center bottom;
}

.lobby-room__shine {
  display: none;
}

.lobby-room__pedestal {
  position: relative;
  width: min(78vmin, 94%, 980px);
  height: var(--lobby-pedestal-h);
  margin-top: -6px;
  flex-shrink: 0;
}

.lobby-room__pedestal::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 35%;
  transform: translateX(-50%);
  width: 85%;
  height: 55%;
  max-height: 28px;
  border-radius: 50%;
  background: radial-gradient(
    ellipse,
    rgba(120, 210, 255, 0.85) 0%,
    rgba(60, 150, 230, 0.45) 45%,
    transparent 72%
  );
  filter: blur(6px);
  animation: pedestal-glow 2.5s ease-in-out infinite;
}

@keyframes pedestal-glow {
  0%,
  100% {
    opacity: 0.75;
    transform: translateX(-50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.06);
  }
}

.lobby-room__pedestal::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 72%;
  height: 40%;
  max-height: 22px;
  min-height: 8px;
  border-radius: 50%;
  background: linear-gradient(180deg, #5a6275 0%, #3a4050 40%, #252a36 100%);
  border: 2px solid rgba(200, 210, 230, 0.55);
  box-shadow:
    0 10px 20px rgba(0, 0, 0, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

/* ---- Bottom bar (segmented) ---- */
.lobby-bottombar {
  display: grid;
  grid-template-columns: 1fr 1fr 1.35fr 1fr 1fr;
  align-items: stretch;
  background: var(--lobby-bar-bottom);
  box-shadow: var(--lobby-bar-gloss), 0 -6px 24px rgba(0, 0, 0, 0.5);
  z-index: 30;
  min-height: var(--bottombar-h);
  max-height: calc(var(--bottombar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0);
  border-radius: 22px 22px 0 0;
  position: relative;
  overflow: hidden;
}

.lobby-bottombar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--lobby-bar-border);
  pointer-events: none;
}

.lobby-bottombar__segment {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.5rem;
}

.lobby-bottombar__segment:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 1px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(232, 197, 71, 0.35) 20%,
    rgba(232, 197, 71, 0.55) 50%,
    rgba(232, 197, 71, 0.35) 80%,
    transparent
  );
}

.lobby-bottombar__segment--center {
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem 0.65rem;
}

.lobby-bottom-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--lobby-muted);
  font-family: inherit;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  position: relative;
  transition: color 0.15s, transform 0.12s;
}

.lobby-bottom-item:hover {
  color: var(--lobby-gold-light);
  transform: translateY(-2px);
}

.lobby-bottom-item__icon {
  width: var(--lobby-icon);
  height: var(--lobby-icon);
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #454c5e 0%, #2a3040 100%);
  border: 1px solid rgba(232, 197, 71, 0.3);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 4px 10px rgba(0, 0, 0, 0.4);
}

.lobby-bottom-item__icon--cards {
  background:
    linear-gradient(180deg, #454c5e, #2a3040),
    linear-gradient(135deg, transparent 42%, #e53935 42%, #e53935 58%, transparent 58%);
}

.lobby-bottom-item__icon--dice {
  background:
    radial-gradient(circle at 32% 38%, #f5e6a8 9px, transparent 9px),
    radial-gradient(circle at 62% 58%, #f5e6a8 9px, transparent 9px),
    linear-gradient(180deg, #454c5e, #2a3040);
}

.lobby-bottom-item__icon--challenge {
  background: linear-gradient(180deg, #6a5a40 0%, #3a3228 100%);
  box-shadow: inset 0 -10px 0 rgba(232, 197, 71, 0.15);
}

.lobby-bottom-item__icon--quests {
  background: linear-gradient(180deg, #5a4530 0%, #322418 100%);
}

.lobby-bottom-item__label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lobby-bottom-item--stacked {
  flex-direction: column;
  gap: 0.25rem;
}

.lobby-bottom-item__text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.lobby-bottom-item__meta {
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--lobby-gold);
}

.lobby-bottom-item--quests .lobby-bottom-item__label {
  margin-inline-start: 0.25rem;
}

.lobby-bottom-item__notify {
  position: absolute;
  top: 0.1rem;
  left: calc(50% + 12px);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff6b6b, #c62828);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.lobby-event-bars {
  display: flex;
  gap: 5px;
  justify-content: center;
  align-items: center;
}

.lobby-event-bars span {
  width: 28px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.2);
  transition: background 0.2s, box-shadow 0.2s;
}

.lobby-event-bars span.is-active {
  background: linear-gradient(180deg, #fff8c8, #e8c547);
  box-shadow: 0 0 8px rgba(232, 197, 71, 0.65);
}

.lobby-main-timer {
  width: 100%;
  max-width: 220px;
  padding: 0.45rem 1rem;
  border-radius: 12px;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-align: center;
  color: var(--lobby-gold-light);
  background: linear-gradient(180deg, #2e3442 0%, #1a1e28 100%);
  border: 3px solid var(--lobby-gold-mid);
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.55),
    0 0 16px rgba(232, 197, 71, 0.2);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* ---- Waiting overlay ---- */
.lobby-waiting {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 10, 20, 0.82);
  backdrop-filter: blur(6px);
}

.lobby-waiting[hidden] {
  display: none;
}

.lobby-waiting__panel {
  text-align: center;
  padding: 2.5rem 2rem;
  min-width: min(360px, 90vw);
  border-radius: 20px;
  background: linear-gradient(165deg, #2a3048, #141820);
  border: 2px solid rgba(232, 197, 71, 0.45);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}
.lobby-waiting__panel--found { min-width: min(520px, 94vw); border-color: #e8c547; background: linear-gradient(160deg, #4e6598, #1b2539 80%); }
.lobby-match-intro { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: clamp(0.45rem, 3vw, 1.25rem); margin: 1.25rem 0; }
.lobby-match-intro__player { min-width: 0; display: grid; justify-items: center; gap: 0.25rem; }
.lobby-match-intro__player img { width: clamp(4rem, 18vw, 7rem); height: clamp(4rem, 18vw, 7rem); border: 3px solid #e8c547; border-radius: 50%; object-fit: cover; box-shadow: 0 0 1rem #e8c54780; }
.lobby-match-intro__player strong { max-width: 100%; overflow: hidden; color: #fff; font-size: clamp(0.85rem, 3vw, 1.2rem); text-overflow: ellipsis; white-space: nowrap; }
.lobby-match-intro__player span { color: #ffe681; font-weight: 800; }
.lobby-match-intro__vs { color: #ffe681; font-weight: 900; font-size: clamp(0.75rem, 3vw, 1.1rem); }

.lobby-waiting__spinner {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  border: 4px solid rgba(232, 197, 71, 0.2);
  border-top-color: var(--lobby-gold);
  animation: spin 0.9s linear infinite;
}

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

.lobby-waiting__title {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 800;
}

.lobby-waiting__room {
  color: var(--lobby-muted);
  margin: 0 0 0.75rem;
}

.lobby-waiting__timer {
  font-size: 1rem;
  margin: 0 0 1.25rem;
}

.lobby-waiting__timer span {
  color: var(--lobby-gold);
  font-weight: 800;
  font-size: 1.25rem;
}

.lobby-waiting__practice {
  margin-bottom: 0.65rem;
  padding: 0.55rem 1.5rem;
  border: 2px solid rgba(61, 204, 90, 0.55);
  border-radius: 10px;
  background: rgba(61, 204, 90, 0.15);
  color: #9dffae;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.lobby-waiting__practice:hover {
  background: rgba(61, 204, 90, 0.28);
}

.lobby-waiting__cancel {
  padding: 0.6rem 1.75rem;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.lobby-waiting__cancel:hover {
  border-color: var(--lobby-gold);
  background: rgba(232, 197, 71, 0.12);
}

/* ---- Toast ---- */
.lobby-toast-container {
  position: fixed;
  bottom: calc(var(--bottombar-h) + 1rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: min(420px, 92vw);
}

.lobby-toast {
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  color: #fff;
  background: linear-gradient(180deg, #3a4058, #1e2430);
  border: 1px solid rgba(232, 197, 71, 0.45);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.35s ease;
}

.lobby-toast--error {
  border-color: rgba(229, 57, 53, 0.6);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .lobby-side--left {
    display: none;
  }

  :root {
    --lobby-case-w: min(68vmin, 56vw, 720px);
    --lobby-case-h: min(90vmin, 88vh, 1080px);
  }
}

/* Portrait / narrow: allow topbar actions to wrap */
@media (max-width: 900px) and (orientation: portrait) {
  :root {
    --topbar-h: clamp(72px, 14vmin, 100px);
    --bottombar-h: clamp(88px, 16vmin, 112px);
  }

  .lobby-topbar {
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
  }

  .lobby-topbar__actions {
    grid-column: 1 / -1;
    justify-content: center;
    flex-wrap: wrap;
  }

  .lobby-carousel-wrap {
    padding: 0 3rem;
  }

  .lobby-room__name {
    letter-spacing: 0.08em;
  }
}

/* Landscape phone / PWA (short height): keep desktop-like single-row chrome */
@media (max-height: 520px), (max-width: 960px) and (orientation: landscape) {
  :root {
    --topbar-h: clamp(40px, 12vh, 56px);
    --bottombar-h: clamp(48px, 16vh, 68px);
    --lobby-avatar: clamp(28px, 9vh, 44px);
    --lobby-icon: clamp(28px, 9vh, 40px);
    --lobby-case-w: min(50vh, 48vw, 560px);
    --lobby-case-h: min(78vh, 88vmin, 620px);
    --lobby-pedestal-h: clamp(28px, 9vh, 64px);
    --rooms-per-page: 3;
  }

  .lobby-topbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.35rem 0.6rem;
    padding: env(safe-area-inset-top, 0px) 0.65rem 0;
    min-height: var(--topbar-h);
  }

  .lobby-topbar__actions {
    grid-column: auto;
    flex-wrap: nowrap;
    gap: 0.3rem;
  }

  .lobby-topbar__profile {
    gap: 0.4rem;
  }

  .lobby-level-badge {
    min-width: 28px;
    height: 24px;
    line-height: 24px;
    font-size: 0.7rem;
  }

  .lobby-xp-bar {
    height: 14px;
    border-radius: 7px;
  }

  .lobby-xp-text {
    font-size: 0.62rem;
    margin-top: 0.1rem;
  }

  .lobby-guest-badge,
  .lobby-auth-link {
    min-height: 28px;
    padding: 0.2rem 0.55rem;
    font-size: 0.65rem;
  }

  .lobby-topbar__coins {
    padding: 0.2rem 0.55rem 0.2rem 0.4rem;
  }

  .lobby-coin-stack {
    width: 28px;
    height: 22px;
  }

  .lobby-coin-icon {
    width: 22px;
    height: 22px;
  }

  .lobby-coins-value {
    font-size: 0.85rem;
  }

  .lobby-carousel-wrap {
    padding: 0 2.25rem;
  }

  .lobby-carousel-nav {
    width: 40px;
    height: 56px;
  }

  .lobby-room {
    padding: 0 0.35rem 0.1rem;
    justify-content: center;
  }

  .lobby-room__label {
    margin-bottom: 0.15rem;
  }

  .lobby-room__name {
    font-size: clamp(0.7rem, 2.4vh, 1rem);
    letter-spacing: 0.06em;
  }

  .lobby-room__bet {
    font-size: clamp(0.6rem, 2vh, 0.85rem);
  }

  .lobby-room:hover:not(.lobby-room--disabled) {
    transform: translateY(-4px);
  }

  .lobby-bottombar {
    grid-template-columns: 1fr 1fr 1.35fr 1fr 1fr;
    grid-template-rows: none;
    min-height: var(--bottombar-h);
    border-radius: 14px 14px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .lobby-bottombar__segment--center {
    grid-column: auto;
    order: 0;
  }

  .lobby-bottom-item__label {
    font-size: 0.55rem;
  }

  .lobby-main-timer {
    max-width: 160px;
    padding: 0.2rem 0.55rem;
    font-size: clamp(0.8rem, 3.2vh, 1.05rem);
  }

  .lobby-event-bars span {
    width: 18px;
    height: 3px;
  }

  .lobby-ribbon {
    font-size: 0.6rem;
    padding: 0.25rem 0.5rem;
  }
}

@media (max-width: 700px) and (orientation: portrait) {
  :root {
    --rooms-per-page: 1;
  }

  .lobby-bottombar {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .lobby-bottombar__segment--center {
    grid-column: 1 / -1;
    order: -1;
  }

  .lobby-bottom-item__label {
    display: none;
  }

  .lobby-ribbon {
    font-size: 0.65rem;
    padding: 0.35rem 0.65rem;
  }
}
