body {
    font-family: 'Hiragino Sans', 'Yu Gothic', sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f5f5f5;
}

.container {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

/* 学習記録操作ボタン */
.record-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
}

.record-btn {
    background: #17a2b8;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s;
}

.record-btn:hover {
    background: #138496;
}

.record-btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

/* 隠しファイル入力 */
#import-file {
    display: none;
}

.error {
    color: #dc3545;
    background: #f8d7da;
    padding: 15px;
    border-radius: 5px;
    margin: 20px 0;
    border: 1px solid #f5c6cb;
}

.success {
    color: #155724;
    background: #d4edda;
    padding: 15px;
    border-radius: 5px;
    margin: 20px 0;
    border: 1px solid #c3e6cb;
}

.set-item {
    border: 1px solid #ddd;
    margin: 10px 0;
    padding: 20px;
    border-radius: 8px;
    background: #fafafa;
}

.set-header {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.set-info {
    margin: 10px 0;
    color: #666;
}

.status {
    display: flex;
    gap: 10px;
    margin: 10px 0;
    font-size: 14px;
    flex-wrap: wrap;
    align-items: center;
}

.status button {
    padding: 6px 12px;
    border: 2px solid transparent;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    font-size: 16px;
    transition: all 0.3s;
}

.status button.active::before {
    content: "▶ ";
    display: block;
    text-align: center;
    font-size: 12px;
    line-height: 1;
    margin-bottom: 2px;
}

.status .completed-btn { 
    background: #d4edda; 
    color: #155724; 
    border-color: #c3e6cb;
}
.status .completed-btn:hover { 
    background: #c3e6cb;
    transform: translateY(-1px);
}

.status .not-memorized-btn { 
    background: #fff3cd; 
    color: #856404; 
    border-color: #ffeaa7;
}
.status .not-memorized-btn:hover { 
    background: #ffeaa7;
    transform: translateY(-1px);
}

.status .untouched-btn { 
    background: #f8d7da; 
    color: #721c24; 
    border-color: #f5c6cb;
}

.status .untouched-btn:hover { 
    background: #f5c6cb;
    transform: translateY(-1px);
}

.status .maa-ok-btn { 
    background: #d1e7dd; 
    color: #0f5132; 
    border-color: #badbcc;
}
.status .maa-ok-btn:hover { 
    background: #badbcc;
    transform: translateY(-1px);
}

.status .rakusho-btn { 
    background:white; 
    color: #155724; 
    border-color: #c3e6cb;
}
.status .rakusho-btn:hover { 
    background: #c4c3e6;
    transform: translateY(-1px);
}


.status .total-btn { 
    background: #e2e3e5; 
    color: #383d41; 
    border-color: #d6d8db;
}
.status .total-btn:hover { 
    background: #d6d8db;
    transform: translateY(-1px);
}

.label-untouched {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
    font-weight: bold;
    white-space: nowrap;
}

.label-not-memorized {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
    font-weight: bold;
    white-space: nowrap;
}

.label-completed {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
    font-weight: bold;
    white-space: nowrap;
}


.label-maa-ok {
    background-color: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
    font-weight: bold;
    white-space: nowrap;
}

.label-rakusho {
    background-color: white;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
    font-weight: bold;
    white-space: nowrap;
}

.label-siwake {
    background-color: #d4edda;
    color: #155724;
    border: none;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    font-weight: bold;
}

.view-mode-selector {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-left: 10px;
}

.view-mode-selector input[type="radio"] {
    margin: 0 5px 0 0;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

button {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.primary-btn {
    background: #007bff;
    color: white;
}

.primary-btn:hover {
    background: #0056b3;
}

.secondary-btn {
    background: #6c757d;
    color: white;
}

.secondary-btn:hover {
    background: #545b62;
}

.secondary-btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.success-btn {
    background: #28a745;
    color: white;
}

.success-btn:hover {
    background: #1e7e34;
}

.warning-btn {
    background: #ffc107;
    color: #212529;
}

.warning-btn:hover {
    background: #e0a800;
}

.study-screen, .list-screen {
    display: none;
}

.question-card {
    background: white;
    border: 2px solid #007bff;
    border-radius: 10px;
    padding: 30px;
    margin: 20px 0;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items:normal;
    text-align:left;
}

.question-text {
    font-size: 22px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.answer-text {
    font-size: 22px; /*16px;*/
    line-height: 1.6;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 20px;
    border-left: 4px solid #28a745;
}

.explanation-text {
    font-size: 22px; /*16px;*/
    line-height: 1.6;
    padding: 20px;
    background: #fff3cd;
    border-radius: 8px;
    margin-top: 10px;
    border-left: 4px solid #ffc107;
}

.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
}

.radio-group {
    display: flex;
    gap: 15px; /* ここは共通で維持 */
    margin: 20px 0;
    justify-content: center;
    flex-wrap: wrap; /* デフォルトは wrap に戻す */
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.question-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fafafa;
}

.question-content {
    flex: 1;
    margin-right: 20px;
}

.question-list-item .question-content {
    font-size: 20px;  /* お好みのサイズに */
}

.controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.back-btn {
    background: #6c757d;
    color: white;
    margin-bottom: 20px;
}

.back-btn:hover {
    background: #545b62;
}

.mode-info {
    text-align: left;
    margin: 20px 0;
    padding: 10px;
    background: #e9ecef;
    border-radius: 5px;
}

.progress-info {
    text-align: center;
    margin: 10px 0;
    color: #666;
}

.loading {
    text-align: center;
    color: #666;
    padding: 20px;
}



/* スマホ対応 */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    /* 学習記録ボタンを上部から通常配置に変更 */
    .record-controls {
        position: static;
        flex-direction: column;
        margin-bottom: 15px;
    }
    
    .record-btn {
        width: 100%;
        padding: 10px;
        font-size: 14px;
    }
    
    /* メイン画面と学習画面のステータスボタン */
    .status {
        gap: 5px;
        flex-wrap: wrap; /* 修正: ステータスボタンは wrap を維持 */
    }
    
    .status button {
        flex: 0 0 calc(50% - 5px); /* 2列表示を維持 */        padding: 8px 4px;
        font-size: 16px;
        white-space: normal;
        min-height: 40px;
    }
    
    /* 表示方式セレクターも折り返し */
    .view-mode-selector {
        flex: 0 0 100%;
        margin-left: 0;
        justify-content: center;
        gap: 15px;
    }
    
    /* カード型のナビゲーション */
    .navigation {
        flex-direction: column;
        gap: 10px;
    }
    
    .navigation > button {
        width: 100%;
        order: 2;
    }

    /* === カード型の分類ボタン用 === */
    /* 学習画面の分類ボタン (navigation 内の radio-group) */
    #study-screen .navigation .radio-group {
        width: 100%;
        gap: 8px; /* スマホでは小さめのギャップ */
        justify-content: center;
        flex-wrap: wrap; /* カード型は改行させる (以前の動作に戻す) */
        overflow-x: visible; /* 横スクロールを不要にする */
        padding-bottom: 0; /* 不要なパディングを削除 */
    }

    .navigation .radio-group {
        width: 100%;
        order: 1;
        gap: 8px;
        justify-content: center;
        flex-wrap: nowrap; /* これを追加 */
        overflow-x: auto; /* はみ出した場合にスクロールできるようにする */
        padding-bottom: 5px; /* スクロールバーが見えるように少しスペースを空ける */        
    }

    #study-screen .navigation .radio-item {
        font-size: 12px;
        flex: 0 0 auto;
        min-width: auto; /* コンテンツに応じた幅に戻す */
        white-space: nowrap; /* テキストが改行されないように */
    }

    /* 「分類」ラベルの改行を防止 (もしあれば) */
    #study-screen .navigation .radio-item:first-child {
        /* flex: 0 0 100%; の設定を削除またはコメントアウト */
        /* justify-content: center; も削除 */
        /* margin-bottom: 3px; も削除 */
        flex: 0 0 auto; /* 他のラジオボタンと同じ振る舞いに */
        margin-bottom: 0; /* 不要なマージンを削除 */
    }

    .navigation .radio-item {
        font-size: 12px;
        flex: 0 0 auto;
        /* min-width を設定して、コンテンツが収まるようにする */
        min-width: fit-content;   }
    
    .navigation .radio-item:first-child {
        flex: 0 0 100%;
        justify-content: center;
        margin-bottom: 3px;
    }
    
    #prev-question {
        order: 3;
    }
    
    #next-question {
        order: 4;
    }
    
    /* 問題カード */
    .question-card {
        padding: 15px;
        min-height: 150px;
    }
    
    .question-text {
        font-size: 20px;
    }
    
    .answer-text, .explanation-text {
        font-size:  20px; /*14px;*/
        padding: 15px;
    }
    
    /* 一覧型の問題アイテム */
    .question-list-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .question-content {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    /* 一覧型のnavigationは幅いっぱいに */
    .question-content .navigation {
        width: 100%;
        justify-content: center;
    }
    
    .question-content .navigation .radio-group {
        width: 100%;
        gap: 5px;
        justify-content: center;
    }
    
    .question-content .navigation .radio-item {
        font-size: 13px;
        flex: 0 0 auto;
    }
          
    /* .question-content .navigation .radio-item:first-child のルールを削除 */
    /* これが原因で「未分類」が強制的に改行されていました */
    /*    
    .question-content .navigation .radio-item:first-child {
        flex-basis: 100%;
        margin-bottom: 5px;
        justify-content: center;
    }    
    */
    /* === 一覧型の分類ボタン用 === */
    /* 問題リスト内の各アイテムの分類ボタン (question-list-item 内の radio-group) */
    .question-list-item .radio-group {
        width: 100%;
        gap: 5px; /* もっと小さめのギャップ */
        justify-content: flex-start; /* 左寄せ */
        flex-wrap: nowrap; /* 一覧型は改行させない */
        overflow-x: auto; /* 必要に応じて横スクロール */
        padding-bottom: 5px; /* スクロールバーが見えるように */
    }

    .question-list-item .radio-item {
        font-size: 13px;
        flex: 0 0 auto;
        min-width: fit-content; /* コンテンツにぴったりの幅を維持 */
        white-space: nowrap; /* テキストが改行されないように */
    }


    /* セットアイテム */
    .set-item {
        padding: 15px;
    }
    
    .set-header {
        font-size: 16px;
    }
}