/* ====== 基础重置 ====== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f172a;
    color: #f1f5f9;
    /* 关键：body需要设置为flex才能让Grid正常工作 */
    display: flex;
    flex-direction: column;
}

/* ====== Grid主容器 ====== */
.app-container {
    flex: 1; /* 占据所有可用空间 */
    display: grid;
    /* 三行布局: 固定 | 自动伸展 | 固定 */
    grid-template-rows: auto 1fr auto;
    grid-template-areas: 
        "header"
        "main"
        "quiz";
    height: 100%;
    min-height: 0; /* 关键！允许内部元素溢出 */
}

/* ====== 顶部横幅 ====== */
.app-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 70px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-bottom: 2px solid #475569;
    flex-shrink: 0;
}

.header-title h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.highlight {
    color: #f97316;
}

.subtitle {
    font-size: 0.875rem;
    color: #94a3b8;
    margin-top: 0.25rem;
}

/* ====== 按钮样式 ====== */
.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #f1f5f9;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* ====== Canvas主区域 ====== */
.canvas-main {
    grid-area: main;
    position: relative;
    background: #0f172a;
    /* 关键：设置最小高度为0，允许缩小 */
    min-height: 0;
}

#renderCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    padding: 2rem;
}

.overlay-icon {
    font-size: 3rem;
    color: #f97316;
    margin-bottom: 1rem;
}

/* ====== 问答区域 ====== */
.quiz-section {
    grid-area: quiz;
    height: 300px; /* 固定高度 */
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-top: 2px solid #475569;
    display: flex;
    flex-direction: column;
    flex-shrink: 0; /* 禁止收缩 */
}

.quiz-header {
    height: 60px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(30, 41, 59, 0.95);
    border-bottom: 1px solid #475569;
    flex-shrink: 0;
}

.quiz-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto; /* 关键：内容太多时内部滚动 */
    min-height: 0; /* 关键！允许内容溢出 */
}

/* 问答区域折叠状态 */
.quiz-section.collapsed {
    height: 60px;
}

.quiz-section.collapsed .quiz-content {
    display: none;
}

.quiz-toggle.expanded span {
    transform: rotate(180deg);
    display: inline-block;
}

/* ====== 通用样式 ====== */
.btn {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

/* ====== 响应式设计 ====== */
@media (max-width: 768px) {
    .app-header {
        height: 60px;
        padding: 0 0.75rem;
    }
    
    .header-title h1 {
        font-size: 1.25rem;
    }
    
    .quiz-section {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .app-header {
        height: 55px;
    }
    
    .quiz-section {
        height: 220px;
    }
    
    .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}

/* ====== 滚动条样式 ====== */
.quiz-content::-webkit-scrollbar {
    width: 6px;
}

.quiz-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.quiz-content::-webkit-scrollbar-thumb {
    background: #f97316;
    border-radius: 3px;
}

/* ====== 辅助类 ====== */
.text-center {
    text-align: center;
}
/* ====== 问答游戏专用样式 ====== */
.q-btn {
    display: block;
    width: 100%;
    margin: 8px 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #475569;
    border-radius: 8px;
    color: #f1f5f9;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.q-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #64748b;
}

/* 正确/错误状态 */
.q-btn.correct {
    background: rgba(34, 197, 94, 0.2);
    border-color: #16a34a;
}

.q-btn.incorrect {
    background: rgba(239, 68, 68, 0.2);
    border-color: #dc2626;
}