/* 日语假名学习系统 - 主样式文件 */

/* 变量定义 */
:root {
    --primary-color: #8b5fbf;
    --secondary-color: #6c567b;
    --accent-color: #ff9a76;
    --light-color: #f8f3ff;
    --dark-color: #3c2a4d;
    --correct-color: #6bcf7f;
    --wrong-color: #ff6b6b;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

/* 重置和基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Noto Sans JP', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

body {
    background-color: #f5f0ff;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background-color: white;
    border-radius: 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* 头部样式 */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 20px;
    text-align: center;
    position: relative;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

/* 模式选择器 */
.mode-selector {
    display: flex;
    background-color: var(--light-color);
    border-bottom: 1px solid #e0d6eb;
}

.mode-btn {
    flex: 1;
    padding: 15px;
    text-align: center;
    background: none;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-color);
    cursor: pointer;
    transition: var(--transition);
}

.mode-btn.active {
    background-color: white;
    color: var(--primary-color);
    box-shadow: 0 -2px 0 var(--primary-color) inset;
}

/* 内容区域 */
.content {
    padding: 20px;
    min-height: 500px;
}

/* 页面切换 */
.page {
    display: none;
    animation: fadeIn 0.5s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 测试设置样式 */
.test-settings {
    background-color: var(--light-color);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--dark-color);
}

.setting-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.option-btn {
    padding: 8px 15px;
    background-color: white;
    border: 1px solid #d0c5e0;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.option-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.range-selector {
    width: 100%;
    margin: 10px 0;
}

.range-display {
    text-align: center;
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-top: 5px;
}

.start-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 20px;
}

.start-btn:hover {
    background-color: #ff8a5c;
    transform: translateY(-2px);
}

/* 测试容器 */
.test-container {
    display: none;
}

.question-container {
    text-align: center;
    padding: 20px 0;
}

.question {
    font-size: 4rem;
    margin: 20px 0;
    min-height: 80px;
    font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic Pro', 'Yu Gothic', 'Meiryo', sans-serif;
}

.options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 30px;
}

.option {
    padding: 15px;
    background-color: var(--light-color);
    border: 2px solid transparent;
    border-radius: 10px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.option:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.option.correct {
    background-color: var(--correct-color);
    color: white;
}

.option.wrong {
    background-color: var(--wrong-color);
    color: white;
}

/* 进度条 */
.progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
}

.progress-bar {
    flex-grow: 1;
    height: 8px;
    background-color: #e0d6eb;
    border-radius: 4px;
    margin: 0 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* 结果容器 */
.result-container {
    display: none;
    text-align: center;
    padding: 30px 0;
}

.result-score {
    font-size: 3rem;
    color: var(--primary-color);
    margin: 20px 0;
}

.result-text {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.result-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.result-btn {
    flex: 1;
    padding: 12px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.result-btn.secondary {
    background-color: var(--primary-color);
}

.result-btn:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

/* 学习模式样式 */
.kana-selector {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.kana-type-btn {
    padding: 10px 20px;
    background-color: white;
    border: 1px solid #d0c5e0;
    border-radius: 20px;
    margin: 0 10px;
    cursor: pointer;
    transition: var(--transition);
}

.kana-type-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.kana-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.kana-card {
    background-color: var(--light-color);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.kana-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.kana-char {
    font-size: 2.5rem;
    margin-bottom: 5px;
    font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic Pro', 'Yu Gothic', 'Meiryo', sans-serif;
}

.kana-romaji {
    font-size: 0.9rem;
    color: var(--secondary-color);
}

/* 假名详情弹窗 */
.kana-detail {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.kana-detail.active {
    display: block;
}

.kana-detail-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

.kana-detail-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.detail-char {
    font-size: 6rem;
    margin-bottom: 20px;
    font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic Pro', 'Yu Gothic', 'Meiryo', sans-serif;
}

.detail-romaji {
    font-size: 1.5rem;
    color: var(--secondary-color);
    margin-bottom: 20px;
}

.stroke-order {
    font-size: 1rem;
    color: var(--dark-color);
    margin-top: 20px;
}

/* 历史记录样式 */
.history-section {
    margin-top: 30px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.history-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--dark-color);
}

.clear-history-btn {
    padding: 8px 15px;
    background-color: #f8d7da;
    color: #721c24;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.clear-history-btn:hover {
    background-color: #f5c6cb;
}

.history-list {
    background-color: var(--light-color);
    border-radius: 10px;
    padding: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    background-color: white;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-score {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.history-time {
    font-size: 0.9rem;
    color: var(--secondary-color);
}

.history-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    font-size: 0.9rem;
    color: #666;
}

/* 历史详情弹窗 */
.history-detail {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1001;
}

.history-detail.active {
    display: block;
}

.history-detail-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

.history-detail-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.history-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.history-detail-header h3 {
    font-size: 1.5rem;
    color: var(--dark-color);
}

/* 历史统计 */
.history-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-item {
    background-color: var(--light-color);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--secondary-color);
}

/* 历史问题 */
.history-questions {
    margin-top: 20px;
}

.question-item {
    background-color: var(--light-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    border-left: 4px solid #ccc;
}

.question-item.correct {
    border-left-color: var(--correct-color);
}

.question-item.wrong {
    border-left-color: var(--wrong-color);
}

.question-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.question-text {
    font-weight: 600;
    flex: 1;
}

.question-result {
    font-weight: 600;
    margin-left: 10px;
}

.question-result.correct {
    color: var(--correct-color);
}

.question-result.wrong {
    color: var(--wrong-color);
}

.question-answer {
    font-size: 0.9rem;
    color: #666;
}

/* 关闭按钮 */
.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--dark-color);
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.close-btn:hover {
    background-color: #f0f0f0;
}

/* 页脚 */
footer {
    text-align: center;
    padding: 15px;
    color: var(--secondary-color);
    font-size: 0.9rem;
    border-top: 1px solid #e0d6eb;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .container {
        border-radius: 10px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .mode-btn {
        padding: 12px;
        font-size: 1rem;
    }
    
    .question {
        font-size: 3rem;
    }
    
    .options {
        grid-template-columns: 1fr;
    }
    
    .kana-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .kana-char {
        font-size: 2rem;
    }
    
    .history-details {
        grid-template-columns: 1fr;
    }
    
    .history-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .content {
        padding: 15px;
    }
    
    .setting-options {
        flex-direction: column;
    }
    
    .option-btn {
        width: 100%;
    }
    
    .kana-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .result-actions {
        flex-direction: column;
    }
}