:root {
    --primary-color: #4A90E2;
    --primary-hover: #357ABD;
    --success-color: #66BB6A;
    --warning-color: #FFA726;
    --error-color: #EF5350;
    --bg-color: #F5F7FA;
    --text-color: #2C3E50;
    --text-secondary: #7F8C8D;
    --card-bg: #FFFFFF;
    --border-radius: 12px;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden; /* 强制一屏 */
    line-height: 1.5;
}

.container {
    max-width: 1100px; /* 加宽以适应横屏布局 */
    width: 95%;
    height: 95vh;
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 内部滚动 */
}

header {
    text-align: center;
    margin-bottom: 10px;
    border-bottom: 1px solid #EEE;
    padding-bottom: 10px;
    flex-shrink: 0;
}

h1 {
    color: var(--text-color);
    font-size: 1.5em;
    font-weight: 700;
    margin: 0 0 10px 0;
    letter-spacing: -0.5px;
}

h2 {
    color: var(--text-color);
    font-weight: 600;
    font-size: 1.2em;
    margin: 0 0 10px 0;
}

h3 {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 1em;
    margin: 0 0 10px 0;
}

/* 进度条 */
.progress-bar {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 5px;
}

.step {
    padding: 5px 15px;
    border-radius: 15px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.8em;
    background: #F0F2F5;
    transition: all 0.3s ease;
    cursor: pointer; /* 增加手型光标 */
}

.step:hover {
    background: #E3F2FD;
    color: var(--primary-color);
}

.step.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* 任务区域通用样式 */
.task-section {
    display: none;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
    width: 100%;
    overflow: hidden; /* 禁止整体滚动，改用内部滚动 */
    padding: 10px 0;
}

.task-section.active {
    display: flex;
    animation: fadeIn 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.instruction {
    text-align: center;
    margin-bottom: 15px;
    max-width: 800px;
    flex-shrink: 0;
}

.instruction p {
    color: var(--text-secondary);
    font-size: 1em;
    margin: 5px 0;
}

.next-btn {
    margin-top: 15px; /* 增加上边距 */
    padding: 10px 30px;
    font-size: 1em;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    font-weight: 600;
    flex-shrink: 0;
    margin-bottom: 5px;
}

.next-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.next-btn:active {
    transform: translateY(0);
}

.hidden {
    display: none !important;
}

/* 任务一：拖拽 */
.game-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    flex: 1;
    min-height: 0; /* 允许 Flex 子项收缩 */
}

/* 默认（竖屏）布局 */
.animals-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    min-height: 0;
    padding: 10px;
    background: #F8F9FA;
    border-radius: var(--border-radius);
    border: 2px dashed #E0E0E0;
    flex: 1; /* 撑开高度 */
    overflow-y: auto; /* 内部滚动 */
    width: 100%; /* 确保宽度 */
}

.drop-zones {
    display: flex;
    gap: 15px;
    justify-content: space-around;
    flex: 1;
    min-height: 0;
}

/* 平板/桌面横屏适配 */
@media (min-width: 768px) and (orientation: landscape) {
    .game-area {
        flex-direction: row;
        align-items: stretch;
    }

    .animals-container {
        width: 220px;
        flex: none; /* 重置 flex 属性，防止被撑开 */
        flex-direction: column; /* 侧边栏模式 */
        flex-wrap: nowrap;
        overflow-y: auto;
        justify-content: flex-start;
        align-items: center;
        min-height: 0;
        border-right: 2px dashed #E0E0E0;
        border-bottom: none;
        margin-right: 5px;
    }

    .drop-zones {
        flex: 1;
        gap: 20px;
    }
}

.animal-card {
    width: 90px;
    height: 110px;
    background: white;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
    text-align: center;
    transition: all 0.2s ease;
    padding: 8px;
    box-shadow: var(--shadow-sm);
    border: 1px solid transparent;
    flex-shrink: 0;
}

.animal-card img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    pointer-events: none;
    margin-bottom: 5px;
}

.animal-card span {
    font-size: 0.85em;
    color: var(--text-color);
    font-weight: 600;
}

.animal-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.animal-card:active {
    cursor: grabbing;
}

.drop-zone {
    flex: 1;
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    transition: all 0.3s ease;
    background-color: #FAFAFA;
    border: 2px solid #EEE;
    overflow-y: auto; /* 允许篮子内部滚动 */
}

.drop-zone h3 {
    margin-top: 5px;
    margin-bottom: 10px;
    font-size: 1em;
}

.vertebrate-zone {
    border-color: #BBDEFB;
    background-color: rgba(225, 245, 254, 0.3);
}

.invertebrate-zone {
    border-color: #C8E6C9;
    background-color: rgba(232, 245, 233, 0.3);
}

.drop-zone.drag-over {
    background-color: #FFF9C4;
    transform: scale(1.01);
    border-color: var(--warning-color);
}

.animal-card-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
    justify-items: center;
    align-content: start; /* 从上开始排 */
}

.animal-card-container .animal-card {
    width: 70px;
    height: 90px;
    transform: none;
    margin: 0;
    box-shadow: none;
    border: 1px solid #EEE;
}

.animal-card-container .animal-card img {
    width: 45px;
    height: 45px;
}

.animal-card-container .animal-card span {
    font-size: 0.75em;
}

/* 任务二：3D */
.thumbnails-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    flex: 1;
    align-items: center;
}

.thumbnail-card {
    width: 160px;
    height: 200px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #EEE;
}

.thumbnail-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.thumbnail-card img {
    width: 120px;
    height: 120px;
    object-fit: contain;
}

.thumbnail-label {
    margin-top: 15px;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-color);
}

/* 3D 模态框 */
.model-content {
    width: 95%;
    max-width: 1000px;
    height: 90vh; /* 增加高度占比 */
    padding: 0;
    background: #1a1a1a;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
}

.model-wrapper {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
    background: radial-gradient(circle at center, #2c3e50 0%, #000000 100%);
}

model-viewer {
    width: 100%;
    height: 100%;
    --poster-color: transparent;
}

.model-hint {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    padding: 8px 20px;
    border-radius: 30px;
    pointer-events: none;
    font-size: 0.9em;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255,255,255,0.2);
}

/* 任务三：Canvas */
.task3-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    flex: 1;
    min-height: 0;
    gap: 15px;
    align-items: center;
}

.group-input {
    display: flex;
    align-items: center;
    margin-left: 20px;
}

.group-input label {
    font-weight: 600;
    margin-right: 10px;
    color: var(--text-color);
    white-space: nowrap;
}

.group-input select {
    font-size: 1em;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #DDD;
    background: white;
    cursor: pointer;
    outline: none;
}

.image-selector {
    width: 100%;
    max-width: 700px;
    flex-shrink: 0;
}

.image-selector h3 {
    text-align: center;
    margin-bottom: 10px;
}

.upload-progress {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-bottom: 10px;
}

.selector-images {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.selector-card {
    width: 80px;
    padding: 5px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    background: #F8F9FA;
}

.selector-card:hover {
    background: #FFF;
    box-shadow: var(--shadow-sm);
}

.selector-card.active {
    border-color: var(--primary-color);
    background: #E3F2FD;
}

.selector-card img {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.selector-card span {
    display: block;
    margin-top: 2px;
    font-size: 0.8em;
    font-weight: 600;
}

.canvas-container {
    flex: 2;
    background: #FAFAFA;
    border-radius: var(--border-radius);
    border: 2px solid #EEE;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 400px;
    padding: 20px; /* 增加内边距 */
}

/* 平板/桌面横屏适配 Task 3 */
@media (min-width: 768px) and (orientation: landscape) {
    .task3-layout {
        flex-direction: row;
        align-items: stretch;
    }

    .image-selector {
        width: 140px; /* 侧边栏宽度 */
        max-width: none;
        display: flex;
        flex-direction: column;
        border-right: 2px dashed #E0E0E0;
        padding-right: 15px;
        margin-right: 5px;
        overflow-y: auto;
        justify-content: flex-start;
    }

    .selector-images {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .selector-card {
        width: 100%;
    }
    
    .canvas-container {
        max-width: none; /* 取消最大宽度限制 */
        flex: 1;
        height: auto;
    }
}

.canvas-wrapper {
    position: relative;
    width: 800px;  /* 固定宽度 */
    height: 400px; /* 固定高度 */
    max-width: 100%;
    max-height: 100%;
    background-color: white; /* 画布背景色 */
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); /* 画布阴影 */
    border-radius: 4px;
}

.canvas-bg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 1; /* 去掉蒙层，改为完全不透明 */
    display: none;
}

#drawingCanvas {
    position: absolute;
    top: 0;
    left: 0;
    touch-action: none;
    z-index: 2;
    width: 100%;
    height: 100%;
}

.canvas-overlay-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
    font-size: 1.2em;
    z-index: 1;
    pointer-events: none;
    font-weight: 500;
}

.tools {
    display: flex;
    gap: 10px;
    z-index: 3;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(5px);
    padding: 6px 12px;
    border-radius: 40px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(0,0,0,0.05);
}

.bottom-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 15px;
    width: 100%;
}

.tool-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid white;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.tool-btn:hover {
    transform: scale(1.1);
}

.clear-btn {
    width: auto;
    height: 32px;
    padding: 0 15px;
    border-radius: 16px;
    background: white;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.8em;
    display: flex;
    align-items: center;
    border: 1px solid #EEE;
}

.clear-btn:hover {
    background: #F8F9FA;
}

.submit-btn {
    margin-top: 0;
    padding: 10px 40px;
    font-size: 1.1em;
    background-color: var(--success-color);
    color: white;
    border: none;
    border-radius: 40px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.2s;
    font-weight: 600;
    flex-shrink: 0;
}

.submit-btn:hover {
    background-color: #57A65B;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    background-color: #CCC;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    max-width: 90%;
    text-align: center;
    position: relative;
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* 小组选择弹窗样式 */
.group-content {
    width: 600px;
    max-width: 95%;
}

.group-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 20px;
    margin-bottom: 25px;
}

.group-btn {
    padding: 15px 5px;
    font-size: 1.1em;
    font-weight: 700;
    color: var(--primary-color);
    background: #E3F2FD;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.group-btn:hover {
    background: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.group-btn.selected {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-md);
    transform: scale(1.05);
}

.confirm-btn {
    padding: 12px 50px;
    font-size: 1.2em;
    background-color: var(--success-color);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.2s;
    font-weight: 600;
}

.confirm-btn:disabled {
    background-color: #CCC;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.confirm-btn:not(:disabled):hover {
    background-color: #57A65B;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.current-group {
    font-weight: 600;
    color: var(--primary-color);
    background: #E3F2FD;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    margin-left: 10px;
}


.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    z-index: 10;
    transition: color 0.2s;
}

.close:hover {
    color: var(--text-color);
}

/* 反馈弹窗样式 */
.feedback-content {
    min-width: 300px;
}

#feedbackIcon {
    font-size: 4em;
    margin-bottom: 15px;
    line-height: 1;
}

#feedbackTitle {
    margin: 0 0 10px 0;
    font-size: 1.3em;
}

#feedbackMessage {
    color: var(--text-secondary);
    margin: 0;
    font-size: 1em;
}
