/* --- CONNECT-4 AI WORLD スタイル（定石見やすさ＆落下速度調整版） --- */
body {
    background-color: #0b0f19;
    color: #f8fafc;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    transition: background-color 0.5s ease;
}

/* ☀️ 昼モード（定石発動時：少し明るめのトーン・太陽のイメージ） */
body.mode-joseki {
    background-color: #1e293b;
}

/* 🌙 夜モード（読み切り発動時：少し暗めのトーン・夜空と月明かりのイメージ） */
body.mode-yomikiri {
    background-color: #030712;
}

.game-container {
    width: 100%;
    max-width: 440px;
    text-align: center;
}

h1 {
    font-size: 1.5rem;
    color: #38bdf8;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.control-panel {
    background-color: #1e293b;
    padding: 10px 14px;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.select-group {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
}

select {
    background-color: #0f172a;
    color: #f8fafc;
    border: 1px solid #334155;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

button {
    background-color: #0284c7;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
}

button:hover {
    background-color: #0369a1;
}

/* 盤面外枠 */
.board-outer {
    position: relative;
    width: 100%;
    aspect-ratio: 7 / 6;
    background-color: #1d4ed8;
    border-radius: 12px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5), 0 8px 16px rgba(0,0,0,0.4);
    box-sizing: border-box;
    overflow: hidden;
    transition: box-shadow 0.5s ease;
}

.board-grid {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 6px;
    z-index: 1;
}

.cell-hole {
    background-color: #0b0f19;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: inset 0 3px 6px rgba(0,0,0,0.8);
}

.pieces-layer {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 6px;
    z-index: 2;
    pointer-events: none;
}

/* 🌟 石がフワッと浮遊しながら落ちてくるアニメーション（速度を約半分＝1.4秒に延長） */
@keyframes pieceDrop {
    0% {
        transform: translateY(-380px);
        opacity: 0.2;
    }
    60% {
        transform: translateY(12px);
    }
    80% {
        transform: translateY(-6px);
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.piece {
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4);
    animation: pieceDrop 1.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.piece.red {
    background: radial-gradient(circle, #ef4444, #991b1b);
}

.piece.yellow {
    background: radial-gradient(circle, #f59e0b, #b45309);
}

/* 🌑【定石発動：見やすさを考慮して影や暗さを半分程度に調整した黒光りエフェクト】 */
@keyframes josekiGlowPulse {
    0% {
        box-shadow: 0 0 6px #475569, 0 0 14px #334155, inset 0 0 6px rgba(0, 0, 0, 0.5);
        filter: brightness(1.10);
    }
    50% {
        box-shadow: 0 0 12px #64748b, 0 0 20px #475569, inset 0 0 10px rgba(0, 0, 0, 0.7);
        filter: brightness(0.90);
    }
    100% {
        box-shadow: 0 0 6px #475569, 0 0 14px #334155, inset 0 0 6px rgba(0, 0, 0, 0.5);
        filter: brightness(1.10);
    }
}

.piece.joseki-glow {
    animation: pieceDrop 1.8s cubic-bezier(0.25, 1, 0.5, 1) forwards, 
               josekiGlowPulse 1.8s infinite ease-in-out !important;
    border: 2px solid #64748b;
}

/* 🌟【読み切り発動：月明かりの白光りエフェクト】 */
@keyframes yomikiriGlowPulse {
    0% {
        box-shadow: 0 0 8px #38bdf8, 0 0 20px #38bdf8, inset 0 0 10px rgba(255, 255, 255, 0.8);
        filter: brightness(1.2);
    }
    50% {
        box-shadow: 0 0 16px #38bdf8, 0 0 35px #0284c7, inset 0 0 15px rgba(255, 255, 255, 1);
        filter: brightness(1.5);
    }
    100% {
        box-shadow: 0 0 8px #38bdf8, 0 0 20px #38bdf8, inset 0 0 10px rgba(255, 255, 255, 0.8);
        filter: brightness(1.2);
    }
}

.piece.yomikiri-glow {
    animation: pieceDrop 1.0s cubic-bezier(0.25, 1, 0.5, 1) forwards, 
               yomikiriGlowPulse 1.5s infinite ease-in-out !important;
    border: 2px solid #e0f2fe;
}

/* AI情報パネル */
.ai-info-panel {
    background-color: #1e293b;
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
    text-align: left;
    font-size: 0.85rem;
}

.speech-bubble {
    background-color: #0f172a;
    border: 1px solid #334155;
    padding: 8px 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    color: #38bdf8;
    font-weight: bold;
}

.winrate-bar-container {
    width: 100%;
    height: 10px;
    background-color: #334155;
    border-radius: 5px;
    overflow: hidden;
    margin: 6px 0;
}

.winrate-bar {
    height: 100%;
    width: 50%;
    background: linear-gradient(90deg, #ef4444, #f59e0b);
    transition: width 0.2s ease;
}

.pv-box {
    font-size: 0.75rem;
    color: #94a3b8;
    word-break: break-all;
    margin-top: 4px;
}

/* サイバー・プログレスバー */
.mcts-progress-container {
    margin: 8px 0;
    padding: 6px 10px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid #38bdf8;
    border-radius: 6px;
}

.mcts-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #38bdf8;
    font-family: monospace;
    font-weight: bold;
    margin-bottom: 4px;
}

.mcts-bar-bg {
    width: 100%;
    height: 6px;
    background-color: #0f172a;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid #1e293b;
}

.mcts-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #06b6d4, #38bdf8);
    transition: width 0.05s linear;
}

/* デバッグパネル */
.debug-panel {
    margin-top: 12px;
    background-color: #020617;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px;
    text-align: left;
    font-size: 0.75rem;
    color: #cbd5e1;
}

.debug-panel h3 {
    margin: 0 0 6px 0;
    font-size: 0.8rem;
    color: #38bdf8;
}

.debug-table {
    width: 100%;
    border-collapse: collapse;
    font-family: monospace;
}

.debug-table th, .debug-table td {
    border: 1px solid #1e293b;
    padding: 3px 4px;
    text-align: center;
}

.debug-table th {
    background-color: #0f172a;
    color: #94a3b8;
}

.debug-table tr.selected-move {
    background-color: #1e3a8a;
    font-weight: bold;
    color: #38bdf8;
}