/* Tablet & iPad (768px–1366px) + all touch iPads in landscape */
@media (min-width: 768px) and (max-width: 1366px),
       not ((hover: hover) and (pointer: fine)) and (min-width: 768px) {

    :root {
        --touch-min: 52px;
        --tablet-pad: 1.25rem;
    }

    .main-content {
        padding: var(--tablet-pad) !important;
        max-width: 100% !important;
    }

    .main-content:has(.home-page),
    .main-content:has(.sky-runner-page),
    .main-content:has(.bowling-page),
    .main-content:has(.uno-page),
    .main-content:has(.chess-page) {
        padding: 0 !important;
    }

    /* ── Home ── */
    .home-inner {
        padding: 2rem 1.75rem 3rem;
    }

    .hero-title {
        font-size: clamp(2.6rem, 5vw, 3.4rem);
    }

    .hero-stats {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        max-width: 42rem;
        margin: 0 auto;
        gap: 0.65rem;
    }

    .hero-stat {
        justify-content: center;
        padding: 0.65rem 0.75rem;
        font-size: 0.95rem;
    }

    .featured-inner {
        flex-wrap: nowrap;
        align-items: center;
        gap: 1.25rem;
    }

    .featured-cta {
        width: auto;
        flex-shrink: 0;
        padding: 0.85rem 1.5rem;
    }

    .games-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.1rem;
    }

    .game-card {
        padding: 1.35rem 1.25rem;
        min-height: 11rem;
    }

    /* ── Sky Runner ── */
    .sky-runner-page {
        height: calc(100dvh - var(--nav-h));
        min-height: calc(100dvh - var(--nav-h));
    }

    .sky-runner-page .mobile-touch-controls {
        display: flex;
    }

    .sky-runner-page .mobile-touch-controls .touch-btn {
        min-width: 64px;
        min-height: 64px;
        width: 64px;
        height: 64px;
        font-size: 1.55rem;
    }

    .sky-runner-page .mobile-touch-controls .touch-jump {
        min-width: 72px;
        min-height: 72px;
        width: 72px;
        height: 72px;
        font-size: 1.75rem;
    }

    .sky-runner-page .sky-hud.playing {
        height: 3rem !important;
    }

    .sky-runner-page .sky-hud.playing .hud-pill {
        font-size: 0.78rem;
        min-height: 2rem;
    }

    .sky-runner-page .sky-hud.playing #sound-btn {
        width: 2.75rem !important;
        min-width: 2.75rem !important;
        max-width: 2.75rem !important;
    }

    /* ── Galaxy Bowling ── */
    .bowling-page .bowling-stage {
        --game-scale: 0.68;
    }

    .bowling-page .hud-ball-picker button,
    .bowling-page .hud-side-controls button,
    .bowling-page .hud-menu-btn {
        min-width: 48px;
        min-height: 48px;
    }

    /* ── Chess — use horizontal arena on tablet ── */
    .chess-page .chess-arena {
        grid-template-columns: minmax(100px, 130px) auto minmax(100px, 130px) !important;
        grid-template-rows: auto !important;
        max-width: none !important;
        width: 100%;
        gap: 0.5rem !important;
    }

    .chess-page #gameArea.active .chess-arena {
        --sq: min(
            calc((100dvh - var(--nav-h) - 120px) / 8),
            calc((100vw - 280px) / 8),
            52px
        ) !important;
        max-width: none !important;
    }

    .chess-page .chess-panel--left { order: 1; }
    .chess-page .chess-board-col { order: 2; }
    .chess-page .chess-panel--right { order: 3; }

    .chess-page .panel-card {
        max-width: 130px !important;
        padding: 0.45rem 0.55rem;
    }

    .chess-page .control-btn {
        min-height: 44px;
        min-width: 44px;
        font-size: 0.8rem;
    }

    /* ── UNO ── */
    .uno-page .uno-hand {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        padding-bottom: 0.35rem;
    }

    .uno-page .uno-hand .uno-card {
        scroll-snap-align: center;
        flex-shrink: 0;
    }

    .uno-page .uno-btn,
    .uno-page .uno-action-btn {
        min-height: 48px;
        min-width: 48px;
    }

    /* ── Whack-a-mole ── */
    .whack-page .whack-btn {
        min-height: 48px;
        min-width: 48px;
        font-size: 0.95rem;
    }

    .whack-page .hole {
        min-height: 88px;
    }

    /* ── Snakes & Ladders ── */
    .snl-page .snl-btn,
    .snl-page .roll-btn {
        min-height: 48px;
        min-width: 48px;
    }

    /* ── Tic-tac-toe ── */
    .ttt-page .ttt-main {
        flex-direction: row;
        align-items: flex-start;
        gap: 1rem;
    }

    .ttt-page .ttt-board-wrap {
        flex: 1;
        max-width: min(420px, 55vw);
    }

    /* ── Leaderboard widget ── */
    .game-lb {
        font-size: 0.9rem;
    }
}

/* iPad landscape — reuse phone-landscape game layouts at tablet height */
@media (min-width: 768px) and (max-width: 1194px) and (orientation: landscape),
       (orientation: landscape) and (min-height: 521px) and (max-height: 900px) and (pointer: coarse) {

    body:has(.sky-runner-page.sky-layout-landscape) .nav-bar,
    body:has(.uno-page) .nav-bar {
        display: none !important;
    }

    body:has(.sky-runner-page) .main-content,
    body:has(.uno-page) .main-content {
        padding: 0 !important;
        max-width: none !important;
    }

    .sky-runner-page.sky-layout-landscape {
        --nav-h: 0px;
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
        max-height: 100dvh !important;
        z-index: 1500;
    }

    .sky-runner-page.sky-layout-landscape .sky-runner-stage {
        height: 100% !important;
        min-height: 100% !important;
    }

    .chess-page .chess-arena {
        grid-template-columns: minmax(96px, 120px) auto minmax(96px, 120px) !important;
    }

    .chess-page #gameArea.active .chess-arena {
        --sq: min(
            calc((100dvh - 100px) / 8),
            calc((100vw - 260px) / 8),
            56px
        ) !important;
    }

    .bowling-page .bowling-stage {
        --game-scale: 0.72;
    }

    .uno-page {
        --nav-h: 0px;
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        z-index: 1500;
    }

    .ttt-page .ttt-main {
        flex-direction: row;
        justify-content: center;
        gap: 1.25rem;
    }
}
