/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow-x: hidden;
}

/* 页面容器 */
.page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: inherit;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.page.active {
    opacity: 1;
    visibility: visible;
}

.container {
    max-width: 400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(102, 126, 234, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: white;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 登录页面 */
.login-header {
    text-align: center;
    margin: 60px 0 40px 0;
    color: white;
}

.login-header h1 {
    font-size: 28px;
    margin-bottom: 10px;
    font-weight: 600;
}

.subtitle {
    font-size: 16px;
    opacity: 0.8;
}

.login-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.login-tabs {
    display: flex;
    margin-bottom: 30px;
    background: #f5f5f5;
    border-radius: 10px;
    padding: 4px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: #666;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: white;
    color: #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.login-form {
    display: none;
}

.login-form.active {
    display: block;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group input {
    width: 100%;
    height: 50px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    padding: 0 15px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-code-btn {
    position: absolute;
    right: 8px;
    top: 8px;
    height: 34px;
    padding: 0 12px;
    border: none;
    background: #667eea;
    color: white;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.send-code-btn:hover {
    background: #5a6fd8;
}

.send-code-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.login-btn {
    width: 100%;
    height: 50px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

/* 主页面 */
.user-info {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
    margin: 20px 0;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 15px;
    border: 3px solid #667eea;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-details h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 5px;
}

.user-details p {
    font-size: 14px;
    color: #666;
}

.menu-items {
    display: grid;
    gap: 15px;
    margin: 20px 0;
}

.menu-item {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.menu-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.menu-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.menu-item h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 5px;
}

.menu-item p {
    font-size: 14px;
    color: #666;
}

.stats-panel {
    display: flex;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 20px;
    margin-top: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-number {
    display: block;
    font-size: 24px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: #666;
}

/* 答题页面 */
.quiz-header {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e1e5e9;
    border-radius: 4px;
    margin-bottom: 15px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.quiz-info {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
}

.timer {
    display: flex;
    justify-content: center;
}

.timer-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: conic-gradient(#667eea 0deg, #e1e5e9 0deg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.1s ease;
}

.timer-circle::before {
    content: '';
    position: absolute;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: white;
}

#timerText {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    position: relative;
    z-index: 1;
}

.question-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

#questionText {
    font-size: 18px;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.6;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option {
    padding: 15px;
    background: #f8f9fa;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    color: #333;
}

.option:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.option.selected {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

.option.correct {
    border-color: #28a745;
    background: #28a745;
    color: white;
}

.option.wrong {
    border-color: #dc3545;
    background: #dc3545;
    color: white;
}

.quiz-actions {
    text-align: center;
}

.submit-btn {
    width: 100%;
    height: 50px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.submit-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

/* 答案解析页面 */
.explanation-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    margin-top: 50px;
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.result-indicator {
    font-size: 60px;
    margin-bottom: 20px;
}

.result-indicator.correct::before {
    content: '✅';
    color: #28a745;
}

.result-indicator.wrong::before {
    content: '❌';
    color: #dc3545;
}

#explanationQuestion {
    font-size: 18px;
    color: #333;
    margin-bottom: 20px;
    text-align: left;
}

.correct-answer, .explanation-text {
    text-align: left;
    margin-bottom: 20px;
}

.correct-answer h3, .explanation-text h3 {
    font-size: 16px;
    color: #667eea;
    margin-bottom: 10px;
}

.correct-answer p, .explanation-text p {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
}

.next-btn {
    width: 100%;
    height: 50px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

/* 结果页面 */
.result-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    margin-top: 50px;
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.score-display h1 {
    font-size: 48px;
    color: #667eea;
    margin-bottom: 10px;
    font-weight: 700;
}

.score-display p {
    font-size: 16px;
    color: #666;
    margin-bottom: 30px;
}

.result-stats {
    margin-bottom: 30px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e1e5e9;
    font-size: 16px;
}

.stat-row:last-child {
    border-bottom: none;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-btn {
    height: 50px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.action-btn.secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.action-btn {
    background: #f8f9fa;
    color: #666;
    border: 2px solid #e1e5e9;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

/* 排行榜和历史记录页面 */
.page-header {
    display: flex;
    align-items: center;
    margin: 20px 0 30px 0;
    color: white;
}

.back-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    margin-right: 15px;
    padding: 10px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
}

.ranking-filters {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 4px;
}

.filter-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: white;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.filter-btn.active {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

.ranking-list, .history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ranking-item, .history-item {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.rank-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    margin-right: 15px;
}

.rank-number.gold {
    background: #ffd700;
    color: #333;
}

.rank-number.silver {
    background: #c0c0c0;
    color: #333;
}

.rank-number.bronze {
    background: #cd7f32;
    color: white;
}

.rank-info {
    flex: 1;
}

.rank-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.rank-score {
    font-size: 14px;
    color: #666;
}

.rank-time {
    font-size: 12px;
    color: #999;
}

/* Toast提示 */
.toast {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    visibility: visible;
}

/* 确认对话框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 25px;
    max-width: 300px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 15px;
}

.modal-content p {
    font-size: 14px;
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.btn-cancel, .btn-confirm {
    flex: 1;
    height: 40px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-cancel {
    background: #f8f9fa;
    color: #666;
}

.btn-confirm {
    background: #667eea;
    color: white;
}

.btn-cancel:hover, .btn-confirm:hover {
    opacity: 0.8;
}

/* 动画效果 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.3s ease forwards;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.pulse {
    animation: pulse 0.5s ease;
}

/* 禁止选择文本 */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
