/* 時間割
   .timetable-container の中だけにスタイルを閉じ込めたもの。
   PC・モバイルともに同じ1週間一覧のテーブルを表示する。 */
.timetable-container {
    background: #ffffff;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);

    max-width: min(1000px, calc(100% - 40px));
    margin: 20px auto 40px;
    box-sizing: border-box;

    overflow-x: auto; /* 幅が足りないときは表だけ横スクロールさせる */
}

@media (min-width: 820px) {
    .timetable-container {
        /* PCでは表が大きすぎるため縮小 */
        max-width: 820px;
    }
}

.timetable-container table {
    width: 100%;
    min-width: 620px; /* これより狭いと読めないので、そこからは横スクロールに切り替える */
    table-layout: fixed; /* 曜日の列幅を均等にして、枠からはみ出させない */
    border-collapse: separate;
    border-spacing: 8px;
}

.timetable-container th,
.timetable-container td {
    text-align: center;
    vertical-align: middle;
    padding: 12px 8px;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: normal; /* 科目名は折り返す */
}

.timetable-container th.period-header {
    background: transparent;
    width: 70px;
}

.timetable-container th.day-header {
    background-color: #f1f5f9;
    color: #1e293b;
    font-weight: bold;
}

.timetable-container .period-cell {
    background-color: #f1f5f9;
    color: #334155;
    font-weight: bold;
    width: 70px;
}

.timetable-container .period-number {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.timetable-container .period-time {
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.3;
}

.timetable-container td.highlight {
    background-color: #e0f2fe;
    color: #0369a1;
    font-weight: bold;
}
.timetable-container td.sub-highlight {
    background-color: #e0feef;
    color: #03a167;
    font-weight: bold;
}

.timetable-container td.empty,
.timetable-container td.course-default {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    color: #334155;
}

.timetable-note {
    margin-top: 8px;
    text-align: center;
    font-size: 0.85rem;
    color: #64748b;
}

/* 表の下に置く、色の意味の説明 */
.timetable-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 0.85rem;
    color: #334155;
}

.timetable-legend__key {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background-color: #e0f2fe;
    border: 1px solid #bae0f7;
    flex-shrink: 0;
}
.timetable-legend__sub-key {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background-color: #e0feef;
    border: 1px solid #baf7e0;
    flex-shrink: 0;
}
.timetable-legend__teacher-key {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background-color: #ffffff;
    border: 1px solid #E2E8F0;
    flex-shrink: 0;
}

@media (max-width: 820px) {
    .timetable-container {
        width: calc(100% - 16px);
        padding: 10px 6px 14px;
        border-radius: 14px;
        box-shadow: 0 3px 14px rgba(15, 23, 42, 0.08);
        overflow: hidden;
    }

    /* スマホでも月〜金の1週間を一覧で表示する */
    .timetable-legend {
        font-size: 10px;
    }

    .timetable-container table {
        min-width: 0; /* 横スクロールさせず、画面幅に収める */
        border-spacing: 3px;
    }

    .timetable-container th,
    .timetable-container td {
        padding: 7px 2px;
        font-size: 0.62rem;
        line-height: 1.35;
        border-radius: 6px;
        overflow-wrap: break-word;
    }

    /* 教科セルの高さを確保する */
    .timetable-container td.empty,
    .timetable-container td.highlight,
    .timetable-container td.sub-highlight,
    .timetable-container td.course-default {
        min-height: 52px;
        height: 52px;
    }

    .timetable-container .period-cell,
    .timetable-container th.period-header {
        width: 20px;
    }

    .timetable-container .period-cell {
        padding: 6px 0;
    }

    .timetable-container .period-number {
        font-size: 0.8rem;
        margin-bottom: 1px;
    }

    /* 820px以下では時刻を非表示にして列幅を確保する */
    .timetable-container .period-time {
        display: none;
    }
}
