/* ========================================
   学習診断アプリ - 統一スタイルシート
   ======================================== */

/* --- CSS変数 --- */
:root {
    --primary: #4CAF50;
    --primary-dark: #388E3C;
    --primary-light: #E8F5E9;
    --secondary: #FF9800;
    --secondary-dark: #F57C00;
    --secondary-light: #FFF3E0;
    --accent: #2196F3;
    --accent-light: #E3F2FD;
    --danger: #E53935;
    --bg: #F5F7FA;
    --white: #FFFFFF;
    --text: #333333;
    --text-light: #757575;
    --border: #E0E0E0;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
    --max-width: 720px;
}

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

body {
    font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
}

/* --- ヘッダー --- */
.site-header {
    background: var(--white);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.back-link {
    font-size: 14px;
    color: var(--text-light);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.back-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* --- コンテナ --- */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 24px 20px;
}

/* --- カード --- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 16px;
}

/* --- ボタン --- */
.btn {
    display: inline-block;
    padding: 12px 32px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--secondary-dark);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary-light);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- ランディングページ --- */
.landing-hero {
    text-align: center;
    padding: 48px 20px 32px;
}

.landing-hero h1 {
    font-size: 28px;
    color: var(--primary);
    margin-bottom: 12px;
}

.landing-hero p {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.hero-image {
    max-width: 280px;
    width: 60%;
    height: auto;
    border-radius: 12px;
}

.landing-features {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px 32px;
}

.feature-item {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.feature-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.feature-icon.green { background: var(--primary-light); }
.feature-icon.orange { background: var(--secondary-light); }
.feature-icon.blue { background: var(--accent-light); }

.feature-item h3 {
    font-size: 15px;
    margin-bottom: 4px;
}

.feature-item p {
    font-size: 13px;
    color: var(--text-light);
}

.landing-cta {
    text-align: center;
    padding: 16px 20px 48px;
}

.landing-footer {
    margin-top: 28px;
}

/* --- ログインページ --- */
.login-container {
    max-width: 400px;
    margin: 80px auto 0;
    padding: 0 20px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 36px 28px;
    text-align: center;
}

.login-card h2 {
    font-size: 22px;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-card .subtitle {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 24px;
}

.input-group {
    margin-bottom: 16px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
}

.input-group input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    outline: none;
    transition: border-color var(--transition);
}

.input-group input:focus {
    border-color: var(--primary);
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 12px;
    min-height: 20px;
}

/* --- メインページ（教科選択） --- */
.subject-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.subject-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    color: var(--text);
    border: 2px solid transparent;
}

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

.subject-card.math {
    border-color: var(--primary-light);
}

.subject-card.math:hover {
    border-color: var(--primary);
}

.subject-card.english {
    border-color: var(--secondary-light);
}

.subject-card.english:hover {
    border-color: var(--secondary);
}

.subject-card .subject-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.subject-card h3 {
    font-size: 18px;
    margin-bottom: 6px;
}

.subject-card p {
    font-size: 13px;
    color: var(--text-light);
}

/* --- 過去の結果 --- */
.history-section h3 {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 12px;
}

.history-item {
    background: var(--white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 14px 18px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-item .history-subject {
    font-weight: 600;
    font-size: 14px;
}

.history-item .history-score {
    font-size: 14px;
    color: var(--primary);
    font-weight: 600;
}

.history-item .history-date {
    font-size: 12px;
    color: var(--text-light);
}

/* --- クイズ画面 --- */
.quiz-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 24px 20px;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    transition: width 0.4s ease;
}

.question-num {
    text-align: center;
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.unit-label {
    text-align: center;
    margin-bottom: 12px;
    min-height: 28px;
}

.unit-label:not(:empty) {
    display: inline-block;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    padding: 5px 16px;
    border-radius: 20px;
}

.question-text {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    font-size: 17px;
    line-height: 1.7;
    margin-bottom: 20px;
    min-height: 80px;
}

.choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-btn {
    display: block;
    width: 100%;
    padding: 16px 20px;
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1.5;
}

.choice-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.choice-btn.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--white);
}

.choice-btn.selected-wrong {
    border-color: var(--danger);
    background: #FFEBEE;
    color: var(--danger);
}

.choice-label {
    font-weight: 700;
    margin-right: 10px;
    color: var(--text-light);
}

.choice-btn.selected .choice-label {
    color: var(--white);
}

/* --- 結果画面 --- */
.result-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 24px 20px;
}

.score-section {
    text-align: center;
    margin-bottom: 24px;
}

.score-circle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: var(--primary-light);
    border: 4px solid var(--primary);
    margin-bottom: 20px;
}

.score-number {
    font-size: 40px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.score-total {
    font-size: 18px;
    color: var(--text-light);
    font-weight: 400;
}

.score-percent {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 4px;
}

.rec-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
    text-align: left;
}

.rec-card {
    padding: 16px 18px;
    border-radius: var(--radius-sm);
    border-left: 4px solid;
}

.rec-primary {
    background: var(--primary-light);
    border-color: var(--primary);
}

.rec-secondary {
    background: var(--secondary-light);
    border-color: var(--secondary);
}

.rec-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.rec-primary .rec-label { color: var(--primary-dark); }
.rec-secondary .rec-label { color: var(--secondary-dark); }

.rec-unit {
    font-size: 16px;
    font-weight: 600;
}

/* --- AIアドバイス --- */
.ai-advice {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    font-size: 15px;
    line-height: 1.8;
    margin-bottom: 24px;
    min-height: 60px;
}

.ai-advice-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
}

/* --- ローディング --- */
.loading-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 20px 0;
}

.loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    animation: dotPulse 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* --- 結果アクション --- */
.result-actions {
    text-align: center;
    padding: 16px 0;
}

.result-actions .btn {
    margin: 0 6px;
}

/* --- エラー --- */
.error-text {
    color: var(--danger);
    text-align: center;
    padding: 12px;
}

/* --- 完了メッセージ --- */
.all-clear {
    background: var(--primary-light);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    margin-bottom: 16px;
}

.all-clear h3 {
    color: var(--primary);
    font-size: 20px;
    margin-bottom: 8px;
}

/* --- スタート画面 --- */
.start-screen {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 40px 20px;
}

.start-inner {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px 28px;
    text-align: center;
}

.start-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.start-inner h2 {
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 10px;
}

.start-inner p {
    font-size: 15px;
    color: var(--text-light);
    margin-bottom: 20px;
}

.start-info {
    list-style: none;
    margin-bottom: 28px;
}

.start-info li {
    font-size: 14px;
    color: var(--text);
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.start-info li:last-child {
    border-bottom: none;
}

.btn-start {
    font-size: 18px;
    padding: 16px 32px;
}

.start-school-name {
    margin-top: 20px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 2px;
}

.start-address {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.6;
}

.btn-site {
    margin-top: 14px;
    font-size: 14px;
    padding: 10px 28px;
}

/* --- レスポンシブ --- */
@media (max-width: 600px) {
    /* ヘッダー */
    .header-inner {
        padding: 10px 14px;
    }

    .site-logo {
        font-size: 16px;
    }

    /* コンテナ */
    .container {
        padding: 16px 14px;
    }

    /* ランディングページ */
    .landing-hero {
        padding: 32px 16px 24px;
    }

    .landing-hero h1 {
        font-size: 22px;
    }

    .landing-hero p {
        font-size: 14px;
    }

    .landing-features {
        padding: 0 14px 24px;
    }

    .feature-item {
        padding: 16px;
        gap: 10px;
    }

    .feature-item h3 {
        font-size: 14px;
    }

    .feature-item p {
        font-size: 12px;
    }

    .landing-cta {
        padding: 12px 14px 36px;
    }

    /* ログインページ */
    .login-container {
        margin-top: 48px;
        padding: 0 14px;
    }

    .login-card {
        padding: 28px 20px;
    }

    .login-card h2 {
        font-size: 20px;
    }

    /* メインページ（教科選択） */
    .subject-cards {
        grid-template-columns: 1fr;
    }

    .subject-card {
        padding: 20px 16px;
    }

    .subject-card .subject-icon {
        font-size: 32px;
    }

    .subject-card h3 {
        font-size: 16px;
    }

    /* スタート画面 */
    .start-screen {
        padding: 24px 14px;
    }

    .start-inner {
        padding: 28px 20px;
    }

    .start-icon {
        font-size: 36px;
    }

    .start-inner h2 {
        font-size: 20px;
    }

    .btn-start {
        font-size: 16px;
        padding: 14px 24px;
    }

    /* クイズ画面 */
    .quiz-container {
        padding: 16px 14px;
    }

    .question-text {
        font-size: 15px;
        padding: 18px;
    }

    .choice-btn {
        font-size: 15px;
        padding: 14px 16px;
    }

    /* 結果画面 */
    .result-container {
        padding: 16px 14px;
    }

    .score-circle {
        width: 120px;
        height: 120px;
    }

    .score-number {
        font-size: 34px;
    }

    .ai-advice {
        padding: 18px;
        font-size: 14px;
    }

    .ai-advice-title {
        font-size: 15px;
    }

    .rec-card {
        padding: 14px 16px;
    }

    .rec-unit {
        font-size: 15px;
    }

    /* 過去の結果 */
    .history-item {
        padding: 12px 14px;
    }
}
