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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    overflow-y: auto;
}

.container {
    max-width: 800px;
    width: 100%;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5em;
    color: #333;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

main {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* モード選択エリア */
.mode-selection {
    width: 100%;
    text-align: center;
    margin-bottom: 30px;
    padding: 30px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.mode-selection h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.8em;
}

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

.btn-mode {
    min-width: 200px;
    padding: 20px 30px;
    font-size: 1.3em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn-mode:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.difficulty-selection {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 2px solid rgba(0, 0, 0, 0.1);
}

.difficulty-selection h3 {
    color: #34495e;
    margin-bottom: 15px;
    font-size: 1.3em;
}

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

.btn-difficulty {
    min-width: 120px;
    padding: 12px 25px;
    font-size: 1.1em;
    border: 3px solid transparent;
    transition: all 0.3s;
}

.btn-difficulty[data-level="easy"] {
    background: #2ecc71;
    color: white;
}

.btn-difficulty[data-level="normal"] {
    background: #f39c12;
    color: white;
}

.btn-difficulty[data-level="hard"] {
    background: #e74c3c;
    color: white;
}

.btn-difficulty:hover {
    transform: scale(1.05);
    border-color: #2c3e50;
}

.mode-selection.hidden,
.game-info.hidden,
.board.hidden,
.controls.hidden {
    display: none;
}

/* ゲーム情報エリア */
.game-info {
    width: 100%;
    margin-bottom: 20px;
}

.score-board {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-radius: 8px;
    transition: all 0.3s;
}

.score-item.black {
    background: #2c3e50;
    color: white;
}

.score-item.white {
    background: #ecf0f1;
    color: #2c3e50;
}

.score-item.active {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.piece-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #333;
}

.black-piece {
    background: #2c3e50;
    border-color: #1a252f;
}

.white-piece {
    background: white;
    border-color: #bdc3c7;
}

.player-label {
    font-weight: bold;
    font-size: 1.2em;
}

.score {
    font-size: 1.5em;
    font-weight: bold;
    min-width: 30px;
    text-align: center;
}

.current-player {
    text-align: center;
    font-size: 1.3em;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 10px;
}

.player-name {
    color: #667eea;
}

.message {
    text-align: center;
    font-size: 1.1em;
    color: #e74c3c;
    min-height: 30px;
    font-weight: 500;
}

/* ゲームボード */
.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    background: #27ae60;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
    max-width: 600px;
    width: 100%;
    aspect-ratio: 1;
}

.cell {
    background: #2ecc71;
    border: 2px solid #27ae60;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    position: relative;
}

.cell:hover {
    background: #3ad782;
}

.cell.valid-move {
    background: #52d98a;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.5);
}

.cell.valid-move::after {
    content: '';
    width: 30%;
    height: 30%;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    position: absolute;
}

.piece {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    transition: all 0.3s;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.piece.black {
    background: radial-gradient(circle at 30% 30%, #555, #000);
    border: 2px solid #1a252f;
}

.piece.white {
    background: radial-gradient(circle at 30% 30%, #fff, #ddd);
    border: 2px solid #bdc3c7;
}

.piece.new {
    animation: placepiece 0.3s ease-out;
}

.piece.flip {
    animation: flippiece 0.5s ease-in-out;
}

@keyframes placepiece {
    0% {
        transform: scale(0) rotate(0deg);
    }
    50% {
        transform: scale(1.2) rotate(180deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
    }
}

@keyframes flippiece {
    0% {
        transform: rotateY(0deg);
    }
    50% {
        transform: rotateY(90deg);
    }
    100% {
        transform: rotateY(180deg);
    }
}

/* コントロール */
.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}

.btn {
    padding: 12px 30px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: #3498db;
    color: white;
}

.btn-undo {
    background: #f39c12;
    color: white;
}

.btn-undo:disabled {
    background: #bdc3c7;
    color: #7f8c8d;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-undo:disabled:hover {
    transform: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* フッター */
footer {
    margin-top: 20px;
}

.rules {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
}

.rules h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.rules ul {
    list-style: none;
    padding-left: 0;
}

.rules li {
    padding: 8px 0;
    color: #555;
    line-height: 1.5;
}

.rules li::before {
    content: '▶ ';
    color: #667eea;
    font-weight: bold;
    margin-right: 8px;
}

/* レスポンシブデザイン */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 2em;
    }

    .score-board {
        flex-direction: column;
        gap: 10px;
    }

    .board {
        max-width: 100%;
    }

    .controls {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        width: 100%;
    }

    .rules {
        padding: 15px;
    }
}


/* ========================================
   説明セクション（アコーディオン）
   ======================================== */
.description-container {
    width: 100%;
    margin-top: 30px;
    margin-bottom: 20px;
}

.toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    font-size: 1.1em;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

#btn-icon {
    transition: transform 0.3s ease;
    font-size: 0.9em;
}

#btn-icon.open {
    transform: rotate(180deg);
}

/* 初期状態：閉じている */
.description-content {
    display: none;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf3 100%);
    border-radius: 0 0 10px 10px;
    padding: 25px 20px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-top: none;
}

/* 開いた状態 */
.description-content.open {
    display: block;
}

.description-title {
    font-size: 1.4em;
    color: #2c3e50;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 3px solid #667eea;
}

.description-content p {
    line-height: 1.9;
    color: #444;
    margin-bottom: 16px;
    text-align: justify;
}

.description-content p:last-child {
    margin-bottom: 0;
}

.description-content strong {
    color: #667eea;
    font-weight: 600;
}

/* ========================================
   モード選択セクションの高さ修正
   ======================================== */
.mode-selection {
    width: 100%;
    text-align: center;
    margin-bottom: 30px;
    padding: 50px 30px;
    min-height: 250px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.mode-selection h2 {
    color: #2c3e50;
    margin-bottom: 35px;
    font-size: 1.8em;
}

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

.btn-mode {
    min-width: 200px;
    padding: 25px 35px;
    font-size: 1.3em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* レスポンシブ対応 */
@media (max-width: 600px) {
    .toggle-btn {
        font-size: 1em;
        padding: 12px 15px;
    }
    
    .description-title {
        font-size: 1.2em;
    }
    
    .description-content p {
        font-size: 0.95em;
        line-height: 1.8;
    }
    
    .description-content.open {
        padding: 20px 15px;
    }
    
    .mode-selection {
        padding: 40px 20px;
        min-height: 200px;
    }
    
    .mode-selection h2 {
        margin-bottom: 25px;
    }
    
    .btn-mode {
        padding: 20px 30px;
    }
}


/* ========================================
   説明セクション
   ======================================== */
.description-container {
    width: 100%;
    margin-top: 30px;
    margin-bottom: 20px;
}

.toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    font-size: 1.1em;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

#btn-icon {
    transition: transform 0.3s ease;
    font-size: 0.9em;
}

.description-content {
    display: none;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf3 100%);
    border-radius: 0 0 10px 10px;
    padding: 25px 20px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-top: none;
    margin-top: 0;
}

.description-title {
    font-size: 1.4em;
    color: #2c3e50;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 3px solid #667eea;
}

.description-content p {
    line-height: 1.9;
    color: #444;
    margin-bottom: 16px;
    text-align: justify;
}

.description-content p:last-child {
    margin-bottom: 0;
}

.description-content strong {
    color: #667eea;
    font-weight: 600;
}

/* ========================================
   モード選択セクションの高さ修正
   ======================================== */
.mode-selection {
    width: 100%;
    text-align: center;
    margin-bottom: 30px;
    padding: 50px 30px;
    min-height: 250px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.mode-selection h2 {
    color: #2c3e50;
    margin-bottom: 35px;
    font-size: 1.8em;
}

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

.btn-mode {
    min-width: 200px;
    padding: 25px 35px;
    font-size: 1.3em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* レスポンシブ */
@media (max-width: 600px) {
    .toggle-btn {
        font-size: 1em;
        padding: 12px 15px;
    }
    
    .description-content {
        padding: 20px 15px;
    }
    
    .description-title {
        font-size: 1.2em;
    }
    
    .description-content p {
        font-size: 0.95em;
    }
    
    .mode-selection {
        padding: 40px 20px;
        min-height: 200px;
    }
}