/**
 * 系统名称：ITeacherPlatform
 * 开发公司：斯帝姆智能科技有限公司
 * 程序名：game-design-system.css
 * 功能描述：思维训练中心共享设计系统 - 字体/配色/动效/氛围背景/组件样式
 *           面向中小学生，活泼友好的视觉风格，3D立体卡片 + 渐变氛围
 * 版本号：v1.0.0
 * 修订历史：
 *   - v1.0.0 (2026-05-31)：初始版本
 */

/* ===== 字体导入 ===== */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Nunito:wght@400;600;700;800&display=swap');

/* ===== 设计变量 ===== */
:root {
    /* 主色 - 靛蓝系（友好但不幼稚）*/
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-glow: rgba(99, 102, 241, 0.35);

    /* 强调色 - 琥珀（温暖、能量感）*/
    --accent: #f59e0b;
    --accent-dark: #d97706;
    --accent-glow: rgba(245, 158, 11, 0.4);

    /* 语义色 */
    --success: #10b981;
    --success-dark: #059669;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --info: #06b6d4;

    /* 背景色系 */
    --bg-base: #eef2ff;
    --bg-soft: #f5f3ff;
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.75);

    /* 文字色系 */
    --text-primary: #1e1b4b;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --text-on-primary: #ffffff;

    /* 阴影系统 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(99, 102, 241, 0.15);
    --shadow-lg: 0 8px 24px rgba(99, 102, 241, 0.2);
    --shadow-xl: 0 16px 40px rgba(99, 102, 241, 0.25);
    --shadow-glow: 0 0 20px var(--primary-glow);
    --shadow-accent: 0 4px 16px var(--accent-glow);

    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;

    /* 字体 */
    --font-display: 'Fredoka', sans-serif;
    --font-body: 'Nunito', sans-serif;

    /* 过渡 */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== 基础重置 ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-body);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ===== 氛围背景 - 渐变 + 圆点纹理 ===== */
body.game-page {
    overflow: hidden;
    background: var(--bg-base);
    position: relative;
}

body.game-page::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 15% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(245, 158, 11, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

body.game-page::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle, rgba(99, 102, 241, 0.08) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
    z-index: 0;
}

/* ===== 主内容布局 ===== */
.game-main {
    position: relative;
    z-index: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 10px 16px;
    overflow: hidden;
}

/* ===== 顶部工具栏 - 玻璃态卡片 ===== */
.game-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 18px;
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
    animation: slideDown 0.5s ease;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

/* 返回按钮 */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--surface);
    color: var(--primary);
    text-decoration: none;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 700;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    border: 2px solid transparent;
}

.btn-back:hover {
    background: var(--primary);
    color: var(--text-on-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* 游戏标题 */
.game-name {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

/* 玩法按钮 */
.btn-help {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border: none;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--info), #0891b2);
    color: white;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.3);
}

.btn-help:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
}

/* ===== 难度按钮组 - 胶囊按钮 ===== */
.difficulty-pills {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.pill-btn {
    padding: 7px 18px;
    border: 2px solid var(--primary);
    border-radius: var(--radius-full);
    background: var(--surface);
    color: var(--primary);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-bounce);
    position: relative;
    overflow: hidden;
}

.pill-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    opacity: 0;
    transition: var(--transition);
    z-index: -1;
}

.pill-btn:hover:not(:disabled) {
    color: white;
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-md);
}

.pill-btn:hover:not(:disabled)::before {
    opacity: 1;
}

.pill-btn.active {
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-glow);
}

.pill-btn:disabled {
    border-color: var(--text-light);
    color: var(--text-light);
    cursor: not-allowed;
    opacity: 0.4;
}

/* ===== 状态栏 ===== */
.status-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 8px 12px;
    margin-top: 8px;
    flex-shrink: 0;
    animation: fadeIn 0.6s ease 0.1s both;
}

/* 计时器 - 玻璃态胶囊 */
.timer-display {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--surface-glass);
    backdrop-filter: blur(8px);
    padding: 8px 22px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: var(--shadow-sm);
}

.timer-display span {
    color: var(--primary);
    font-family: 'Courier New', monospace;
    font-size: 1.05rem;
    min-width: 90px;
    text-align: right;
}

/* 进度条容器 */
.progress-wrapper {
    flex: 1;
    max-width: 400px;
}

/* ===== 游戏区域 - 居中、弹性 ===== */
.game-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* safe center：内容小于容器时居中，溢出时回退 flex-start，避免顶部被裁剪无法滚动 */
    justify-content: safe center;
    min-height: 0;
    /* 方格溢出时在 stage 内滚动，避免延伸到下方按钮区域 */
    overflow-y: auto;
    padding: 8px 0;
    animation: fadeIn 0.6s ease 0.2s both;
}

/* ===== 开始按钮 - 超大、醒目、3D ===== */
.btn-start {
    flex-shrink: 0;
    padding: 14px 56px;
    border: none;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent), #fb923c);
    color: white;
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition-bounce);
    box-shadow:
        0 6px 0 var(--accent-dark),
        0 8px 24px var(--accent-glow);
    position: relative;
    margin-top: 8px;
    letter-spacing: 2px;
}

.btn-start:hover {
    transform: translateY(-4px);
    box-shadow:
        0 10px 0 var(--accent-dark),
        0 12px 32px var(--accent-glow);
}

.btn-start:active {
    transform: translateY(4px);
    box-shadow:
        0 2px 0 var(--accent-dark),
        0 4px 12px var(--accent-glow);
}

/* ===== 玩法说明弹窗 ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 27, 75, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    display: block;
    opacity: 1;
}

.modal-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 28px 32px;
    max-width: 480px;
    width: 90%;
    z-index: 10000;
    display: none;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-card.show {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.modal-card h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 16px;
}

.modal-card ul {
    padding-left: 20px;
    font-size: 0.92rem;
    line-height: 2;
    color: var(--text-secondary);
}

.modal-card ul strong {
    color: var(--text-primary);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--bg-base);
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--danger);
    color: white;
    transform: rotate(90deg);
}

/* ===== 结果折叠区 ===== */
.results-toggle {
    text-align: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary);
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
    transition: var(--transition);
    user-select: none;
}

.results-toggle:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.results-panel {
    flex-shrink: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    background: var(--surface-glass);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-md);
    margin-top: 4px;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.results-panel.show {
    max-height: 140px;
    overflow-y: auto;
    padding: 10px 16px;
    box-shadow: var(--shadow-sm);
}

.results-panel h3 {
    margin: 0 0 6px 0;
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--text-primary);
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.result-row:last-child {
    border-bottom: none;
}

/* ===== 动画 ===== */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.5); }
    50% { transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes floatY {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .game-main { padding: 8px 10px; }

    .game-toolbar {
        flex-direction: column;
        gap: 8px;
        padding: 8px 12px;
    }

    .toolbar-left { justify-content: center; }
    .game-name { font-size: 1.15rem; }

    .pill-btn { padding: 6px 12px; font-size: 0.75rem; }
    .timer-display { font-size: 1rem; padding: 6px 16px; }
    .timer-display span { min-width: 70px; }

    .btn-start { padding: 12px 40px; font-size: 1.1rem; }
}

@media (max-width: 480px) {
    .game-name { font-size: 1rem; }
    .difficulty-pills { justify-content: center; }
    .btn-help span, .btn-back span { display: none; }
}
