/* ========== 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6c5ce7;
    --primary-light: #a29bfe;
    --primary-dark: #4834d4;
    --secondary: #00cec9;
    --accent: #fdcb6e;
    --danger: #e17055;
    --success: #00b894;
    --bg-dark: #0f0e17;
    --bg-card: #1a1932;
    --bg-card-hover: #252347;
    --text-main: #f5f6fa;
    --text-muted: #a0a0b8;
    --border-radius: 16px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(108, 92, 231, 0.4);
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
    user-select: none;
}

/* ========== 屏幕管理 ========== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.screen.active {
    display: flex;
}

/* ========== 背景动画 ========== */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 206, 201, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(253, 203, 110, 0.08) 0%, transparent 50%);
    z-index: 0;
    pointer-events: none;
}

/* ========== 开始界面 ========== */
#start-screen {
    flex-direction: column;
    padding: 20px;
}

.floating-shapes {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.shape {
    position: absolute;
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.06);
    font-weight: bold;
    animation: float-shape linear infinite;
}

.shape-1 { top: 10%; left: 5%; animation-duration: 15s; font-size: 3rem; }
.shape-2 { top: 70%; left: 85%; animation-duration: 20s; font-size: 2.5rem; }
.shape-3 { top: 40%; left: 90%; animation-duration: 18s; font-size: 2rem; }
.shape-4 { top: 80%; left: 10%; animation-duration: 22s; font-size: 3.5rem; }
.shape-5 { top: 20%; left: 75%; animation-duration: 16s; font-size: 2.2rem; }
.shape-6 { top: 60%; left: 50%; animation-duration: 25s; font-size: 2.8rem; }
.shape-7 { top: 15%; left: 40%; animation-duration: 19s; font-size: 3rem; }
.shape-8 { top: 85%; left: 60%; animation-duration: 17s; font-size: 2.4rem; }

@keyframes float-shape {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.06; }
    25% { transform: translateY(-30px) rotate(90deg); opacity: 0.12; }
    50% { transform: translateY(-60px) rotate(180deg); opacity: 0.06; }
    75% { transform: translateY(-30px) rotate(270deg); opacity: 0.12; }
}

.start-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 700px;
    width: 100%;
}

.game-title {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: title-glow 2s ease-in-out infinite;
}

@keyframes title-glow {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(108, 92, 231, 0.3)); }
    50% { filter: drop-shadow(0 0 25px rgba(108, 92, 231, 0.6)); }
}

.title-icon {
    display: inline-block;
    -webkit-text-fill-color: initial;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.game-subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 40px;
}

/* 难度选择 */
.difficulty-selector, .mode-selector {
    margin-bottom: 30px;
}

.difficulty-selector h3, .mode-selector h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.difficulty-buttons, .mode-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.diff-btn, .mode-btn {
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 18px 20px;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 110px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.diff-btn::before, .mode-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transition: left 0.5s;
}

.diff-btn:hover::before, .mode-btn:hover::before {
    left: 100%;
}

.diff-btn:hover, .mode-btn:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

.diff-btn.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

.mode-btn.active {
    border-color: var(--secondary);
    background: linear-gradient(135deg, rgba(0, 206, 201, 0.2), rgba(0, 206, 201, 0.1));
    transform: translateY(-3px);
    box-shadow: 0 0 20px rgba(0, 206, 201, 0.3);
}

.diff-icon, .mode-icon {
    font-size: 1.8rem;
}

.diff-name, .mode-name {
    font-weight: 700;
    font-size: 1rem;
}

.diff-desc, .mode-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 开始按钮 */
.start-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    border-radius: 50px;
    padding: 18px 60px;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px auto 0;
    transition: all 0.3s;
    opacity: 0.5;
    pointer-events: none;
}

.start-btn:not(:disabled) {
    opacity: 1;
    pointer-events: all;
    animation: pulse-btn 2s infinite;
}

@keyframes pulse-btn {
    0%, 100% { box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(108, 92, 231, 0.7); }
}

.start-btn:not(:disabled):hover {
    transform: scale(1.05);
}

.btn-arrow {
    transition: transform 0.3s;
}

.start-btn:hover .btn-arrow {
    transform: translateX(5px);
}

/* ========== 游戏界面 ========== */
#game-screen {
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 30px;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 900px;
    margin-bottom: 20px;
}

.header-left {
    display: flex;
    gap: 15px;
}

.score-box, .combo-box {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 10px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-label, .combo-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-box span:last-child, .combo-box span:last-child {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent);
}

.combo-box span:last-child {
    color: var(--secondary);
}

/* 计时器 */
.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-circle {
    position: relative;
    width: 80px;
    height: 80px;
}

.timer-svg {
    width: 80px;
    height: 80px;
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 6;
}

.timer-progress {
    fill: none;
    stroke: var(--primary);
    stroke-width: 6;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear, stroke 0.3s;
}

.timer-circle span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 800;
}

.timer-circle.warning .timer-progress {
    stroke: var(--danger);
    animation: timer-pulse 0.5s infinite;
}

@keyframes timer-pulse {
    0%, 100% { filter: drop-shadow(0 0 5px var(--danger)); }
    50% { filter: drop-shadow(0 0 15px var(--danger)); }
}

.header-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.level-badge {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.quit-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.quit-btn:hover {
    background: rgba(225, 112, 85, 0.2);
    border-color: var(--danger);
    color: var(--danger);
}

/* 游戏主体 */
.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 700px;
}

.question-area {
    text-align: center;
    margin-bottom: 30px;
}

.question-number {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.question-display {
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: 3px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px 40px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.question-display .num {
    color: var(--text-main);
}

.question-display .operator {
    color: var(--primary-light);
    margin: 0 15px;
    font-size: 3.5rem;
}

.question-display .equals {
    color: var(--text-muted);
    margin: 0 15px;
}

.question-display .blank {
    display: inline-block;
    width: 80px;
    height: 5px;
    background: var(--primary);
    border-radius: 3px;
    vertical-align: middle;
    margin: 0 10px;
    animation: blank-pulse 1.5s infinite;
}

@keyframes blank-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 5px var(--primary); }
    50% { opacity: 0.5; box-shadow: 0 0 15px var(--primary); }
}

/* 答题区域 */
.answer-area {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
}

.answer-input {
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px 30px;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    text-align: center;
    width: 200px;
    outline: none;
    transition: all 0.3s;
    font-family: inherit;
}

.answer-input:focus {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.answer-input.correct {
    border-color: var(--success);
    box-shadow: 0 0 20px rgba(0, 184, 148, 0.4);
    animation: correct-shake 0.4s ease;
}

.answer-input.wrong {
    border-color: var(--danger);
    box-shadow: 0 0 20px rgba(225, 112, 85, 0.4);
    animation: wrong-shake 0.4s ease;
}

@keyframes correct-shake {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes wrong-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.submit-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    border-radius: 12px;
    padding: 15px 25px;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.submit-btn:hover {
    transform: scale(1.05);
}

.btn-key {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* 反馈区域 */
.feedback-area {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.feedback-area .fb-correct {
    color: var(--success);
    animation: fadeUp 0.5s ease;
}

.feedback-area .fb-wrong {
    color: var(--danger);
    animation: fadeUp 0.5s ease;
}

.feedback-area .fb-combo {
    color: var(--accent);
    animation: fadeUp 0.5s ease;
}

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

/* 选择题选项 */
.quick-answers {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
}

.quick-answer-btn {
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 24px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 70px;
}

.quick-answer-btn:hover {
    border-color: var(--primary);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

.quick-answer-btn.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

/* 游戏底部 */
.game-footer {
    width: 100%;
    max-width: 700px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s;
}

.stats-row {
    display: flex;
    justify-content: space-around;
    gap: 10px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.stat-item span:last-child {
    color: var(--text-main);
    font-weight: 700;
}

/* ========== 结算界面 ========== */
#result-screen {
    flex-direction: column;
}

.result-content {
    text-align: center;
    max-width: 600px;
    padding: 40px;
    background: var(--bg-card);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow);
    animation: result-appear 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes result-appear {
    from { opacity: 0; transform: scale(0.8) translateY(30px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.result-emoji {
    font-size: 5rem;
    margin-bottom: 10px;
    animation: bounce 1s ease infinite;
}

.result-title {
    font-size: 2rem;
    margin-bottom: 10px;
}

.result-rank {
    font-size: 3.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent), var(--danger));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 30px;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.result-stat-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.rs-icon {
    font-size: 1.5rem;
}

.rs-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent);
}

.rs-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.result-achievements {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 30px;
    min-height: 40px;
}

.achievement-badge {
    background: linear-gradient(135deg, rgba(253, 203, 110, 0.2), rgba(253, 203, 110, 0.1));
    border: 1px solid var(--accent);
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 0.85rem;
    color: var(--accent);
    animation: fadeUp 0.5s ease;
}

.result-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.result-btn {
    border: none;
    border-radius: 12px;
    padding: 14px 30px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    color: white;
}

.result-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.result-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.result-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* ========== 粒子效果 ========== */
.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: particle-fall linear forwards;
}

@keyframes particle-fall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg) scale(0);
    }
}

/* 屏幕闪烁 */
.flash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 998;
    opacity: 0;
}

.flash-overlay.flash-green {
    background: rgba(0, 184, 148, 0.15);
    animation: flash-anim 0.4s ease;
}

.flash-overlay.flash-red {
    background: rgba(225, 112, 85, 0.15);
    animation: flash-anim 0.4s ease;
}

@keyframes flash-anim {
    0% { opacity: 0; }
    30% { opacity: 1; }
    100% { opacity: 0; }
}

/* ========== 连击特效 ========== */
.combo-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    font-weight: 900;
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent);
    pointer-events: none;
    z-index: 997;
    animation: combo-popup-anim 1s ease forwards;
}

@keyframes combo-popup-anim {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    30% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(0.8); }
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
    }
    
    .question-display {
        font-size: 2.5rem;
        padding: 15px 20px;
    }
    
    .answer-input {
        width: 150px;
        font-size: 1.5rem;
        padding: 12px 20px;
    }
    
    .diff-btn, .mode-btn {
        min-width: 80px;
        padding: 12px 15px;
    }
    
    .diff-icon, .mode-icon {
        font-size: 1.3rem;
    }
    
    .result-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-row {
        flex-wrap: wrap;
    }
    
    .game-header {
        flex-wrap: wrap;
        gap: 10px;
    }
}
