
/* ========================================
   基本設定
======================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100%;
}

body {
    margin: 0;
    min-width: 0;
    background: #f5f7fb;
    color: #243043;
    font-family: system-ui, -apple-system,
        'Noto Sans JP', sans-serif;
}

a {
    color: #1767b1;
}

header {
    background: #173a63;
    color: #fff;
    padding: 18px max(20px, calc((100vw - 1050px) / 2));
    display: flex;
    justify-content: space-between;
    gap: 16px;
    min-width: 0;
}

header a {
    color: #fff;
    text-decoration: none;
}

main {
    width: 100%;
    max-width: 1050px;
    min-width: 0;
    margin: 35px auto;
    padding: 0 18px;
}

h1 {
    font-size: 27px;
}

h2 {
    font-size: 20px;
}

section,
.panel {
    background: #fff;
    padding: 24px;
    border-radius: 14px;
    margin: 18px 0;
    min-width: 0;
    max-width: 100%;
    box-shadow: 0 2px 12px #142b4710;
}

footer {
    padding: 30px;
}


/* ========================================
   フォーム
======================================== */

input,
select,
textarea {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 11px;
    font: inherit;
    background: #fff;
}

label {
    display: block;
    margin: 12px 0 5px;
    font-weight: 600;
}

button,
.btn {
    display: inline-block;
    border: 0;
    border-radius: 8px;
    background: #1767b1;
    color: #fff;
    padding: 11px 20px;
    max-width: 100%;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
}

button:disabled {
    background: #a9b5c2;
    cursor: not-allowed;
}

.check {
    display: inline-block;
    width: auto;
}

.inline {
    display: inline;
}

.inline input {
    width: auto;
}


/* ========================================
   共通レイアウト
======================================== */

.grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fill, minmax(min(235px, 100%), 1fr));
    gap: 14px;
    min-width: 0;
}

.row {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
    min-width: 0;
}

.row > * {
    width: 170px;
    min-width: 0;
}

.scroll {
    max-width: 100%;
    overflow: auto;
}


/* ========================================
   共通パーツ
======================================== */

.muted {
    color: #687587;
}

.small {
    font-size: 13px;
}

.error {
    background: #ffe6e6;
    padding: 14px;
    border-radius: 8px;
    color: #982727;
    overflow-wrap: anywhere;
}

.success {
    background: #e1f6e8;
    padding: 14px;
    border-radius: 8px;
    color: #166534;
}

.danger {
    background: #b83232;
}

.pill {
    display: inline-block;
    padding: 4px 9px;
    background: #e3edf8;
    border-radius: 20px;
}


/* ========================================
   通常テーブル
======================================== */

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}

th {
    background: #edf3fa;
}


/* ========================================
   旧ブース表示用
   ※管理画面などで使用する可能性があるため維持
======================================== */

.booth {
    border: 1px solid #dbe3ec;
    border-radius: 10px;
    padding: 16px;
    background: #fff;
}

.slots {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(min(115px, 100%), 1fr));
    gap: 8px;
}

.slot {
    padding: 12px;
    border: 1px solid #d9e2ee;
    border-radius: 8px;
}

.slot input {
    width: auto;
}

.slot.off {
    background: #f0f2f5;
    color: #8c95a0;
}


/* ========================================
   予約表
   横軸：時間帯
   縦軸：ブース
======================================== */

/* 横スクロール領域 */

.matrix-scroll {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: auto;
    border: 1px solid #d9e2ee;
    border-radius: 9px;
    -webkit-overflow-scrolling: touch;
}

/* 予約表全体 */

.booking-matrix {
    width: max-content;
    min-width: 100%;
    max-width: none;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
    font-size: 14px;
}

/* セル共通 */

.booking-matrix th,
.booking-matrix td {
    border-right: 1px solid #d9e2ee;
    border-bottom: 1px solid #d9e2ee;
    padding: 0;
    text-align: center;
    vertical-align: middle;
}

/* 横軸：時間帯 */

.booking-matrix thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #eaf1fa;
    min-width: 115px;
    padding: 12px 8px;
    white-space: nowrap;
    font-weight: 700;
}

/* 時間帯の終了時刻 */

.booking-matrix .time-end {
    display: block;
    font-size: 11px;
    font-weight: 400;
    margin-top: 3px;
}

/* 縦軸：ブース名 */

.booking-matrix .booth-head {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #f0f4fa;
    min-width: 170px;
    max-width: 220px;
    padding: 12px;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    font-weight: 700;
}

/* 左上のブース名セル */

.booking-matrix thead .booth-head {
    z-index: 4;
}


/* ========================================
   予約マス
======================================== */

.matrix-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    margin: 0;
    padding: 9px 7px;
    min-height: 65px;
    cursor: pointer;
    font-weight: 600;
}

/* チェックボックスを非表示 */

.matrix-option input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    pointer-events: none;
}

/* ◎ ○ × の記号 */

.matrix-symbol {
    font-size: 23px;
    line-height: 1.2;
    color: #1976a7;
}

/* 残り人数 */

.matrix-count {
    font-size: 11px;
    color: #617083;
}

/* 残りわずか */

.matrix-cell.low .matrix-symbol {
    color: #c07914;
}

/* 満枠・予約不可 */

.matrix-cell.full {
    background: #f0f1f3;
}

.matrix-cell.full .matrix-symbol {
    color: #9aa2ad;
}

.matrix-cell.full .matrix-option {
    cursor: not-allowed;
}

/* 選択中 */

.matrix-cell:has(input:checked) {
    background: #d9edff;
    box-shadow: inset 0 0 0 3px #1767b1;
}

/* キーボード操作時 */

.matrix-cell:has(input:focus-visible) {
    outline: 3px solid #1767b1;
    outline-offset: -3px;
}

/* マウスホバー */

@media (hover: hover) {
    .matrix-cell:not(.full):hover {
        background: #eef7ff;
    }

    .matrix-cell:has(input:checked):hover {
        background: #d9edff;
    }
}


/* ========================================
   スマートフォン
======================================== */

@media screen and (max-width: 767px) {

    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    /* ヘッダー */

    header {
        padding: 15px 16px;
        flex-wrap: wrap;
        gap: 10px;
    }

    header > * {
        min-width: 0;
        max-width: 100%;
    }

    /* メインコンテンツ */

    main {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin: 20px auto;
        padding: 0 12px;
    }

    main > form,
    main > section,
    main > .panel {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    section,
    .panel {
        padding: 16px;
        margin: 14px 0;
    }

    h1 {
        font-size: 23px;
    }

    h2 {
        font-size: 18px;
    }

    /* 共通レイアウト */

    .row {
        display: block;
    }

    .row > * {
        margin: 8px 0;
    }

    /* 予約表だけ横スクロール */

    .matrix-scroll {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        overflow-y: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }

    .booking-matrix {
        width: max-content;
        min-width: 100%;
        max-width: none;
        table-layout: auto;
    }

    /* ブース名の列幅 */

    .booking-matrix .booth-head {
        min-width: 110px;
        max-width: 120px;
        font-size: 12px;
        padding: 10px 8px;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    /* 時間帯の列幅 */

    .booking-matrix thead th {
        min-width: 100px;
        padding: 10px 6px;
    }

    /* 予約マス */

    .matrix-option {
        min-height: 60px;
        padding: 8px 5px;
    }

    .matrix-symbol {
        font-size: 21px;
    }

    .matrix-count {
        font-size: 10px;
    }

    /* 入力フォーム */

    input:not([type="checkbox"]),
    select,
    textarea {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    /* 通常テーブルの長い文字列対策 */

    .panel,
    section {
        overflow-wrap: break-word;
    }
}

/* 予約表の横はみ出し対策 */
.matrix-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    position: relative;
}

.booking-matrix {
    width: max-content;
    max-width: none;
}

/* スマホでも一番左のブース名を固定 */
@media (max-width: 767px) {
    .booking-matrix .booth-head {
        position: sticky;
        left: 0;
        z-index: 3;
        background: #f0f4fa;
    }

    /* 左上のセルは最前面 */
    .booking-matrix thead .booth-head {
        z-index: 4;
    }
}

.back-button-wrap {
    margin-top: 28px;
    text-align: center;
}

.back-button {
    display: inline-block;
    padding: 14px 36px;
    background: #2563eb;
    color: #fff;
    font-weight: bold;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s;
}

.back-button:hover {
    background: #1d4ed8;
    color: #fff;
}

.booth-duration {
    display: block;
    margin-top: 4px;
}

.booking-matrix .booth-target-age {
    display: block;
    width: fit-content;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
    white-space: normal;
    margin-top: 4px;
}
.booking-matrix .booth-target-age.age-color-blue { background: #e8f2ff; color: #2864a0; }
.booking-matrix .booth-target-age.age-color-green { background: #e5f5e9; color: #287b48; }
.booking-matrix .booth-target-age.age-color-orange { background: #fff0df; color: #b66319; }
.booking-matrix .booth-target-age.age-color-pink { background: #fce8ef; color: #ad486c; }
.booking-matrix .booth-target-age.age-color-purple { background: #f0e9fc; color: #7652a6; }

/* 予約表のスクロール領域 */
.matrix-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: 75vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* 予約表の幅を維持 */
.booking-matrix {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

/* 時間帯の見出しを上部に固定 */
.booking-matrix thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #eaf1fa;
}

/* スマホでページ全体が横にはみ出さないようにする */
@media (max-width: 767px) {
    .matrix-scroll {
        max-width: 100%;
        max-height: 70vh;
    }
}

form .form label {
    display: flex;
    align-items: center;
    gap: 0 10px;
}

form .form label span {
    border: 1px solid #ad486c;
    border-radius: 5px;
    color: #ad486c;
    padding: 1px 4px;
    font-size: 12px;
}