:root{--spinpop-safe-bottom:env(safe-area-inset-bottom,0px);}
/* Shared tablet presentation. Phone rules and the gameplay coordinate system stay unchanged. */
@media (min-width:600px) and (min-height:600px){
  html body #ui{
    top:calc(8px + env(safe-area-inset-top,0px)) !important;
    width:min(86vw,800px) !important;
  }
  html body #ui #top{gap:10px !important;}
  html body #ui #top .panel{padding:6px 10px !important;border-radius:9px !important;}
  html body #ui #top .panel .label{font-size:12px !important;line-height:1 !important;}
  html body #ui #top .panel .value{margin-top:3px !important;font-size:22px !important;line-height:1 !important;}
  html body #ui #feverWrap{margin-top:6px !important;padding:5px 12px !important;gap:12px !important;}
  html body #ui #feverLabel{font-size:12px !important;line-height:1 !important;}
  html body #ui #feverBg{height:12px !important;}
  html body #ui #quickRetryBtn{width:44px;height:44px;right:3px;top:2px;font-size:26px;}
  html body.spQuickRestartReady #ui #timePanel{padding-right:48px !important;}
  html body #controlHint{
    max-width:calc(100vw - 48px);
    bottom:calc(24px + env(safe-area-inset-bottom,0px));
    padding:12px 20px;font-size:16px !important;text-align:center;
  }

  html body #overlay:has(> .card.titleCard){
    padding:calc(16px + env(safe-area-inset-top,0px)) calc(16px + env(safe-area-inset-right,0px)) calc(16px + env(safe-area-inset-bottom,0px)) calc(16px + env(safe-area-inset-left,0px)) !important;
  }
  html body #overlay > .card.titleCard{
    --sp-title-scene-height:clamp(220px,22vh,300px);
    display:block;width:min(100%,960px) !important;max-width:960px !important;min-width:0;min-height:0;
    max-height:calc(100dvh - 32px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px)) !important;
    padding:24px clamp(24px,3.9vw,40px) 28px !important;
    overflow-y:auto !important;overflow-x:hidden !important;touch-action:pan-y !important;
    overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
  }
  html body #overlay > .titleCard .titleIdentity{min-height:0;padding:calc(var(--sp-title-scene-height) + 8px) 0 22px;}
  html body #overlay > .titleCard .titleStage{top:0;height:var(--sp-title-scene-height);display:block;}
  html body #overlay > .titleCard .spinpopTitle{font-size:clamp(52px,6.6vw,72px) !important;line-height:1.08;text-align:center;}
  html body #overlay > .titleCard .spinpopSub{font-size:18px !important;line-height:1.4;margin-top:8px;text-align:center;}
  html body #overlay > .titleCard .titleSettingsBtn{top:20px;right:28px;width:48px;height:48px;}
  html body #overlay > .titleCard .titleSettingsBtn img{width:26px;height:26px;}
  html body #overlay > .titleCard .statGrid{margin:0 0 22px;padding:10px 0;}
  html body #overlay > .titleCard .statBox{min-height:76px;row-gap:8px;padding:0 14px 8px;}
  html body #overlay > .titleCard .statBox .k{font-size:14px !important;line-height:1.35 !important;}
  html body #overlay > .titleCard .statBox .v{font-size:34px;}
  html body #overlay > .titleCard .titleWorldStat{padding-right:26px;}
  html body #overlay > .titleCard .titleStartBlock{margin-bottom:22px;}
  html body #overlay > .titleCard .titleStartBtn{height:72px;min-height:72px;font-size:28px;gap:14px;}
  html body #overlay > .titleCard .titleStartBtn img{width:28px;height:28px;}
  html body #overlay > .titleCard .weekdayMissionPanel{min-height:98px;margin:0 0 22px !important;}
  html body #overlay > .titleCard .weekdayMissionRow{grid-template-columns:minmax(0,1fr) 124px 136px;min-height:96px;gap:16px;padding:14px 18px;}
  html body #overlay > .titleCard .weekdayMissionName{font-size:18px;line-height:1.35;}
  html body #overlay > .titleCard .weekdayMissionRewardState{max-width:100%;margin-top:8px;padding:5px 9px;font-size:13px;line-height:1.4;white-space:normal;overflow-wrap:anywhere;}
  html body #overlay > .titleCard .weekdayMissionRank,
  html body #overlay > .titleCard .weekdayMissionGo{min-height:60px;font-size:15px !important;line-height:1.35;white-space:normal;overflow-wrap:anywhere;}
  html body #overlay > .titleCard .weekdayMissionRank span{font-size:12px;line-height:1.35;white-space:normal;overflow-wrap:anywhere;}
  html body #overlay > .titleCard .weekdayMissionRank b{font-size:20px;line-height:1.2;}
  html body #overlay > .titleCard .weekdayMissionLock{gap:13px;padding:14px 20px;}
  html body #overlay > .titleCard .weekdayMissionLockIcon{font-size:22px;}
  html body #overlay > .titleCard .weekdayMissionLock b{font-size:16px;line-height:1.4;}
  html body #overlay > .titleCard .weekdayMissionLock em{margin-top:5px;font-size:14px;line-height:1.4;}
  html body #overlay > .titleCard .titleWallet{padding:18px 0 16px;gap:24px;}
  html body #overlay > .titleCard .titleWallet .k,
  html body #overlay > .titleCard .titleLoadout h2,
  html body #overlay > .titleCard .titleLoadoutCopy small{font-size:14px;}
  html body #overlay > .titleCard .titleWallet .v{font-size:32px;}
  html body #overlay > .titleCard .titleWallet .totalEarned,
  html body #overlay > .titleCard .titleOwnedBonuses .titleSkinOwnedBonus,
  html body #overlay > .titleCard .titleOwnedBonuses .titleSkinItemSpawn{font-size:14px;line-height:1.5;}
  html body #overlay > .titleCard .titleLoadout{padding:16px 0;margin-bottom:20px;}
  html body #overlay > .titleCard .titleLoadout h2{margin-bottom:10px;}
  html body #overlay > .titleCard .titleLoadoutSlots{gap:24px;}
  html body #overlay > .titleCard .titleLoadoutSlot{grid-template-columns:52px minmax(0,1fr) 10px;min-height:68px;gap:14px;}
  html body #overlay > .titleCard .titleLoadoutSlot + button{padding-left:20px;}
  html body #overlay > .titleCard .titleLoadoutSlot > .skinPreview{width:52px !important;height:52px !important;min-width:52px !important;max-width:52px !important;min-height:52px !important;max-height:52px !important;}
  html body #overlay > .titleCard .titleThemeThumb{width:52px;height:52px;}
  html body #overlay > .titleCard .titleLoadoutCopy b{font-size:18px;}
  html body #overlay > .titleCard .menuBtns{gap:18px;}
  html body #overlay > .titleCard .menuBtns .menuBtn{min-height:78px;padding:14px;gap:14px;}
  html body #overlay > .titleCard .menuBtn img{width:28px;height:28px;}
  html body #overlay > .titleCard .menuBtn .txt{font-size:20px;}
  html body #overlay > .titleCard .menuBtn .titleStoreHint{font-size:14px;}
  html body #overlay > .titleCard .titleStudioCredit{margin-top:18px;min-height:24px;font-size:10px;line-height:16px;}
  html body #overlay > .titleCard .titleStudioWordmark{font-size:12px;line-height:16px;}
  /* Existing panel scrolling and touch exceptions remain responsible for navigation. */
  html body #overlay > .card:not(.titleCard),
  html body #overlay > .card.resultCard.resultCardStable{
    width:min(88vw,720px) !important;max-width:720px !important;min-width:0;
    max-height:calc(100dvh - 48px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px)) !important;
    padding:26px 28px !important;font-size:16px;
  }
  html body #overlay > .card:not(.titleCard) h1,
  html body #overlay > .card:not(.titleCard) h2,
  html body #overlay .achievementsTitle,
  html body #overlay .settingsTitle{font-size:28px !important;}
  html body #overlay > .card:not(.titleCard) button,
  html body #overlay > .card:not(.titleCard) > .btn{min-height:48px;font-size:16px !important;}
  html body #overlay .settingsClose,
  html body #overlay .titleSettingsBtn{min-width:48px;min-height:48px;}
  html body #overlay .settingsCard .settingRow{padding:16px 0 !important;gap:20px;}
  html body #overlay .settingRow b{font-size:17px;}
  html body #overlay .settingRow small{font-size:13px;line-height:1.5;}
  html body #overlay .settingRangeBox{min-width:210px;}
  html body #overlay .settingRangeBox em,
  html body #overlay .settingLanguageCurrent{font-size:16px;}
  html body #overlay .settingLanguageButton,
  html body #overlay .settingLanguageChoice{min-height:48px;font-size:16px;}
  html body #overlay .settingsDone{min-height:50px;padding:14px 20px;font-size:17px;}
  html body #overlay .achItem{padding:17px 0 !important;gap:18px;}
  html body #overlay .achItem .badge{font-size:13px;max-width:116px;}
  html body #overlay .achItem .name{font-size:17px;}
  html body #overlay .achItem .desc{font-size:14px;line-height:1.5;}
  html body #overlay .arenaBalance,
  html body #overlay .customSkinPanel .skinUnifiedPoint{font-size:18px;}
  html body #overlay .customCategories,
  html body #overlay .customFilter,
  html body #overlay .arenaModes{gap:6px;}
  html body #overlay .arenaGrid{gap:18px;}
  html body #overlay .arenaTileName,
  html body #overlay .customSkinPanel .customSkinName{font-size:17px !important;}
  html body #overlay .customSkinPanel .customSkinDesc,
  html body #overlay .arenaWeekdayToggle,
  html body #overlay .arenaDayLabel,
  html body #overlay .skinCollectionSummary{font-size:14px !important;}
  html body #overlay .customSkinPanel .shopItem{grid-template-columns:minmax(0,1fr) 110px;min-height:96px;gap:18px;}
  html body #overlay .arenaBack{font-size:16px;min-height:50px;}
  html body #overlay .arenaDayLabel select{font-size:15px;min-height:44px;}
  html body #overlay > .card.resultCard .resultHeader,
  html body #overlay > .card.resultCard .resultMainTitle,
  html body #overlay > .card.resultCard.resultCardStable .resultHeader,
  html body #overlay > .card.resultCard.resultCardStable .resultMainTitle{font-size:27px !important;}
  html body #overlay > .card.resultCard .resultScore,
  html body #overlay > .card.resultCard.resultCardStable .resultScore{font-size:66px !important;}
  html body #overlay > .card.resultCard .resultBtn,
  html body #overlay > .card.resultCard.resultCardStable .resultBtn{min-height:52px !important;font-size:16px !important;}
  html body #overlay > .card.resultCard .resultCaption,
  html body #overlay > .card.resultCard .rankTitle,
  html body #overlay > .card.resultCard.resultCardStable .resultCaption,
  html body #overlay > .card.resultCard.resultCardStable .rankTitle{font-size:14px !important;}
  html body #overlay > .card.resultCard .resultRankTable,
  html body #overlay > .card.resultCard.resultCardStable .resultRankTable{font-size:14px;}
}

/* Keep the title visible beside its scene in shorter portrait and split windows. */
@media (min-width:600px) and (min-height:600px) and (max-width:999px) and (max-height:1100px){
  html body #overlay > .card.titleCard{--sp-title-scene-height:190px;padding-top:20px !important;}
  html body #overlay > .titleCard .titleIdentity{display:grid;grid-template-columns:minmax(0,.42fr) minmax(0,.58fr);align-items:center;gap:16px;padding:0 0 18px;}
  html body #overlay > .titleCard .titleStage{position:relative;left:auto;top:auto;width:100%;height:var(--sp-title-scene-height);}
  html body #overlay > .titleCard .titleIdentity > div{min-width:0;padding-right:16px;}
  html body #overlay > .titleCard .spinpopTitle{font-size:clamp(42px,6.4vw,56px) !important;}
  html body #overlay > .titleCard .spinpopSub{font-size:16px !important;}
  html body #overlay > .titleCard .weekdayMissionRow{grid-template-columns:minmax(0,1fr) 108px 116px;gap:12px;padding:12px 14px;}
  html body #overlay > .titleCard .titleWallet{padding:14px 0 12px;}
  html body #overlay > .titleCard .titleLoadout{padding:12px 0;}
}

/* Wide, low tablets use two columns so the supporting rows stay beside START. */
@media (min-width:1000px) and (min-height:600px) and (orientation:landscape){
  html body #overlay > .card.titleCard{
    --sp-title-scene-height:clamp(250px,36vh,340px);
    display:grid;grid-template-columns:minmax(0,.82fr) minmax(0,1.18fr);
    column-gap:36px;row-gap:14px;align-items:center;
    width:min(100%,1280px) !important;max-width:1280px !important;
    padding:64px 28px 24px !important;
  }
  html body #overlay > .titleCard .titleIdentity{grid-column:1;grid-row:1 / span 4;width:100%;min-height:0;padding:calc(var(--sp-title-scene-height) + 10px) 0 14px;}
  html body #overlay > .titleCard .titleStage{height:var(--sp-title-scene-height);}
  html body #overlay > .titleCard .spinpopTitle{font-size:clamp(52px,4.7vw,64px) !important;}
  html body #overlay > .titleCard .statGrid{grid-column:1;grid-row:5;margin:0;}
  html body #overlay > .titleCard .statBox{padding-left:8px;padding-right:8px;}
  html body #overlay > .titleCard .titleWorldStat{padding-right:24px;}
  html body #overlay > .titleCard .statBox .k{font-size:13px !important;}
  html body #overlay > .titleCard .statBox .v{font-size:30px;}
  html body #overlay > .titleCard .titleStartBlock{grid-column:2;grid-row:1;margin:0;}
  html body #overlay > .titleCard .weekdayMissionPanel{grid-column:2;grid-row:2;margin:0 !important;}
  html body #overlay > .titleCard .weekdayMissionRow{grid-template-columns:minmax(0,1fr) 104px 112px;gap:12px;padding:12px;}
  html body #overlay > .titleCard .weekdayMissionName{font-size:16px;}
  html body #overlay > .titleCard .titleWallet{grid-column:2;grid-row:3;padding:14px 0 12px;gap:18px;}
  html body #overlay > .titleCard .titleLoadout{grid-column:2;grid-row:4;margin:0;padding:12px 0;}
  html body #overlay > .titleCard .titleLoadoutSlots{gap:16px;}
  html body #overlay > .titleCard .titleLoadoutSlot{grid-template-columns:46px minmax(0,1fr) 8px;gap:10px;}
  html body #overlay > .titleCard .titleLoadoutSlot + button{padding-left:14px;}
  html body #overlay > .titleCard .titleLoadoutSlot > .skinPreview{width:46px !important;height:46px !important;min-width:46px !important;max-width:46px !important;min-height:46px !important;max-height:46px !important;}
  html body #overlay > .titleCard .titleThemeThumb{width:46px;height:46px;}
  html body #overlay > .titleCard .titleLoadoutCopy b{font-size:16px;}
  html body #overlay > .titleCard .menuBtns{grid-column:2;grid-row:5;margin:0;gap:12px;}
  html body #overlay > .titleCard .menuBtns .menuBtn{min-height:70px;padding:12px;gap:10px;}
  html body #overlay > .titleCard .menuBtn .txt{font-size:18px;}
  html body #overlay > .titleCard .titleStudioCredit{grid-column:1 / -1;grid-row:6;margin:0;}
  html body #overlay > .titleCard .titleSettingsBtn{top:10px;right:24px;}
}

/* Preserve readable labels and reachable controls when height is constrained. */
@media (min-width:600px) and (min-height:600px) and (max-height:800px){
  html body #overlay > .card.titleCard{padding-top:18px !important;padding-bottom:20px !important;}
  html body #overlay > .titleCard .statGrid{padding:6px 0;margin-bottom:16px;}
  html body #overlay > .titleCard .statBox{min-height:66px;row-gap:5px;padding-bottom:6px;}
  html body #overlay > .titleCard .statBox .v{font-size:29px;}
  html body #overlay > .titleCard .titleStartBlock{margin-bottom:16px;}
  html body #overlay > .titleCard .titleStartBtn{height:66px;min-height:66px;font-size:26px;}
  html body #overlay > .titleCard .weekdayMissionPanel{min-height:88px;margin-bottom:16px !important;}
  html body #overlay > .titleCard .weekdayMissionRow{min-height:86px;padding-top:10px;padding-bottom:10px;}
  html body #overlay > .titleCard .weekdayMissionRank,
  html body #overlay > .titleCard .weekdayMissionGo{min-height:54px;font-size:14px !important;}
  html body #overlay > .titleCard .titleWallet{padding-top:12px;padding-bottom:10px;}
  html body #overlay > .titleCard .titleLoadout{padding-top:10px;padding-bottom:10px;margin-bottom:16px;}
  html body #overlay > .titleCard .titleLoadout h2{margin-bottom:6px;}
  html body #overlay > .titleCard .titleLoadoutSlot{min-height:60px;}
  html body #overlay > .titleCard .menuBtns .menuBtn{min-height:66px;}
}
@media (min-width:600px) and (min-height:600px) and (max-width:999px) and (max-height:800px){
  html body #overlay > .card.titleCard{--sp-title-scene-height:160px;}
}
@media (min-width:1000px) and (min-height:600px) and (max-height:800px) and (orientation:landscape){
  html body #overlay > .card.titleCard{--sp-title-scene-height:250px;row-gap:10px;padding-top:62px !important;}
  html body #overlay > .titleCard .statGrid,
  html body #overlay > .titleCard .titleStartBlock,
  html body #overlay > .titleCard .weekdayMissionPanel,
  html body #overlay > .titleCard .titleLoadout{margin:0 !important;}
}