/* ================= 手机端终极适配 (仅此部分生效于手机) ================= */
@media (max-width: 768px) {
    body { padding: 5px; }
    .title-row {
        margin-top: 45px;
        margin-bottom: 5px;
        justify-content: center;
    }
    .title-row h1 { font-size: 22px; margin: 0; text-align: center; padding-left: 0; }
    .mobile-bingo-info-btn {
        display: inline-flex;
        margin-top: 1px;
        flex: 0 0 auto;
    }
    .bingo-hint { display: none; }
    .mobile-battle-hud { display: none; top: 6px; width: calc(100% - 2px); }
    body.mobile-hud-visible .mobile-battle-hud { display: block; }
    .mobile-intel-strip { display: none !important; }
    body.game-started .side-action-stack { display: flex; }
    .side-action-stack { right: 10px; bottom: 92px; gap: 6px; }
    .side-action-fab { width: 40px; height: 40px; font-size: 17px; }
    .side-action-fab-count { min-width: 16px; height: 16px; line-height: 16px; font-size: 9px; }
    #mobile-log-fab,
    #mobile-note-fab {
        display: inline-flex;
    }
    
    /* 顶部折叠菜单机制 */
    .top-tools { right: 5px; top: 5px; width: auto; max-width: none; align-items: flex-end; z-index: 260;}
    .menu-toggle { display: block; padding: 8px 12px; font-size: 13px; box-shadow: var(--card-shadow); }
    .tools-menu { 
        display: none; background: var(--panel-bg); padding: 12px; 
        border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); 
        border: 1px solid var(--border-color); flex-direction: column; gap: 10px; 
    }
    .tools-menu.show { display: flex; }
    .tool-btn { padding: 10px 15px; font-size: 14px; text-align: center;}
    .mobile-battle-hud { padding: 9px 11px; margin-bottom: 8px; }
    .mobile-hud-main { gap: 0; }
    .mobile-hud-topline { align-items: center; gap: 8px; }
    .mobile-turn-badge { padding: 3px 8px; font-size: 10px; }
    .mobile-hp-chip { padding: 3px 6px; font-size: 10px; }
    .mobile-hp-chip strong { font-size: 11px; }
    .mobile-turn-text { display: none; }
    #game-container { flex-direction: column; gap: 10px; }
    
    /* 状态栏精简紧凑排版 */
    #left-panel {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-width: 100%;
        width: 100%;
        gap: 8px;
        align-items: start;
    }
    .status-box {
        min-width: 0;
        width: 100%;
        padding: 10px;
        font-size: 13px;
        box-sizing: border-box;
    }
    .role-name-display,
    .player-role-row .role-name-display {
        font-size: 11px;
        line-height: 1.35;
    }
    .player-title-tag {
        height: 18px;
        padding: 0 7px;
        font-size: 10px;
        max-width: min(34vw, 112px);
        margin-right: 4px;
    }
    .hp-bar { font-size: 18px; margin-top: 2px;}
    .role-desc-text { display: none; } /* 隐藏过长的介绍文案 */
    .blacklist { font-size: 12px; margin-top: 4px; }
    .collection-progress {
        margin-top: 7px;
        padding: 8px;
    }
    .collection-progress-head { margin-bottom: 6px; }
    .collection-progress-label,
    .collection-progress-count,
    .collection-progress-missing { font-size: 11px; }
    .collection-progress-label {
        font-size: 0;
    }
    .collection-progress-label::before {
        content: '🛒 全收集';
        font-size: 11px;
        font-weight: 700;
        color: inherit;
    }
    .collection-progress-chevron { font-size: 10px; }
    .intel-strip { font-size: 11px; margin-top: 4px; padding: 5px 7px; }
    #ai-safe-wrap {
        display: flex;
        align-items: center;
        gap: 4px;
        white-space: nowrap;
        background: linear-gradient(135deg, rgba(46, 213, 115, 0.22), rgba(46, 213, 115, 0.08));
        border-color: rgba(46, 213, 115, 0.38);
        color: #16673b;
    }
    #ai-safe-wrap .intel-label {
        font-size: 0;
        margin-right: 4px;
        opacity: 1;
    }
    #ai-safe-wrap .intel-label::before {
        content: '✅';
        font-size: 11px;
        font-weight: 800;
    }
    #ai-safe-display {
        font-size: 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: inline-block;
        max-width: calc(100% - 20px);
        vertical-align: middle;
    }
    
    #log-panel {
        position: fixed;
        top: 0;
        left: -88vw;
        width: min(82vw, 360px);
        height: 100vh;
        margin: 0;
        grid-column: auto;
        z-index: 305;
        border-radius: 0 14px 14px 0;
        box-shadow: 8px 0 24px rgba(0,0,0,0.2);
        transition: left 0.28s ease;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    #log-panel.mobile-log-open { left: 0; }
    .log-panel-header { padding: 11px 12px; }
    #log-box {
        width: 100%;
        height: calc(100vh - 56px);
        margin-top: 0;
        padding: 10px 14px 10px 10px;
        box-sizing: border-box;
        scrollbar-gutter: stable;
        border: none;
        border-radius: 0;
        box-shadow: inset 0 2px 8px rgba(0,0,0,0.05);
    }
    #log-box > div {
        padding-right: 8px;
        box-sizing: border-box;
        word-break: break-word;
    }
    .drawer-overlay { z-index: 300; }
    .drawer {
        width: min(82vw, 360px);
        max-width: 82vw;
        right: -88vw;
        z-index: 305;
        padding: 18px 14px;
    }
    .drawer.open { right: 0; }
    #right-panel { max-width: 100%; order: 2; width: 100%; }
    .mobile-intel-card { padding: 9px 10px; }
    .mobile-intel-card strong { font-size: 11px; }
    .mobile-intel-meta { font-size: 10px; }
    .mobile-progress-bar { height: 7px; }
    
    /* 榨干所有像素给卡牌网格 */
    #board { gap: 4px; padding: 8px; border-radius: 10px; width: 100%; }
    .card-front { font-size: 18px; }
    .card-back { font-size: 11px; padding: 1px; gap: 1px; line-height: 1.1; }
    
    /* 手机端内部标签极限缩放 */
    .card-back span { font-size: 10px !important; }
    .ing-danger { font-size: 10px !important; padding: 1px 2px; border-radius: 3px; }
    .card.eaten-player .card-back::after,
    .card.eaten-ai .card-back::after,
    .card.damage-poison .card-back::before {
        font-size: 10px;
    }
    .eat-content .ing-danger {
        font-size: inherit !important;
        padding: 2px 6px;
        border-radius: 6px;
    }

    #toast-container {
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
    }
    .toast {
        width: auto;
        min-width: min(84vw, 440px);
        max-width: calc(100vw - 20px);
        padding: 12px 18px;
        box-sizing: border-box;
    }
    
    #action-area { padding: 7px; margin-top: 8px; min-height: 66px; border-radius: 12px; }
    #action-area.show { position: sticky; bottom: 8px; z-index: 72; box-shadow: 0 16px 36px rgba(0,0,0,0.2); }
    #action-title { font-size: 13px !important; font-weight: bold !important; margin-bottom: 8px !important; }
    #action-buttons { flex-direction: column; gap: 8px !important; }
    .btn { width: 100%; margin: 0; padding: 8px; font-size: 13px; }
    
    .btn-action-choice { padding: 8px !important; min-height: 72px; border-radius: 11px; gap: 6px; }
    .eat-warning { font-size: 10px; padding: 5px 6px; }
    .eat-row { padding: 5px 6px; }
    .eat-badge-player, .eat-badge-opponent { padding: 3px 6px; font-size: 11px; margin-right: 6px; }
    .eat-content { font-size: 13px; line-height: 1.45; }
    .seed-panel-actions .btn,
    .daily-setup-btn {
        min-width: 0;
        width: 100%;
    }
    .daily-setup-btn {
        gap: 6px;
        white-space: normal;
        line-height: 1.4;
        padding-inline: 10px;
    }
    
    .modal-box { padding: 15px; width: 95%; max-height: 90vh; box-sizing: border-box; overflow-x: hidden; }
    .modal-box-help {
        width: min(95vw, 560px);
        padding-top: 50px;
    }
    .modal-close-btn {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
        font-size: 24px;
    }
    #help-modal .help-content {
        font-size: 13px;
        line-height: 1.7;
    }
    #help-modal .help-content p,
    #help-modal .help-content li,
    #help-modal .help-content ul {
        font-size: inherit !important;
    }
    .role-grid { display: grid; grid-template-columns: 1fr; gap: 10px; width: 100%; }
    .role-card { width: 100%; min-width: 0; padding: 10px; box-sizing: border-box; }
    .setup-actions { flex-direction: column; gap: 10px;}
    .event-banner { top: 12px; width: calc(100vw - 22px); padding: 12px 16px 14px; border-radius: 16px; }
    .event-banner-title { font-size: 19px; }
    .event-banner-detail { font-size: 12px; }
    .fx-number { font-size: 22px; }
    .game-over-summary {
        gap: 10px;
        max-width: 100%;
    }
    .overlay {
        justify-content: flex-start;
        align-items: stretch;
        padding: 18px 8px 28px;
        width: 100vw;
        max-width: 100vw;
    }
    #game-over-text,
    #game-over-stats {
        width: 100%;
        max-width: 100%;
        align-self: stretch;
    }
    #game-over-stats {
        width: 100%;
        max-width: 100%;
        padding: 18px 14px 22px;
        border-radius: 18px;
    }
    .game-over-trend-card {
        margin-bottom: 20px;
        padding: 18px 14px 16px;
    }
    .game-over-title { font-size: 28px; }
    .game-over-highlight {
        font-size: 19px;
        line-height: 1.5;
    }
    .game-over-tags {
        gap: 8px;
        width: 100%;
        max-width: 100%;
    }
    .result-tag {
        min-height: 30px;
        padding: 6px 11px;
        font-size: 12px;
    }
    .game-over-remark {
        width: 100%;
        max-width: 100%;
        padding: 10px 12px;
        font-size: 14px;
        box-sizing: border-box;
    }
    .game-over-blacklist {
        font-size: 13px;
        line-height: 1.6;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    .game-over-actions {
        width: 100%;
        gap: 10px;
        box-sizing: border-box;
    }
    .game-over-actions .restart-btn {
        width: 100%;
        margin-top: 14px;
    }
    .share-card-modal-box {
        width: 95%;
        padding: 16px 14px 14px;
        box-sizing: border-box;
    }
    .share-card-actions {
        flex-direction: column;
    }
    .share-card-actions .btn {
        width: 100%;
    }
    .share-card-loading {
        min-height: 156px;
        padding: 20px 16px;
    }
    .share-card-loading-text {
        font-size: 15px;
    }
    .share-card-loading-subtext {
        font-size: 11px;
    }
    .account-panel-actions,
    .account-auth-actions,
    .developer-mode-actions {
        flex-direction: column;
    }
    .account-panel-actions .btn,
    .account-auth-actions .btn,
    .account-auth-tab,
    .developer-mode-actions .btn {
        width: 100%;
    }
    .developer-mode-modal-box {
        width: 95%;
        max-height: 90vh;
        padding: 14px;
        box-sizing: border-box;
    }
    .developer-users-table {
        min-width: 900px;
    }
    .account-captcha-row,
    .account-dialog-actions {
        flex-direction: column;
    }
    .account-captcha-preview,
    .account-captcha-refresh,
    .account-dialog-actions .btn,
    .system-dialog-actions .btn {
        width: 100%;
    }
    .achievement-modal-box {
        width: 95%;
        max-height: 90vh;
        padding: 14px;
        box-sizing: border-box;
    }
    .achievement-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .achievement-filter-bar {
        gap: 8px;
        padding: 8px;
    }
    .achievement-filter-label {
        width: 100%;
    }
    .achievement-filter-select {
        width: 100%;
    }
    .achievement-filter-search {
        width: 100%;
        min-width: 0;
    }
    .achievement-filter-count {
        margin-left: 0;
        width: 100%;
    }
    .system-dialog-actions {
        flex-direction: column;
    }
    [data-theme="dark"] #ai-safe-wrap {
        background: linear-gradient(135deg, rgba(46, 213, 115, 0.2), rgba(46, 213, 115, 0.07));
        border-color: rgba(123, 237, 159, 0.34);
        color: #9af0b7;
    }
    .restaurant-story-box {
        width: 95%;
        padding: 18px 14px 16px;
    }
    .restaurant-story-bubble {
        padding: 12px 13px;
        font-size: 13px;
        line-height: 1.7;
    }
    .restaurant-story-rule-card {
        padding: 12px 13px;
    }
    .restaurant-story-rule-text {
        font-size: 12px;
        line-height: 1.7;
    }
    .restaurant-story-actions { flex-direction: column; }
    .tutorial-card {
        left: 12px;
        right: 12px;
        bottom: 14px;
        transform: none;
        width: auto;
        padding: 16px 14px 14px;
    }
    .tutorial-header {
        align-items: center;
        justify-content: space-between;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 10px;
    }
    .tutorial-skip-btn {
        flex: 0 0 auto;
        white-space: nowrap;
        font-size: 12px;
    }
    .tutorial-actions .btn {
        width: 100%;
    }
}

/* 针对非常小的手机屏幕兜底 */
@media (max-width: 380px) {
    .card-back { font-size: 9px; line-height: 1; }
    .card-back span { font-size: 9px !important; }
    .ing-danger { font-size: 9px !important; }
    .eat-content .ing-danger {
        font-size: inherit !important;
    }
    .tutorial-header { gap: 8px; }
    .tutorial-tag { padding: 4px 8px; font-size: 11px; }
    .tutorial-skip-btn { font-size: 11px; }
    .seed-panel-main { align-items: flex-start; }
    .seed-panel-actions { grid-template-columns: 1fr; }
    .mobile-hud-topline { flex-direction: row; align-items: center; gap: 6px; }
    .opening-turn-actions { flex-direction: column; }
    .game-over-title { font-size: 24px; }
    .game-over-highlight { font-size: 17px; }
    .achievement-list { grid-template-columns: 1fr; }
}
