/* codex: 2026-11-24 升级核心样式表，新增边长选择器、画板缩放控制与手机/平板深度触控响应式适配 */

:root {
    --primary-color: #5d4037;
    --primary-hover: #4e342e;
    --accent-color: #d81b60;
    --bg-gradient: linear-gradient(135deg, #fdfbf7 0%, #ece5dd 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
    --border-color: #d7ccc8;
    --shadow-soft: 0 8px 24px rgba(78, 52, 46, 0.08);
    --shadow-lift: 0 12px 32px rgba(78, 52, 46, 0.14);
    --text-main: #3e2723;
    --text-muted: #6d4c41;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 16px 16px max(20px, env(safe-area-inset-bottom));
}

.game-container {
    width: 100%;
    max-width: 980px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--shadow-lift);
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 顶栏 */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    border-bottom: 2px dashed #d7ccc8;
    padding-bottom: 14px;
}

.header-title h1 {
    font-size: clamp(1.25rem, 3.2vw, 1.6rem);
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -0.4px;
}

.header-title p {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.header-tools {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-tool {
    background: #efebe9;
    color: var(--primary-color);
    border: 1px solid #d7ccc8;
    padding: 7px 13px;
    border-radius: 10px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-tool:hover {
    background: #e0d8d3;
    transform: translateY(-1px);
}

/* 一体两面双模式切换栏 */
.dual-face-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.face-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 14px;
    border: 2px solid #e0d7d0;
    background: #fbf9f6;
    color: #5d4037;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.face-card:hover {
    border-color: #bcaaa4;
    background: #f5efe8;
    transform: translateY(-1px);
}

.face-card.active {
    border-color: #d81b60;
    background: linear-gradient(135deg, #fff5f8 0%, #fce4ec 100%);
    box-shadow: 0 4px 14px rgba(216, 27, 96, 0.16);
}

.face-icon {
    font-size: 1.7rem;
    line-height: 1;
    flex-shrink: 0;
}

.face-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.face-text strong {
    font-size: 0.94rem;
    color: #3e2723;
}

.face-text small {
    font-size: 0.77rem;
    color: #6d4c41;
    line-height: 1.35;
}

.max-piece-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.max-piece-wrap.hidden {
    display: none;
}

/* 边长选择器与画板缩放栏 */
.size-selector-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    background: #f8f4ef;
    border: 1px solid #e2d9d0;
    border-radius: 14px;
    padding: 10px 14px;
}

.size-selector-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    flex: 1;
}

.size-select-label {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--primary-color);
    white-space: nowrap;
}

.size-select-dropdown {
    background: #ffffff;
    border: 1.5px solid #bcaaa4;
    border-radius: 9px;
    padding: 6px 10px;
    font-size: 0.88rem;
    font-weight: 700;
    color: #3e2723;
    cursor: pointer;
    min-height: 36px;
}

.size-quick-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.size-quick-pill {
    background: #ffffff;
    border: 1px solid #d7ccc8;
    color: #5d4037;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.16s ease;
    white-space: nowrap;
}

.size-quick-pill:hover {
    background: #efebe9;
}

.size-quick-pill.active {
    background: #5d4037;
    color: #ffffff;
    border-color: #5d4037;
}

.zoom-controls {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #ffffff;
    border: 1px solid #d7ccc8;
    border-radius: 10px;
    padding: 3px 6px;
}

.btn-zoom {
    background: #efebe9;
    border: none;
    color: #4e342e;
    border-radius: 7px;
    padding: 4px 8px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 28px;
}

.btn-zoom:hover {
    background: #d7ccc8;
}

.zoom-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #6d4c41;
    min-width: 38px;
    text-align: center;
}

/* 游戏目的与玩法横幅 */
.mission-banner {
    background: linear-gradient(135deg, #fffaf0 0%, #fff3e0 100%);
    border: 1.5px solid #ffcc80;
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mission-goal {
    font-size: 0.94rem;
    line-height: 1.55;
    color: #4e342e;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.mission-tag {
    background: #e65100;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
}

.mission-howto {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 0.82rem;
    color: #6d4c41;
    border-top: 1px dashed #ffe0b2;
    padding-top: 7px;
}

/* 统计卡片栏 */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.stat-item {
    background: #fbf9f6;
    border: 1px solid #e0d7d0;
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.stat-item.highlight-card {
    background: linear-gradient(135deg, #fff5f8 0%, #fce4ec 100%);
    border-color: #f48fb1;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.stat-value {
    font-size: clamp(1.15rem, 2.8vw, 1.45rem);
    font-weight: 800;
    color: var(--primary-color);
}

.stat-value.highlight {
    color: var(--accent-color);
}

.stat-value.highlight-alt {
    color: #2e7d32;
}

.stat-unit {
    font-size: 0.74rem;
    color: #8d6e63;
}

.coverage-bar-track {
    width: 100%;
    height: 6px;
    background: #e0d7d0;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 5px;
}

.coverage-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #66bb6a 0%, #2e7d32 100%);
    transition: width 0.25s ease;
}

/* 探索纪录履带 */
.achievement-section {
    background: #fdfaf6;
    border: 1px solid #e2d9d0;
    border-radius: 14px;
    padding: 12px 16px;
}

.achievement-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.btn-clear-collection {
    background: #fff0f0;
    color: #c62828;
    border: 1px solid #ffcdd2;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-clear-collection:hover {
    background: #ffebee;
}

.record-badge-track {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.record-badge {
    padding: 6px 11px;
    border-radius: 8px;
    font-size: 0.83rem;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.record-badge.mystery {
    background: #fff8e1;
    color: #f57f17;
    border: 1.5px dashed #fbc02d;
    cursor: default;
}

.record-badge.unlocked {
    background: #e8f5e9;
    color: #1b5e20;
    border-color: #81c784;
}

.record-badge.optimal {
    background: linear-gradient(135deg, #fff8e1 0%, #ffe082 100%);
    color: #b71c1c;
    border: 1.5px solid #ffb300;
    box-shadow: 0 2px 8px rgba(255, 179, 0, 0.35);
}

/* 一步步教学指导面板 */
.guide-panel {
    background: #f3e5f5;
    border: 1.5px solid #ce93d8;
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.guide-panel.hidden {
    display: none;
}

.guide-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-weight: 800;
    color: #4a148c;
    font-size: 0.94rem;
}

.guide-status {
    font-size: 0.82rem;
    background: #ffffff;
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid #ce93d8;
}

.guide-tabs-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.mode-toggle-group {
    display: inline-flex;
    background: #e1bee7;
    border-radius: 9px;
    padding: 3px;
    gap: 2px;
    flex-wrap: wrap;
}

.btn-mode-toggle {
    background: transparent;
    border: none;
    color: #4a148c;
    padding: 6px 12px;
    border-radius: 7px;
    font-size: 0.83rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-mode-toggle.active {
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(74, 20, 140, 0.15);
}

.guide-sub-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.guide-sub-controls.hidden {
    display: none;
}

.lesson-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.lesson-pill-btn {
    background: #ffffff;
    border: 1px solid #ba68c8;
    color: #6a1b9a;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.lesson-pill-btn.active {
    background: #7b1fa2;
    color: #ffffff;
    border-color: #7b1fa2;
}

.demo-controls-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-demo-ctrl {
    background: #ffffff;
    border: 1px solid #ba68c8;
    color: #4a148c;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 36px;
}

.btn-practice-toggle.active {
    background: #e65100;
    color: #ffffff;
    border-color: #e65100;
}

.btn-exit-guide {
    color: #c62828;
    border-color: #ef9a9a;
}

.speed-label {
    font-size: 0.84rem;
    color: #512da8;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.speed-label select {
    border-radius: 6px;
    border: 1px solid #ba68c8;
    padding: 4px 6px;
    font-size: 0.82rem;
}

.demo-explain-card {
    background: #ffffff;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 0.9rem;
    color: #3e2723;
    line-height: 1.6;
    border-left: 4px solid #ab47bc;
}

/* 尺寸托盘（自动适配 1×1 ~ 24×24） */
.palette-section {
    background: #fdfaf7;
    border: 1px solid #e0d7cf;
    border-radius: 14px;
    padding: 12px 16px;
}

.palette-header {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.size-palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    gap: 7px;
}

.size-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 7px 4px;
    min-height: 46px;
    border-radius: 10px;
    border: 2px solid rgba(62, 39, 35, 0.18);
    cursor: pointer;
    transition: all 0.16s ease;
    color: #3e2723;
    user-select: none;
}

.size-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.size-chip.active {
    border-color: #d81b60;
    box-shadow: 0 0 0 3px rgba(216, 27, 96, 0.25);
    transform: translateY(-2px) scale(1.03);
}

.size-chip-main {
    font-size: 0.88rem;
    font-weight: 800;
    line-height: 1.15;
}

.size-chip-area {
    font-size: 0.69rem;
    opacity: 0.82;
    margin-top: 2px;
}

/* 底部动作控制栏 */
.action-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-action {
    padding: 10px 18px;
    min-height: 42px;
    border-radius: 12px;
    font-size: 0.93rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.btn-undo { background: #eceff1; color: #37474f; }
.btn-undo:hover { background: #cfd8dc; transform: translateY(-2px); }
.btn-reset { background: #fff3e0; color: #e65100; }
.btn-reset:hover { background: #ffe0b2; transform: translateY(-2px); }
.btn-hint { background: #ede7f6; color: #4a148c; }
.btn-hint:hover { background: #d1c4e9; transform: translateY(-2px); }
.btn-demo { background: #e8eaf6; color: #1a237e; }
.btn-demo:hover { background: #c5cae9; transform: translateY(-2px); }

/* 吉祥物伴学栏 */
.mascot-section {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #faf7f2;
    border: 1px solid #e8dfd8;
    border-radius: 14px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
}

.mascot-avatar {
    font-size: 2rem;
    line-height: 1;
}

.mascot-speech {
    font-size: 0.9rem;
    color: #4e342e;
    line-height: 1.5;
    flex: 1;
}

/* ======================== 平板端适配 (iPad / 720px ~ 1024px) ======================== */
@media (max-width: 1024px) {
    .game-container {
        padding: 18px;
    }
    .size-palette {
        grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
    }
}

/* ======================== 手机端深度适配 (<= 680px) ======================== */
@media (max-width: 680px) {
    body {
        padding: 6px 6px max(16px, env(safe-area-inset-bottom));
    }
    .game-container {
        padding: 12px;
        border-radius: 14px;
        gap: 11px;
    }
    .header-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding-bottom: 10px;
    }
    .header-tools {
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
    }
    .dual-face-bar {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .face-card {
        padding: 9px 12px;
    }
    .btn-tool {
        padding: 7px 10px;
        font-size: 0.82rem;
        flex: 0 0 auto;
    }
    .size-selector-bar {
        padding: 9px 10px;
        gap: 8px;
    }
    .size-quick-pills {
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
    }
    .zoom-controls {
        width: 100%;
        justify-content: center;
    }
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .stat-item {
        padding: 8px;
    }
    .size-palette {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
        max-height: 180px;
        overflow-y: auto;
        padding-right: 2px;
    }
    .size-chip {
        min-height: 44px;
        padding: 5px 2px;
    }
    .size-chip-main {
        font-size: 0.82rem;
    }
    .action-controls {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .btn-action {
        width: 100%;
        padding: 10px 8px;
        font-size: 0.88rem;
    }
    .mascot-section {
        padding: 10px 12px;
    }
    .mascot-speech {
        font-size: 0.84rem;
    }
}
