/* Mobile route only. Every rule is scoped so the desktop shell remains unchanged. */
html.mobileMode {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  background: #070213;
  -webkit-text-size-adjust: 100%;
}

html.mobileMode body {
  width: 100%;
  min-width: 0;
  min-height: 100dvh;
  justify-content: flex-start;
  overflow-x: hidden;
  padding: calc(88px + env(safe-area-inset-top)) 6px calc(138px + env(safe-area-inset-bottom));
  overscroll-behavior: none;
  touch-action: manipulation;
}

html.mobileMode button,
html.mobileMode [role="button"] {
  -webkit-tap-highlight-color: transparent;
}

html.mobileMode button:focus-visible,
html.mobileMode [role="button"]:focus-visible {
  outline: 3px solid #fff3c4;
  outline-offset: 2px;
}

/* Authentication and onboarding */
html.mobileMode #loginGate {
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  overflow-y: auto;
}

html.mobileMode #lgWrap {
  width: min(100%, 430px);
  max-width: 430px;
  min-height: 100%;
  align-items: center;
}

html.mobileMode #lgMascot { display: none; }

html.mobileMode #lgPanel {
  width: 100%;
  max-height: calc(100dvh - max(28px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  margin: auto;
  padding: 18px 16px 20px;
  overflow-y: auto;
  border-radius: 18px;
}

html.mobileMode #lgLogo { width: min(68vw, 260px); }
html.mobileMode .lgBtn { min-height: 50px; }

html.mobileMode #guide { overflow: hidden; }

html.mobileMode video#guideMascot,
html.mobileMode img#guideMascot,
html.mobileMode canvas#guideMascot {
  right: 50% !important;
  bottom: calc(62px + env(safe-area-inset-bottom)) !important;
  width: min(88vw, 430px) !important;
  height: min(131vw, 640px) !important;
  max-width: 430px !important;
  max-height: min(68dvh, 640px) !important;
  transform: translateX(50%);
  object-fit: contain;
}

html.mobileMode #guideMascot.speaking,
html.mobileMode #guideMascot.idle { animation-name: none; }

html.mobileMode #guideBubble {
  left: 12px;
  right: 12px;
  top: max(12px, env(safe-area-inset-top));
  bottom: auto;
  width: auto;
  min-height: 0;
  max-height: 31dvh;
  overflow-y: auto;
  padding: 14px 16px;
  border-radius: 16px;
  font-size: clamp(14px, 4vw, 17px);
}

html.mobileMode #guideCollect {
  left: 50%;
  right: auto;
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(88vw, 390px);
  min-height: 56px;
  transform: translateX(-50%);
  padding: 14px 20px;
}

/* Lobby */
html.mobileMode #lobby {
  width: 100%;
  min-width: 0;
  height: 100dvh;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

html.mobileMode #lobbyHud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 7px 8px;
  padding: max(7px, env(safe-area-inset-top)) 8px 7px;
  flex: none;
}

html.mobileMode .lobbyHudGroup { min-width: 0; }

html.mobileMode #lobbyHudPrimary,
html.mobileMode #lobbyHudAccount,
html.mobileMode #lobbyHudActions {
  display: flex;
  align-items: center;
}

html.mobileMode #lobbyHudPrimary { grid-column: 1; grid-row: 1; gap: 6px; }
html.mobileMode #lobbyHudAccount { grid-column: 2; grid-row: 1; gap: 6px; }
html.mobileMode #lobbyHudActions {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  overflow: visible;
  padding: 2px 1px 4px;
}

html.mobileMode #lobbyHudActions::-webkit-scrollbar { display: none; }
html.mobileMode #lobbyHudAccount > div:first-child { display: none; }
html.mobileMode #lobbyAvatar { width: 38px; height: 38px; }
html.mobileMode #lobbyGift { min-width: 42px; min-height: 42px; font-size: 22px; }
html.mobileMode #lobbyHud .hudPill { min-height: 38px; padding: 6px 9px; font-size: 12px; }
html.mobileMode #lobbyHudPrimary .hudPill { min-width: 0; max-width: 42vw; overflow: hidden; }
html.mobileMode #lobbyBalance { overflow: hidden; text-overflow: ellipsis; }
html.mobileMode #lobbyHudAccount > .hudPill:not(#lobbyLvl) { display: none; }
html.mobileMode #lobbyLvl { min-width: 66px; width: 66px; }
html.mobileMode #lobbyMenu { min-width: 42px; min-height: 42px; padding: 4px; }

html.mobileMode #lobbyStoreBtn,
html.mobileMode .lobbyMetaBtn,
html.mobileMode #lobbyAdmin {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 7px 3px;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
}

html.mobileMode #lobbyStage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 10px 10px 72px;
  overflow: hidden;
}

html.mobileMode #lobbyHero {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 4px 10px;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 92px;
  margin: 0;
  padding: 9px 10px;
  border-radius: 14px;
}

html.mobileMode #lobbyHero .heroGift {
  grid-row: 1 / 3;
  width: 70px;
  max-width: 70px;
  max-height: 78px;
  object-fit: contain;
}

html.mobileMode #lobbyHero h3 {
  grid-column: 2 / 4;
  align-self: end;
  text-align: left;
  font-size: 12px;
  line-height: 1.2;
}

html.mobileMode #heroReward {
  grid-column: 2;
  width: 100%;
  margin: 0;
  padding: 5px 7px;
  border-radius: 10px;
}

html.mobileMode #heroRewardPill { padding: 4px 8px; font-size: 10px; }
html.mobileMode #heroRewardTimer { margin-top: 3px; font-size: 9px; }
html.mobileMode #lobbyHeroBtn {
  grid-column: 3;
  min-width: 74px;
  min-height: 44px;
  padding: 8px 10px;
  font-size: 11px;
  animation: none;
}

html.mobileMode #lobbyGamesWrap {
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

html.mobileMode #lobbyGames {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-columns: auto;
  gap: 10px;
  padding: 2px 2px 86px;
}

html.mobileMode #lobby .slotCard {
  width: 100%;
  min-width: 0;
  aspect-ratio: 3 / 4;
  border-width: 2px;
  border-radius: 12px;
}

html.mobileMode .slotCard:hover { transform: none; }
html.mobileMode .slotCard .slotName { padding: 16px 5px 6px; font-size: 11px; }
html.mobileMode .slotCard .jackpotRibbon { top: 6px; font-size: 8px; }

html.mobileMode #lobbyCollect {
  right: 10px;
  bottom: max(8px, env(safe-area-inset-bottom));
  transform: none;
  animation: none;
}

html.mobileMode #lobbyCollect .ico { display: none; }
html.mobileMode #lobbyCollect .btn { min-height: 44px; padding: 11px 18px; }

/* Machine gameplay */
html.mobileMode #brandLogo,
html.mobileMode #ticker,
html.mobileMode #boosterPills,
html.mobileMode #lever { display: none !important; }

html.mobileMode .topbar {
  position: fixed;
  left: 58px;
  right: 8px;
  top: max(6px, env(safe-area-inset-top));
  z-index: 11;
  height: 44px;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 5px;
  padding: 4px 7px;
  border: 1px solid #ffffff20;
  border-radius: 14px;
  background: linear-gradient(180deg, #2b1645f2, #100719f2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

html.mobileMode .topbar .pill { min-width: 0; padding: 5px 8px; font-size: 11px; }
html.mobileMode .topbar .pill:nth-of-type(3) { display: none; }
html.mobileMode .topbar #balancePill { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; }
html.mobileMode .topbar #avatarChip { display: none !important; }
html.mobileMode .topbar #xpbar { width: min(38vw, 140px); }

html.mobileMode #eventRail {
  position: fixed;
  left: 8px;
  right: 8px;
  top: calc(max(6px, env(safe-area-inset-top)) + 52px);
  z-index: 10;
  margin: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  justify-content: flex-start;
  scrollbar-width: none;
}

html.mobileMode #eventRail::-webkit-scrollbar { display: none; }
html.mobileMode #sprintPill,
html.mobileMode #eventBanner { flex: 0 0 auto; max-width: 82vw; font-size: 10px; }

html.mobileMode .machine {
  --cell: min(72px, calc((100vw - 46px) / 5), calc((100dvh - 330px) / 3));
  --cell-y: min(calc(var(--cell) * 1.55), calc((100dvh - 380px) / 3));
  width: fit-content;
  max-width: calc(100vw - 8px);
  min-width: 0;
  margin: 24px auto 0;
  padding: 7px;
  border-width: 6px;
  border-radius: 22px;
}

html.mobileMode #marqueeBox { margin-bottom: 6px; padding: 7px 8px 5px; border-radius: 10px; }
html.mobileMode #marquee { font-size: clamp(15px, 5vw, 22px); letter-spacing: 2px; }
html.mobileMode #marqueeSub { font-size: 8px; }
html.mobileMode .reels { gap: 3px; padding: 4px; border-radius: 13px; }
html.mobileMode .reel { border-radius: 5px; }
html.mobileMode .cell img { width: 110%; height: 110%; }
html.mobileMode #winLine { max-width: 92vw; min-width: 0; min-height: 28px; margin-top: 5px; padding: 4px 14px; font-size: 13px; }
html.mobileMode #fsBanner,
html.mobileMode #hwBanner { max-width: 90vw; margin-top: 5px; padding: 5px 10px; font-size: 12px; }
html.mobileMode #meterBox { max-width: 90vw; }

html.mobileMode #lobbyBack {
  left: 8px;
  top: max(6px, env(safe-area-inset-top));
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  overflow: hidden;
  color: transparent;
  font-size: 0;
}

html.mobileMode #lobbyBack::before {
  content: "🏠";
  color: #ffd86b;
  font-size: 19px;
}

html.mobileMode #dock {
  height: auto;
  min-height: 126px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 108px auto minmax(0, 1fr);
  grid-template-rows: 116px;
  align-items: center;
  gap: 4px 6px;
  padding: 5px 8px max(5px, env(safe-area-inset-bottom));
}

html.mobileMode #dockCenter {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  justify-content: flex-end;
  gap: 4px;
  position: static !important;
  left: auto !important;
  transform: none !important;
}

html.mobileMode #dockBet { min-width: 0; gap: 2px; padding: 4px; }
html.mobileMode #dockBet button { min-width: 38px; min-height: 52px; padding: 5px; font-size: 16px; }
html.mobileMode #dockBet .pill { min-width: 54px; padding: 6px; font-size: 12px; text-align: center; }
html.mobileMode #dock #spinBtn {
  grid-column: 3;
  grid-row: 1;
  position: static !important;
  left: auto !important;
  bottom: auto !important;
  width: 108px !important;
  height: 108px !important;
  margin: 0 !important;
  transform: none;
}

html.mobileMode #dockAction {
  grid-column: 4;
  grid-row: 1;
  margin: 0;
  justify-content: flex-start;
}

html.mobileMode #dock #autoBtn { min-width: 76px; min-height: 54px; padding: 8px 10px; font-size: 13px; }

html.mobileMode .lobbyQuickGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html.mobileMode .lobbyQuickGrid button { min-height: 108px; }

/* Mobile dialogs use one contained scroll area and safe-area clearance. */
html.mobileMode .modal,
html.mobileMode .mgModal,
html.mobileMode #store,
html.mobileMode #wheelModal,
html.mobileMode #pickModal,
html.mobileMode #profileHub {
  padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  overflow: hidden;
  align-items: center;
}

html.mobileMode .modal .sheet,
html.mobileMode .mgSheet,
html.mobileMode #pickSheet,
html.mobileMode #profileHub .sheetWide {
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 16px;
}

html.mobileMode .sheetClose,
html.mobileMode #storeClose,
html.mobileMode #phClose,
html.mobileMode .ga-close,
html.mobileMode .cp-close,
html.mobileMode .sp-close {
  min-width: 44px !important;
  min-height: 44px !important;
}

html.mobileMode #storeSheet {
  width: 100%;
  height: calc(100dvh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  max-height: none;
  padding: 10px;
  border-width: 5px;
  border-radius: 16px;
}

html.mobileMode #storeBody {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

html.mobileMode #storeHost {
  grid-row: 1;
  width: 100%;
  max-height: 102px;
  margin: 0;
  overflow: hidden;
}

html.mobileMode .storeTabs {
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  margin: 0;
  overflow: visible;
  padding: 0 0 4px;
}

html.mobileMode .storeTabs button {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 7px 4px;
  font-size: 10px;
  white-space: normal;
}

html.mobileMode #storeMain {
  grid-row: 3;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

html.mobileMode #storeGrid {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) !important;
  align-content: start;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 3px 4px 24px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

html.mobileMode #storeGrid > * {
  width: 100%;
  max-width: 440px;
  margin-inline: auto;
}

html.mobileMode .paymentConfirmSheet { width: 100%; max-height: calc(100dvh - 16px); }
html.mobileMode .paymentConfirmArt { min-height: min(34dvh, 270px); }
html.mobileMode .paymentConfirmCopy { padding: 20px 16px 24px; }

html.mobileMode .cp-sheet,
html.mobileMode .gross-album,
html.mobileMode .sloto-pass-sheet {
  width: 100% !important;
  max-width: 100% !important;
  height: calc(100dvh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom))) !important;
  max-height: none !important;
  border-radius: 16px !important;
}

html.mobileMode .cp-head { height: 88px; padding: 14px 58px 10px 14px; }
html.mobileMode .cp-title h2 { font-size: 30px; }
html.mobileMode .cp-body { height: calc(100% - 88px); grid-template-columns: 1fr; padding: 8px 7px 84px; }
html.mobileMode .cp-board { min-height: 44dvh; }
html.mobileMode .cp-list { max-height: none; min-height: 160px; }
html.mobileMode .cp-actions { bottom: 8px; width: calc(100% - 20px); max-width: none; }

html.mobileMode .ga-head { height: 84px; padding: 12px 56px 9px 12px; }
html.mobileMode .ga-brand { min-width: 0; }
html.mobileMode .ga-brand h2 { font-size: 27px; }
html.mobileMode .ga-book { height: calc(100% - 84px); grid-template-columns: 34px minmax(0, 1fr) 34px; padding: 7px 4px 76px; }
html.mobileMode .ga-page { padding: 10px 6px 72px; }
html.mobileMode .ga-grid { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; gap: 4px; }
html.mobileMode .ga-actions { bottom: 10px; width: calc(100% - 22px); overflow-x: auto; justify-content: flex-start; }

html.mobileMode #bigwin .title { max-width: 94vw; text-align: center; font-size: clamp(40px, 15vw, 64px); }
html.mobileMode #bigwin .amount { font-size: clamp(28px, 10vw, 44px); }
html.mobileMode .toast { top: max(10px, env(safe-area-inset-top)); max-width: calc(100vw - 24px); text-align: center; }

@media (max-width: 359px) {
  html.mobileMode body { padding-left: 3px; padding-right: 3px; }
  html.mobileMode #lobbyHero { grid-template-columns: 58px minmax(0, 1fr) auto; }
  html.mobileMode #lobbyHero .heroGift { width: 56px; }
  html.mobileMode #lobbyHero h3 { font-size: 10px; }
  html.mobileMode #lobbyHeroBtn { min-width: 62px; padding: 6px; }
  html.mobileMode .machine { --cell: min(55px, calc((100vw - 42px) / 5), calc((100dvh - 320px) / 3)); }
  html.mobileMode #dock { grid-template-columns: minmax(0, 1fr) auto 96px auto minmax(0, 1fr); }
  html.mobileMode #dock #spinBtn { width: 96px !important; height: 96px !important; }
  html.mobileMode #dockBet { padding: 3px; }
  html.mobileMode #dockBet button { min-width: 34px; min-height: 48px; padding: 3px; }
  html.mobileMode #dockBet .pill { min-width: 48px; padding: 5px 3px; font-size: 11px; }
  html.mobileMode #dock #autoBtn { min-width: 66px; padding: 7px; font-size: 12px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  html.mobileMode body {
    padding: calc(46px + env(safe-area-inset-top)) 6px calc(98px + env(safe-area-inset-bottom));
  }

  html.mobileMode .topbar {
    left: max(58px, env(safe-area-inset-left));
    right: auto;
    width: max-content;
    max-width: min(35vw, 300px);
    height: 38px;
  }

  html.mobileMode .topbar #xpPill { display: none; }

  html.mobileMode #eventRail { display: none; }
  html.mobileMode #lobbyBack { top: max(6px, env(safe-area-inset-top)); }

  html.mobileMode .machine {
    --cell: min(170px, calc((100vw - 42px) / 5));
    --cell-y: min(100px, calc((100dvh - 204px) / 3));
    width: fit-content;
    max-width: calc(100vw - 12px);
    margin-top: 12px;
    margin-bottom: 18px;
    padding: 5px;
    border-width: 5px;
  }

  html.mobileMode #marqueeBox { display: none; }
  html.mobileMode #winLine,
  html.mobileMode #fsBanner,
  html.mobileMode #hwBanner { font-size: 10px; min-height: 22px; padding: 2px 8px; margin-top: 2px; }

  html.mobileMode #dock {
    min-height: 96px;
    grid-template-columns: minmax(0, 1fr) auto 88px 82px minmax(0, 1fr);
    grid-template-rows: 90px;
    column-gap: 8px;
    padding-bottom: max(2px, env(safe-area-inset-bottom));
  }

  html.mobileMode #dockCenter { grid-column: 2; }
  html.mobileMode #dock #spinBtn { grid-column: 3; width: 88px !important; height: 88px !important; }
  html.mobileMode #dockBet button { min-width: 40px; min-height: 40px; }
  html.mobileMode #dockAction { grid-column: 4; margin: 0; justify-content: flex-start; }
  html.mobileMode #dock #autoBtn { min-width: 72px; min-height: 40px; padding: 7px 12px; font-size: 12px; }
  html.mobileMode #lobbyHud {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto;
    padding-top: max(4px, env(safe-area-inset-top));
  }

  html.mobileMode #lobbyHudPrimary { grid-column: 1; grid-row: 1; }
  html.mobileMode #lobbyHudActions { grid-column: 2; grid-row: 1; padding: 0; }
  html.mobileMode #lobbyHudAccount { grid-column: 3; grid-row: 1; }
  html.mobileMode #lobbyStage { flex-direction: row; padding: 7px 8px 50px; }
  html.mobileMode #lobbyHero { width: 176px; min-width: 176px; display: flex; flex-direction: column; min-height: 0; }
  html.mobileMode #lobbyHero .heroGift { width: 58px; }
  html.mobileMode #lobbyHero h3 { text-align: center; font-size: 9px; }
  html.mobileMode #heroReward { display: none; }
  html.mobileMode #lobbyHeroBtn { width: 100%; min-height: 40px; }
  html.mobileMode #lobbyGames { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-bottom: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  html.mobileMode *,
  html.mobileMode *::before,
  html.mobileMode *::after {
    scroll-behavior: auto !important;
  }
}
