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

body {
    font-family: 'Georgia', serif;
    background: 
        linear-gradient(#fff8e0, #ffe4c4);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    gap: 30px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(139, 90, 43, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(139, 90, 43, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    background: linear-gradient(to bottom, #faf5eb 0%, #f0e8d8 100%) ;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 
        0 0 0 3px #8b5a2b,
        0 0 0 6px #d4a574,
        0 20px 60px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    max-width: 600px;
    width: 100%;
    position: relative;
    border: 2px solid #5c3d1f;
    z-index: 1;
}

h1 {
    text-align: left;
    color: #5c3d1f;
    margin-bottom: 20px;
    font-size: 2em;
    cursor: pointer;
    transition: all 0.3s;
    font-family: sans-serif;
    font-weight: 700;
    letter-spacing: 1px;
}

h1:hover {
    color: #8b5a2b;
}

#author {
    font-size: 0.9em;
    color: #5c3d1f;
    margin-left: 10px;
    font-weight: normal;
    font-family: 'Georgia', serif;
}

/* ヘッダー */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
}

.header h1 {
    margin-bottom: 0;
    flex: 1;
}

.settings-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.settings-icon img {
    width: 24px;
    height: 24px;
    transition: opacity 0.3s;
}

/* タブナビゲーション */
.tab-navigation {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 3px solid #8b5a2b;
    background: linear-gradient(to bottom, rgba(139, 90, 43, 0.1), transparent);
}

.tab-button {
    flex: 1;
    padding: 12px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Georgia', serif;
    color: #5c3d1f;
    transition: all 0.3s;
    letter-spacing: 0.5px;
}

.tab-button:hover {
    background : linear-gradient(to bottom, transparent, rgba(139, 90, 43, 0.05));
}

.tab-button.active {
    color: #fff;
    background: linear-gradient(to bottom, #ac6f36, #6b4423);
    border:none;
}

.tab-button.active:hover {
    background: linear-gradient(to bottom, #bc7f46, #7b5423);
}

/* タブコンテンツ */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 難易度セレクター */
.difficulty-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.difficulty-selector label {
    font-weight: 600;
    color: #2a1810;
    font-family: 'Cinzel', serif;
}

.difficulty-btn {
    padding: 8px 16px;
    border: 2px solid #8b5a2b;
    background: linear-gradient(to bottom, #fff, #f5ede0);
    color: #2a1810;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-family: 'Georgia', serif;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.difficulty-btn:hover {
    background: linear-gradient(to bottom, #f5ede0, #e8dcc4);
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
    border-color: #6b4423;
}

.difficulty-btn.active {
    background: linear-gradient(to bottom, #8b5a2b, #6b4423);
    color: #fff;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
    border-color: #5c3d1f;
}

/* ゲーム情報 */
.game-info {
    background: linear-gradient(to bottom, #fff9f0, #f5ede0);
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    text-align: center;
    border: 2px solid #8b5a2b;
    box-shadow: 
        inset 0 1px 3px rgba(0, 0, 0, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info p {
    margin: 5px 0;
    font-size: 16px;
    color: #2a1810;
    font-family: 'Georgia', serif;
}

.game-info span {
    font-weight: bold;
    color: #7a4a1f;
    font-family: 'Cinzel', serif;
}

/* チェス盤 */
.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    aspect-ratio: 1;
    border: 8px solid #3d2817;
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto 20px;
    box-shadow: 
        0 0 0 2px #8b5a2b,
        0 0 0 4px #3d2817,
        0 8px 24px rgba(0, 0, 0, 0.6),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.chessboard.flipped {
    transform: rotate(180deg);
}

.chessboard.flipped .square {
    transform: rotate(180deg);
}

.square {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5em;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
    height: 100%;
    width: 100%;
    min-height: 0;
    min-width: 0;
    line-height: 1;
}

.square.white {
    background-color: #f0d9b5;
}

.square.black {
    background-color: #b58863;
}

.square.white:hover {
    background-color: #e8d1ad;
}

.square.black:hover {
    background-color: #a77a5b;
}

.square.selected {
    background: 
        radial-gradient(ellipse at center, rgba(184, 134, 11, 0.4) 0%, transparent 70%),
        linear-gradient(135deg, #c9a961 0%, #b8860b 100%) !important;
    box-shadow: 
        inset 0 0 20px rgba(184, 134, 11, 0.6),
        0 0 15px rgba(218, 165, 32, 0.5);
}

.square.selected.white{
    background: 
        radial-gradient(ellipse at center, rgba(184, 134, 11, 0.4) 0%, transparent 70%),
        linear-gradient(135deg, #f2e1b8 0%, #d4a017 100%) !important;
}

.square.valid-move {
    position: relative;
}

.square.valid-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    pointer-events: none;
}

.square.valid-move.has-piece::after {
    width: 90%;
    height: 90%;
    background-color: transparent;
    border: 4px solid rgba(255, 0, 0, 0.5);
    border-radius: 50%;
}

.square.check {
    position: relative;
}

.square.check::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        rgba(220, 38, 38, 0.35) 0%,
        rgba(239, 68, 68, 0.25) 30%,
        rgba(248, 113, 113, 0.15) 60%,
        transparent 100%
    );
    pointer-events: none;
    border-radius: 2px;
}

.square.checking-piece {
    background: radial-gradient(circle at center, #ffa502 0%, #ff6348 50%, #ff4757 100%) !important;
    box-shadow: inset 0 0 25px rgba(255, 100, 0, 0.5), 0 0 15px rgba(255, 100, 0, 0.4);
    animation: attackPulse 1.2s ease-in-out infinite;
}

@keyframes attackPulse {
    0%, 100% {
        box-shadow: inset 0 0 35px rgba(255, 100, 0, 0.7), 0 0 25px rgba(255, 100, 0, 0.6);
    }
    50% {
        box-shadow: inset 0 0 25px rgba(255, 100, 0, 0.5), 0 0 15px rgba(255, 100, 0, 0.4);
    }
}

.square.last-move {
    background-color: #ffa93fb4 !important;
    box-shadow: inset 0 0 20px rgba(255, 157, 0, 0.237);
}

.square.hint-highlight {
    animation: hintPulse 2s ease-in-out infinite;
    position: relative;
}

.square.hint-highlight::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        rgba(255, 230, 0, 0.35) 0%,
        rgba(208, 212, 2, 0.2) 35%,
        transparent 70%
    );
    pointer-events: none;
}


@keyframes hintPulse {
    0%, 100% {
        box-shadow: none;
    }
    50% {
        box-shadow: inset 0 0 25px rgba(255, 221, 0, 0.25);
    }
}

/* 駒情報ボタン */
.piece-info-button {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: linear-gradient(to bottom, #9d6d3d, #7d4d2d);
    color: #fff;
    border: 2px solid #d4a574;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    font-family: 'Cinzel', serif;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.piece-info-button:hover {
    background: linear-gradient(to bottom, #ad7d4d, #8d5d3d);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
    transform: scale(1.1);
}

/* 駒情報モーダル */
.piece-info-modal-content {
    max-width: 600px;
    max-height: 80vh;
}

.piece-info-content {
    overflow-y: auto;
    max-height: calc(80vh - 100px);
}

.piece-info-content img {
    width: auto;
    height: 250px;
    margin: 1rem auto;
    border-radius: 8px;
    object-fit: contain;
    display: block;
}

.piece-info-content h2 {
    color: #7a4a1f;
    font-size: 1.5em;
    margin: 0 0 10px 0;
    font-family: 'Cinzel', serif;
    text-shadow: 1px 1px 2px rgba(212, 165, 116, 0.3);
}

.piece-info-content h3 {
    color: #5c3d1f;
    font-size: 1.2em;
    margin: 15px 0 8px 0;
    font-family: 'Cinzel', serif;
}

.piece-info-content p {
    color: #2a1810;
    line-height: 1.7;
    margin-bottom: 12px;
    font-size: 15px;
    font-family: 'Georgia', serif;
}

.piece-info-content ul {
    margin: 10px 0 15px 20px;
    color: #2a1810;
}

.piece-info-content li {
    margin-bottom: 8px;
    line-height: 1.6;
    font-family: 'Georgia', serif;
}

/* 駒の説明コンテンツを非表示 */
.piece-descriptions {
    display: none;
}

/* コントロールボタン */
.controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ボタン */
.control-button {
    padding: 12px;
    color: #fff;
    background: linear-gradient(to bottom, #9d6d3d, #7d4d2d);
    border: 2px solid #5c3d1f;
    border-radius: 4px;
    font-size: 16px;
    font-family: sans-serif;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
    box-shadow: 
        0 3px 0 #4d2d17,
        0 4px 8px rgba(0, 0, 0, 0.4);
}

.control-button:hover:not(:disabled) {
    background: linear-gradient(to bottom, #b07c48, #8a5836);
}

.control-button:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 
        0 1px 0 #4d2d17,
        0 2px 4px rgba(0, 0, 0, 0.4);
}

.control-button:disabled {
    background: linear-gradient(to bottom, #aaa, #888);
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: 
        0 2px 0 #666,
        0 3px 6px rgba(0, 0, 0, 0.3);
    color: #ddd;
    border: 2px solid #666;
}

.sub-control-btn {
    flex: 0.8;
    background: linear-gradient(to bottom, #9d6d3d, #7d4d2d);
}

.sub-control-btn:hover:not(:disabled) {
    background: linear-gradient(to bottom, #ad7d4d, #8d5d3d);
}

#reset-ai, #reset-board {
    background: linear-gradient(to bottom,  #1baf3e,#129e33);
    border-color: #3d8d20;
    box-shadow: 
        0 3px 0 #2d6d10,
        0 4px 8px rgba(0, 0, 0, 0.4);
}

#reset-ai:hover:not(:disabled), #reset-board:hover:not(:disabled) {
    background: linear-gradient(to bottom, #0dab35, #048727);
}

/* 設定セクション */
.settings-modal-content {
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 3px solid #8b5a2b;
    padding-bottom: 15px;
    flex-shrink: 0;
    background: linear-gradient(to bottom, rgba(139, 90, 43, 0.08), transparent);
}

.modal-header h2 {
    color: #2a1810;
    font-size: 1.8em;
    margin: 0;
    font-family: 'Cinzel', serif;
    text-shadow: 1px 1px 2px rgba(212, 165, 116, 0.3);
}

.close-button {
    background: none;
    border: none;
    font-size: 2em;
    color: #7a4a1f;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
    line-height: 1;
    padding: 0;
}

.close-button:hover {
    background: rgba(139, 90, 43, 0.15);
    color: #5c3d1f;
}

.settings-section {
    padding: 0;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.setting-item {
    background: linear-gradient(to bottom, #fff9f0, #f5ede0);
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 2px solid rgba(139, 90, 43, 0.4);
    box-shadow: 
        inset 0 1px 3px rgba(0, 0, 0, 0.05),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.setting-item h3 {
    color: #7a4a1f;
    margin-bottom: 10px;
    font-size: 1.3em;
    font-family: 'Cinzel', serif;
    text-shadow: 0 1px 2px rgba(212, 165, 116, 0.2);
}

.setting-description {
    color: #3d2817;
    margin-bottom: 15px;
    font-size: 14px;
    font-family: 'Georgia', serif;
}

.setting-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-option {
    display: flex;
    align-items: center;
    padding: 12px;
    background: linear-gradient(to bottom, #fff, #f9f3e8);
    border: 2px solid #c9a574;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.radio-option:hover {
    border-color: #8b5a2b;
    background: linear-gradient(to bottom, #f9f3e8, #f0e8d8);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.radio-option input[type="radio"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #8b5a2b;
}

.radio-option span {
    font-size: 16px;
    color: #2a1810;
    font-weight: 500;
    font-family: 'Georgia', serif;
}

.checkbox-option {
    display: flex;
    align-items: center;
    padding: 12px;
    background: linear-gradient(to bottom, #fff, #f9f3e8);
    border: 2px solid #c9a574;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.checkbox-option:hover {
    border-color: #8b5a2b;
    background: linear-gradient(to bottom, #f9f3e8, #f0e8d8);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.checkbox-option input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #8b5a2b;
}

.checkbox-option span {
    font-size: 16px;
    color: #2a1810;
    font-weight: 500;
    font-family: 'Georgia', serif;
}

/* プロモーションモーダル */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(20, 10, 5, 0.85);
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: linear-gradient(to bottom, #faf5eb 0%, #f0e8d8 100%);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 
        0 0 0 3px #8b5a2b,
        0 0 0 6px #d4a574,
        0 20px 60px rgba(0, 0, 0, 0.8);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border: 2px solid #5c3d1f;
}

.modal-content h2 {
    text-align: center;
    color: #2a1810;
    margin-bottom: 25px;
    font-size: 1.5em;
    font-family: 'Cinzel', serif;
    text-shadow: 1px 1px 2px rgba(212, 165, 116, 0.3);
}

.promotion-pieces {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.promotion-piece {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: linear-gradient(to bottom, #fff, #f5ede0);
    border: 3px solid #8b5a2b;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.promotion-piece:hover {
    background: linear-gradient(to bottom, #9d6d3d, #7d4d2d);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(139, 90, 43, 0.6);
}

.promotion-piece:hover .piece-name {
    color: #fff;
}

.promotion-piece .piece-icon {
    font-size: 3em;
    margin-bottom: 10px;
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.3));
}

.promotion-piece .piece-name {
    font-size: 16px;
    font-weight: 600;
    font-family: 'Cinzel', serif;
    color: #2a1810;
    transition: color 0.3s;
}

/* 他のゲーム紹介セクション */
#other-games {
    background: linear-gradient(to bottom, #faf5eb 0%, #f0e8d8 100%);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 
        0 0 0 3px #8b5a2b,
        0 0 0 6px #d4a574,
        0 20px 60px rgba(0, 0, 0, 0.6);
    max-width: 600px;
    width: 100%;
    border: 2px solid #5c3d1f;
    position: relative;
    z-index: 1;
}

#other-games h2 {
    text-align: center;
    color: #2a1810;
    margin-bottom: 20px;
    font-size: 1.5em;
    font-family: 'Cinzel', serif;
    text-shadow: 1px 1px 2px rgba(212, 165, 116, 0.3);
}

.game-links {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.game-link {
    display: block;
    background: linear-gradient(to bottom, #9d6d3d, #7d4d2d);
    padding: 20px;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.3s;
    box-shadow: 
        0 3px 0 #4d2d17,
        0 4px 12px rgba(0, 0, 0, 0.4);
    border: 2px solid #5c3d1f;
}

.game-link:hover {
    background: linear-gradient(to bottom, #ad7d4d, #8d5d3d);
}

.game-name {
    color: #fff;
    font-size: 1.1em;
    text-align: center;
    font-family: sans-serif;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

@media (max-width: 600px) {
    .promotion-pieces {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .promotion-piece {
        padding: 15px;
    }

    .promotion-piece .piece-icon {
        font-size: 2.5em;
    }

    .container {
        padding: 20px;
    }

    h1 {
        font-size: 1.5em;
    }

    .header h1 {
        font-size: 1.3em;
    }

    .settings-icon {
        width: 36px;
        height: 36px;
    }

    .settings-icon img {
        width: 20px;
        height: 20px;
    }

    .square {
        font-size: 1.8em;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }

    .modal-header h2 {
        font-size: 1.4em;
    }

    .control-button {
        font-size: 13px;
        padding: 10px;
    }
    #undo-board, #redo-board, #undo-ai, #redo-ai {
        width: 50px;
        flex:none;
    }
    #flip-ai, #flip-board {
        min-width: 4.8rem;
    }

    #other-games {
        padding: 20px;
        margin-top: 20px;
    }

    #other-games h2 {
        font-size: 1.3em;
    }

    .game-name {
        font-size: 1em;
    }
}