* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    animation: fadeInDown 0.6s ease;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* 导航栏 */
.main-nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    animation: fadeIn 0.8s ease;
}

.nav-btn {
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.nav-btn.active {
    background: white;
    color: #667eea;
    border-color: white;
}

/* 姓名输入框 */
.setup-input {
    width: 100%;
    padding: 12px 15px;
    font-size: 1.1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.setup-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 统计栏 */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    animation: fadeIn 0.8s ease;
}

.stat-item {
    background: white;
    padding: 15px 25px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    text-align: center;
    min-width: 100px;
    transition: transform 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-3px);
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

/* 模式选择 */
.mode-selection {
    animation: fadeIn 1s ease;
}

.mode-selection h2 {
    text-align: center;
    color: white;
    font-size: 1.8rem;
    margin-bottom: 25px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    padding: 10px;
}

.mode-card {
    background: white;
    border-radius: 20px;
    padding: 25px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.mode-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.mode-card:hover::before {
    transform: scaleX(1);
}

.mode-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.mode-card:active {
    transform: translateY(-4px);
}

.mode-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.mode-card h3 {
    color: #333;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.mode-card p {
    color: #888;
    font-size: 0.85rem;
}

.mode-card.special {
    background: linear-gradient(135deg, #fff5e6 0%, #ffe6f0 100%);
    border: 2px dashed #ff9800;
}

.mode-card.special:hover {
    border-style: solid;
    border-color: #ff5722;
}

/* 游戏区域 */
.game-area {
    animation: fadeIn 0.5s ease;
}

.question-card {
    background: white;
    border-radius: 25px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    margin-bottom: 25px;
    position: relative;
}

.mode-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.question-text {
    font-size: 3rem;
    font-weight: bold;
    color: #333;
    margin: 20px 0;
    letter-spacing: 2px;
}

.timer-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin: 20px 0 10px;
}

.timer-progress {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 4px;
    transition: width 1s linear, background-color 0.3s;
    width: 100%;
}

.timer-progress.warning {
    background: linear-gradient(90deg, #FF9800, #FFC107);
}

.timer-progress.danger {
    background: linear-gradient(90deg, #F44336, #FF5722);
}

.timer-text {
    color: #666;
    font-size: 1rem;
}

/* 答案区域 */
.answer-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.answer-input {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    padding: 15px 25px;
    font-size: 1.5rem;
    border: 3px solid #e0e0e0;
    border-radius: 15px;
    outline: none;
    transition: all 0.3s ease;
    text-align: center;
}

.answer-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.2);
}

.btn {
    padding: 15px 35px;
    font-size: 1.1rem;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #4CAF50, #8BC34A);
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.btn-back {
    background: #f5f5f5;
    color: #666;
}

.btn-back:hover {
    background: #e0e0e0;
}

/* 反馈信息 */
.feedback {
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    padding: 20px;
    border-radius: 15px;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.feedback.correct {
    background: rgba(76, 175, 80, 0.2);
    color: #2E7D32;
    animation: bounceIn 0.5s ease;
}

.feedback.wrong {
    background: rgba(244, 67, 54, 0.2);
    color: #C62828;
    animation: shake 0.5s ease;
}

.feedback.timeout {
    background: rgba(255, 152, 0, 0.2);
    color: #E65100;
    animation: pulse 0.5s ease;
}

/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-10px); }
    80% { transform: translateX(10px); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .mode-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
    }
    
    .mode-card {
        padding: 20px 10px;
    }
    
    .mode-icon {
        font-size: 2rem;
    }
    
    .question-text {
        font-size: 2rem;
    }
    
    .answer-input {
        font-size: 1.2rem;
        padding: 12px 20px;
    }
    
    .btn {
        padding: 12px 25px;
        font-size: 1rem;
    }
    
    .stats-bar {
        gap: 10px;
    }
    
    .stat-item {
        padding: 10px 15px;
        min-width: 80px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .mode-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .question-card {
        padding: 25px 15px;
    }
    
    .answer-section {
        padding: 20px 15px;
    }
}

/* 自定义面板样式 */
.custom-panel {
    background: white;
    border-radius: 25px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    animation: fadeIn 0.5s ease;
}

.custom-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.custom-header h2 {
    color: #333;
    font-size: 1.8rem;
    margin: 0;
}

.custom-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.setting-group label {
    font-size: 1.1rem;
    color: #555;
    font-weight: bold;
    min-width: 100px;
}

.setting-group select {
    padding: 10px 20px;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.setting-group select:focus {
    border-color: #667eea;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.2);
}

.setting-group select:hover {
    border-color: #667eea;
}

.number-settings, .operator-settings {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
}

.number-setting-item, .operator-setting-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.number-setting-item label, .operator-setting-item label {
    font-size: 1rem;
    color: #333;
    font-weight: bold;
    min-width: 100px;
}

.number-setting-item select, .operator-setting-item select {
    padding: 8px 15px;
    font-size: 0.95rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    flex: 1;
    max-width: 200px;
}

.number-setting-item select:focus, .operator-setting-item select:focus {
    border-color: #667eea;
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.2);
}

.setting-title {
    font-size: 1.2rem;
    color: #667eea;
    font-weight: bold;
    margin-bottom: 10px;
    padding-left: 10px;
    border-left: 4px solid #667eea;
}

#startCustomBtn {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    display: block;
}

@media (max-width: 768px) {
    .custom-panel {
        padding: 20px 15px;
    }
    
    .custom-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .custom-header h2 {
        font-size: 1.5rem;
    }
    
    .setting-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .setting-group label {
        min-width: auto;
    }
    
    .number-setting-item, .operator-setting-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .number-setting-item label, .operator-setting-item label {
        min-width: auto;
    }
    
    .number-setting-item select, .operator-setting-item select {
        max-width: none;
    }
}

/* 题号显示 */
.question-number {
    font-size: 1.1rem;
    color: #888;
    margin-bottom: 5px;
}

/* 结束挑战按钮 */
.btn-finish {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
}

.btn-finish:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.4);
}

/* 结果汇总页面 */
.result-area {
    animation: fadeIn 0.5s ease;
}

.result-header {
    background: white;
    border-radius: 20px;
    padding: 25px 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.result-header h2 {
    font-size: 1.8rem;
    color: #333;
    margin: 0;
}

.result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.result-summary {
    background: white;
    border-radius: 20px;
    padding: 25px 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
}

.summary-table th,
.summary-table td {
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
}

.summary-table th {
    background: #f8f9fa;
    font-weight: bold;
    color: #555;
    font-size: 1rem;
}

.summary-table td {
    font-size: 1.3rem;
    font-weight: bold;
    color: #667eea;
}

.summary-table td.good {
    color: #4CAF50;
}

.summary-table td.bad {
    color: #F44336;
}

.summary-row {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
}

.summary-item {
    text-align: center;
    padding: 15px 25px;
    border-radius: 15px;
    background: #f8f9fa;
    min-width: 120px;
}

.summary-item .summary-label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.summary-item .summary-value {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    color: #667eea;
}

.summary-item.good .summary-value { color: #4CAF50; }
.summary-item.bad .summary-value { color: #F44336; }

.result-list {
    background: white;
    border-radius: 20px;
    padding: 25px 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.result-list h3 {
    font-size: 1.3rem;
    color: #333;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
}

.result-table th,
.result-table td {
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
}

.result-table th {
    background: #f8f9fa;
    font-weight: bold;
    color: #555;
    font-size: 0.95rem;
}

.result-table td {
    font-size: 1rem;
    color: #333;
}

.result-table tr.correct-row td {
    background: #f1f8e9;
}

.result-table tr.wrong-row td {
    background: #fce4ec;
}

.result-table .status-correct {
    color: #4CAF50;
    font-weight: bold;
}

.result-table .status-wrong {
    color: #F44336;
    font-weight: bold;
}

.result-table .status-timeout {
    color: #FF9800;
    font-weight: bold;
}

.wrong-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
}

.wrong-section h3 {
    color: #F44336;
    border-bottom-color: #ffcdd2;
}

/* 打印样式 */
@media print {
    body {
        background: white !important;
        padding: 10px;
    }
    
    .stats-bar,
    .mode-selection,
    .custom-panel,
    .game-area,
    .result-actions,
    .main-nav,
    .ranking-area,
    .challenge-setup,
    #backBtn,
    #finishBtn {
        display: none !important;
    }
    
    .result-area {
        display: block !important;
    }
    
    .result-header {
        box-shadow: none;
        border: 1px solid #ddd;
        padding: 15px;
    }
    
    .result-header h2 {
        font-size: 1.5rem;
    }
    
    .result-summary {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .result-list {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .result-table th {
        background: #eee !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .result-table th,
    .result-table td {
        padding: 8px 10px;
        font-size: 0.9rem;
    }
    
    .result-table tbody tr:nth-child(odd) {
        background: #f9f9f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .result-table tbody tr:nth-child(even) {
        background: white !important;
    }
    
    .result-table tr.correct-row td {
        background: #f1f8e9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .result-table tr.wrong-row td {
        background: #fce4ec !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .summary-table {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .summary-table th,
    .summary-table td {
        padding: 8px 10px;
        font-size: 0.95rem;
    }
    
    .summary-table th {
        background: #eee !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* 挑战设置面板 */
.challenge-setup {
    animation: fadeIn 0.5s ease;
}

.setup-header {
    background: white;
    border-radius: 20px;
    padding: 25px 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.setup-header h2 {
    font-size: 1.8rem;
    color: #333;
    margin: 0;
}

.setup-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.setup-group {
    margin-bottom: 25px;
}

.setup-label {
    display: block;
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 10px;
    font-weight: bold;
}

.setup-mode {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
}

.setup-select {
    width: 100%;
    padding: 12px 15px;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.setup-select:focus {
    outline: none;
    border-color: #667eea;
}

.difficulty-options {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.difficulty-item {
    flex: 1;
    min-width: 150px;
    cursor: pointer;
}

.difficulty-item input[type="radio"] {
    display: none;
}

.difficulty-card {
    display: block;
    padding: 20px;
    border: 3px solid #e0e0e0;
    border-radius: 15px;
    text-align: center;
    transition: all 0.3s ease;
    background: white;
}

.difficulty-item input[type="radio"]:checked + .difficulty-card {
    border-color: #667eea;
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.3);
}

.difficulty-card.easy {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
}

.difficulty-card.medium {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
}

.difficulty-card.hard {
    background: linear-gradient(135deg, #fce4ec, #f8bbd9);
}

.difficulty-icon {
    display: block;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.difficulty-name {
    display: block;
    font-size: 1.3rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.difficulty-desc {
    display: block;
    font-size: 0.9rem;
    color: #666;
}

.btn-start {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
    margin-top: 10px;
}

/* 题目进度显示 */
.question-progress {
    font-size: 1.1rem;
    color: #888;
    margin-bottom: 5px;
    font-weight: bold;
}

/* 排行榜页面 */
.ranking-area {
    animation: fadeIn 0.5s ease;
}

.ranking-header {
    background: white;
    border-radius: 20px;
    padding: 25px 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    text-align: center;
}

.ranking-header h2 {
    font-size: 1.8rem;
    color: #333;
    margin: 0;
}

.ranking-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    justify-content: center;
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 15px;
}

.ranking-tabs::-webkit-scrollbar {
    width: 6px;
}

.ranking-tabs::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.ranking-tab {
    padding: 8px 16px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: bold;
    color: #666;
    white-space: nowrap;
}

.ranking-tab:hover {
    border-color: #667eea;
    color: #667eea;
}

.ranking-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: #667eea;
}

.ranking-content {
    background: white;
    border-radius: 20px;
    padding: 25px 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
}

.ranking-table th,
.ranking-table td {
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
}

.ranking-table th {
    background: #f8f9fa;
    font-weight: bold;
    color: #555;
    font-size: 1rem;
}

.ranking-table td {
    font-size: 1rem;
    color: #333;
}

.ranking-table tbody tr:hover {
    background: #f5f5f5;
}

.rank-1 {
    background: linear-gradient(135deg, #FFD700, #FFA500) !important;
    color: white !important;
    font-weight: bold;
}

.rank-2 {
    background: linear-gradient(135deg, #C0C0C0, #808080) !important;
    color: white !important;
    font-weight: bold;
}

.rank-3 {
    background: linear-gradient(135deg, #CD7F32, #8B4513) !important;
    color: white !important;
    font-weight: bold;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 1.1rem;
}
