﻿/* ゲーム固有のスタイル */

/* モダンUI用変数の上書き・拡張 */
:root {
    --wood-primary: #e6c288;
    --wood-shadow: #cda86f;
    --line-color: #4a3b2a;
}

.game-container {
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
    width: 100%;
}

/* UIパネル：モダン化 */
.game-ui-panel {
    display: flex;
    gap: 2rem;
    align-items: flex-end;
    /* ラベルとボタンの整列 */
    justify-content: center;
    flex-wrap: wrap;
    background: var(--bg-panel);
    padding: 1.5rem 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 800px;
    box-shadow: var(--shadow-sm);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* モダンなセレクトボックス */
.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    min-width: 200px;
    transition: all 0.2s;
}

.select-wrapper select:hover {
    border-color: var(--text-secondary);
}

.select-wrapper select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(0, 192, 254, 0.2);
}

.select-wrapper::after {
    content: "▼";
    font-size: 0.7rem;
    color: var(--text-muted);
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* ターンインジケーター */
.turn-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1.1rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-app);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    min-width: 220px;
    justify-content: center;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: var(--accent-primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-primary);
    transition: background 0.3s;
}

.turn-indicator.cpu-turn .status-dot {
    background: #ef4444;
    /* CPUのターンは赤色 */
    box-shadow: 0 0 8px #ef4444;
}

/* モダンなボタン */
.btn-modern {
    background: var(--accent-primary);
    color: #1a202c;
    /* コントラストのための暗いテキスト */
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-modern:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 192, 254, 0.2);
}

.btn-modern:active {
    transform: translateY(0);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* 盤面のスタイリング */
.board-wrapper {
    position: relative;
    padding: 30px;
    /* パディングで枠を作成 */
    background: var(--wood-primary);
    /* 木目調のグラデーション */
    background-image:
        linear-gradient(90deg, rgba(80, 50, 20, 0.05) 0%, rgba(80, 50, 20, 0.1) 20%, rgba(80, 50, 20, 0.05) 40%, rgba(80, 50, 20, 0.1) 100%);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.5),
        inset 0 0 0 2px rgba(255, 255, 255, 0.1),
        inset 0 0 20px rgba(0, 0, 0, 0.2);
    /* 内側の奥行き */
    border-radius: 4px;
    display: inline-block;
}

.gomoku-board {
    display: grid;
    /* 15x15 セル */
    grid-template-columns: repeat(15, 32px);
    /* 少し大きめのセル */
    grid-template-rows: repeat(15, 32px);
    position: relative;
    /* 疑似要素で線を描画 */
}

/* 線の描画ロジック */
/* 
   15x15の交点ラインのロジック:
   セル幅は32px。
   各セルの中心を線が通るようにします。
   疑似要素は1番目のセルの中心から最後のセルの中心までをカバーします。
   全幅 = 15 * 32 = 480px。
   0列目の中心 = 16px。
   14列目の中心 = 480 - 16 = 464px。
   スパン = 464 - 16 = 448px。
   
   left: 16px; right: 16px; と設定すると幅は448pxになります。
   グラデーションは32pxごとに繰り返します。
   448 / 32 = 14。ちょうど14スペース。
   
   線が1pxの場合:
   0px地点に0本目の線。
   32px地点に1本目の線。
   ...
   448px地点に14本目の線。
*/

.gomoku-board::before {
    content: '';
    position: absolute;
    top: 16px;
    bottom: 16px;
    left: 16px;
    right: 16px;
    background-image: linear-gradient(to right, var(--line-color) 1px, transparent 1px);
    background-size: 32px 100%;
    pointer-events: none;
    z-index: 0;

    /* 最後の線を追加 */
    border-right: 1px solid var(--line-color);
}

.gomoku-board::after {
    content: '';
    position: absolute;
    top: 16px;
    bottom: 16px;
    left: 16px;
    right: 16px;
    background-image: linear-gradient(to bottom, var(--line-color) 1px, transparent 1px);
    background-size: 100% 32px;
    pointer-events: none;
    z-index: 0;

    /* 最後の線を追加 */
    border-bottom: 1px solid var(--line-color);
}

/* 星（セルの基本スタイル） */
.cell {
    width: 32px;
    height: 32px;
    position: relative;
    cursor: pointer;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ホバー時のガイド */
.cell:not(.taken):hover::after {
    content: '';
    width: 12px;
    height: 12px;
    background: rgba(0, 0, 0, 0.15);
    /* 控えめな表示 */
    border-radius: 50%;
}

/* 碁石のスタイリング - よりリアルに */
.stone {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    /* 3D効果の影 */
    box-shadow:
        1px 2px 3px rgba(0, 0, 0, 0.4),
        inset -3px -3px 5px rgba(0, 0, 0, 0.2),
        inset 3px 3px 5px rgba(255, 255, 255, 0.2);
    position: relative;
    transition: transform 0.1s;
    animation: placeStone 0.15s ease-out;
}

@keyframes placeStone {
    from {
        transform: scale(1.5);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.stone.black {
    background: radial-gradient(circle at 35% 35%, #555 0%, #111 100%);
}

.stone.white {
    background: radial-gradient(circle at 35% 35%, #fff 0%, #ddd 100%);
}

.stone.last-move::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 4px #ef4444;
}

/* オーバーレイ */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    z-index: 10;
    opacity: 1;
    transition: opacity 0.3s;
}

.game-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    background: var(--bg-panel);
    padding: 3rem;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    transform: scale(1);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        transform: scale(0.8);
    }

    to {
        transform: scale(1);
    }
}

.overlay-content h2 {
    margin: 0 0 1rem;
    font-size: 2.5rem;
    font-weight: 800;
}

/* ルール表示 */
.game-rules {
    max-width: 800px;
    width: 100%;
    padding: 2rem;
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.game-rules h3 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.game-rules ul {
    margin: 0;
    padding-left: 1.5rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* レスポンシブ対応 */
@media (max-width: 600px) {
    .board-wrapper {
        padding: 15px;
    }

    .gomoku-board {
        grid-template-columns: repeat(15, 20px);
        grid-template-rows: repeat(15, 20px);
    }

    .cell {
        width: 20px;
        height: 20px;
    }

    .stone {
        width: 18px;
        height: 18px;
    }

    .gomoku-board::before,
    .gomoku-board::after {
        top: 10px;
        bottom: 10px;
        left: 10px;
        right: 10px;
        background-size: 20px 20px;
    }

    .game-ui-panel {
        flex-direction: column;
        align-items: stretch;
    }
}
