/* ========================================
   五目並べ - スタイルシート
   ======================================== */

:root {
    --primary-color: #2d3436;
    --secondary-color: #636e72;
    --accent-color: #0984e3;
    --board-color: #deb887;
    --board-line: #8b7355;
    --black-stone: #1a1a2e;
    --white-stone: #f5f5f5;
    --win-highlight: #00b894;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 30px;
    max-width: 600px;
    width: 100%;
}

/* ヘッダー */
header {
    text-align: center;
    margin-bottom: 25px;
}

header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.subtitle {
    color: var(--secondary-color);
    font-size: 0.9rem;
}

/* 画面切り替え */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

.hidden {
    display: none !important;
}

/* ========================================
   モード選択画面
   ======================================== */

#mode-selection h2 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 25px;
    font-size: 1.3rem;
}

.mode-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 25px 35px;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    max-width: 200px;
}

.mode-btn:hover {
    border-color: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.mode-btn .icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.mode-btn .label {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.mode-btn .desc {
    font-size: 0.8rem;
    color: var(--secondary-color);
}

/* 難易度選択 */
#difficulty-selection {
    margin-top: 30px;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

#difficulty-selection h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.difficulty-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.difficulty-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 25px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.difficulty-btn:hover {
    border-color: var(--accent-color);
    background: #f8f9fa;
}

.difficulty-btn span:first-child {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

/* ========================================
   ゲーム画面
   ======================================== */

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 0;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    border-radius: 25px;
    background: #f8f9fa;
}

.stone {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.stone.black {
    background: radial-gradient(circle at 30% 30%, #4a4a5a, var(--black-stone));
}

.stone.white {
    background: radial-gradient(circle at 30% 30%, #ffffff, #e0e0e0);
    border: 1px solid #ccc;
}

#turn-indicator {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    padding: 8px 20px;
    background: linear-gradient(135deg, #667eea22 0%, #764ba222 100%);
    border-radius: 25px;
}

/* 盤面 */
.board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

#board {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    grid-template-rows: repeat(15, 1fr);
    background: var(--board-color);
    border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2), var(--shadow);
    padding: 15px;
    gap: 0;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1;
    border: 3px solid #5d4e37;
}

.cell {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s ease;
    border: 1px solid var(--board-line);
}

/* セルの外枠を太く */
.cell[data-row="0"] { border-top: 2px solid #5d4e37; }
.cell[data-row="14"] { border-bottom: 2px solid #5d4e37; }
.cell[data-col="0"] { border-left: 2px solid #5d4e37; }
.cell[data-col="14"] { border-right: 2px solid #5d4e37; }

/* 星（天元と四隅）- 交点に表示 */
.cell.star::before {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: #5d4e37;
    border-radius: 50%;
    z-index: 1;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* セルホバー効果 */
.cell:hover:not(.placed) {
    background: rgba(0, 0, 0, 0.15);
}

/* 置かれた石 */
.cell .piece {
    width: 85%;
    height: 85%;
    border-radius: 50%;
    z-index: 2;
    animation: placePiece 0.2s ease;
}

@keyframes placePiece {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

.cell .piece.black {
    background: radial-gradient(circle at 30% 30%, #4a4a5a, var(--black-stone));
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
}

.cell .piece.white {
    background: radial-gradient(circle at 30% 30%, #ffffff, #e0e0e0);
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
    border: 1px solid #bbb;
}

/* 最後に置いた石のハイライト */
.cell .piece.last-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: rgba(255, 0, 0, 0.6);
    border-radius: 50%;
}

/* 勝利ハイライト */
.cell .piece.win-highlight {
    animation: winPulse 0.5s ease infinite alternate;
}

@keyframes winPulse {
    from { box-shadow: 0 0 5px var(--win-highlight); }
    to { box-shadow: 0 0 20px var(--win-highlight), 0 0 30px var(--win-highlight); }
}

/* ゲームコントロール */
.game-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: #f8f9fa;
    color: var(--primary-color);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.control-btn:hover {
    background: var(--accent-color);
    color: white;
    transform: translateY(-2px);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ========================================
   結果モーダル
   ======================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 40px 50px;
    border-radius: 20px;
    text-align: center;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { transform: scale(0.8) translateY(-20px); }
    to { transform: scale(1) translateY(0); }
}

.modal-content h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 25px;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    font-weight: 500;
}

.modal-btn.primary {
    background: var(--accent-color);
    color: white;
}

.modal-btn.primary:hover {
    background: #0773c7;
    transform: translateY(-2px);
}

.modal-btn.secondary {
    background: #f8f9fa;
    color: var(--primary-color);
}

.modal-btn.secondary:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

/* ========================================
   レスポンシブデザイン
   ======================================== */

@media (max-width: 600px) {
    .container {
        padding: 20px;
        border-radius: 15px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .mode-buttons {
        flex-direction: column;
        align-items: center;
    }

    .mode-btn {
        width: 100%;
        max-width: 250px;
    }

    .game-info {
        flex-direction: column;
        gap: 10px;
    }

    .player-info {
        width: 100%;
        justify-content: center;
    }

    #board {
        max-width: 100%;
    }

    .game-controls {
        flex-direction: column;
    }

    .control-btn {
        width: 100%;
        justify-content: center;
    }

    .modal-content {
        padding: 30px;
        margin: 20px;
    }

    .modal-buttons {
        flex-direction: column;
    }

    .modal-btn {
        width: 100%;
    }
}

/* CPU思考中表示 */
.thinking {
    position: relative;
}

.thinking::after {
    content: '🤔 思考中...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 25px;
    border-radius: 10px;
    font-weight: 700;
    color: var(--primary-color);
    box-shadow: var(--shadow);
    z-index: 10;
    animation: thinking 1s ease infinite;
}

@keyframes thinking {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}