/* ===== 响应式 - 桌面缩小 ===== */
@media (max-width: 900px) {
    #side-nav {
        width: 70px;
    }
    .nav-btn {
        font-size: 11px;
        padding: 8px 4px;
    }
}

/* ===== 响应式 - 移动端 ===== */
@media (max-width: 768px) {
    /* ── body & container ── */
    body {
        overflow: auto;
        height: auto;
        min-height: 100vh;
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }
    #game-container {
        height: auto;
        min-height: 100vh;
        padding-bottom: 64px; /* space for bottom nav */
    }

    /* ── Top bar ── */
    #top-bar {
        padding: 6px 10px;
        gap: 8px;
    }
    .game-title {
        font-size: 15px;
    }

    /* ── Main content: stack vertically ── */
    #main-content {
        flex-direction: column;
        overflow: visible;
    }

    /* ── Hide side-nav, show bottom-nav ── */
    #side-nav {
        display: none !important;
    }
    #bottom-tab-nav {
        display: flex !important;
    }

    /* ── Content area ── */
    #content-area {
        overflow: visible;
    }
    .tab-panel {
        height: auto;
        overflow: visible;
        padding: 12px 10px;
    }

    /* ── Bottom status bar: hide on mobile to save space ── */
    #bottom-bar {
        display: none;
    }

    /* ── Pet grid: 2 columns ── */
    .pet-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .pet-card {
        padding: 10px;
    }
    .pet-avatar {
        font-size: 32px;
    }
    .pet-name {
        font-size: 13px;
    }

    /* ── Pet detail: full width ── */
    .pet-detail-grid {
        flex-direction: column;
    }
    .radar-section {
        width: 100%;
    }

    /* ── Explore grid: single column ── */
    .explore-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    /* ── Building grid: single column ── */
    .building-type-grid {
        grid-template-columns: 1fr;
    }

    /* ── Battle container: stack ── */
    .battle-container {
        grid-template-columns: 1fr;
    }

    /* ── Breed: stack vertically ── */
    .breed-slots {
        flex-direction: column;
        gap: 10px;
    }
    .slot-content {
        width: 120px;
        height: 140px;
    }
    .breed-heart {
        transform: rotate(90deg);
    }

    /* ── Hatch slots: single column ── */
    .hatch-slots-grid {
        grid-template-columns: 1fr;
    }
    .egg-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* ── Tech nodes: wrap tighter ── */
    .tech-nodes {
        gap: 8px;
    }
    .tech-node {
        width: 140px;
    }

    /* ── Achievements: single column ── */
    .achievements-grid {
        grid-template-columns: 1fr;
    }

    /* ── Quests: single column ── */
    .quest-grid {
        grid-template-columns: 1fr;
    }

    /* ── Panel header: wrap ── */
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .panel-header h2 {
        font-size: 16px;
    }
    .panel-actions {
        margin-left: 0;
    }

    /* ── Sub tabs: scrollable ── */
    .sub-tabs {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .sub-tabs::-webkit-scrollbar {
        display: none;
    }

    /* ── Buttons: larger touch targets ── */
    .btn-primary, .btn-secondary {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px;
    }
    .btn-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    /* ── Notifications: full width ── */
    .notification-area {
        right: 8px;
        left: 8px;
        top: 50px;
    }
    .notification {
        max-width: 100%;
    }

    /* ── Modal: mobile fullscreen ── */
    #modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    #modal-box {
        min-width: unset;
        max-width: 100%;
        width: 100%;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
        padding: 16px;
        animation: modalSlideUp 0.3s ease;
    }
    #modal-body {
        font-size: 14px;
    }
    #modal-footer {
        flex-direction: column;
        gap: 8px;
    }
    #modal-footer .btn-primary,
    #modal-footer .btn-secondary {
        width: 100%;
        text-align: center;
    }

    /* ── Pet selector: mobile fullscreen ── */
    #pet-selector-box {
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
        animation: modalSlideUp 0.3s ease;
    }
    #pet-selector-overlay {
        align-items: flex-end;
    }
    #pet-selector-list {
        grid-template-columns: repeat(2, 1fr);
    }

    /* ── Battle panel: mobile ── */
    #battle-panel-box {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    #battle-field {
        flex-direction: column;
        padding: 10px;
        min-height: auto;
    }
    #battle-vs-divider {
        width: auto;
        height: 30px;
        transform: rotate(90deg);
    }
    .battle-unit {
        min-width: 60px;
        max-width: 80px;
        padding: 4px 6px;
    }
    .unit-emoji {
        font-size: 18px;
    }
    #battle-log {
        max-height: 150px;
    }

    /* ── Account overlay: mobile ── */
    #account-overlay {
        align-items: flex-end !important;
    }
    #account-box {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
        padding: 20px 16px !important;
    }

    /* ── Activity log: shorter on mobile ── */
    .activity-log {
        max-height: 150px;
    }

    /* ── Building tabs: scroll ── */
    .bld-tab-bar {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
    }
    .bld-tab-bar::-webkit-scrollbar {
        display: none;
    }

    /* ── Instance rows: stack on narrow screens ── */
    .bld-inst-row {
        flex-wrap: wrap;
        gap: 6px;
    }
    .bld-inst-right {
        width: 100%;
        justify-content: space-between;
    }

    /* ── Inventory grid: 3 columns ── */
    .inventory-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

