/* ===== Design Token & Variables ===== */
:root {
    /* Color Palette - Vibrant UI for learning app */
    --primary: #6366f1;         /* Indigo 500 */
    --primary-hover: #4f46e5;   /* Indigo 600 */
    --primary-light: #e0e7ff;   /* Indigo 100 */
    
    --success: #10b981;         /* Emerald 500 */
    --success-light: #d1fae5;   /* Emerald 100 */
    --success-border: #34d399;  /* Emerald 400 */
    
    --error: #ef4444;           /* Red 500 */
    --error-light: #fee2e2;     /* Red 100 */
    --error-border: #f87171;    /* Red 400 */

    --text-main: #1f2937;       /* Gray 800 */
    /* Color Palette - Premium Violet & Indigo */
    --primary: #6366f1;
    --primary-light: #e0e7ff;
    --primary-hover: #4f46e5;
    --secondary: #8b5cf6;
    --accent: #f59e0b;
    --success: #10b981;
    --success-light: #ecfdf5;
    --error: #ef4444;
    --error-light: #fef2f2;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --bg-light: #f8fafc;
    --bg-gradient: linear-gradient(135deg, #f5f7ff 0%, #eef2ff 100%);
    
    /* Glassmorphism Tokens */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    
    /* Spacing & Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    color: var(--text-main);
    background: var(--bg-app); /* よりシンプルな背景色 */
    background: linear-gradient(135deg, #e0e7ff 0%, #fae8ff 100%);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex; /* 中央揃えは維持しつつスクロール対応 */
    flex-direction: column;
    padding: 1rem;
    line-height: 1.6;
}

#global-header {
    width: 100%;
    max-width: 950px;
    margin: 0 auto 1.5rem;
    position: sticky;
    top: 1rem;
    z-index: 1000;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    padding: 0.75rem 1.25rem;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.site-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
}

.tab-nav {
    display: flex;
    gap: 0.35rem;
    background: var(--bg-gradient-1);
    padding: 3px;
    border-radius: 10px;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    color: var(--primary);
    background: rgba(255,255,255,0.5);
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ===== ページコンテナ切り替え ===== */
.page-container {
    display: none;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    flex-grow: 1;
}

.page-container.active {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.4s ease-out forwards;
}

/* ===== 試験概要ページ ===== */
.overview-page {
    padding: 2rem;
}

.overview-hero {
    text-align: left;
    margin-bottom: 2rem;
}

.overview-hero h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.overview-lead {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.overview-cards {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.overview-card {
    background: rgba(255,255,255,0.6);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 14px;
    padding: 1.5rem;
}

.overview-card-header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 1.25rem !important;
    margin-bottom: 1.25rem;
}

.overview-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.overview-card h3 {
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 0;
    color: var(--text-main);
}

/* 情報テーブル */
.info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.info-table th,
.info-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    text-align: left;
}

.info-table th {
    font-weight: 600;
    color: var(--text-muted);
    width: 35%;
    white-space: nowrap;
}

.info-table td {
    color: var(--text-main);
}

.info-table tr:last-child th,
.info-table tr:last-child td {
    border-bottom: none;
}

.note-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

/* 第一種・第二種 比較 */
.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.comp-col {
    background: var(--bg-gradient-2);
    border-radius: 10px;
    padding: 1rem;
}

.comp-col h4 {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.comp-col ul {
    list-style: none;
    padding: 0;
}

.comp-col li {
    font-size: 0.8rem;
    color: var(--text-main);
    padding: 0.3rem 0;
    padding-left: 1rem;
    position: relative;
}

.comp-col li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: bold;
}

/* 合格基準 */
.pass-criteria {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.criteria-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-gradient-2);
    border-radius: 10px;
    font-size: 0.9rem;
}

.criteria-item.highlight {
    background: var(--primary-light);
    border: 1px solid var(--primary);
}

.criteria-label {
    font-weight: 600;
    color: var(--text-muted);
}

.criteria-value {
    font-weight: 500;
}

.criteria-value strong {
    font-size: 1.15rem;
    color: var(--primary);
}

.criteria-item.highlight .criteria-label {
    color: var(--primary);
}

/* サブタブ（第一種・第二種切り替え） */
.sub-tab-nav {
    display: flex;
    gap: 0;
    background: var(--bg-gradient-1);
    padding: 3px;
    border-radius: 10px;
    margin-bottom: 1.25rem;
}

.sub-tab-btn {
    flex: 1;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.sub-tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* CTA */
.overview-cta {
    margin-top: 2rem;
    text-align: center;
}

.overview-cta .primary-btn {
    font-size: 1.05rem;
    padding: 0.85rem 2rem;
}

.mini-primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0 1rem;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

/* ===== 過去問一覧ページ ===== */
.pastexam-year-header {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    margin-bottom: 0.75rem;
}

.pastexam-year-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1.5px solid rgba(0,0,0,0.08);
    border-radius: 12px;
    background: rgba(255,255,255,0.6);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    transition: all var(--transition-fast);
}

.pastexam-year-toggle:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.pastexam-year-toggle .year-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.pastexam-year-group.open .pastexam-year-toggle {
    border-radius: 12px 12px 0 0;
    border-bottom-color: transparent;
    background: var(--primary-light);
    color: var(--primary);
}

.pastexam-year-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
    border: 1.5px solid transparent;
    border-top: none;
    border-radius: 0 0 12px 12px;
}

.pastexam-year-group.open .pastexam-year-body {
    max-height: 5000px;
    border-color: rgba(0,0,0,0.08);
}

.pastexam-q-row {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    font-size: 0.82rem;
    line-height: 1.5;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.pastexam-q-row:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.pastexam-q-row:last-child {
    border-bottom: none;
}

.pastexam-q-num {
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    min-width: 2rem;
}

.pastexam-q-text {
    flex: 1;
    color: var(--text-main);
}

.pastexam-q-badges {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}

.pastexam-q-badges .mini-badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    font-weight: 600;
    white-space: nowrap;
}

.mini-badge.cat-badge {
    background: #f0f9ff;
    color: #0369a1;
}

.mini-badge.freq-high-badge {
    background: #fee2e2;
    color: #dc2626;
}

.mini-badge.freq-mid-badge {
    background: #ffedd5;
    color: #ea580c;
}

/* ===== 共通フッター ===== */
#global-footer {
    width: 100%;
    max-width: 950px;
    margin: 2rem auto 0;
    padding: 1.5rem 1.25rem;
    text-align: center;
    border-top: 1px solid rgba(0,0,0,0.06);
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.footer-links a {
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: opacity var(--transition-fast);
}

.footer-links a:hover {
    opacity: 0.7;
}

.footer-sep {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.footer-copy {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.footer-note {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* レスポンシブ（ヘッダー・概要ページ） */
@media (max-width: 600px) {
    .header-inner {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .comparison-grid {
        grid-template-columns: 1fr;
    }
    
    .tab-btn span {
        display: none;
    }
    
    .tab-btn {
        padding: 0.45rem 0.65rem;
    }
}

#app-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    flex-grow: 1;
}


/* ===== Components ===== */
/* Glass Panel */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
}

/* ===== Screen Control (Must be after .glass-panel) ===== */
.screen {
    width: 100%;
    display: none !important; /* 強制的に非表示 */
    flex-direction: column;
    opacity: 0;
    transform: translateY(10px) scale(0.99);
    transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.screen.active {
    display: flex !important; /* 強制的に表示 */
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: fadeIn 0.4s ease-out forwards;
}

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

/* Home Layout - Dashboard & Settings (Updated for Top Dashboard) */
.main-title, .sub-title, .badge-container {
    display: none; /* User requested removal */
}

.card-panel {
    background: white;
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 1);
    margin-top: 0.5rem; /* Small offset from top */
}

.sub-title {
    display: none;
}

.badge-container {
    display: none;
}

.category-badge {
    background: var(--primary);
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
}

.card-panel {
    background: white;
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
    margin-bottom: 3rem;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.card-title-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-main);
}

.dashboard-stats {
    display: flex;
    justify-content: space-around;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.d-stat {
    text-align: center;
    flex: 1;
}

.d-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.d-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.d-unit {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.rank-stat .d-value {
    font-size: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
}

.rank-c { background: #fee2e2; color: #ef4444; }
.rank-b { background: #fef3c7; color: #d97706; }
.rank-a { background: #dcfce7; color: #16a34a; }

/* Settings Restory */
.settings-container {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 24px;
    padding: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    margin-bottom: 3rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-bottom: 2.5rem;
}

@media (max-width: 600px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
}

.setting-item select {
    width: 100%;
    padding: 1rem 1.25rem;
    border-radius: 16px;
    border: 2px solid #e2e8f0;
    background: white;
    font-size: 1.1rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

.setting-item select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px var(--primary-light);
}

.filter-summary {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 2rem;
    color: var(--text-main);
}

.glass-header {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

/* Buttons */
.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.secondary-btn:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: var(--primary-light);
}

.secondary-btn:active {
    transform: translateY(0);
}

/* Text Utilities */
.text-center { text-align: center; justify-content: center; }
.flex-grow { flex-grow: 1; overflow-y: auto; }
.mt-4 { margin-top: 1rem; }
.hidden { display: none !important; }

/* Card Panels (Dashboard & Filters) */
.card-panel {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 0.75rem;
}

.card-header h3 {
    font-size: 1.1rem;
    color: var(--text-main);
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.text-btn {
    background: transparent;
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    transition: background-color var(--transition-fast);
}

.text-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.danger-text {
    color: var(--error);
}

.dashboard-stats {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.d-stat {
    display: flex;
    flex-direction: column;
}

.d-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.d-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.highlight-stat {
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.rank-a { color: var(--success); }
.rank-b { color: var(--primary); }
.rank-c { color: var(--error); }
.rank-unset { color: var(--text-muted); font-weight: normal; }

/* カテゴリ別成績セクション（アコーディオン） */
.category-stats-section {
    margin-top: 1.25rem;
    padding-top: 0;
    border-top: none;
}

.accordion-toggle {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 2px solid var(--primary-light) !important;
    border-radius: 12px;
    background: linear-gradient(135deg, #f8faff, #eff6ff);
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700 !important;
    position: relative;
    gap: 0.6rem !important;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.accordion-toggle span {
    font-weight: 700 !important;
}

.accordion-toggle:hover {
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    border-color: var(--primary);
}

.chevron {
    transition: transform 0.3s ease;
    color: var(--primary);
    background: white;
    border-radius: 50%;
    padding: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: absolute;
    right: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.category-stats-section.open .accordion-toggle {
    border-radius: 10px 10px 0 0;
    border-bottom-color: transparent;
}

.category-stats-section.open .chevron {
    transform: rotate(180deg);
}

.category-stats-section.open .accordion-toggle {
    border-radius: 10px 10px 0 0;
    border-bottom-color: transparent;
}

.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
    border: 1.5px solid transparent;
    border-top: none;
    border-radius: 0 0 10px 10px;
}

.category-stats-section.open .accordion-body {
    max-height: 600px;
    border-color: var(--primary-light);
    padding: 0.75rem 0.85rem;
}

.category-stats-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    letter-spacing: 0.03em;
}

.cat-stat-row {
    margin-bottom: 0.75rem;
}

.cat-stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.cat-stat-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.cat-stat-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
}

.cat-stat-bar-bg {
    height: 6px;
    background: var(--bg-gradient-1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.15rem;
}

.cat-stat-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease-out;
}

.cat-stat-detail {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.no-data-msg {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.5rem 0;
    margin: 0;
}

/* 苦手復習ボタン */
.weak-review-btn {
    width: 100%;
    margin-top: 1.25rem;
    padding: 0.85rem 1.25rem;
    border: 2px solid #f59e0b;
    border-radius: 12px;
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    color: #92400e;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
}

.weak-review-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.weak-review-btn:active:not(:disabled) {
    transform: translateY(0);
}

/* Badge */
.badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

/* Typography */
h1 {
    font-size: 2rem;
    line-height: 1.3;
    color: var(--text-main);
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.question-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

#q-meta-year { background: #6366f1; }
#q-meta-type { background: #14b8a6; }
#q-meta-category { background: #f59e0b; }

/* 出題頻度バッジ */
.freq-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}
.freq-high {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    animation: freqPulse 2s infinite;
}
.freq-mid {
    background: linear-gradient(135deg, #f97316, #ea580c) !important;
}
.freq-low {
    background: #94a3b8 !important;
}

@keyframes freqPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

.question-text {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2rem;
    line-height: 1.6;
    letter-spacing: -0.01em;
}

/* Home Stats & Filters */
.stats-preview {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 1rem 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

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

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Filter Forms */
.filter-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 480px) {
    .filter-container {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
}

/* Custom Select Wrapper */
.select-wrapper {
    position: relative;
    width: 100%;
}

.select-wrapper::after {
    content: '';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.25rem;
    height: 1.25rem;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
    transition: transform var(--transition-fast);
}

.select-wrapper:focus-within::after {
    transform: translateY(-50%) rotate(180deg);
}

select {
    width: 100%;
    padding: 0.85rem 2.5rem 0.85rem 1.25rem;
    background: white;
    border: 2px solid transparent;
    border-radius: 14px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    appearance: none;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

select:hover {
    border-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* Filter Actions (Quiz Info & Start) */
.filtered-info-box {
    width: 100%;
    padding: 1rem 1.25rem;
    background: #f0f4ff !important;
    border: 2px solid var(--primary-light) !important;
    border-radius: 16px;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    height: 58px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.08);
    margin-bottom: 0;
}

#filtered-count-display {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.count-badge {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.count-sep {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
}

.total-num {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
}

.total-count-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Quiz Header & Progress */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1.5rem;
}

/* クイズ中断ボタン */
.quit-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.75rem;
    border: 1.5px solid rgba(0,0,0,0.15);
    border-radius: 8px;
    background: rgba(255,255,255,0.7);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quit-btn:hover {
    background: var(--error-light);
    border-color: var(--error);
    color: var(--error);
}

.quiz-progress-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
    min-width: 140px;
}

.q-counter {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
}

#current-q-num {
    font-size: 1.5rem;
    color: var(--primary);
}

/* ドットフィラーによる位置調整レイアウト */
.dot-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    width: 100%;
    margin: 0.25rem 0;
    line-height: normal;
}
.dot-label {
    flex-shrink: 1;
    text-align: left;
    white-space: normal;
    word-break: break-all;
}
.dot-filler {
    flex-grow: 1;
    border-bottom: 2px dotted rgba(0,0,0,0.1);
    margin: 0 8px;
    height: 14px;
    min-width: 10px;
}
.dot-value {
    flex-shrink: 0;
    text-align: right;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.q-divider {
    font-size: 0.9rem;
    color: var(--text-muted);
}

#total-q-display {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background-color: var(--primary-light);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    border-radius: 999px;
    width: 0%;
    transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Quiz Options */
.options-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.option-btn {
    background: white;
    border: 1.5px solid rgba(0,0,0,0.05);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.option-prefix {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 800;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.option-btn:hover:not(:disabled) {
    border-color: var(--primary-light);
    background: #fcfdff;
    transform: translateX(6px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.08);
}

.option-btn:hover:not(:disabled) .option-prefix {
    background: var(--primary);
    color: white;
}

.option-btn.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

.option-btn.correct {
    border-color: var(--success);
    background: var(--success-light);
    color: var(--success);
}
.option-btn.correct .option-prefix {
    background: var(--success);
    color: white;
}

.option-btn.incorrect {
    border-color: var(--error);
    background: var(--error-light);
    color: var(--error);
    opacity: 0.8;
}
.option-btn.incorrect .option-prefix {
    background: var(--error);
    color: white;
}

/* Feedback Area */
.feedback-area {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 1rem;
    border-left: 4px solid var(--primary);
    animation: slideUp 0.4s ease-out forwards;
}

.feedback-area.correct-feedback {
    border-left-color: var(--success);
    background: #f0fdf4;
}

.feedback-area.incorrect-feedback {
    border-left-color: var(--error);
    background: #fef2f2;
}

.feedback-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.feedback-header h3 {
    font-size: 1.25rem;
    margin: 0;
}

.correct-feedback h3 { color: var(--success); }
.incorrect-feedback h3 { color: var(--error); }

.status-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.correct-feedback .status-icon { background: var(--success); }
.incorrect-feedback .status-icon { background: var(--error); }

.explanation-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-main);
    margin-bottom: 0;
}

.explanation-correct {
    color: #2563eb;
    font-weight: 700;
}

.explanation-incorrect {
    color: #dc2626;
    font-weight: 700;
}

.explanation-bold {
    font-weight: 700;
}

/* Results Screen */
.result-actions {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
    margin-top: 1.5rem;
}
.score-circle-container {
    width: 160px;
    height: 160px;
    margin: 0 auto 2rem;
}

.circular-chart {
    display: block;
    margin: 0 auto;
    max-width: 80%;
    max-height: 250px;
}

.circle-bg {
    fill: none;
    stroke: var(--bg-gradient-1);
    stroke-width: 2.5;
}

.circle {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    transition: stroke-dasharray 1.5s ease-out;
}

.percentage {
    fill: var(--text-main);
    font-family: inherit;
    font-weight: 700;
    font-size: 8px;
    text-anchor: middle;
}

.score-text {
    fill: var(--text-muted);
    font-family: inherit;
    font-size: 3px;
    text-anchor: middle;
}

.result-feedback {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 2rem;
}

/* Canvas for Confetti */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

/* Animations */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

.pulse-anim {
    animation: pulse 2.5s infinite;
}

/* Modal Overlay Data Clear */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.modal-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.modal-actions button {
    flex: 1;
    padding: 0.75rem;
    font-size: 0.95rem;
}

.danger-bg {
    background: var(--error);
}

.danger-bg:hover {
    background: #dc2626;
}

/* Scrollbar styling for content areas */
.flex-grow::-webkit-scrollbar {
    width: 6px;
}

.flex-grow::-webkit-scrollbar-track {
    background: transparent;
}

.flex-grow::-webkit-scrollbar-thumb {
    background: var(--bg-gradient-1);
    border-radius: 10px;
}

.flex-grow::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* Importance Indicator */
.question-section {
    position: relative;
}

.importance-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    pointer-events: none;
    transition: all var(--transition-normal);
}

.importance-level-5 { background: #fee2e2; color: #ef4444; border: 1px solid #fca5a5; }
.importance-level-4 { background: #ffedd5; color: #ea580c; border: 1px solid #fdba74; }
.importance-level-3 { background: #fef9c3; color: #ca8a04; border: 1px solid #fde047; }
.importance-level-2 { background: #f0f9ff; color: #0284c7; border: 1px solid #7dd3fc; }
.importance-level-1 { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; }

.star-container {
    display: flex;
    gap: 1px;
    font-size: 0.7rem;
}

.star-filled { color: currentColor; }
.star-empty { color: #ccc; opacity: 0.5; }
@keyframes overlayZoom {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0; }
}

.answer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    pointer-events: none;
    background: transparent;
}

.overlay-symbol {
    font-size: 10rem;
    font-weight: 800;
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: overlayZoom 0.6s ease-out forwards;
}

.overlay-symbol.correct {
    color: #10b981; /* Emerald 500 */
}
.overlay-symbol.correct::before {
    content: "○";
}

.overlay-symbol.incorrect {
    color: #ef4444; /* Red 500 */
}
.overlay-symbol.incorrect::before {
    content: "×";
}

/* 強化された解説上部の判定表示 */
.feedback-title-styled {
    font-size: 1.5rem !important;
    font-weight: 800 !important;
    margin-bottom: 0.5rem !important;
    display: block;
}

.feedback-title-styled.correct {
    color: #10b981 !important;
}

.feedback-title-styled.incorrect {
    color: #ef4444 !important;
}

/* 解析と「次へ」ボタンの間隔を調整 */
.next-action {
    margin-top: 1.5rem !important;
}

/* 学習ドリルに戻るリンクのスタイル */
.back-link-container {
    margin-top: 1.25rem;
    text-align: right;
}

.back-link {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-fast);
    padding: 0.25rem 0;
    display: inline-block;
    border-bottom: 1px solid transparent;
}

.back-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ===== 文字サイズ変更コントロール (単一アイコン + ドロップダウン) ===== */
.font-size-selector-container {
    position: relative;
    display: inline-block;
}

.font-icon-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1.5px solid var(--primary-light);
    color: var(--primary);
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.font-icon-btn:hover {
    background: white;
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

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

.font-size-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: white;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    min-width: 110px;
    animation: fadeInDown 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.font-menu-item {
    padding: 0.65rem 1rem;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s;
    font-family: inherit;
}

.font-menu-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.font-menu-item.active {
    background: var(--primary);
    color: white;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 文字サイズ調整の反映 */
/* 大 */
#quiz-screen.size-large .question-text { font-size: 1.4rem; }
#quiz-screen.size-large .option-btn { font-size: 1.1rem; }
#quiz-screen.size-large .explanation-text { font-size: 0.95rem; }

/* 中 */
#quiz-screen.size-medium .question-text { font-size: 1.2rem; }
#quiz-screen.size-medium .option-btn { font-size: 1.0rem; padding: 1.1rem 1.3rem; }
#quiz-screen.size-medium .explanation-text { font-size: 0.85rem; }

/* 小 */
#quiz-screen.size-small .question-text { font-size: 1.0rem; }
#quiz-screen.size-small .option-btn { font-size: 0.9rem; padding: 0.9rem 1.1rem; }
#quiz-screen.size-small .explanation-text { font-size: 0.75rem; }

/* 極小 */
#quiz-screen.size-tiny .question-text { font-size: 0.85rem; }
#quiz-screen.size-tiny .option-btn { font-size: 0.8rem; padding: 0.75rem 0.9rem; }
#quiz-screen.size-tiny .explanation-text { font-size: 0.7rem; }

@media (max-width: 600px) {
    .header-top {
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.75rem !important;
    }
    .font-size-selector-container {
        margin: 0 !important;
    }
}



