/* ═══════════════════════════════════════════════
   COMPREHENSIVE RESPONSIVE STYLES
   All devices: large tablets → small phones
   ═══════════════════════════════════════════════ */

/* ─── Variables ─── */

/* ─── Large Tablets & Desktops (≥ 1200px) ─── */
@media (min-width: 1200px) {
  .app {
    max-width: 620px;
  }
  .menuBtn.classic {
    width: 320px;
    height: 74px;
    font-size: 24px;
  }
}

/* ─── Medium Tablets / Landscape (1024px) ─── */
@media (max-width: 1024px) and (min-width: 769px) {
  .boardCard {
    --boardSize: min(88vmin, 520px);
  }
  .menuBtn.classic {
    width: min(300px, 85vw);
    height: 74px;
  }
}

/* ─── Portrait Tablets / Large Phones (768px) ─── */
@media (max-width: 768px) {
  .boardCard {
    --boardSize: min(90vmin, 520px);
  }
  .menuBtn.classic {
    width: min(280px, 80vw);
    height: 68px;
    font-size: 18px;
  }
  .noSpaceBtn {
    bottom: 130px;
  }
  .shopGrid {
    grid-template-columns: 1fr 1fr;
  }
  .profileStats {
    gap: 8px;
  }
  .profileStatCard {
    max-width: 130px;
    padding: 12px 8px;
  }
}

/* ─── Large Phones (480px) ─── */
@media (max-width: 480px) {
  :root {
    --scoreSize: clamp(42px, 10vw, 64px);
    --slotMinH: clamp(100px, 20vw, 130px);
  }
  .app {
    padding:
      calc(10px + env(safe-area-inset-top))
      calc(10px + env(safe-area-inset-right))
      calc(10px + env(safe-area-inset-bottom))
      calc(10px + env(safe-area-inset-left));
  }
  .boardCard {
    --boardSize: min(92vmin, 480px);
  }
  .board {
    gap: 3px;
    padding: 6px;
    border-width: 3px;
  }
  .layout {
    gap: 10px;
    margin-top: 10px;
  }
  .topbar {
    padding: 6px 4px;
    gap: 8px;
  }
  .stats {
    gap: 6px;
  }
  .stat {
    padding: 6px 8px;
  }
  .statValue {
    font-size: 22px;
  }
  .stats .stat:nth-child(2) .statValue {
    font-size: var(--scoreSize);
  }
  .bestStat .statValue {
    font-size: 22px;
  }
  .brand {
    min-width: 0;
  }
  .brandLogo {
    width: 32px;
    height: 32px;
    gap: 2px;
  }
  .brandTitle {
    font-size: 16px;
  }
  .brandSubtitle {
    font-size: 11px;
  }
  .btn {
    padding: 8px 10px;
    font-size: 13px;
  }
  .tray {
    padding: 10px;
    gap: 6px;
  }
  .trayHeader {
    padding: 10px;
  }
  .slot {
    min-height: var(--slotMinH);
    padding: 6px;
  }
  .pieceBlock {
    width: var(--trayBlockPx);
    height: var(--trayBlockPx);
  }
  .noSpaceBtn {
    bottom: 100px;
    min-height: 60px;
    padding: 36px 14px;
    font-size: 28px;
  }
  .boosterBtn {
    width: 38px;
    height: 38px;
  }
  .boosterBtn .boosterIcon {
    font-size: 15px;
  }
  .boosterBtn .boosterCount {
    font-size: 8px;
    min-width: 14px;
  }

  /* Menu screen */
  .menuTopRow {
    padding: 4px 8px;
  }
  .menuCurrencyRow {
    gap: 10px;
  }
  .menuBadge {
    height: 32px;
    padding: 2px 6px 2px 22px;
    border-width: 2px;
  }
  .menuBadge .menuBadgeIcon {
    width: 40px;
    height: 40px;
    left: -14px;
  }
  .menuBadgeValue {
    font-size: 16px;
    min-width: 20px;
  }
  .menuBadgePlusBtn {
    width: 22px;
    height: 22px;
  }
  .menuBadgePlusBtn svg {
    width: 22px;
    height: 22px;
  }
  .menuHeaderBtn {
    width: 36px;
    height: 36px;
  }
  .menuHeaderIcon {
    width: 18px;
    height: 18px;
  }
  .menuSettingImgBtn {
    width: 60px !important;
    height: 60px !important;
  }
  .menuRemoveAds {
    top: 50px;
  }
  .menuRemoveAdsBtn {
    font-size: 11px;
    padding: 4px 10px 4px 8px;
  }
  .menuLevelBarWrap {
    top: 82px;
  }
  .menuLevelBarInner {
    height: 36px;
  }
  .menuLevelBarText {
    font-size: 20px;
  }
  .menuLevelLock {
    width: 42px;
    height: 52px;
    right: -8px;
  }
  .menuLogoTitle {
    font-size: clamp(42px, 13vw, 56px);
  }
  .menuLogoSubtitle {
    font-size: clamp(32px, 10vw, 44px);
  }
  .menuLogoTag {
    font-size: 14px;
    letter-spacing: 4px;
  }
  .menuButtons {
    bottom: 220px;
    padding: 0 16px;
    gap: 14px;
  }
  .menuBtn.withIcon {
    width: min(280px, 100%);
  }
  .menuBtnLabel {
    font-size: 24px;
  }
  .glossy-play-btn {
    width: min(260px, 80vw) !important;
    height: 72px !important;
    font-size: 26px !important;
  }
  .glossy-play-sparkle {
    font-size: 14px !important;
  }
  .menuNavBtns {
    gap: 4px;
    max-width: 320px;
  }
  .menuNavBtn {
    min-width: 44px;
    padding: 4px 8px;
  }
  .menuNavIcon {
    width: 18px;
    height: 18px;
  }
  .menuNavLabel {
    font-size: 7px;
  }
  .menuSpirit {
    width: 80px;
    height: 110px;
    bottom: 60px;
  }
  .menuVersion {
    font-size: 10px;
    bottom: 68px;
  }
  .menuBottomNav {
    height: 64px;
  }
  .navBtnInner svg {
    width: 36px;
    height: 36px;
  }
  .navActiveBubble svg {
    width: 50px;
    height: 56px;
  }
  .navActiveArch {
    width: 72px;
  }
  .navActiveLabel {
    font-size: 11px;
  }

  /* Game menu popup */
  .gameMenuCard {
    width: min(420px, 92vw);
    min-height: 360px;
  }
  .gameMenuHeaderTitle {
    font-size: 24px;
    letter-spacing: 2px;
  }
  .gameMenuBody {
    padding: 12px;
  }
  .gameMenuBodyBtn {
    font-size: 14px;
    padding: 12px 14px;
  }

  /* Shop */
  .shopHeader {
    padding: 8px 0;
  }
  .shopTitle {
    font-size: 20px;
    letter-spacing: 2px;
  }
  .shopCoins {
    font-size: 14px;
  }
  .shopTab {
    font-size: 12px;
    padding: 8px 4px;
  }
  .shopItem {
    padding: 10px;
  }
  .shopPreview {
    height: 60px;
  }
  .shopPreviewColor {
    width: 22px;
    height: 22px;
  }
  .shopItemName {
    font-size: 12px;
  }
  .shopItemAction {
    font-size: 11px;
    padding: 6px 0;
  }
  .shopBooster {
    padding: 10px;
  }
  .shopBoosterIcon {
    width: 44px;
    height: 44px;
  }
  .shopBoosterName {
    font-size: 13px;
  }

  /* Modal */
  .modalTitle {
    font-size: clamp(32px, 8vw, 44px);
  }
  .modalValue {
    font-size: clamp(40px, 8vw, 54px);
  }
  .modalActions .btn.primary {
    height: 60px;
    font-size: 28px;
  }

  /* Profile */
  .profileStats {
    gap: 6px;
    padding: 8px 10px;
  }
  .profileStatCard {
    max-width: 110px;
    padding: 10px 6px;
  }
  .profileStatValue {
    font-size: 18px;
  }
  .profileStatLabel {
    font-size: 8px;
  }

  /* Rewards / Daily */
  .wheelCanvasWrap {
    width: 220px;
    height: 220px;
  }
  .dailyShopList {
    gap: 8px;
  }
  .shopDailyCard {
    min-width: 100px;
    padding: 12px 8px 10px;
  }
  .shopDailyName {
    font-size: 12px;
  }

  /* Ranked/Leaderboard */
  .rankedCard {
    max-width: 460px;
  }
  .rankedTitle {
    font-size: 16px;
    padding: 10px 12px;
  }
  .rankedRow {
    padding: 8px 10px;
    gap: 8px;
  }

  /* Settings */
  .settingsPanel {
    padding: 12px;
  }
  .settingsTitle {
    font-size: 13px;
  }
  .settingsSub {
    font-size: 11px;
  }
}

/* ─── 420px (Current main breakpoint) ─── */
@media (max-width: 420px) {
  :root {
    --appPad: 10px;
    --trayBlockPx: clamp(14px, 4.2vw, 18px);
    --slotMinH: clamp(90px, 18vw, 110px);
  }
  .app {
    max-width: 100%;
  }
  .boardCard {
    --boardSize: min(94vmin, 440px);
  }
  .board {
    gap: 2px;
    padding: 5px;
    border-width: 2px;
  }
  .cell {
    --bevel: 4px;
  }
  .topbar {
    padding: 4px 4px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .stats {
    justify-content: space-between;
    gap: 6px;
  }
  .btn {
    width: 100%;
    padding: 8px 10px;
    font-size: 12px;
  }
  .stat {
    min-width: 0;
    padding: 6px 8px;
  }
  .statValue {
    font-size: 18px;
  }
  .stats .stat:nth-child(1) .statValue {
    font-size: var(--scoreSize);
  }
  .stats .stat:nth-child(2) .statValue {
    font-size: var(--scoreSize);
  }
  .brandText {
    display: none;
  }
  .brandLogo {
    width: 28px;
    height: 28px;
    gap: 2px;
  }
  .trayHeader {
    padding: 10px 8px;
  }
  .tray {
    padding: 8px;
    gap: 5px;
  }
  .slot {
    min-height: var(--slotMinH);
    padding: 4px;
  }
  .piece {
    gap: 0px;
    padding: 0;
  }
  .pieceBlock {
    width: var(--trayBlockPx);
    height: var(--trayBlockPx);
    --bevel: 2px;
  }
  .trayTitle {
    font-size: 13px;
  }
  .traySub {
    font-size: 11px;
  }
  .noSpaceBtn {
    bottom: 80px;
    min-height: 54px;
    padding: 30px 12px;
    font-size: 24px;
  }
  .boosterBtn {
    width: 34px;
    height: 34px;
  }
  .boosterBtn .boosterIcon {
    font-size: 13px;
    margin-top: -1px;
  }
  .boosterBtn .boosterCount {
    font-size: 7px;
    min-width: 12px;
    line-height: 11px;
  }

  /* Menu */
  .menuTopRow {
    padding: 2px 6px;
  }
  .menuCurrencyRow {
    gap: 8px;
  }
  .menuBadge {
    height: 28px;
    padding: 2px 4px 2px 18px;
    border-radius: 14px;
  }
  .menuBadge .menuBadgeIcon {
    width: 34px;
    height: 34px;
    left: -12px;
  }
  .menuBadgeValue {
    font-size: 14px;
    min-width: 18px;
  }
  .menuBadgePlusBtn {
    width: 18px;
    height: 18px;
  }
  .menuBadgePlusBtn svg {
    width: 18px;
    height: 18px;
  }
  .menuHeaderBtn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }
  .menuHeaderIcon {
    width: 16px;
    height: 16px;
  }
  .menuSettingImgBtn {
    width: 50px !important;
    height: 50px !important;
  }
  .menuLevelBarWrap {
    top: 74px;
  }
  .menuLevelBarInner {
    height: 30px;
  }
  .menuLevelBarText {
    font-size: 16px;
  }
  .menuLevelLock {
    width: 36px;
    height: 44px;
    right: -6px;
  }
  .menuLogo {
    top: 46%;
  }
  .menuLogoTitle {
    font-size: clamp(36px, 12vw, 48px);
  }
  .menuLogoSubtitle {
    font-size: clamp(28px, 9vw, 38px);
  }
  .menuLogoTag {
    font-size: 12px;
    letter-spacing: 3px;
  }
  .menuButtons {
    bottom: 190px;
    padding: 0 12px;
    gap: 12px;
  }
  .menuBtn.withIcon {
    width: min(240px, 100%);
  }
  .menuBtnLabel {
    font-size: 20px;
  }
  .glossy-play-btn {
    width: min(220px, 75vw) !important;
    height: 64px !important;
    font-size: 22px !important;
  }
  .glossy-play-sparkle {
    font-size: 12px !important;
  }
  .menuNavBtns {
    gap: 3px;
    max-width: 280px;
    margin-top: 10px;
  }
  .menuNavBtn {
    min-width: 40px;
    padding: 3px 6px;
    border-radius: 10px;
  }
  .menuNavIcon {
    width: 16px;
    height: 16px;
  }
  .menuNavLabel {
    font-size: 6px;
  }
  .menuSpirit {
    width: 64px;
    height: 90px;
    bottom: 50px;
  }
  .menuButtons {
    gap: 10px;
  }
  .menuBottomNav {
    height: 58px;
  }
  .navBtnInner svg {
    width: 32px;
    height: 32px;
  }
  .navActiveBubble svg {
    width: 44px;
    height: 50px;
  }
  .navActiveArch {
    width: 62px;
    border-top-left-radius: 36px;
    border-top-right-radius: 36px;
    border-width: 3px;
  }
  .navActiveLabel {
    font-size: 10px;
  }
  .navActiveBubble {
    bottom: 14px;
  }

  /* Game menu popup */
  .gameMenuCard {
    width: min(360px, 95vw);
    min-height: 300px;
  }
  .gameMenuHeader {
    padding: 12px 10px 10px;
  }
  .gameMenuHeaderTitle {
    font-size: 20px;
  }
  .gameMenuBody {
    padding: 10px;
    gap: 8px;
  }
  .gameMenuBodyBtn {
    font-size: 13px;
    padding: 10px 12px;
    border-radius: 12px;
  }
  .gameMenuBodyBtnSvg {
    width: 18px;
    height: 18px;
  }

  /* Shop */
  .shopGrid {
    grid-template-columns: 1fr;
  }
  .shopHeader {
    padding: 6px 0;
  }
  .shopBackBtn {
    width: 34px;
    height: 34px;
  }
  .shopBackSvg {
    width: 18px;
    height: 18px;
  }
  .shopTitle {
    font-size: 18px;
  }
  .shopCoinDisplay {
    padding: 4px 8px 4px 6px;
  }
  .shopCoins {
    font-size: 13px;
  }
  .shopTab {
    font-size: 11px;
    padding: 6px 4px;
    gap: 4px;
  }
  .shopTabSvg {
    width: 14px;
    height: 14px;
  }

  /* Profile */
  .profileAvatar {
    width: 64px;
    height: 64px;
  }
  .profileUsername {
    font-size: 17px;
  }
  .profileStats {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding: 6px 8px;
  }
  .profileStatCard {
    min-width: 90px;
    max-width: none;
    flex: 0 0 auto;
    padding: 8px 6px;
  }
  .profileStatIcon {
    width: 32px;
    height: 32px;
  }
  .profileStatValue {
    font-size: 16px;
  }
  .profileStatLabel {
    font-size: 7px;
  }
  .profileBoosterRow {
    gap: 4px;
  }

  /* Modal */
  .modalTitle {
    font-size: clamp(28px, 7vw, 36px);
    margin-bottom: 12px;
  }
  .modalValue {
    font-size: clamp(36px, 7vw, 44px);
  }
  .modalActions .btn.primary {
    height: 52px;
    font-size: 24px;
    border-radius: 14px;
  }

  /* Ranked/Leaderboard */
  .rankedBackdrop {
    padding: 10px;
  }
  .rankedCard {
    max-width: 400px;
    border-radius: 16px;
  }
  .rankedTrophy img {
    width: 56px;
    height: 56px;
  }
  .rankedBody {
    padding: 0 12px 12px;
  }

  /* Rewards */
  .wheelCanvasWrap {
    width: 180px;
    height: 180px;
  }
  .wheelSpinBtn {
    width: 180px;
    font-size: 16px;
    padding: 12px;
  }
  .rewardDayCell {
    min-width: 56px;
    padding: 10px 4px 8px;
  }
  .rewardDayIcon {
    font-size: 20px;
  }

  /* Settings */
  .settingsIcon {
    width: 34px;
    height: 34px;
  }
}

/* ─── 380px (Very small phones) ─── */
@media (max-width: 380px) {
  :root {
    --appPad: 8px;
    --scoreSize: clamp(36px, 9vw, 48px);
    --trayBlockPx: clamp(12px, 3.6vw, 16px);
    --slotMinH: clamp(80px, 16vw, 100px);
  }
  .boardCard {
    --boardSize: min(96vmin, 400px);
  }
  .board {
    gap: 2px;
    padding: 4px;
  }
  .cell {
    --bevel: 3px;
  }
  .layout {
    gap: 8px;
    margin-top: 8px;
  }
  .topbar {
    padding: 3px 2px;
    gap: 6px;
  }
  .stat {
    padding: 4px 6px;
  }
  .statValue {
    font-size: 16px;
  }
  .bestStat .statValue {
    font-size: 18px;
  }
  .brandLogo {
    width: 24px;
    height: 24px;
    gap: 1px;
  }
  .noSpaceBtn {
    bottom: 70px;
    min-height: 48px;
    padding: 24px 10px;
    font-size: 20px;
  }
  .tray {
    padding: 6px;
    gap: 4px;
  }
  .slot {
    padding: 3px;
    min-height: var(--slotMinH);
  }
  .pieceBlock {
    width: var(--trayBlockPx);
    height: var(--trayBlockPx);
  }
  .boosterBtn {
    width: 30px;
    height: 30px;
    border-radius: 10px;
  }
  .boosterBtn .boosterIcon {
    font-size: 11px;
  }

  /* Menu */
  .menuCurrencyRow {
    gap: 6px;
  }
  .menuBadge {
    height: 24px;
    padding: 1px 3px 1px 14px;
    border-radius: 12px;
  }
  .menuBadge .menuBadgeIcon {
    width: 28px;
    height: 28px;
    left: -10px;
  }
  .menuBadgeValue {
    font-size: 12px;
    min-width: 14px;
  }
  .menuBadgePlusBtn {
    width: 16px;
    height: 16px;
  }
  .menuBadgePlusBtn svg {
    width: 16px;
    height: 16px;
  }
  .menuHeaderBtn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }
  .menuSettingImgBtn {
    width: 44px !important;
    height: 44px !important;
  }
  .menuLevelBarWrap {
    top: 66px;
  }
  .menuLevelBarInner {
    height: 26px;
  }
  .menuLevelBarText {
    font-size: 13px;
  }
  .menuLevelLock {
    width: 30px;
    height: 38px;
    right: -4px;
  }
  .menuLogo {
    top: 44%;
  }
  .menuLogoTitle {
    font-size: clamp(30px, 11vw, 40px);
  }
  .menuLogoSubtitle {
    font-size: clamp(24px, 8vw, 32px);
  }
  .menuLogoTag {
    font-size: 10px;
    letter-spacing: 2px;
  }
  .menuButtons {
    bottom: 170px;
    gap: 8px;
  }
  .menuBtnLabel {
    font-size: 18px;
  }
  .glossy-play-btn {
    height: 56px !important;
    font-size: 20px !important;
  }
  .glossy-play-sparkle {
    display: none !important;
  }
  .menuNavBtns {
    gap: 2px;
    max-width: 240px;
    margin-top: 8px;
  }
  .menuNavBtn {
    min-width: 34px;
    padding: 2px 4px;
  }
  .menuNavIcon {
    width: 14px;
    height: 14px;
  }
  .menuSpirit {
    width: 52px;
    height: 72px;
    bottom: 44px;
  }
  .menuVersion {
    bottom: 62px;
    font-size: 9px;
  }
  .menuBottomNav {
    height: 52px;
  }
  .navBtnInner svg {
    width: 28px;
    height: 28px;
  }
  .navActiveBubble svg {
    width: 38px;
    height: 44px;
  }
  .navActiveArch {
    width: 54px;
    border-top-left-radius: 30px;
    border-top-right-radius: 30px;
    border-width: 2px;
  }
  .navActiveLabel {
    font-size: 9px;
  }
  .navActiveBubble {
    bottom: 12px;
  }
  .navBtnInner svg {
    width: 28px;
    height: 28px;
  }
  .navBtn {
    padding: 4px 2px;
  }

  /* Game menu */
  .gameMenuCard {
    min-height: 260px;
  }
  .gameMenuHeaderTitle {
    font-size: 18px;
  }
  .gameMenuBodyBtn {
    font-size: 12px;
    padding: 8px 10px;
    gap: 8px;
  }

  /* Shop */
  .shopPreview {
    height: 50px;
  }
  .shopPreviewColor {
    width: 18px;
    height: 18px;
  }
  .shopItem {
    padding: 8px;
  }
  .shopBooster {
    padding: 8px;
    gap: 8px;
  }
  .shopBoosterIcon {
    width: 36px;
    height: 36px;
  }

  /* Modal */
  .modalTitle {
    font-size: clamp(24px, 6vw, 30px);
  }
  .modalValue {
    font-size: clamp(30px, 6vw, 36px);
  }
  .modalActions .btn.primary {
    height: 46px;
    font-size: 20px;
  }

  /* Profile */
  .profileAvatar {
    width: 56px;
    height: 56px;
  }
  .profileUsername {
    font-size: 15px;
  }
  .profileStatCard {
    min-width: 76px;
    padding: 6px 4px;
  }
  .profileStatIcon {
    width: 28px;
    height: 28px;
  }
  .profileStatValue {
    font-size: 14px;
  }

  /* Rewards */
  .wheelCanvasWrap {
    width: 160px;
    height: 160px;
  }
  .wheelSpinBtn {
    width: 160px;
    font-size: 14px;
    padding: 10px;
  }
  .rewardDayCell {
    min-width: 48px;
    padding: 8px 3px 6px;
  }

  /* Ranked */
  .rankedBackdrop {
    padding: 6px;
  }
  .rankedCard {
    border-radius: 14px;
  }
}

/* ─── 350px (iPhone SE / very small) ─── */
@media (max-width: 350px) {
  .boardCard {
    --boardSize: min(98vmin, 360px);
  }
  .board {
    gap: 1px;
    padding: 3px;
    border-width: 2px;
  }
  .cell {
    --bevel: 2px;
  }
  .noSpaceBtn {
    font-size: 18px;
    padding: 18px 8px;
    min-height: 42px;
    bottom: 60px;
  }
  .slot {
    min-height: clamp(70px, 14vw, 86px);
  }
  .pieceBlock {
    width: clamp(10px, 3.2vw, 14px);
    height: clamp(10px, 3.2vw, 14px);
  }
  .tray {
    padding: 4px;
    gap: 3px;
  }
  .menuBadge {
    height: 22px;
    padding: 1px 2px 1px 12px;
    border-radius: 10px;
  }
  .menuBadge .menuBadgeIcon {
    width: 24px;
    height: 24px;
    left: -8px;
  }
  .menuBadgeValue {
    font-size: 11px;
    min-width: 12px;
  }
  .menuBadgePlusBtn {
    width: 14px;
    height: 14px;
    margin-left: 2px;
  }
  .menuBadgePlusBtn svg {
    width: 14px;
    height: 14px;
  }
  .menuLevelBarInner {
    height: 22px;
  }
  .menuLevelBarText {
    font-size: 11px;
  }
  .menuLevelLock {
    display: none;
  }
  .menuButtons {
    bottom: 160px;
  }
  .glossy-play-btn {
    height: 50px !important;
    font-size: 18px !important;
  }
  .menuBtnLabel {
    font-size: 16px;
  }
  .menuBottomNav {
    height: 48px;
  }
  .navBtnInner svg {
    width: 24px;
    height: 24px;
  }
  .navActiveBubble svg {
    width: 34px;
    height: 38px;
  }
  .navActiveArch {
    width: 48px;
    border-width: 2px;
  }
  .navActiveLabel {
    font-size: 8px;
  }
  .navActiveBubble {
    bottom: 10px;
  }
  .gameMenuCard {
    width: min(320px, 98vw);
  }
  .gameMenuBodyBtn {
    font-size: 11px;
    padding: 6px 8px;
  }
  .gameMenuBodyBtnSvg {
    width: 16px;
    height: 16px;
  }
  .shopGrid {
    grid-template-columns: 1fr;
  }
  .profileStats {
    gap: 4px;
  }
  .profileStatCard {
    min-width: 68px;
    padding: 4px 3px;
  }
  .modalActions .btn.primary {
    height: 42px;
    font-size: 18px;
  }
  .wheelCanvasWrap {
    width: 140px;
    height: 140px;
  }
  .wheelSpinBtn {
    width: 140px;
    font-size: 12px;
    padding: 8px;
  }
}

/* ─── 320px (Smallest phones) ─── */
@media (max-width: 320px) {
  :root {
    --appPad: 6px;
    --scoreSize: clamp(28px, 8vw, 36px);
    --trayBlockPx: clamp(9px, 2.8vw, 12px);
    --slotMinH: clamp(64px, 12vw, 76px);
  }
  .boardCard {
    --boardSize: min(98vmin, 320px);
  }
  .board {
    gap: 1px;
    padding: 2px;
  }
  .cell {
    --bevel: 2px;
  }
  .app {
    padding:
      calc(6px + env(safe-area-inset-top))
      calc(6px + env(safe-area-inset-right))
      calc(6px + env(safe-area-inset-bottom))
      calc(6px + env(safe-area-inset-left));
  }
  .topbar {
    padding: 2px 2px;
    gap: 4px;
  }
  .stat {
    padding: 3px 4px;
  }
  .statValue {
    font-size: 14px;
  }
  .bestStat .statValue {
    font-size: 16px;
  }
  .noSpaceBtn {
    font-size: 16px;
    padding: 14px 6px;
    min-height: 38px;
    bottom: 52px;
  }
  .tray {
    padding: 3px;
    gap: 2px;
  }
  .trayHeader {
    padding: 6px 4px;
  }
  .trayTitle {
    font-size: 11px;
  }
  .traySub {
    font-size: 9px;
  }
  .boosterBtn {
    width: 26px;
    height: 26px;
    border-radius: 8px;
  }
  .boosterBtn .boosterIcon {
    font-size: 10px;
  }

  /* Menu */
  .currencyRow {
    gap: 4px;
  }
  .menuBadge {
    height: 20px;
    padding: 1px 2px 1px 10px;
    border-radius: 8px;
  }
  .menuBadge .menuBadgeIcon {
    width: 20px;
    height: 20px;
    left: -7px;
  }
  .menuBadgeValue {
    font-size: 10px;
    min-width: 10px;
  }
  .menuBadgePlusBtn {
    display: none;
  }
  .menuHeaderBtn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
  }
  .menuHeaderIcon {
    width: 14px;
    height: 14px;
  }
  .menuSettingImgBtn {
    width: 38px !important;
    height: 38px !important;
  }
  .menuLevelBarWrap {
    top: 58px;
  }
  .menuLevelBarInner {
    height: 20px;
  }
  .menuLevelBarText {
    font-size: 10px;
  }
  .menuLogoTitle {
    font-size: clamp(24px, 10vw, 30px);
  }
  .menuLogoSubtitle {
    font-size: clamp(20px, 7vw, 26px);
  }
  .menuLogoTag {
    display: none;
  }
  .menuButtons {
    bottom: 150px;
    gap: 6px;
  }
  .glossy-play-btn {
    height: 44px !important;
    font-size: 16px !important;
    letter-spacing: 2px !important;
  }
  .menuNavBtns {
    display: none;
  }
  .menuSpirit {
    display: none;
  }
  .menuVersion {
    bottom: 54px;
    font-size: 8px;
  }
  .menuBottomNav {
    height: 44px;
  }
  .navBtnInner svg {
    width: 22px;
    height: 22px;
  }
  .navActiveBubble svg {
    width: 30px;
    height: 34px;
  }
  .navActiveArch {
    width: 42px;
    border-radius: 26px 26px 0 0;
  }
  .navActiveLabel {
    font-size: 7px;
  }
  .navActiveBubble {
    bottom: 8px;
  }

  /* Shop */
  .shopBackBtn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }
  .shopTitle {
    font-size: 14px;
  }
  .shopCoinDisplay {
    padding: 2px 6px 2px 4px;
  }
  .shopCoinIcon {
    width: 16px;
    height: 16px;
  }
  #shopCoins {
    font-size: 11px;
  }
  .shopTabSvg {
    display: none;
  }
  .shopTab {
    font-size: 10px;
    padding: 4px 2px;
  }

  /* Profile */
  .profileAvatar {
    width: 48px;
    height: 48px;
  }
  .profileUsername {
    font-size: 13px;
  }
  .profileStatCard {
    min-width: 60px;
    padding: 4px 2px;
    border-radius: 10px;
  }
  .profileStatIcon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
  }
  .profileStatValue {
    font-size: 12px;
  }
  .profileStatLabel {
    font-size: 6px;
  }

  /* Modal */
  .modalTitle {
    font-size: clamp(20px, 6vw, 24px);
  }
  .modalValue {
    font-size: clamp(24px, 6vw, 30px);
  }
  .modalRow {
    gap: 4px;
  }
  .modalActions .btn.primary {
    height: 38px;
    font-size: 16px;
  }

  /* Ranked */
  .rankedTitle {
    font-size: 13px;
    padding: 8px 10px;
    gap: 6px;
  }
  .rankedRow {
    padding: 6px 8px;
    gap: 6px;
  }
  .rankedPos {
    width: 24px;
    font-size: 12px;
  }
  .rankedName {
    font-size: 12px;
  }
  .rankedScore {
    font-size: 12px;
  }

  /* Settings */
  .settingsRow {
    flex-wrap: wrap;
    gap: 8px;
  }
  .settingsTitle {
    font-size: 12px;
  }
  .settingsSub {
    font-size: 10px;
  }
  .settingsToggle {
    width: 44px;
    height: 24px;
  }
  .settingsToggleSlider:before {
    width: 20px;
    height: 20px;
  }
  .settingsToggle input:checked+.settingsToggleSlider:before {
    transform: translateX(20px);
  }
  .settingsSelect {
    font-size: 12px;
    padding: 6px 8px;
  }
}

/* ─── Height-based breakpoints ─── */

/* Short screens (landscape phones, small tablets) */
@media (max-height: 700px) {
  .menuLogo {
    top: 44%;
  }
  .menuLogoTitle {
    font-size: clamp(34px, 10vw, 48px);
  }
  .menuLogoSubtitle {
    font-size: clamp(26px, 8vw, 38px);
  }
  .menuButtons {
    bottom: 180px;
    gap: 10px;
  }
  .menuSpirit {
    width: 70px;
    height: 100px;
    bottom: 50px;
  }
  .menuLevelBarWrap {
    top: 76px;
  }
}

@media (max-height: 640px) {
  .noSpaceBtn {
    bottom: 56px;
    min-height: 48px;
    padding: 24px 12px;
    font-size: 22px;
  }
  .menuLogo {
    top: 42%;
  }
  .menuLogoTitle {
    font-size: clamp(28px, 8vw, 40px);
  }
  .menuLogoSubtitle {
    font-size: clamp(22px, 6vw, 30px);
  }
  .menuButtons {
    bottom: 160px;
    gap: 8px;
  }
  .menuBtnLabel {
    font-size: 20px;
  }
  .glossy-play-btn {
    height: 58px !important;
    font-size: 20px !important;
  }
  .menuSpirit {
    width: 56px;
    height: 80px;
    bottom: 42px;
  }
  .menuLevelBarWrap {
    top: 68px;
  }
  .menuLevelBarInner {
    height: 28px;
  }
  .menuLevelBarText {
    font-size: 14px;
  }
  .menuBottomNav {
    height: 56px;
  }
  .rankedTrophy img {
    width: 52px;
    height: 52px;
  }
}

@media (max-height: 580px) {
  .menuLogo {
    top: 40%;
  }
  .menuLogoTitle {
    font-size: clamp(22px, 7vw, 32px);
  }
  .menuLogoSubtitle {
    font-size: clamp(18px, 5vw, 24px);
  }
  .menuLogoTag {
    display: none;
  }
  .menuButtons {
    bottom: 140px;
    gap: 6px;
  }
  .menuBtnLabel {
    font-size: 16px;
  }
  .glossy-play-btn {
    height: 48px !important;
    font-size: 16px !important;
  }
  .menuSpirit {
    display: none;
  }
  .menuLevelBarWrap {
    top: 60px;
  }
  .menuLevelBarInner {
    height: 24px;
  }
  .menuLevelBarText {
    font-size: 12px;
  }
  .menuLevelLock {
    width: 30px;
    height: 38px;
  }
}

@media (max-height: 500px) {
  .noSpaceBtn {
    bottom: 48px;
    min-height: 40px;
    padding: 18px 10px;
    font-size: 18px;
  }
  .menuLogo {
    top: 36%;
  }
  .menuLogoTitle {
    font-size: clamp(18px, 5vw, 24px);
  }
  .menuLogoSubtitle {
    font-size: clamp(14px, 4vw, 18px);
  }
  .menuButtons {
    bottom: 120px;
  }
  .glossy-play-btn {
    height: 40px !important;
    font-size: 14px !important;
  }
  .menuLevelBarWrap {
    top: 54px;
  }
  .menuLevelBarInner {
    height: 20px;
  }
  .menuLevelBarText {
    font-size: 10px;
  }
  .menuBottomNav {
    height: 48px;
  }
  .navBtnInner svg {
    width: 26px;
    height: 26px;
  }
  .navActiveBubble svg {
    width: 32px;
    height: 36px;
  }
}

/* ─── Landscape mode for phones ─── */
@media (orientation: landscape) and (max-height: 500px) {
  .menuScreen {
    height: 100vh;
    overflow-y: auto;
  }
  .menuLevelBarWrap {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    width: 80%;
    margin: 8px auto 0;
  }
  .menuLogo {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    margin: 4px 0;
  }
  .menuButtons {
    position: relative;
    bottom: auto;
    left: auto;
    transform: none;
    margin: 4px 0;
    padding: 0 16px;
  }
  .menuSpirit {
    display: none;
  }
  .menuBottomNav {
    position: fixed;
  }
  .boardCard .board {
    margin: 4px auto;
  }
}

/* Landscape game mode */
@media (orientation: landscape) and (max-height: 480px) {
  .layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 8px;
  }
  .boardCard {
    flex: 0 0 auto;
  }
  .boardCard {
    --boardSize: min(60vh, 60vw);
  }
  .trayCard {
    flex: 1;
    min-width: 0;
  }
  .tray {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 6px;
  }
  .slot {
    min-height: clamp(60px, 12vh, 90px);
  }
  .topbar {
    padding: 2px 4px;
  }
  .noSpaceBtn {
    bottom: 10px;
    min-height: 36px;
    padding: 12px 8px;
    font-size: 16px;
  }
}

/* Override for very short landscape (keyboard open) */
@media (orientation: landscape) and (max-height: 400px) {
  .boardCard {
    --boardSize: min(55vh, 55vw);
  }
  .slot {
    min-height: 50px;
  }
  .pieceBlock {
    width: 10px;
    height: 10px;
    --bevel: 1px;
  }
  .noSpaceBtn {
    display: none;
  }
}

/* ─── 481px–599px (Medium-large phones, phablets) ─── */
@media (min-width: 481px) and (max-width: 599px) {
  :root {
    --trayBlockPx: clamp(18px, 4vw, 20px);
    --slotMinH: clamp(110px, 18vw, 130px);
  }
  .boardCard {
    --boardSize: min(90vmin, 480px);
  }
  .board {
    gap: 3px;
    padding: 6px;
  }
  .layout {
    gap: 12px;
    margin-top: 12px;
  }
  .topbar {
    padding: 6px 6px;
    gap: 8px;
  }
  .stat {
    padding: 6px 10px;
  }
  .statValue {
    font-size: 24px;
  }
  .stats .stat:nth-child(2) .statValue {
    font-size: clamp(44px, 10vw, 56px);
  }
  .noSpaceBtn {
    bottom: 120px;
    min-height: 64px;
    font-size: 30px;
  }
  .gameMenuCard {
    width: min(440px, 92vw);
  }
  .tray {
    padding: 12px;
    gap: 8px;
  }
  .modalTitle {
    font-size: clamp(36px, 8vw, 48px);
  }
  .modalValue {
    font-size: clamp(44px, 8vw, 56px);
  }
  .modalActions .btn.primary {
    height: 66px;
    font-size: 32px;
  }
  .boosterBtn {
    width: 40px;
    height: 40px;
  }
  .boosterBtn .boosterIcon {
    font-size: 16px;
  }
}

/* ─── 600px–767px (Phablets / small tablets in portrait) ─── */
@media (min-width: 600px) and (max-width: 767px) {
  :root {
    --trayBlockPx: clamp(20px, 4.4vw, 24px);
    --slotMinH: clamp(120px, 20vw, 150px);
    --scoreSize: clamp(52px, 10vw, 72px);
  }
  .boardCard {
    --boardSize: min(88vmin, 520px);
  }
  .board {
    gap: 3px;
    padding: 7px;
  }
  .layout {
    gap: 14px;
    margin-top: 14px;
  }
  .topbar {
    padding: 8px 8px;
  }
  .stat {
    padding: 8px 12px;
  }
  .statValue {
    font-size: 28px;
  }
  .stats .stat:nth-child(2) .statValue {
    font-size: var(--scoreSize);
  }
  .noSpaceBtn {
    bottom: 130px;
    min-height: 68px;
    font-size: 32px;
  }
  .gameMenuCard {
    width: min(460px, 88vw);
  }
  .tray {
    padding: 12px;
    gap: 8px;
  }
  .boosterBtn {
    width: 42px;
    height: 42px;
  }
}

/* ─── Height-based: Short screens game layout (portrait small phones) ─── */
@media (max-height: 740px) {
  .layout {
    gap: 10px;
    margin-top: 10px;
  }
  .topbar {
    padding: 4px 4px;
    gap: 6px;
  }
  .stat {
    padding: 4px 6px;
  }
  .statValue {
    font-size: 20px;
  }
  .stats .stat:nth-child(2) .statValue {
    font-size: clamp(34px, 8vw, 48px);
  }
  .boardCard {
    --boardSize: min(88vmin, 480px);
  }
  .board {
    gap: 2px;
    padding: 5px;
  }
  .tray {
    padding: 8px;
    gap: 5px;
  }
  .slot {
    min-height: clamp(80px, 16vw, 110px);
    padding: 4px;
  }
  .pieceBlock {
    width: clamp(14px, 3.6vw, 18px);
    height: clamp(14px, 3.6vw, 18px);
  }
  .boosterBtn {
    width: 32px;
    height: 32px;
  }
  .noSpaceBtn {
    bottom: 90px;
    min-height: 50px;
    padding: 28px 12px;
    font-size: 24px;
  }
}

@media (max-height: 680px) {
  .boardCard {
    --boardSize: min(84vmin, 440px);
  }
  .board {
    gap: 2px;
    padding: 4px;
  }
  .layout {
    gap: 6px;
    margin-top: 6px;
  }
  .topbar {
    padding: 2px 2px;
    gap: 4px;
  }
  .stat {
    padding: 2px 4px;
  }
  .statValue {
    font-size: 16px;
  }
  .stats .stat:nth-child(2) .statValue {
    font-size: clamp(28px, 6vw, 38px);
  }
  .tray {
    padding: 5px;
    gap: 3px;
  }
  .slot {
    min-height: clamp(64px, 12vw, 90px);
    padding: 3px;
  }
  .pieceBlock {
    width: clamp(11px, 3vw, 15px);
    height: clamp(11px, 3vw, 15px);
  }
  .noSpaceBtn {
    bottom: 70px;
    min-height: 44px;
    padding: 20px 10px;
    font-size: 20px;
  }
  .boosterBtn {
    width: 28px;
    height: 28px;
  }
  .boosterBtn .boosterIcon {
    font-size: 11px;
  }
  .boosterBtn .boosterCount {
    font-size: 7px;
    min-width: 12px;
  }
}

/* ─── Minimum touch target sizes across all devices ─── */
@media (pointer: coarse) {
  .slot {
    min-height: max(var(--slotMinH, 90px), 44px);
  }
  .boosterBtn {
    min-width: 32px;
    min-height: 32px;
  }
  .iconBtn {
    min-width: 40px;
    min-height: 40px;
  }
  .gameMenuCloseBtn {
    min-width: 36px;
    min-height: 36px;
  }
  .stats .stat:nth-child(1) {
    min-width: 44px;
  }
}

/* ─── Improved landscape game layout ─── */
@media (orientation: landscape) and (max-height: 520px) {
  .layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
  }
  .boardCard {
    flex: 0 0 auto;
  }
  .boardCard {
    --boardSize: min(55vh, 55vw);
  }
  .trayCard {
    flex: 1;
    min-width: 0;
  }
  .tray {
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    padding: 4px;
  }
  .slot {
    min-height: clamp(50px, 10vh, 80px);
    padding: 2px;
  }
  .pieceBlock {
    width: clamp(8px, 2.6vw, 12px);
    height: clamp(8px, 2.6vw, 12px);
    --bevel: 2px;
  }
  .topbar {
    padding: 2px 4px;
    gap: 4px;
  }
  .stat {
    padding: 2px 4px;
  }
  .statValue {
    font-size: 14px;
  }
  .stats .stat:nth-child(2) .statValue {
    font-size: clamp(20px, 4vw, 28px);
  }
  .noSpaceBtn {
    bottom: 8px;
    min-height: 34px;
    padding: 10px 6px;
    font-size: 14px;
  }
  .boosterBtn {
    width: 26px;
    height: 26px;
  }
  .boosterBtn .boosterIcon {
    font-size: 10px;
  }
  .boosterBtn .boosterCount {
    font-size: 6px;
    min-width: 10px;
  }
}

/* ─── Touch device optimizations ─── */

@media (hover: none) and (pointer: coarse) {
  .btn {
    transition: background 120ms ease, border-color 120ms ease;
  }
  .btn:hover {
    transform: none;
    background: rgba(0, 0, 0, 0.12);
  }
  .menuScreen {
    --menuPad: 14px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .menuBtn.withIcon {
    width: min(280px, 100%);
  }
  .menuButtons {
    width: min(280px, 100%);
  }
  .glossy-play-btn:hover {
    transform: none !important;
  }
  .gameMenuBodyBtn:hover {
    transform: none;
  }
  .gameMenuBodyBtn:active {
    transform: scale(0.97);
  }
}

@media (pointer: coarse) {
  .menuScreen::before {
    filter: none;
  }
  .gameMenuBackdrop,
  .gameMenuCard,
  .menuHeaderBtn,
  .menuBadge,
  .menuRemoveAdsBtn,
  .menuBtn.more,
  .menuFooter,
  .skinPanel {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .menuBtn.withIcon::after {
    filter: none;
  }
  .gameMenuBackdrop:not(.hidden) .gameMenuCard {
    animation: none;
  }
  .gameMenuBackdrop:not(.hidden) .gameMenuBodyButtons > * {
    animation: none;
  }
  .dragPiece {
    filter: none;
  }
  .cell.linePreview {
    box-shadow: none;
    outline: 2px solid var(--linePreviewRing, rgba(255, 255, 255, 0.18));
    animation: linePreviewPulse 700ms ease-in-out infinite;
  }
  @keyframes linePreviewPulse {
    0%, 100% { outline-width: 2px; }
    50% { outline-width: 3px; outline-color: rgba(255, 255, 255, 0.45); }
  }
  .cell.ghostPiece,
  .cell.ghostPieceBad {
    filter: none;
  }
  .cell.flash,
  .cell.place-pop,
  .cell.clear-flash,
  .scorePop {
    animation: none !important;
  }
  .cell.line-clear {
    overflow: visible !important;
    z-index: 10 !important;
    animation: clearLine calc(180ms / var(--time-scale)) ease-out 1 forwards !important;
    transform-origin: center;
  }
  .cell.line-clear.row {
    overflow: visible !important;
    z-index: 10 !important;
    animation: clearRow calc(180ms / var(--time-scale)) ease-out 1 forwards !important;
  }
  .cell.line-clear.col {
    overflow: visible !important;
    z-index: 10 !important;
    animation: clearCol calc(180ms / var(--time-scale)) ease-out 1 forwards !important;
  }
  #fx,
  #column-clear-beam,
  #row-clear-beam,
  .column-clear-beam,
  .row-clear-beam {
    display: none;
  }
  #legalOverlay {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}

/* ─── Dark mode / High contrast support ─── */
@media (prefers-contrast: high) {
  .cell.filled {
    border-width: calc(var(--bevel) + 1px);
  }
  .menuLevelBarOuter {
    border-width: 2px;
  }
  .menuBadge {
    border-width: 2px;
  }
}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  .menuLogo {
    animation: none;
  }
  .menuBtn.classic {
    animation: none;
  }
  .menuSpirit {
    animation: none;
  }
  .glossy-play-btn {
    animation: none !important;
  }
  .glossy-play-sparkle {
    animation: none !important;
    opacity: 0.8;
  }
  .navActiveBubble {
    animation: none;
  }
  .rewardDayCell.rewardToday {
    animation: none;
  }
  .dailyClaimBtn:not(:disabled) {
    animation: none;
  }
  .wheelSpinBtn:not(:disabled) {
    animation: none;
  }
  .cell.flash,
  .cell.place-pop,
  .cell.clear-flash {
    animation: none !important;
  }
  .rankedRow {
    animation: none !important;
  }
}

/* ─── Print styles ─── */
@media print {
  .menuScreen::before,
  .snowLayer,
  .menuSpirit,
  .menuBottomNav,
  .menuVersion,
  .noSpaceBtn {
    display: none !important;
  }
  .menuScreen {
    height: auto;
    overflow: visible;
  }
  .menuLogo {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
  }
  .menuButtons {
    position: relative;
    bottom: auto;
    left: auto;
    transform: none;
  }
}
