* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Hiragino Kaku Gothic ProN",
        "Yu Gothic",
        Meiryo,
        sans-serif;

    background: #f3f4f6;
    color: #222;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}


/* =========================
   イベントヘッダー
   ========================= */

.event-header {
    width: 100%;
    padding: 20px 24px;

    text-align: center;
}

.event-header h1 {
    margin: 0;

    font-size: 28px;
    font-weight: bold;
}


/* =========================
   全体
   ========================= */

.app {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}


/* =========================
   参加者
   ========================= */

.player-section {
    margin-bottom: 24px;
}

.player-input {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.player-input label {
    font-weight: bold;
    white-space: nowrap;
}

.player-input input {
    width: 240px;
    max-width: 100%;
    height: 42px;
    padding: 0 12px;

    border: 1px solid #c7cbd1;
    border-radius: 6px;
    background: #fff;
}

.player-input input:focus {
    outline: none;
    border-color: #555;
}

.player-input button {
    height: 42px;
    padding: 0 18px;

    border: none;
    border-radius: 6px;
    background: #333;
    color: #fff;
}

.player-input button:hover:not(:disabled) {
    background: #222;
}

.player-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.status-message {
    min-height: 1.5em;
    margin: 8px 0 0;
    font-size: 14px;
}


/* =========================
   当選番号
   ========================= */

.number-section {
    margin-bottom: 32px;
    padding: 20px;

    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.current-number {
    text-align: center;
}

.section-title {
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: bold;
}

.current-number-value {
    font-size: 72px;
    font-weight: bold;
    line-height: 1.1;
}

.number-history {
    margin-top: 20px;
}

.number-history-list {
    display: flex;
    gap: 8px;

    overflow-x: auto;
    padding: 4px 0 8px;

    white-space: nowrap;
}

.number-history-list span {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 42px;
    height: 42px;

    border: 1px solid #ccc;
    border-radius: 50%;

    background: #f8f8f8;

    font-weight: bold;
}

#updateButton {
    display: block;

    width: 160px;
    height: 44px;

    margin: 16px auto 0;

    border: none;
    border-radius: 6px;

    background: #333;
    color: #fff;
}

#updateButton:hover:not(:disabled) {
    background: #222;
}

#updateButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* =========================
   ビンゴカード
   ========================= */

.cards-section {
    margin-bottom: 32px;
}

.cards-header {
    display: flex;
    align-items: baseline;
    gap: 12px;

    margin-bottom: 12px;
}

.cards-header h1 {
    margin: 0;
    font-size: 24px;
}

#cardCount {
    font-size: 14px;
    color: #666;
}


/* =========================
   カード一覧
   ========================= */

.cards-container {
    display: grid;

    grid-template-columns:
        repeat(auto-fit, minmax(280px, 1fr));

    gap: 20px;

    padding: 4px;
}


/* =========================
   ビンゴカード本体
   ========================= */

.bingo-card {
    width: 100%;

    padding: 16px;

    border-radius: 10px;

    background: #fff;

    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.bingo-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 12px;
}

.bingo-card-title {
    margin: 0;

    font-size: 18px;
}

.bingo-card-result {
    font-size: 14px;
    font-weight: bold;
}


/* =========================
   ビンゴマス
   ========================= */

.bingo-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));

    width: 100%;
    min-width: 0;

    border-top: 1px solid #ccc;
    border-left: 1px solid #ccc;
}

.bingo-cell {
    display: flex;
    align-items: center;
    justify-content: center;

    aspect-ratio: 1 / 1;

    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;

    font-size: 20px;
    font-weight: bold;

    background: #fff;
}

.bingo-cell.marked {
    background: #ddd;
}

/* =========================
   BINGOライン
   ========================= */

.bingo-cell.bingo-line {

    box-shadow:
        inset 0 0 0 3px #e53935;

    background: #ffe5e5;

}


/* =========================
   リーチライン
   ========================= */

.bingo-cell.reach-line {

    box-shadow:
        inset 0 0 0 3px #f0a000;

    background: #fff4d6;

}

.bingo-cell.free {
    background: #eee;
    font-size: 14px;
}


/* =========================
   リーチ・ビンゴ情報
   ========================= */

.bingo-card-status {
    margin-top: 12px;

    min-height: 24px;

    text-align: center;

    font-size: 16px;
    font-weight: bold;

    white-space: pre-line;
}

.bingo-card-lines {
    margin-top: 4px;

    text-align: center;

    font-size: 14px;
}


/* =========================
   スクロールバー
   ========================= */

.cards-container::-webkit-scrollbar,
.number-history-list::-webkit-scrollbar {
    height: 8px;
}

.cards-container::-webkit-scrollbar-track,
.number-history-list::-webkit-scrollbar-track {
    background: #e5e7eb;
    border-radius: 4px;
}

.cards-container::-webkit-scrollbar-thumb,
.number-history-list::-webkit-scrollbar-thumb {
    background: #aaa;
    border-radius: 4px;
}

.cards-container::-webkit-scrollbar-thumb:hover,
.number-history-list::-webkit-scrollbar-thumb:hover {
    background: #888;
}


/* =========================
   スマートフォン
   ========================= */

@media (max-width: 600px) {

    .event-header {
        padding: 14px 12px;
    }

    .event-header h1 {
        font-size: 20px;
    }


    .app {
        padding: 10px;
    }


    .player-input {
        align-items: stretch;
        flex-direction: column;
    }

    .player-input input {
        width: 100%;
    }

    .player-input button {
        width: 100%;
    }


    .number-section {
        padding: 16px;
    }

    .current-number-value {
        font-size: 56px;
    }


    /* カードは2列 */
    .cards-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        padding: 4px 6px;
    }


    .bingo-card {
        width: 100%;
        min-width: 0;
        padding: 10px;
    }


    .bingo-cell {
        font-size: 16px;
    }

}

/* =========================
   ビンゴ・リーチ表示
   ========================= */

.bingo-cell.bingo-line {
    background: #ffb3b3;
    box-shadow: inset 0 0 0 3px #e53935;
}

.bingo-cell.reach-cell {
    background: #fff3a3;
    box-shadow: inset 0 0 0 3px #f0b400;
    color: #9a6800;
    font-weight: 900;
}


/* =========================
   待ち番号
   ========================= */

.bingo-card-waiting {
    margin-top: 8px;

    min-height: 22px;

    text-align: center;

    font-size: 14px;
    font-weight: bold;

    color: #9a6800;
}