/* --- 基本スタイル --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    background-color: #f8f9fa;
    color: #343a40;
}

h1, h2, h3 {
    color: #333;
    margin-top: 1.5em;
    margin-bottom: 0.8em;
}

h1 {
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 0.3em;
    font-size: 2em;
    margin-top: 0;
}
h2 {
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.3em;
    font-size: 1.6em;
}

h3 {
    font-size: 1.2em;
}


a {
    color: #007bff;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* 条件やメッセージ表示用 */
.conditions, .error-message, .info-message {
    padding: 10px 15px;
    margin-bottom: 15px;
    border-radius: 4px;
}
.conditions {
    background-color: #e9ecef;
    border-left: 5px solid #adb5bd;
    font-size: 0.95em;
}
.conditions code {
    background-color: #dfe2e5;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9em;
}

.error-message {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}
.info-message {
    color: #0c5460;
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    margin-top: 10px;
}
/* フィルタ結果がない場合用メッセージ */
.no-video-message {
     color: #856404;
     background-color: #fff3cd;
     border: 1px solid #ffeeba;
     padding: 10px 15px;
     margin-top: 10px;
     border-radius: 4px;
     text-align: center;
 }


/* --- フィルタリングコンテナ --- */
.filter-container {
    display: flex; /* 横並びにする */
    flex-wrap: wrap; /* 折り返し可能にする */
    gap: 20px; /* 要素間の隙間 */
    align-items: flex-end; /* ラベルとセレクトの下端を揃える */
    margin-bottom: 25px;
    padding: 15px 20px;
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}
.filter-item {
    /* 特に指定不要 */
}
.filter-container label {
    display: block; /* ラベルをブロック要素にして改行させる */
    margin-bottom: 5px; /* ラベルとセレクトの間 */
    margin-right: 0; /* 右マージン不要 */
    font-weight: 600;
    color: #495057;
    font-size: 0.9em; /* ラベルを少し小さく */
}
.filter-container select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    min-width: 180px;
    font-size: 1em;
    background-color: #fff;
    cursor: pointer;
    height: 38px; /* 高さを揃える */
}
.filter-container select:focus {
     border-color: #80bdff;
     outline: 0;
     box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}


/* --- ランキングセクション --- */
.ranking-section {
    background-color: #fff;
    padding: 20px;
    margin-bottom: 30px;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}
.ranking-section h2 {
    margin-top: 0;
    border-bottom: none;
    font-size: 1.5em;
    padding-bottom: 0;
}

.ranking-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

.ranking-group { /* JavaScriptで表示/非表示制御 */ }

.ranking-group h3 {
    font-size: 1.1em;
    background-color: #f1f3f5;
    padding: 8px 12px;
    border-radius: 3px;
    margin-bottom: 10px;
    color: #495057;
    border-left: 4px solid #007bff;
    margin-top: 0;
}

.ranking-group table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9em;
    border: 1px solid #dee2e6;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.ranking-group th,
.ranking-group td {
    border: none;
    border-bottom: 1px solid #dee2e6;
    padding: 10px 12px;
    text-align: left;
    vertical-align: middle;
}
.ranking-group tbody tr:last-child td {
     border-bottom: none;
}


.ranking-group th {
    background-color: #e9ecef;
    font-weight: 600;
    border-bottom-width: 2px;
    color: #495057;
}
.ranking-group td:last-child { /* 採用率セル */
    text-align: right;
    font-weight: 500;
    white-space: nowrap;
}

/* ランキングテーブルの行の背景色を交互に変更 */
.ranking-group table tbody tr:nth-child(even) { background-color: #f8f9fa; }
.ranking-group table tbody tr:nth-child(odd) { background-color: #ffffff; }
.ranking-group table tbody tr:hover { background-color: #e2e6ea; cursor: default; }

/* ランキングテーブル内の生徒名セルのスタイル調整 */
.ranking-group table td:first-child { }

.student-cell {
    display: flex;
    align-items: center;
    min-height: 24px;
}

.student-face-icon {
    width: 24px; height: 24px; margin-right: 8px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0; background-color: #eee;
    display: inline-block; vertical-align: middle; border: 1px solid #ddd;
}
.student-face-icon.placeholder {
    background-color: #e9ecef; border: 1px dashed #adb5bd;
}

.student-name {
    display: inline-block; line-height: 1.2; vertical-align: middle;
}


/* --- 動画セクション --- */
.video-section { margin-bottom: 30px; }
.video-section h2 { font-size: 1.5em; margin-bottom: 1em; }
.armor-group { margin-bottom: 30px; /* JavaScriptで表示/非表示制御 */ }
.armor-group h3 { font-size: 1.2em; background-color: #e9ecef; padding: 10px 15px; border-radius: 4px; margin-bottom: 15px; color: #495057; margin-top: 0; }
.video-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; list-style: none; padding: 0; margin: 0; }


/* --- 動画アイテムのスタイル --- */
.video-item { background-color: #fff; border-radius: 6px; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.1); transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out; display: flex; flex-direction: column; border: 1px solid #e9ecef; }
.video-item:hover { transform: translateY(-3px); box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
.video-thumbnail { position: relative; width: 100%; padding-top: 56.25%; background-color: #eee; overflow: hidden; }
.video-thumbnail a { display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.video-thumbnail img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; display: block; border: none; background-color: #000; } /* contain時の背景色も指定 */
.video-details { padding: 12px; flex-grow: 1; display: flex; flex-direction: column; justify-content: space-between; }
.video-details h4 { font-size: 0.9em; font-weight: 600; line-height: 1.4; margin: 0 0 8px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; min-height: 2.8em; }
.video-details h4 a { color: #343a40; }
.video-details h4 a:hover { color: #0056b3; }
.meta-info { font-size: 0.8em; color: #6c757d; display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 8px; border-top: 1px solid #f1f3f5; }
.meta-info .channel { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 65%; padding-right: 5px; }
.meta-info .channel a { color: #6c757d; }
.meta-info .channel a:hover { color: #495057; }
.meta-info .score { font-weight: 700; color: #dc3545; white-space: nowrap; font-size: 1.5em; }


/* --- レスポンシブデザイン --- */
@media (max-width: 1200px) {
    .video-list { grid-template-columns: repeat(3, 1fr); }
    .ranking-container { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}
@media (max-width: 992px) {
    .video-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .video-list { grid-template-columns: repeat(2, 1fr); gap: 15px; }
     .ranking-container { grid-template-columns: 1fr; }
}

/* --- スマートフォンなど狭い画面向けのスタイル --- */
@media (max-width: 576px) {
    body { padding: 10px; }
    .video-list { grid-template-columns: 1fr; gap: 10px; }
    h1 { font-size: 1em; } h2 { font-size: 1em; } h3 { font-size: 1em; }

    .ranking-section h2 { font-size: 1em; }
    .video-section h2 { font-size: 1em; }

    .filter-container { flex-direction: column; align-items: stretch; gap: 15px; } /* フィルタを縦積みに */
    .filter-container select { min-width: 100%; } /* セレクトボックスを幅いっぱいに */
    .ranking-group th, .ranking-group td { padding: 8px 10px; font-size: 0.85em; }
    .student-face-icon { width: 20px; height: 20px; margin-right: 6px; }

    /* 動画アイテムのレイアウト変更 */
    .video-item { flex-direction: row; transition: none; }
    .video-item:hover { transform: none; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
    .video-thumbnail { flex: 0 0 170px; padding-top: 0; height: auto; align-self: stretch; overflow: hidden; background-color: #eee; } /* 幅100pxに戻す */
    .video-thumbnail a { position: static; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
    .video-thumbnail img { position: static; width: 100%; height: 100%; object-fit: contain; /* 画像全体を表示 */ display: block; border: none; border-right: 1px solid #eee; background-color: #000; /* contain時の背景色 */ max-width: 100%; max-height: 100%; }
    .video-details { flex-grow: 1; padding: 8px 12px; display: flex; flex-direction: column; justify-content: flex-start; }
    .video-details h4 { font-size: 0.9em; line-height: 1.3; margin: 0 0 4px 0; -webkit-line-clamp: 3; max-height: 3.9em; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-box-orient: vertical; min-height: 0; }
    .meta-info { font-size: 0.8em; margin-top: auto; padding-top: 6px; border-top: 1px solid #f1f3f5; display: flex; justify-content: space-between; align-items: center; flex-direction: row-reverse; }
    .meta-info .channel { max-width: 60%; }

    .channel { display: none; }
}

/* プレースホルダー画像のスタイル */
img[src="placeholder.png"] {
    object-fit: contain;
    background-color: #ccc;
    border: 1px solid #bbb;
}

/* ランキングテーブルの順位セルのスタイル */
.ranking-group table th.th-rank,
.ranking-group table td:first-child { /* 順位セル */
    text-align: center;
    font-weight: bold;
    width: 50px; /* 順位の列幅を固定（調整可） */
    padding-left: 5px;
    padding-right: 5px;
}
/* 生徒名セルのスタイルを上書き（順位セルが追加されたため） */
.ranking-group table td:nth-child(2) { /* 生徒名セル */
    text-align: left; /* 左揃えに戻す */
    font-weight: normal; /* 通常の太さに戻す */
    width: auto; /* 幅を自動に */
}
.ranking-group table td:nth-child(2) .student-cell {
    justify-content: flex-start; /* 左寄せにする */
}


/* 11位以下を非表示にするクラス */
.rank-hidden {
    /* display: none; はJavaScript側で直接設定するため、CSSでは不要 */
}

/* 「もっと見る」ボタンのスタイル */
.show-more-container {
    text-align: center; /* ボタンを中央寄せ */
    margin-top: 15px; /* テーブルとの間隔 */
}
.show-more-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease;
}
.show-more-btn:hover {
    background-color: #0056b3;
}

/* 採用率セルのスタイルを上書き（列が増えたため） */
.ranking-group td:last-child { /* 採用率セル */
    text-align: right;
    font-weight: 500;
    white-space: nowrap;
}


/* 必要であれば、レスポンシブ調整 */
@media (max-width: 576px) {
     .ranking-group table th.th-rank,
     .ranking-group table td:first-child { /* 順位セル */
        width: 40px; /* スマホでは少し狭く */
        font-size: 0.8em;
        padding-left: 3px;
        padding-right: 3px;
     }
     .ranking-group table td:nth-child(2) { /* 生徒名セル */
        font-size: 0.85em; /* 他のセルと合わせる */
     }
}

/* メニューのスタイル */
.menu-bar {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10; /* 他の要素より前面に表示 */
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px;
    color: gray;
}

.menu {
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: none; /* 初期状態では非表示 */
    position: absolute;
    top: 100%;
    right: 0;
    width: 200px;
}

.menu.open {
    display: block; /* openクラスが付与されると表示 */
}

.menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu li {
    padding: 8px 15px;
    border-bottom: 1px solid #eee;
    text-align: left;
}

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

.menu a {
    text-decoration: none;
    color: #333;
}

.menu a:hover {
    color: #007bff;
}