/* 固定ヘッダー */
.fixed-header {
    position: fixed;
    top: 0;
    width: 100%;
    background-color: #f4f4f9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-container {
    display: flex;
    gap: 20px;
    align-items: center;
}

#question-status {
    display: flex;
    gap: 10px;
}

.question-number {
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
}

.question-number.correct {
    background-color: green;
    color: white;
}

.question-number.incorrect {
    background-color: red;
    color: white;
}

.question-number.correct:hover {
    background-color: #76c776; /* 正解時の薄い緑 */
}

.question-number.incorrect:hover {
    background-color: #ff9999; /* 不正解時の薄い赤 */
}


body {
    margin-top: 70px; /* ヘッダーの高さ分の余白 */
}

/* 全体の基本スタイル */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f9;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    margin-top: 70px; /* ヘッダーの高さ分を確保 */
    padding: 20px;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

h1 {
    text-align: center;
    color: #2c3e50;
}

label {
    font-weight: bold;
}

/* ボタンスタイル */
button {
    display: block;
    width: 100%;
    padding: 10px;
    font-size: 16px;
    color: white;
    background-color: #3498db;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 20px;
}

/* 再出題ボタン */
.retry-button {
    display: none; /* 初期状態は非表示 */
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001; /* fixed-header(1000)より手前 */
    padding: 8px 24px;
    font-size: 16px;
    font-weight: bold;
    color: white;
    background-color: #e67e22; /* オレンジ系の色 */
    border: none;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: background-color 0.3s, transform 0.2s;
    width: auto; /* 幅を自動調整 */
}

.retry-button.visible {
    display: block;
}

button:hover {
    background-color: #2980b9;
}

.retry-button:hover {
    background-color: #d35400;
    transform: translateX(-50%) scale(1.05);
}

/* 正解・不正解の結果スタイル */
.correct {
    color: green;
    font-weight: bold;
}

.incorrect {
    color: red;
    font-weight: bold;
}

/* 問題の結果スタイル */
.question-result {
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f9f9f9;
}

/* 各問題スタイル */
.question {
    margin: 20px 0;
}

.choices {
    margin: 10px 0;
}

.result {
    margin-top: 20px;
    font-weight: bold;
    text-align: center;
}

.fixed-header.hidden {
    display: none;
}

.fixed-header {
    display: none; /* 初期状態で非表示に設定 */
    position: fixed;
    top: 0;
    width: 100%;
    background-color: #f4f4f9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 10px 20px;
    justify-content: space-between;
    align-items: center;
    overflow-x: auto; /* 横スクロールを可能にする */
}

.fixed-header.visible {
    display: flex; /* 解答確認後に表示 */
}

/* 1270px以上（サイドナビ表示時）のヘッダー調整 */
@media (min-width: 1270px) {
    .fixed-header.visible {
        width: calc(100% - 200px); /* サイドナビの幅(200px)を引く */
    }
}

/* 1269px以下（ハンバーガーメニュー表示時）のヘッダー調整 */
@media (max-width: 1269px) {
    .fixed-header.visible {
        padding-right: 70px; /* ハンバーガーメニューと重ならないよう右の余白を確保 */
    }
}

.header-container {
    display: flex;
    gap: 20px;
    align-items: center;
}

#question-status {
    display: flex;
    gap: 10px;
}

/* レスポンシブ対応 */
@media screen and (max-width: 768px) {
    .fixed-header {
        padding: 5px 10px; /* スマホでのヘッダー内の余白調整 */
    }

    .header-container {
        flex-wrap: nowrap; /* 横スクロールを強制 */
        overflow-x: auto; /* 横スクロール対応 */
        gap: 10px; /* アイテム間の間隔を小さく */
    }

    .question-number {
        padding: 3px 6px; /* ボタンサイズを縮小 */
        font-size: 12px; /* フォントサイズを縮小 */
    }
}

@media screen and (min-width: 769px) and (max-width: 1024px) {
    .fixed-header {
        padding: 8px 15px; /* iPadでのヘッダー内の余白調整 */
    }

    .question-number {
        padding: 4px 8px; /* iPad向けサイズ調整 */
        font-size: 14px; /* フォントサイズを中間に */
    }
}

#range-selection {
    margin-bottom: 20px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f9f9f9;
}

#range-selection h3 {
    margin-top: 0;
}

#range-selection div {
    margin-bottom: 10px;
}

#range-selection label {
    font-weight: bold;
}

#range-selection input {
    margin-left: 5px;
    margin-right: 10px;
    padding: 5px;
    width: 60px;
}

#question-status {
    display: flex;
    gap: 5px;
    align-items: center;
}

.question-number {
    padding: 5px 8px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.question-number.correct {
    background-color: #4CAF50; /* 緑（正解） */
    color: white;
}

.question-number.incorrect {
    background-color: #E74C3C; /* 赤（不正解） */
    color: white;
}

.question-number:hover {
    transform: scale(1.2);
}

/* 単元リストのアイテム */
.unit-item {
    display: flex;
    align-items: center;
    gap: 5px; /* ボタンとチェックボックスの間隔を設定 */
}

/* 「↑」ボタンのスタイル（小さくする） */
.small-btn {
    padding: 2px 5px; /* ボタンの余白を小さく */
    font-size: 12px; /* フォントサイズを小さく */
    width: 20px; /* 幅を小さく */
    height: 20px; /* 高さを小さく */
    text-align: center;
    color: #00008f;
    border: 1px solid #ccc; /* 枠線を追加 */
    background-color: #f4f4f4; /* 背景色を淡いグレー */
    cursor: pointer;
    border-radius: 3px; /* 角丸 */
}

/* 「↑」ボタンをホバーしたとき */
.small-btn:hover {
    background-color: #e0e0e0;
}

/* トップへ戻るボタン */
.scroll-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    font-size: 20px;
    text-align: center;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
    display: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 9999;
}

/* ボタンをホバーしたときのスタイル */
.scroll-to-top:hover {
    background-color: #2980b9;
}

/* ボタンを表示する状態 */
.scroll-to-top.show {
    display: block;
    margin-bottom: 20px;
    margin-right: 15px;
}

.select-toggle {
    background-color: #ccc;  /* 地味なグレー */
    color: #003f63;  /* 文字色は黒系 */
    font-size: 16px; /* 小さめのフォント */
    padding: 5px 10px; /* 余白を小さめに */
    border: none;
    border-radius: 4px; /* 少し丸みをつける */
    cursor: pointer;
    transition: background-color 0.3s;
}

.select-toggle:hover {
    background-color: #bbb; /* 少し濃いグレー（目立ちすぎない） */
}

.answer-textarea {
    width: 100%; /* 横幅いっぱい */
    height: 40px; /* 高さを広げる */
    font-size: 16px; /* 文字を読みやすく */
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical; /* 手動で高さ調整可能 */
    font-family: "BIZ UD Gothic", Arial, Helvetica, sans-serif;
}

#score-summary {
    white-space: nowrap; /* 改行させない */
    font-size: 16px;
    font-weight: bold;
}

.score-percentage {
    font-size: 0.9em; /* パーセント表示を少し小さくする */
}

.feedback-container {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
}

.feedback-container p {
    font-size: 16px;
    color: #333;
    margin-bottom: 10px;
}

.feedback-button {
    display: inline-block;
    padding: 10px 16px;
    font-size: 16px;
    color: #2c5e1a; /* 濃い緑 */
    background-color: #dff2bf; /* 薄い黄緑 */
    border: 2px solid #a3d17a; /* ボーダーを少し濃い黄緑 */
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    width: auto; /* 幅を狭める */
}

.feedback-button:hover {
    background-color: #c8e6a3; /* ホバー時に少し濃い黄緑 */
    transform: scale(1.05);
}

@media screen and (max-width: 480px) {
    /* カテゴリと回答形式のラジオボタンを縦並びにする */
    .container > div {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    }

    /* ラベル内の文字が折れても見やすくする */
    label {
    white-space: normal;
    word-break: break-word;
    }
}

.question-result {
    position: relative; /* 単元を相対配置の基準に */
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f9f9f9;
    margin-bottom: 15px;
    min-height: 80px; /* 単元表示に余裕を持たせる */
}

.unit-tag {
    position: absolute;
    bottom: 5px;
    left: 10px;
    font-size: 12px;
    color: #296697;
    font-style: italic;
    pointer-events: none; /* クリックイベントを防ぐ */
    user-select: none; /* テキスト選択も防ぐ */
}

.site-description {
    text-align: center;
    font-size: 14px;
    color: #666;
    margin-top: -10px;
    margin-bottom: 20px;
    white-space: nowrap;       /* 改行させない */
    overflow: hidden;          /* はみ出たら切る（スマホ対応） */
    text-overflow: ellipsis;   /* 長すぎたら...に */
}

.ad-container {
    width: 100%;
    min-height: 120px; /* 広告バナー用の最低高さ（適宜調整） */
    margin-top: 30px;  /* フィードバックボタンとの間隔 */
    margin-bottom: 20px; /* ページ下部との間隔 */
    display: flex;
    justify-content: center;
    align-items: center;
}

.tab-container {
    max-width: 800px; /* .container と同じ幅 */
    margin: 30px auto; /* 上下余白 + 中央寄せ */
    background-color: #f9f9f9;
    border: 1px solid #ccc;
    border-radius: 6px;
    overflow: hidden;
}

.tab-buttons {
    display: flex;
    justify-content: space-around;
    background-color: #e0f7e9;
    border-bottom: 1px solid #ccc;
}

.tab-button {
    flex: 1;
    padding: 10px;
    text-align: center;
    background: none;
    border: none;
    font-weight: bold;
    cursor: pointer;
    color: #666; /* 🔸アクティブでないタブの文字色をグレーに */
}

.tab-button.active {
    background-color: #bde5c8;
    color: #2c3e50; /* アクティブ時は濃い色で */
}

.tab-button:hover:not(.active) {
    background-color: #4c7c5c;  /* 鮮やかではない濃い緑 */
    color: white;               /* ホバー時の文字色（お好みで調整可） */
}

.tab-panel {
    display: none;
    padding: 15px;
}

.tab-panel.active {
    display: block;
}

.feedback-table {
    width: 100%;
    table-layout: fixed; /* 横幅を均等に分割するために追加 */
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 14px;
}

.feedback-table th,
.feedback-table td {
    border: 1px solid #ccc;
    padding: 8px;
    text-align: left;
    vertical-align: top;
    word-wrap: break-word; /* 長いテキストの折り返し */
    width: 50%; /* 各列の横幅を50%に固定 */
}

.feedback-table th {
    background-color: #e0f7e9;
    font-weight: bold;
}

.feedback-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* 問題文と選択肢のテキストを選択できないようにする */
.question,
.choices,
.question-result {
    user-select: none;
    -webkit-user-select: none; /* Safari対応 */
    -moz-user-select: none;    /* Firefox対応 */
    -ms-user-select: none;     /* IE対応 */
}
.loading {
    display: flex;
    flex-direction: column;   /* ← ここを追加（縦方向に並べる） */
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.8);
    z-index: 2000;
    pointer-events: all;
}

.loading.hidden {
    display: none;
}

.gear {
    width: 50px;
    height: 50px;
    border: 5px solid #3498db;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg);}
    100% { transform: rotate(360deg);}
}

.loading-message {
    display: none;
    margin-top: 30px;  /* ギアから十分下げる */
    max-width: 320px;
    width: 80vw;
    padding: 12px 18px;
    border-radius: 10px;
    background: #3498db;
    color: #ffffff;
    text-align: center;
    font-size: 16px;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
    word-break: break-all;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.12);
}

@media screen and (max-width: 480px) {
    .loading-message {
        font-size: 14px;
        padding: 10px 8px;
        max-width: 94vw;
    }
}

/* PCサイズ（幅769px以上） */
@media screen and (min-width: 769px) {
    .tab-panel {
        min-height: 120px;
    }
    .feedback-container {
        min-height: 80px;
    }
    .ad-container {
        min-height: 120px;
    }
}

/* iPad・タブレット（幅481〜768px） */
@media screen and (min-width: 481px) and (max-width: 768px) {
    .tab-panel {
        min-height: 80px;
    }
    .feedback-container {
        min-height: 60px;
    }
    .ad-container {
        min-height: 80px;
    }
}

/* スマホ（幅〜480px） */
@media screen and (max-width: 480px) {
    .tab-panel {
        min-height: 60px;
    }
    .feedback-container {
        min-height: 50px;
    }
    .ad-container {
        min-height: 60px;
    }
}

#bio-unit{
    min-height: 1500px;  /* 単元リストが出る前もこの高さを確保 */
}

#bio-basic-unit{
    min-height: 10px;
}

/*　本サイトの使い方　*/

.site-description-box {
    background: #457eda;
    color: #fff;
    border-radius: 12px;
    padding: 20px 28px 18px 28px;
    box-shadow: 0 2px 10px rgba(59,130,246,0.11);
    font-size: 17px;
    margin-bottom: 14px;
    position: relative;
    min-height: 80px;
    /* max-height を削除または以下のように調整 */
    max-height: none;  /* ← これで見切れなくなる */
    overflow: visible;
    transition: opacity 0.4s;
    opacity: 1;
}

/* 折り畳み時の状態は保持 */
.site-description-box.desc-collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
    overflow: hidden;
}

@media (max-width: 600px) {
    .site-description-box {
        max-height: 70vh;
        overflow-y: auto;
    }
}

/* ボタン中央寄せのためのラッパー */
.desc-toggle-btn-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 16px 0 8px 0;  /* ← 上下の余白を狭める */
}

/* ボタン本体 */
.desc-toggle-btn {
    background: #fff;
    color: #3b82f6;
    border: 2.5px solid #2563eb;  /* 青い枠線を追加 */
    border-radius: 18px;
    font-size: 15px;
    font-weight: bold;
    padding: 5px 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    max-width: 500px;
    width: 100%;
    white-space: normal;
    overflow-wrap: break-word;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border 0.18s;
    outline: none;
}

.desc-toggle-btn:focus,
.desc-toggle-btn:hover {
    border-color: #3b82f6;
    background: #e5f1fd;
    color: #1e40af;
}

.desc-hide-forever-btn {
    background: #f0f7ff;
    color: #2563eb;
    border: 2px solid #2563eb;   /* 青い枠線を強調 */
    border-radius: 12px;
    font-size: 13px;
    font-weight: bold;
    padding: 6px 16px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border 0.18s;
    max-width: 260px;
    width: auto;
    box-sizing: border-box;
    margin-right: 8px;
}

.desc-hide-forever-btn:hover {
    background: #e0eafe;
    color: #1e40af;
    border-color: #3b82f6;
}

.desc-hide-forever-btn.active {
    background: #2563eb;
    color: #fff;
    border: 2px solid #2563eb;
}

.desc-status-row {
    margin-top: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;   /* 右端に寄せる */
}

#desc-status-label {
    color: #000000a8;
    border-radius: 12px;    /* ここを追加＆大きめにする */
    padding: 2px 12px;      /* 少し余白もUP（お好みで調整） */
    font-size: 14px;
    background: #fffd94;    /* スクリプトで切り替える場合はここは初期値でOK */
    display: inline-block;  /* 丸みと余白が効きやすくなる */
}

.section-title {
    font-size: 1.1em;
    font-weight: bold;
}
.underline {
    text-decoration: underline;
}

/* サイドナビ */
.side-nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 200px;
    height: 100vh;
    background: #f4f4f9;
    box-shadow: -2px 0 6px rgba(0,0,0,0.07);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding-top: 60px; /* ヘッダーがあれば調整 */
    z-index: 1100;
}
.side-nav ul {
    list-style: none;
    margin: 0;
    padding: 0 20px;
    width: 100%;
}
.side-nav li {
    margin-bottom: 22px;
}
.side-nav a {
    display: block;
    font-size: 1.0em;
    color: #3b82f6;
    background: #fff;
    border-radius: 7px;
    padding: 10px 16px;
    text-decoration: none;
    font-weight: bold;
    transition: background 0.2s, color 0.2s;
}
.side-nav a:hover {
    background: #e3edfd;
    color: #0c2966;
}

/* モバイル時: サイドナビ非表示、ハンバーガー表示 */
.menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    width: 48px;
    height: 48px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 2em;
    line-height: 48px;
    padding: 0;
    z-index: 1301; /* ギアより下・他より上に。ギアがz-index:2000なら20001等に調整可 */
    box-shadow: 0 2px 8px rgba(59,130,246,0.16);
    cursor: pointer;
    text-align: center;
}
.menu-toggle:focus { outline: 2px solid #2563eb; }

.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 210px;
    height: 100vh;
    background: #fff;
    box-shadow: -2px 0 12px rgba(0,0,0,0.14);
    z-index: 1300;
    padding-top: 60px;
    /* スライドアニメーション用 */
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.45,0.07,0.62,0.97);
    display: block; /* 常にblockに */
}

.mobile-menu.open {
    transform: translateX(0%);
}

@keyframes slideInRight {
    from { transform: translateX(100%);}
    to { transform: translateX(0);}
}
.mobile-menu ul {
    list-style: none;
    padding: 0 16px;
}
.mobile-menu li {
    margin-bottom: 22px;
}
.mobile-menu a {
    display: block;
    font-size: 1.1em;
    color: #3b82f6;
    background: #f4f4f9;
    border-radius: 7px;
    padding: 10px 14px;
    text-decoration: none;
    font-weight: bold;
    transition: background 0.2s, color 0.2s;
}
.mobile-menu a:hover {
    background: #e3edfd;
    color: #0c2966;
}

/* 1270px未満でサイドナビ非表示・ハンバーガー表示 */
@media (max-width: 1269px) {
    .side-nav { display: none !important; }
    .menu-toggle { display: block; }
}
/* 1270px以上でサイドナビ表示・ハンバーガー非表示 */
@media (min-width: 1270px) {
    .side-nav { display: flex !important; }
    .menu-toggle, .mobile-menu { display: none !important; }
}
