/* ===== CSS Variables ===== */
:root {
    --primary: #1e3a5f;
    --primary-dark: #172e4a;
    --primary-light: #2a5a8f;
    --accent: #4a90d9;
    --accent-light: #6bb0f0;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --text-muted: #999999;
    --border: #e0e4e8;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
    --radius: 8px;
    --radius-lg: 12px;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 0 20px;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.logo {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.logo-accent {
    color: var(--accent-light);
    margin-left: 4px;
}

.header-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.header-progress-bar {
    width: 120px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.header-progress-fill {
    height: 100%;
    background: var(--accent-light);
    border-radius: 3px;
    transition: width 0.5s ease;
    width: 0%;
}

/* ===== Main Content ===== */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
    width: 100%;
    flex: 1;
}

/* ===== Dashboard ===== */
.welcome-section {
    text-align: center;
    margin-bottom: 32px;
}

.welcome-section h1 {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.welcome-section p {
    color: var(--text-light);
    font-size: 1.05rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.level-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid var(--border);
    position: relative;
}

.level-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.level-card.completed {
    border-left-color: var(--success);
}

.level-card.in-progress {
    border-left-color: var(--accent);
}

.level-card .level-number {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.level-card .level-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}

.level-card .level-desc {
    font-size: 0.88rem;
    color: var(--text-light);
    margin-bottom: 12px;
}

.level-card .level-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

.level-card .level-status .badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.badge-completed {
    background: #e8f5e9;
    color: var(--success);
}

.badge-not-started {
    background: #f0f0f0;
    color: var(--text-muted);
}

.badge-score {
    background: #e3f2fd;
    color: var(--accent);
}

/* ===== Learning Section ===== */
.learning-header {
    margin-bottom: 24px;
}

.learning-header h2 {
    color: var(--primary);
    font-size: 1.5rem;
    margin-top: 12px;
}

.learning-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
    line-height: 1.9;
    font-size: 1rem;
    margin-bottom: 24px;
}

.learning-content h3 {
    color: var(--primary);
    font-size: 1.2rem;
    margin: 24px 0 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--accent-light);
}

.learning-content h3:first-child {
    margin-top: 0;
}

.learning-content p {
    margin-bottom: 12px;
}

.learning-content ul, .learning-content ol {
    margin: 8px 0 16px 24px;
}

.learning-content li {
    margin-bottom: 4px;
}

.learning-content .highlight {
    background: #fff8e1;
    border-left: 4px solid var(--warning);
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.learning-actions {
    text-align: center;
}

/* ===== Quiz Section ===== */
.quiz-header {
    margin-bottom: 24px;
}

.quiz-header h2 {
    color: var(--primary);
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.quiz-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.quiz-progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.quiz-body {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
}

.quiz-question {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.6;
}

.quiz-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.quiz-choice {
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    font-size: 0.95rem;
    line-height: 1.5;
}

.quiz-choice:hover {
    border-color: var(--accent);
    background: #f0f7ff;
}

.quiz-choice.selected {
    border-color: var(--accent);
    background: #e3f2fd;
}

.quiz-choice.correct {
    border-color: var(--success);
    background: #e8f5e9;
}

.quiz-choice.incorrect {
    border-color: var(--danger);
    background: #fde8e8;
}

.quiz-choice.disabled {
    pointer-events: none;
}

.quiz-feedback {
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.quiz-feedback.correct {
    background: #e8f5e9;
    border: 1px solid var(--success);
    color: #1b5e20;
}

.quiz-feedback.incorrect {
    background: #fde8e8;
    border: 1px solid var(--danger);
    color: #b71c1c;
}

/* ===== Result Section ===== */
.result-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 500px;
    margin: 40px auto;
}

.result-card h2 {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.result-score {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
}

.result-detail {
    color: var(--text-light);
    margin-bottom: 28px;
    font-size: 1rem;
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== Buttons ===== */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 10px 28px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #f0f4f8;
}

.btn-back {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 4px 0;
}

.btn-back:hover {
    color: var(--primary);
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        height: auto;
        padding: 12px 0;
        gap: 8px;
    }

    .header {
        height: auto;
    }

    .header-progress-bar {
        width: 100px;
    }

    .welcome-section h1 {
        font-size: 1.4rem;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 14px 8px;
    }

    .stat-number {
        font-size: 1.5rem;
    }

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

    .learning-content {
        padding: 20px;
    }

    .quiz-body {
        padding: 20px;
    }

    .result-card {
        padding: 28px 20px;
        margin: 20px auto;
    }

    .result-score {
        font-size: 2.4rem;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.1rem;
    }

    .main-content {
        padding: 16px 12px;
    }

    .welcome-section h1 {
        font-size: 1.2rem;
    }

    .stat-number {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .level-card {
        padding: 18px;
    }
}
