/* 基本設定 */
:root {
    --bg-color: #f0f4f8;
    --bg-gradient: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    --text-color: #333;
    --card-bg-color: white;
    --panel-bg-color: white;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --border-color: #d1d5db;
    --input-bg-color: white;
    --input-disabled-bg: #f3f4f6;
    --input-disabled-text: #6b7280;
    --btn-reset-bg: #6b7280;
    --btn-reset-hover-bg: #4b5563;
    --winner-alert-bg: #fef3c7;
    --winner-alert-border: #f59e0b;
    --winner-alert-text: #92400e;
    --winner-badge-text: #d97706;
    --reach-alert-bg: #dbeafe;
    --reach-alert-border: #3b82f6;
    --reach-alert-text: #1e40af;
    --reach-card-border: #60a5fa;
    --header-bg: #1f2937;
    --header-text: white;
}

.theme-dark {
    --bg-color: #111827;
    --bg-gradient: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    --text-color: #f9fafb;
    --card-bg-color: #1f2937;
    --panel-bg-color: #1f2937;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --border-color: #4b5563;
    --input-bg-color: #374151;
    --input-disabled-bg: #374151;
    --input-disabled-text: #9ca3af;
    --btn-reset-bg: #4b5563;
    --btn-reset-hover-bg: #6b7280;
    --winner-alert-bg: #363023;
    --winner-alert-border: #f59e0b;
    --winner-alert-text: #fef3c7;
    --winner-badge-text: #fbbf24;
    --reach-alert-bg: #1e293b;
    --reach-alert-border: #3b82f6;
    --reach-alert-text: #93c5fd;
    --reach-card-border: #3b82f6;
    --header-bg: #000;
    --header-text: white;
}

.theme-forest {
    --bg-gradient: linear-gradient(135deg, #f0fff4, #e6f4ea);
    --text-color: #2f4f4f;
    --panel-bg-color: #ffffff;
    --header-bg: #228b22;
    --winner-alert-bg: #f5fff5;
    --winner-alert-border: #32cd32;
    --reach-alert-bg: #f0fff0;
    --reach-alert-border: #98fb98;
}

.theme-ocean {
    --bg-gradient: linear-gradient(135deg, #f0f8ff, #e0ffff);
    --text-color: #00008b;
    --panel-bg-color: #ffffff;
    --header-bg: #1e90ff;
    --winner-alert-bg: #f0ffff;
    --winner-alert-border: #87cefa;
    --reach-alert-bg: #e0ffff;
    --reach-alert-border: #add8e6;
}

.theme-sunset {
    --bg-gradient: linear-gradient(135deg, #fff0f5, #ffe4e1);
    --text-color: #8b0000;
    --panel-bg-color: #fffafa;
    --header-bg: #ff6347;
    --winner-alert-bg: #fff5ee;
    --winner-alert-border: #ffa07a;
    --reach-alert-bg: #ffe4e1;
    --reach-alert-border: #f08080;
}

.theme-grape {
    --bg-gradient: linear-gradient(135deg, #f5f5f5, #e6e6fa);
    --text-color: #483d8b;
    --panel-bg-color: #ffffff;
    --header-bg: #8a2be2;
    --winner-alert-bg: #f8f8ff;
    --winner-alert-border: #dda0dd;
    --reach-alert-bg: #e6e6fa;
    --reach-alert-border: #d8bfd8;
}

.theme-coffee {
    --bg-gradient: linear-gradient(135deg, #f5f5dc, #fff8dc);
    --text-color: #8b4513;
    --panel-bg-color: #fdf5e6;
    --header-bg: #a0522d;
    --winner-alert-bg: #faf0e6;
    --winner-alert-border: #d2b48c;
    --reach-alert-bg: #fff8dc;
    --reach-alert-border: #f5deb3;
}

.theme-mint {
    --bg-gradient: linear-gradient(135deg, #f5fffa, #f0fff0);
    --text-color: #008080;
    --panel-bg-color: #ffffff;
    --header-bg: #20b2aa;
    --winner-alert-bg: #f0fff0;
    --winner-alert-border: #7fffd4;
    --reach-alert-bg: #f5fffa;
    --reach-alert-border: #afeeee;
}

.theme-coral {
    --bg-gradient: linear-gradient(135deg, #fff0f5, #fff5ee);
    --text-color: #ff7f50;
    --panel-bg-color: #ffffff;
    --header-bg: #ff6347;
    --winner-alert-bg: #fffafa;
    --winner-alert-border: #ffa07a;
    --reach-alert-bg: #fff0f5;
    --reach-alert-border: #f08080;
}

.theme-charcoal {
    --bg-gradient: linear-gradient(135deg, #696969, #778899);
    --text-color: #f5f5f5;
    --panel-bg-color: #36454f;
    --card-bg-color: #36454f;
    --header-bg: #2f4f4f;
    --winner-alert-bg: #4f4f4f;
    --winner-alert-border: #9ac9d2;
    --reach-alert-bg: #5a5a5a;
    --reach-alert-border: #b0c4de;
}

.theme-sakura {
    --bg-gradient: linear-gradient(135deg, #fff0f5, #ffe4e1);
    --text-color: #8b4513;
    --panel-bg-color: #fffafa;
    --header-bg: #ffb6c1;
    --winner-alert-bg: #fff5ee;
    --winner-alert-border: #ffc0cb;
    --reach-alert-bg: #ffe4e1;
    --reach-alert-border: #ffb6c1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}


.menu-select {
    padding: 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg-color);
    color: var(--text-color);
}

.container {
    min-height: 100vh;
}

.content {
    width: 90%;
    margin: 0 auto;
}

.title {
    font-size: 2.5rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 2rem;
}

/* コントロールパネル */
.control-panel {
    background: var(--panel-bg-color);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px var(--shadow-color);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.control-item {
    display: flex;
    flex-direction: column;
}

.label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.select,
.input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg-color);
    color: var(--text-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s;
}

.select:focus,
.input:focus {
    outline: none;
    box-shadow: 0 0 0 2px #3b82f6;
    border-color: transparent;
}

.select:disabled,
.input:disabled {
    background-color: var(--input-disabled-bg);
    color: var(--input-disabled-text);
    cursor: not-allowed;
}

.file-import-controls {
    display: flex;
    gap: 0.5rem;
}

.file-input {
    flex-grow: 1;
    font-size: 0.875rem;
}

.checkbox-wrapper {
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
}

.checkbox-wrapper input {
    margin-right: 0.5rem;
}

/* ボタンスタイル */
.game-controls {
    display: flex;
    gap: 0.5rem;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-weight: 600;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    background-color: #3b82f6;
    color: white;
}

.btn:hover:not(:disabled) {
    background-color: #2563eb;
}

.btn-start {
    flex: 1;
    background: #10b981;
}

.btn-start:hover:not(:disabled) {
    background: #059669;
}

.btn-draw {
    flex: 1;
    background: #3b82f6;
}

.btn-draw:hover:not(:disabled) {
    background: #2563eb;
}

.btn-reset {
    background: var(--btn-reset-bg);
}

.btn-reset:hover {
    background: var(--btn-reset-hover-bg);
}

.btn:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}

/* 情報パネル */
.info-panel {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 0.5rem;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.info-title {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.info-description {
    font-size: 0.875rem;
}

/* 抽選エリア */
.draw-area {
    background: var(--panel-bg-color);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px var(--shadow-color);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.draw-content {
    text-align: center;
}

.draw-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.current-number-display {
    display: inline-block;
    margin-bottom: 1rem;
}

.drawn-number-effect {
    animation: number-pop 0.4s ease-out;
}

@keyframes number-pop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    70% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.no-number {
    font-size: 1.5rem;
    padding: 2rem;
}

.current-number {
    font-size: 4rem;
    font-weight: bold;
    padding: 2rem;
    border-radius: 50%;
    display: inline-block;
    min-width: 120px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.letter-label {
    margin-top: 0.5rem;
    font-size: 1.125rem;
}

.draw-count {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.drawn-numbers-container {
    max-width: 32rem;
    margin: 0 auto;
}

.drawn-numbers-title {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.drawn-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: center;
}

.drawn-number {
    padding: 0.4rem 0.8rem;
    border-radius: 0.3rem;
    font-size: 1rem;
    font-weight: 600;
}

/* 数字の色分け (B-I-N-G-O) */
.number-b {
    background: #fee2e2;
    color: #b91c1c;
}

.number-i {
    background: #dbeafe;
    color: #1d4ed8;
}

.number-n {
    background: #dcfce7;
    color: #15803d;
}

.number-g {
    background: #fef3c7;
    color: #a16207;
}

.number-o {
    background: #e9d5ff;
    color: #7c2d12;
}

/* 勝者・リーチ表示 */
.winner-alert,
.reach-alert {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0.5rem;
}

.winner-alert {
    background: var(--winner-alert-bg);
    border-left: 4px solid var(--winner-alert-border);
    color: var(--winner-alert-text);
}

.reach-alert {
    background: var(--reach-alert-bg);
    border-left: 4px solid var(--reach-alert-border);
    color: var(--reach-alert-text);
}

.winner-title,
.reach-title {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.winner-text,
.reach-text {
    color: inherit;
}

/* ビンゴカード */
.bingo-cards-container {
    display: grid;
    gap: 1rem;
}

.bingo-card {
    background: var(--card-bg-color);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px var(--shadow-color);
    padding: 0.75rem;
    transition: all 0.2s;
    border: 3px solid transparent;
}

.bingo-card.winner {
    border-color: var(--winner-alert-border);
}

.bingo-card.reach {
    border-color: var(--reach-card-border);
}

.bingo-card-header {
    font-weight: bold;
    text-align: center;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-name-input {
    font-weight: bold;
    text-align: center;
    border: 1px solid transparent;
    background-color: transparent;
    color: var(--text-color);
    border-radius: 0.25rem;
    padding: 0.25rem;
    width: 100%;
    font-size: 1em;
}

.player-name-input:focus {
    border-color: var(--border-color);
    background-color: var(--input-bg-color);
}

.winner-badge {
    margin-left: 0.5rem;
    color: var(--winner-badge-text);
}

/* BINGOヘッダー */
.bingo-header {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}

.bingo-letter {
    background: var(--header-bg);
    color: var(--header-text);
    text-align: center;
    font-weight: bold;
    border-radius: 0.25rem;
    padding: 0.5rem 0;
}

/* ビンゴグリッド */
.bingo-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
}

.bingo-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border: 2px solid var(--border-color);
    border-radius: 0.25rem;
    transition: all 0.2s;
    background: var(--card-bg-color);
    font-size: 0.875rem;
}

.bingo-cell:hover {
    border-color: #9ca3af;
}

.bingo-cell.marked {
    background: #ef4444;
    color: white;
    border-color: #dc2626;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* レスポンシブ対応 - 人数に応じたサイズ調整 */
.size-small .bingo-card-header {
    font-size: 0.875rem;
}

.size-small .bingo-letter {
    padding: 0.25rem 0;
    font-size: 0.875rem;
}

.size-small .bingo-cell {
    font-size: 0.75rem;
}

.size-tiny .bingo-card-header {
    font-size: 0.75rem;
}

.size-tiny .bingo-letter {
    padding: 0.25rem 0;
    font-size: 0.75rem;
}

.size-tiny .bingo-cell {
    font-size: 0.625rem;
}

/* ユーティリティクラス */
.hidden {
    display: none;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {

    .content,
    .menu-content {
        width: 95%;
    }

    .title {
        font-size: 2rem;
    }

    .control-grid {
        grid-template-columns: 1fr;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .current-number {
        font-size: 3rem;
        min-width: 100px;
        min-height: 100px;
    }
}

@media (max-width: 480px) {

    .content,
    .menu-content {
        width: 100%;
    }

    .title {
        font-size: 1.5rem;
    }

    .current-number {
        font-size: 2.5rem;
        min-width: 80px;
        min-height: 80px;
    }
}

.auto-mode-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-auto-play {
    flex: 1;
    background: #22c55e;
}

.btn-auto-play:hover:not(:disabled) {
    background: #16a34a;
}

.btn-auto-stop {
    flex: 1;
    background: #ef4444;
}

.btn-auto-stop:hover:not(:disabled) {
    background: #dc2626;
}

/* 忖度ビンゴ用スタイル */
.sontaku-controls {
    background: var(--panel-bg-color);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.sontaku-mode-selector {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.sontaku-mode-label {
    font-size: 0.875rem;
    font-weight: 500;
}

.sontaku-mode-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-sontaku-mode {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: var(--btn-reset-bg);
    border: 2px solid transparent;
}

.btn-sontaku-mode.active {
    background: #3b82f6;
    border-color: #2563eb;
}

.btn-sontaku-mode:hover:not(:disabled) {
    background: var(--btn-reset-hover-bg);
}

.btn-sontaku-mode.active:hover:not(:disabled) {
    background: #2563eb;
}

.manual-number-selection {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.manual-number-select {
    width: 200px;
    text-align: center;
}

.btn-select-number {
    background: #10b981;
    padding: 0.5rem 1.5rem;
}

.btn-select-number:hover:not(:disabled) {
    background: #059669;
}

.btn-select-number:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .sontaku-mode-selector {
        flex-direction: column;
    }

    .sontaku-mode-buttons {
        flex-direction: column;
        width: 100%;
    }

    .btn-sontaku-mode {
        width: 100%;
    }

    .manual-number-select {
        width: 100%;
    }
}