/* リセットCSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* ヘッダー */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 画面管理 */
.screen {
    display: none;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    position: relative;
}

.screen.active {
    display: block;
    animation: slideIn 0.3s ease-out;
}

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

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

/* 設定画面 */
#setup-screen {
    padding: 30px;
}

.setup-section {
    margin-bottom: 30px;
}

.setup-section h2 {
    color: #4a5568;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

/* カテゴリグリッド */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.category-option {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8fafc;
}

.category-option:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.category-option.selected {
    border-color: #667eea;
    background: #e6edff;
}

.category-option input[type="checkbox"] {
    margin-right: 10px;
    transform: scale(1.2);
}

.category-info {
    flex: 1;
}

.category-name {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 2px;
}

.category-count {
    font-size: 0.85rem;
    color: #718096;
}

/* 難易度選択 */
.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-option {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8fafc;
}

.radio-option:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.radio-option input[type="radio"] {
    margin-right: 10px;
    transform: scale(1.2);
}

.radio-option input[type="radio"]:checked + span {
    font-weight: 600;
    color: #667eea;
}

/* 問題数設定 */
.question-count-selector {
    display: flex;
    align-items: center;
    gap: 15px;
}

.question-count-selector label {
    font-weight: 600;
    color: #4a5568;
}

.question-count-selector select {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

.question-count-selector select:focus {
    outline: none;
    border-color: #667eea;
}

/* ボタン */
.btn-primary, .btn-secondary {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-primary:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: #f7fafc;
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

#start-quiz {
    width: 100%;
    margin-top: 20px;
    font-size: 1.2rem;
    padding: 15px;
}

/* クイズ画面 */
#quiz-screen {
    padding: 0;
}

.quiz-header {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    padding: 20px 30px;
}

.progress-bar {
    background: rgba(255,255,255,0.3);
    height: 8px;
    border-radius: 4px;
    margin-bottom: 15px;
    overflow: hidden;
}

.progress-fill {
    background: white;
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.quiz-info {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
}

.question-card {
    padding: 30px;
}

.question-category {
    display: inline-block;
    background: #e6edff;
    color: #667eea;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.question-difficulty {
    display: inline-block;
    background: #f0fff4;
    color: #38a169;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 20px;
    margin-left: 10px;
}

#question-text {
    font-size: 1.3rem;
    color: #2d3748;
    margin-bottom: 25px;
    line-height: 1.5;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
}

.option {
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8fafc;
    display: flex;
    align-items: center;
}

.option:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.option.selected {
    border-color: #667eea;
    background: #e6edff;
}

.option.correct {
    border-color: #38a169;
    background: #f0fff4;
    color: #2f855a;
}

.option.incorrect {
    border-color: #e53e3e;
    background: #fed7d7;
    color: #c53030;
}

.option-letter {
    background: #667eea;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 15px;
    flex-shrink: 0;
}

.option.correct .option-letter {
    background: #38a169;
}

.option.incorrect .option-letter {
    background: #e53e3e;
}

.quiz-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.explanation {
    margin-top: 25px;
    padding: 20px;
    background: #f7fafc;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.explanation.hidden {
    display: none;
}

.explanation h4 {
    color: #4a5568;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.explanation p {
    color: #718096;
    line-height: 1.6;
}

/* 結果画面 */
#result-screen {
    padding: 40px;
    text-align: center;
}

.result-card h2 {
    color: #4a5568;
    margin-bottom: 30px;
    font-size: 2rem;
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: linear-gradient(45deg, #667eea, #764ba2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    color: white;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.score-value {
    font-size: 2.5rem;
    font-weight: bold;
    line-height: 1;
}

.score-total {
    font-size: 1.2rem;
    opacity: 0.8;
}

.score-percentage {
    font-size: 1.5rem;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 30px;
}

.result-details {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 10px;
}

.result-item {
    text-align: center;
}

.result-label {
    display: block;
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 5px;
}

.result-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #4a5568;
}

.result-message {
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    font-size: 1.1rem;
    font-weight: 600;
}

.result-message.excellent {
    background: #f0fff4;
    color: #2f855a;
    border: 2px solid #9ae6b4;
}

.result-message.good {
    background: #e6fffa;
    color: #2c7a7b;
    border: 2px solid #81e6d9;
}

.result-message.average {
    background: #fffbeb;
    color: #d69e2e;
    border: 2px solid #f6e05e;
}

.result-message.poor {
    background: #fed7d7;
    color: #c53030;
    border: 2px solid #feb2b2;
}

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

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .category-grid {
        grid-template-columns: 1fr;
    }
    
    .difficulty-options {
        gap: 8px;
    }
    
    .quiz-controls {
        flex-direction: column;
    }
    
    .result-details {
        flex-direction: column;
        gap: 15px;
    }
    
    .result-controls {
        flex-direction: column;
    }
    
    #question-text {
        font-size: 1.1rem;
    }
    
    .score-circle {
        width: 120px;
        height: 120px;
    }
    
    .score-value {
        font-size: 2rem;
    }
}
