* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header h1 {
    font-size: 2.8em;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.3em;
    opacity: 0.95;
    position: relative;
    z-index: 1;
}

.main-content {
    padding: 30px;
}

/* ローディング改善 */
.loading {
    text-align: center;
    padding: 60px;
    color: #667eea;
    font-size: 1.2em;
}

/* 年度選択画面 */
.year-selection {
    text-align: center;
}

.year-selection h2 {
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 2.2em;
    position: relative;
}

.year-selection h2::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

.year-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin: 30px 0;
}

.year-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid #e9ecef;
    border-radius: 16px;
    padding: 30px 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}

.year-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.year-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.15);
    border-color: #667eea;
}

.year-card h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.6em;
    font-weight: 700;
    position: relative;
}

.year-card h3::before {
    content: '📚';
    margin-right: 10px;
    font-size: 0.8em;
}

.year-info {
    color: #6c757d;
    margin-bottom: 15px;
    font-weight: 500;
}

/* 合格基準表示スタイル */
.passing-criteria {
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f8ff 100%);
    border: 1px solid #e6f3ff;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: inset 0 2px 4px rgba(102, 126, 234, 0.1);
}

.passing-criteria h4 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 1.0em;
    font-weight: 600;
    text-align: center;
}


.criteria-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    margin-bottom: 6px;
    border-left: 3px solid #667eea;
    min-height: 24px;
}

.criteria-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.8em;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
}

.criteria-value {
    font-weight: 700;
    color: #667eea;
    font-size: 0.8em;
    text-align: right;
    flex-shrink: 0;
}

.criteria-total {
    margin-top: 12px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    text-align: center;
    font-size: 0.95em;
}

.criteria-total strong {
    font-weight: 700;
}

.exam-number {
    color: #6c757d;
    margin-bottom: 15px;
    font-weight: 500;
    font-size: 1.1em;
}

.no-criteria {
    color: #868e96;
    font-style: italic;
    text-align: center;
    padding: 15px;
}

/* モード選択 */
.mode-selection {
    display: none;
    text-align: center;
}

.mode-selection h2 {
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 2.2em;
    position: relative;
}

.mode-selection h2::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border-radius: 2px;
}

.mode-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.mode-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 16px;
    padding: 25px 20px;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.3);
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(40, 167, 69, 0.4);
}

.mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.3);
}

.mode-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

.mode-btn.primary {
    background: linear-gradient(135deg, #007bff, #0056b3);
}

.mode-btn.primary:hover {
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.3);
}

.mode-btn.secondary {
    background: linear-gradient(135deg, #6f42c1, #e83e8c);
}

.mode-btn.secondary:hover {
    box-shadow: 0 8px 20px rgba(111, 66, 193, 0.3);
}

.mode-btn.danger {
    background: linear-gradient(135deg, #dc3545, #c82333);
}

.mode-btn.danger:hover {
    box-shadow: 0 8px 20px rgba(220, 53, 69, 0.3);
}

/* 問題画面 */
.question-interface {
    display: none;
}

.question-container {
    position: relative;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
}

.question-section {
    background: #007bff;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    display: inline-block;
    margin-bottom: 20px;
}

.question-content h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.question-text {
    font-size: 1.1em;
    line-height: 1.8;
    margin-bottom: 20px;
    color: #495057;
}

.select-instruction {
    background: #fff3cd;
    color: #856404;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #ffc107;
}

.choices-container {
    margin: 20px 0;
}

.choice {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer !important;
    transition: all 0.3s ease;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    user-select: none;
}

.choice:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.choice.selected {
    background: #cce5ff;
    border-color: #007bff;
}

.choice.correct {
    background: #d4edda;
    border-color: #28a745;
}

.choice.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
}

.choice.user-correct {
    background: #d1ecf1;
    border-color: #17a2b8;
}

.choice-number {
    background: #6c757d;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.choice.selected .choice-number {
    background: #007bff;
}

.choice.correct .choice-number {
    background: #28a745;
}

.choice.incorrect .choice-number {
    background: #dc3545;
}

.choice-text {
    flex: 1;
    line-height: 1.6;
}

.answer-feedback {
    margin-top: 20px;
    padding: 20px;
    border-radius: 10px;
}

.answer-feedback.correct {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.answer-feedback.incorrect {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border-top: 3px solid #007bff;
    gap: 15px;
}

.nav-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-btn:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.nav-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-btn:disabled {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
    border: 2px solid #dee2e6;
}

.nav-btn.finish {
    background: #28a745;
    font-weight: 600;
}

.nav-btn.finish:hover {
    background: #218838;
}

.nav-btn.show-answer {
    background: #28a745;
    font-weight: 600;
}

.nav-btn.show-answer:hover {
    background: #218838;
}

.back-button {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    margin: 20px 0;
    transition: all 0.3s ease;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.back-button:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.back-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.back-button:hover {
    background: #5a6268;
}

/* 学習統計ボタン */
.stats-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.2);
    text-decoration: none;
    display: inline-block;
    margin: 8px 4px;
}

.stats-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.3);
    background: linear-gradient(135deg, #218838, #1e7e34);
}

/* 戻るボタン */
.back-btn {
    background: linear-gradient(135deg, #6c757d, #5a6268);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.2);
    text-decoration: none;
    display: inline-block;
    margin: 8px 4px;
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(108, 117, 125, 0.3);
    background: linear-gradient(135deg, #5a6268, #545b62);
}

/* 結果画面 */
#results-display {
    display: none;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.results-container {
    display: block !important;
}

.results-header {
    text-align: center;
    margin-bottom: 30px;
}

.overall-judgment {
    text-align: center;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    font-size: 1.5em;
    font-weight: bold;
}

.overall-judgment.passed {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border: 2px solid #28a745;
}

.overall-judgment.failed {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
    border: 2px solid #dc3545;
}

.overall-judgment.no-criteria {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    color: #856404;
    border: 2px solid #ffc107;
}

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

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.results-table th,
.results-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.results-table th {
    background: #f8f9fa;
    font-weight: bold;
    color: #495057;
}

.section-passed {
    background: #d4edda;
}

.section-failed {
    background: #f8d7da;
}

.statistics {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

.stat-item {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stat-label {
    display: block;
    color: #6c757d;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.stat-value {
    display: block;
    color: #2c3e50;
    font-size: 1.8em;
    font-weight: bold;
}

.wrong-questions-section {
    background: #fff3cd;
    padding: 25px;
    border-radius: 12px;
    border-left: 5px solid #ffc107;
}

.review-button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.review-button:hover {
    background: #c82333;
    transform: translateY(-2px);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 10px;
    }

    .header {
        padding: 20px;
    }

    .header h1 {
        font-size: 2em;
    }

    .main-content {
        padding: 20px;
    }

    .year-grid {
        grid-template-columns: 1fr;
    }

    .navigation {
        flex-direction: column;
        gap: 15px;
    }

    .nav-btn {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}
