/* ═══════════════════════════════════════════════════════════════
   rpsc.css — RPSC・RSSB 模試スイート（ページ固有スタイル）
   Version: 2.0.1 — shared.css 依存版（重複削除済み）
   ═══════════════════════════════════════════════════════════════ */

/* ── RPSC 固有の CSS カスタムプロパティ ───────────────────── */
:root {
    --primary-gradient: linear-gradient(135deg, #4648d4 0%, #6063ee 100%);
    --bg-color: #fcf8ff;
    --card-bg: #ffffff;
    --text-color: #1b1b23;
    --border-color: #c7c4d7;
    --hover-bg: rgba(70,72,212,0.08);
    --muted-color: #767586;
    --danger: #dc3545;
    --success: #28a745;
    --warning: #ffc107;
    --info: #17a2b8;
    --primary: #4648d4;
}

[data-theme="dark"] {
    --bg-color: #12121c;
    --card-bg: #1e1e2e;
    --text-color: #e4e1ed;
    --border-color: #3a3a52;
    --hover-bg: rgba(70,72,212,0.18);
    --muted-color: #9d9ab0;
}

/* ── RPSC ページ用の body 背景（shared.css のリセットはそのまま利用） ── */
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

/* ── Noscript バナー ───────────────────────────────────────── */
.noscript-banner {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    z-index: 10000;
}

/* ── メインコンテナ ───────────────────────────────────────── */
.container {
    max-width: 1000px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(70,72,212,0.12), 0 4px 16px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: background 0.3s, box-shadow 0.3s;
}

/* ── ヘッダー（RPSC 専用） ───────────────────────────────── */
.header {
    background: var(--primary-gradient);
    color: white;
    padding: 24px 20px 20px;
    text-align: center;
    position: relative;
}

.header h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
    font-family: var(--font-display, 'Manrope', 'Playfair Display', sans-serif);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.header p {
    opacity: 0.88;
    font-size: 0.9rem;
    font-weight: 500;
}

.header-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── ヘッダーアイコン（色付き） ───────────────────────────── */
.header-controls .icon-btn:nth-child(2) { color: #6ee48f; }
.header-controls .icon-btn:nth-child(3) { color: #fbbf24; }
.header-controls .icon-btn:nth-child(4) { color: #60a5fa; }
.header-controls .icon-btn:nth-child(5) { color: #f87171; }

.icon-btn {
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
}

.icon-btn:hover {
    background: rgba(255,255,255,0.32);
    transform: scale(1.1);
}

.icon-btn:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* ── タイマー ─────────────────────────────────────────────── */
.timer-info {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
    flex-wrap: wrap;
}

.timer-box {
    background: rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 30px;
    margin: 5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.timer-box__icon {
    font-size: 18px;
    opacity: 0.8;
}

.timer-box__label {
    font-size: 0.85rem;
    opacity: 0.85;
}

.timer-box__value {
    font-size: 1.2rem;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

/* ── タブ（RPSC 専用） ───────────────────────────────────── */
.tabs {
    display: flex;
    background: var(--card-bg);
    border-bottom: 2px solid var(--border-color);
    overflow-x: auto;
    gap: 0.25rem;
    padding: 0 0.5rem;
    transition: background 0.3s;
}

.tab {
    padding: 14px 20px;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 0.9rem;
    color: var(--text-color);
    white-space: nowrap;
    transition: all 0.2s;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab.active,
.tab[aria-current="page"] {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.tab:hover:not(:disabled) {
    background: var(--hover-bg);
    color: var(--primary);
}

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

.tab:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

/* ── コンテンツ・画面切り替え ───────────────────────────── */
.content {
    padding: 20px;
}

.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

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

/* ── スタート画面要素 ───────────────────────────────────── */
.screen__tagline {
    text-align: center;
    color: var(--muted-color);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.notice {
    background: rgba(70,72,212,0.05);
    border-left: 4px solid var(--primary);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.notice--info {
    background: rgba(23,162,184,0.06);
    border-left-color: var(--info);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 2rem 0 1rem;
}

.step-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.step-header__title {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-display, 'Manrope', 'Playfair Display', sans-serif);
}

/* ── モード選択カード ─────────────────────────────────── */
.mode-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    margin: 2rem 0;
}

.mode-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.25s;
    flex: 1;
    min-width: 180px;
    max-width: 230px;
    text-align: center;
}

.mode-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(70,72,212,0.18);
}

.mode-card.selected,
.mode-card[aria-checked="true"] {
    border-color: var(--primary);
    background: var(--hover-bg);
    box-shadow: 0 4px 16px rgba(70,72,212,0.15);
}

.mode-card__title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0.5rem 0;
    font-family: var(--font-display, 'Manrope', 'Playfair Display', sans-serif);
}

.mode-card__desc {
    font-size: 0.85rem;
    color: var(--muted-color);
}

.mode-icon {
    font-size: 2.2rem;
    display: block;
    margin: 0 auto 0.5rem;
}

/* ── 科目選択グリッド ───────────────────────────────────── */
.subject-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
}

.subject-group {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 1.25rem;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.3s;
}

.subject-group:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(70,72,212,0.1);
}

.subject-group-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.75rem 1.1rem;
    background: rgba(70,72,212,0.06);
    border-bottom: 1px solid var(--border-color);
}

.subject-group-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.subject-group-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    flex: 1;
}

.subject-group-count {
    font-size: 0.75rem;
    color: var(--muted-color);
}

.subject-papers {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
}

.subject-card {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 2rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.88rem;
    font-weight: 500;
    background: var(--card-bg);
    color: var(--text-color);
    position: relative;
}

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

.subject-card.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.subject-card::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: 0.25rem;
}

.subject-card.selected::after {
    opacity: 1;
}

/* ── 科目選択ドロップダウン（追加） ────────────────────── */
.subject-select {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    transition: border-color 0.2s;
    margin-bottom: 1rem;
}

.subject-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(70,72,212,0.15);
}

/* ── ペーパーチップ（模試 / 150問） ────────────────────── */
.paper-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.paper-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 140px;
}

.paper-chip:hover {
    border-color: var(--primary);
    background: var(--hover-bg);
    transform: translateY(-2px);
}

.paper-chip.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.paper-chip-meta {
    font-size: 0.8rem;
    color: var(--muted-color);
    font-weight: 500;
}

.paper-chip.selected .paper-chip-meta {
    color: rgba(255,255,255,0.9);
}

/* ── 試験選択ドロップダウン ────────────────────────────── */
.exam-select {
    padding: 0.6rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.exam-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(70,72,212,0.15);
}

/* ── 統計ダッシュボード ────────────────────────────────── */
.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px,1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1rem;
    text-align: center;
    transition: box-shadow 0.2s, border-color 0.2s, background 0.3s;
}
.stat-card--full-width  { grid-column: 1 / -1; }
.stat-card--centered    { text-align: center;   }
.stat-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(70,72,212,0.1);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    font-family: var(--font-display, 'Manrope', 'Playfair Display', sans-serif);
}

/* ── カスタムオプション ──────────────────────────────── */
.custom-options {
    max-width: 600px;
    margin: 1rem auto;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1.5rem;
    transition: background 0.3s;
}

.custom-options__title {
    font-family: var(--font-display, 'Manrope', 'Playfair Display', sans-serif);
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--primary);
}

.form-group {
    margin: 1rem 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.6rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--card-bg);
    color: var(--text-color);
    transition: border-color 0.2s, background 0.3s, color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(70,72,212,0.15);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    color: var(--text-color);
}

.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--border-color);
    border-radius: 0.625rem;
    background: var(--card-bg);
    color: var(--text-color);
    font-family: var(--font-body, 'Inter', 'DM Sans', sans-serif);
    font-size: 0.9rem;
    transition: border-color 0.2s ease, background 0.3s, color 0.3s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(70,72,212,0.15);
}

.form-group--inline {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.topic-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.topic-tag {
    padding: 0.3rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 2rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    user-select: none;
}

.topic-tag:hover {
    border-color: var(--primary);
    background: var(--hover-bg);
}

.topic-tag.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ── 指示文 ───────────────────────────────────────────── */
.instructions {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1.25rem;
    margin: 1.5rem auto;
    max-width: 700px;
    text-align: left;
    transition: background 0.3s;
}

.instructions--accent {
    border-left: 4px solid var(--primary);
}

.instructions--success {
    border-left: 4px solid var(--success);
}
.instructions--info {
    border-left: 4px solid var(--info);
}

.instructions--info .instructions__title {
    color: var(--info);
}

.instructions__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-family: var(--font-display, 'Manrope', 'Playfair Display', sans-serif);
    font-size: 1.1rem;
}

.instructions__list {
    padding-left: 1.5rem;
    line-height: 1.8;
}

/* ── スタートアクション ──────────────────────────────── */
.start-action {
    text-align: center;
    margin: 2rem 0;
}

.start-action__label {
    margin-bottom: 1rem;
    color: var(--muted-color);
}

.btn-start-large {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
}

/* ── 言語トグル ─────────────────────────────────────── */
.lang-toggle-section {
    margin: 1.5rem 0;
    display: flex;
    justify-content: center;
}

.lang-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border-color);
    border-radius: 24px;
    transition: 0.3s;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .toggle-slider {
    background: var(--primary);
}

input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ── ボタン（shared.css の .btn を拡張） ───────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.7rem 1.5rem;
    border-radius: 2rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.25s;
    font-size: 0.9rem;
    margin: 0.25rem;
    font-family: var(--font-body, 'Inter', 'DM Sans', sans-serif);
    letter-spacing: 0.01em;
    justify-content: center;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 14px rgba(70,72,212,0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(70,72,212,0.42);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.97);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.2s;
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(70,72,212,0.05);
    transform: translateY(-1px);
}

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

.btn-danger:hover:not(:disabled) {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220,53,69,0.4);
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ── 問題コンテナ ───────────────────────────────────── */
.question-container {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: background 0.3s;
}

.question-header {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.question-number {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
    font-family: var(--font-display, 'Manrope', 'Playfair Display', sans-serif);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    margin: 0.8rem 0;
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    width: 0;
    transition: width 0.3s;
}

.question-text {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.question-text-hi {
    font-size: 0.9rem;
    color: var(--muted-color);
    margin-top: 0.3rem;
}
.preamble-wrap { 
    margin-bottom: 0.5rem; 
}
/* Question parts / assertions / lists */
.question-parts {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.question-part {
    display: flex;
    gap: 0.6rem;
    line-height: 1.6;
    align-items: flex-start;
}

.question-part-label {
    font-weight: 700;
    color: var(--primary);
    min-width: 3.5rem;
    flex-shrink: 0;
}

.question-assertions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.6rem;
    padding: 0.7rem 0.9rem;
    background: rgba(70,72,212,0.05);
    border-left: 3px solid rgba(70,72,212,0.35);
    border-radius: 0 0.5rem 0.5rem 0;
}

.question-assertion-item {
    display: flex;
    gap: 0.6rem;
    line-height: 1.6;
    align-items: flex-start;
    font-size: 0.95rem;
}

.question-assertion-label {
    font-weight: 700;
    color: var(--primary);
    min-width: 2rem;
    flex-shrink: 0;
}

.question-lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-top: 0.8rem;
}

@media (max-width: 540px) {
    .question-lists {
        grid-template-columns: 1fr;
    }
}

.question-list-col {
    border: 1.5px solid var(--border-color);
    border-radius: 0.7rem;
    overflow: hidden;
}

.question-list-header {
    background: rgba(70,72,212,0.12);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border-bottom: 1.5px solid var(--border-color);
    text-align: center;
}

.question-list-items {
    padding: 0.5rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.question-list-item {
    display: flex;
    gap: 0.5rem;
    font-size: 0.92rem;
    line-height: 1.5;
    align-items: flex-start;
    padding: 0.15rem 0;
}

.question-list-item-label {
    font-weight: 700;
    color: var(--primary);
    min-width: 2rem;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.question-list-col:last-child .question-list-item-label {
    color: #c0392b;
}

.question-list-instruction {
    margin-top: 0.5rem;
    font-style: italic;
    font-size: 0.88rem;
    color: var(--muted-color);
}

/* ── 選択肢 ─────────────────────────────────────────── */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-top: 1rem;
}

.option {
    padding: 0.8rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: var(--card-bg);
}
.opt-text-hi {
    font-size: 0.9em;
    color: var(--text-muted, #666);
    margin-top: 2px;
}
.option:hover {
    border-color: var(--primary);
    background: var(--hover-bg);
    transform: translateX(4px);
}

.option.selected {
    border-color: var(--primary);
    background: rgba(70,72,212,0.12);
}

.option-label {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
}
/* ── Option E ("Not attempted") label badge ───────────── */
.option-label--skip {
    background: #6c757d;
    color: #fff;
}
 
/* ── Practice-mode answer indicators ───────────────────── */
.option-indicator--correct {
    color: var(--success);
}
 
.option-indicator--wrong {
    color: var(--danger);
}
.option.selected .option-label {
    background: var(--primary);
    color: white;
}

.option.practice-correct {
    border-color: var(--success) !important;
    background: rgba(40,167,69,0.1) !important;
}

.option.practice-wrong {
    border-color: var(--danger) !important;
    background: rgba(220,53,69,0.1) !important;
}

.not-attempted-opt {
    border-style: dashed;
    opacity: 0.85;
}

.options-locked {
    pointer-events: none;
}

.question-context {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(70,72,212,0.08);
    border-left: 4px solid var(--primary);
    border-radius: 0.5rem;
    display: none;
}

.question-context.show {
    display: block;
}

.question-context-title {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.meta-badge {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 1rem;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.meta-badge--marked {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.topic-badge {
    background: rgba(70,72,212,0.12);
    color: var(--primary);
    border-color: rgba(70,72,212,0.3);
}

.recommendation {
    padding: 0.8rem 1rem;
    border-radius: 0.6rem;
    border-left: 4px solid var(--primary);
    background: rgba(70,72,212,0.07);
    margin-top: 0.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ── Practice banner ─────────────────────────────────── */
.practice-banner {
    background: linear-gradient(135deg, #84fab0, #8fd3f4);
    color: #333;
    padding: 0.5rem;
    border-radius: 2rem;
    text-align: center;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
}

/* ── ナビゲーションボタン ───────────────────────────── */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.nav-buttons--primary,
.nav-buttons--secondary {
    justify-content: center;
}

.nav-buttons__group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── パレット ───────────────────────────────────────── */
.palette-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}

.palette-search {
    flex: 1;
    min-width: 120px;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--card-bg);
    color: var(--text-color);
    transition: border-color 0.2s;
}

.palette-search:focus {
    border-color: var(--primary);
    outline: none;
}

.palette-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    color: var(--muted-color);
}

.palette-legend__item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.palette-legend__swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.palette-legend__swatch--answered {
    background: rgba(40,167,69,0.2);
    border-color: var(--success);
}

.palette-legend__swatch--marked {
    background: rgba(255,193,7,0.2);
    border-color: var(--warning);
}

.palette-legend__swatch--not-attempted {
    background: rgba(108,117,125,0.15);
    border-color: #6c757d;
}

.palette-legend__swatch--not-visited {
    background: var(--card-bg);
    border-color: var(--border-color);
}

.palette-legend__swatch--blank {
    background: rgba(220,53,69,0.15);
    border-color: var(--danger);
}

.palette-legend__swatch--current {
    background: var(--primary);
    border-color: var(--primary);
}

.palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
    gap: 0.7rem;
    margin: 1.5rem 0;
}

.palette-item {
    aspect-ratio: 1;
    border: 2px solid var(--border-color);
    border-radius: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s, background 0.3s, color 0.3s;
    font-weight: 600;
}

.palette-item:hover {
    transform: scale(1.05);
    border-color: var(--primary);
}

.palette-item.current {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 2px 10px rgba(70,72,212,0.4);
}

.palette-item.answered {
    background: rgba(40,167,69,0.2);
    border-color: var(--success);
}

.palette-item.marked {
    background: rgba(255,193,7,0.2);
    border-color: var(--warning);
}

.palette-item.not-attempted-pal {
    background: rgba(108,117,125,0.15);
    border-color: #6c757d;
}

.palette-item.blank-risk {
    background: rgba(220,53,69,0.15);
    border-color: var(--danger);
    color: var(--danger);
}

.palette-footer {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

/* ── 結果画面 ──────────────────────────────────────── */
.score-card {
    background: var(--primary-gradient);
    border-radius: 1.5rem;
    padding: 2rem 1.5rem;
    text-align: center;
    color: white;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 32px rgba(70,72,212,0.3);
}

.score-value {
    font-size: 3rem;
    font-weight: 800;
    margin: 1rem 0;
    font-family: var(--font-display, 'Manrope', 'Playfair Display', sans-serif);
    letter-spacing: -0.02em;
}

.score-details {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.score-detail__value {
    font-size: 1.8rem;
    font-weight: bold;
}

.score-detail__label {
    display: block;
    font-size: 0.85rem;
    opacity: 0.9;
}

.performance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px,1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.performance-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1.25rem;
    transition: box-shadow 0.2s, background 0.3s;
}

.performance-card:hover {
    box-shadow: 0 4px 14px rgba(70,72,212,0.1);
}

.performance-card__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display, 'Manrope', 'Playfair Display', sans-serif);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
}

.performance-card__stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 0.25rem;
}

.stat-row dt {
    font-weight: 500;
    color: var(--muted-color);
}

.stat-row dd {
    font-weight: 600;
}

.analysis-panel {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1.25rem;
    margin-top: 1rem;
}

.analysis-panel__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display, 'Manrope', 'Playfair Display', sans-serif);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
}

.result-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 1.5rem;
}

/* ── レビュー画面 ──────────────────────────────────── */
.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.review-header h2 {
    font-family: var(--font-display, 'Manrope', 'Playfair Display', sans-serif);
    font-weight: 700;
}

.review-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.review-legend__item--correct {
    color: var(--success);
}

.review-legend__item--wrong {
    color: var(--danger);
}

.review-legend__item--unattempted {
    color: var(--muted-color);
}

.review-footer {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

/* ══════════════════════════════════════════════════════════════
   MODALS — Native <dialog>（divベースの .modal を置き換え）
   ══════════════════════════════════════════════════════════════ */

dialog.modal {
    border: none;
    background: transparent;
    padding: 0;
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
    inset: 0;
    overflow: hidden;
    color: var(--text-color);
}

dialog.modal[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.submit-warn-box {
    margin-top: 0.8rem;
    padding: 0.6rem;
    background: rgba(220,53,69,0.1);
    border-left: 4px solid #dc3545;
    color: #721c24;
}

dialog.modal::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.modal__content {
    background: var(--card-bg);
    max-width: 500px;
    width: 90%;
    border-radius: 1.5rem;
    padding: 1.75rem;
    animation: slideUp 0.2s ease;
    box-shadow: 0 24px 60px rgba(0,0,0,0.25);
    transition: background 0.3s;
    overflow-y: auto;
    max-height: 90vh;
}

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

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.close-btn:hover {
    background: var(--hover-bg);
    color: var(--danger);
    border-color: var(--danger);
}

.modal__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    margin: 0;
    font-family: var(--font-display, 'Manrope', 'Playfair Display', sans-serif);
}

.modal__title--warning {
    color: var(--warning);
}

.modal__title--danger {
    color: var(--danger);
}

.modal__subtitle {
    margin-bottom: 0.7rem;
    color: var(--muted-color);
    font-size: 0.9rem;
}

.modal__message {
    margin: 1rem 0 1.5rem;
    color: var(--muted-color);
}

.modal__alert {
    margin-top: 1rem;
}

.modal__alert--danger {
    color: var(--danger);
}

.modal__actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.modal__actions--centered {
    justify-content: center;
}

.modal__content--centered {
    text-align: center;
}

.anticheat-counter {
    font-size: 2rem;
    font-weight: 800;
    color: var(--danger);
    margin: 1rem 0;
}

.time-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    background: #e3f2fd;
    color: #1565c0;
    margin-left: 8px;
}

.time-badge.slow {
    background: #fce4ec;
    color: #b71c1c;
}

/* ── Toast ───────────────────────────────────────────── */
#rpsc-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 2rem;
    padding: 0.75rem 1.5rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 9999;
    font-weight: 500;
    animation: toastIn 0.3s ease;
    transition: opacity 0.3s;
    pointer-events: none;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── ローディングオーバーレイ — Native <dialog> ────── */
dialog.loading-overlay {
    border: none;
    background: transparent;
    padding: 0;
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
    inset: 0;
    z-index: 10000;
    color: white;
}

dialog.loading-overlay[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

dialog.loading-overlay::backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.loading-overlay__content {
    text-align: center;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.spinner {
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* ── DB ステータスインジケータ ────────────────────── */
.db-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    padding: 3px 10px;
    border-radius: 1rem;
    background: rgba(255,255,255,0.15);
    color: white;
}

.db-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
}

.db-dot.connected {
    background: var(--success);
}

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

/* ── ショートカットモーダル ───────────────────────── */
.shortcut-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 0.7rem;
    margin: 1rem 0;
}

.shortcut-row {
    display: contents;
}

.shortcut-key {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    font-family: monospace;
    font-weight: bold;
}

.shortcut-key kbd {
    background: var(--border-color);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    font-family: var(--font-body, 'Inter', 'DM Sans', monospace);
}

/* ── 履歴モーダルスタイル ─────────────────────────── */
.history-list {
  max-height: 300px;
  overflow-y: auto;
  margin: 1rem 0;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.5rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item:hover {
  background: var(--hover-bg);
}

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

.history-date {
  font-size: 0.85rem;
  color: var(--muted-color);
}

/* ── Skip link & screen reader ─────────────────────── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    background: var(--primary-gradient);
    color: white;
    padding: 8px 16px;
    border-radius: 0 0 8px 8px;
    font-weight: 700;
    font-size: 0.9rem;
    z-index: 10000;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
}

/* ── 印刷用スタイル ───────────────────────────────── */
@media print {
    .no-print { display: none !important; }
    .container { box-shadow: none; border-radius: 0; }
    body { background: white; padding: 0; }
    .screen { display: block !important; }
    #testScreen, #paletteScreen, #startScreen { display: none !important; }
    #resultScreen, #reviewScreen { display: block !important; }

    /* Hide all dialogs on print */
    dialog.modal,
    dialog.loading-overlay { display: none !important; }
}

/* ── レスポンシブ ─────────────────────────────────── */
@media (max-width: 768px) {
    .header h1 { font-size: 1.3rem; }
    .header-controls { position: static; justify-content: center; margin-top: 12px; }
    .subject-card, .mode-card { min-width: 160px; }
    .score-value { font-size: 2rem; }
}

@media (max-width: 640px) {
    .shortcut-key kbd { min-width: 28px; padding: 0.2rem 0.4rem; font-size: 0.75rem; }
    .nav-buttons { flex-direction: column; align-items: stretch; }
    .nav-buttons__group { justify-content: center; }
}

/* ── フォーカス & アクセシビリティ ────────────────── */
output { font: inherit; color: inherit; }
kbd { font-family: var(--font-body, 'Inter', 'DM Sans', monospace); }

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .screen { animation: none; }
    .modal__content { animation: none; }
}

@media (prefers-contrast: more) {
    :root {
        --primary: #0000ee;
        --danger: #cc0000;
        --success: #006600;
        --border-color: #000;
        --muted-color: #444;
    }
    .btn-primary, .btn-danger { border-width: 2px; }
    .mode-card, .performance-card, .instructions,
    .question-container, .subject-group, .option, .palette-item {
        border-width: 2px;
    }
    .icon-btn { border-width: 2px; }
    .tab.active, .tab[aria-current="page"] { border-bottom-width: 4px; }
    .score-card { border: 3px solid #000; }
}
