/* ===== 将棋盤コンテナ ===== */
.shogi-container {
    margin: 24px 0;
    padding: 16px;
    background: #fdfbf9;
    border: 1px solid #eee;
    border-radius: 8px;
}

.shogi-container-title {
    font-weight: bold;
    color: #333;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

/* ===== メインレイアウト ===== */
.shogi-main-layout {
    display: flex;
    gap: 16px;
    align-items: stretch;
}

.shogi-board-section {
    flex-shrink: 0;
}

/* コメントセクション */
.shogi-comment-section {
    flex: 1;
    min-width: 150px;
    display: flex;
    flex-direction: column;
}

/* ===== 将棋盤 ===== */
.shogi-board-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: flex-start;
}

.shogi-board-area {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.shogi-board {
    display: grid;
    grid-template-columns: repeat(9, 27px);
    grid-template-rows: repeat(9, 30px);
    border: 2px solid #b0a080;
    background: #f5e8c0;
    width: calc(27px * 9 + 4px);
    height: calc(30px * 9 + 4px);
    box-shadow: 2px 2px 8px rgba(139, 115, 85, 0.3);
}

.shogi-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: default;
    position: relative;
    background: #f5e8c0;
    border-right: 1px solid #b0a080;
    border-bottom: 1px solid #b0a080;
    overflow: hidden;
}

.shogi-cell:nth-child(9n) {
    border-right: none;
}

.shogi-cell:nth-child(n+73) {
    border-bottom: none;
}

.shogi-cell.highlight {
    background: #fff0a0;
}

.shogi-cell.last-move {
    background: #ffe080;
}

/* 駒のスタイル */
.shogi-piece {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90%;
    height: 90%;
    font-size: 0.95rem;
}

.shogi-piece.gote {
    transform: rotate(180deg);
    color: #333;
}

.shogi-piece.sente {
    color: #000;
}

.shogi-piece.promoted {
    color: #c62828;
}

/* ===== 持ち駒 ===== */
.shogi-hand {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    width: 42px;
    min-width: 42px;
    padding: 0.5rem;
    background: #f5f0e6;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.85rem;
}

.shogi-hand-gote {
    transform: rotate(180deg);
}

.shogi-hand-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.75rem;
    color: #666;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.3rem;
    margin-bottom: 0.3rem;
}

.shogi-hand-icon {
    font-size: 0.9rem;
    line-height: 1;
}

.shogi-hand-label {
    font-size: 0.65rem;
    line-height: 1;
}

.shogi-hand-piece {
    text-align: center;
    padding: 0.1rem;
}

/* ===== 分岐オプション（コメント内） ===== */
.shogi-branch-options {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 8px 10px;
    margin-bottom: 8px;
    background: #fff8e8;
    border: 1px solid #e8d8a8;
    border-radius: 6px;
}

.shogi-branch-options-label {
    font-size: 0.8rem;
    color: #996600;
    font-weight: bold;
    white-space: nowrap;
    flex-shrink: 0;
}

.shogi-branch-moves {
    display: flex;
    gap: 0.3rem;
    overflow-x: auto;
    flex: 1;
    padding: 2px 0;
    -webkit-overflow-scrolling: touch;
}

.shogi-branch-moves::-webkit-scrollbar {
    height: 4px;
}

.shogi-branch-moves::-webkit-scrollbar-track {
    background: #f0e8d0;
    border-radius: 2px;
}

.shogi-branch-moves::-webkit-scrollbar-thumb {
    background: #d4a860;
    border-radius: 2px;
}

.shogi-branch-move-btn {
    padding: 0.25rem 0.5rem;
    border: 1px solid #ccc;
    background: white;
    color: #666;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s;
}

.shogi-branch-move-btn:hover {
    background: #f5f5f5;
    border-color: #999;
}

.shogi-branch-move-btn.active {
    background: #d4813a;
    border-color: #d4813a;
    color: white;
    font-weight: bold;
}

/* ===== コントロール ===== */
.shogi-controls {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    margin-top: 12px;
}

.shogi-controls button {
    padding: 0.4rem 0.6rem;
    border: 1px solid #d4813a;
    background: white;
    color: #d4813a;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.shogi-controls button:hover {
    background: #d4813a;
    color: white;
}

.shogi-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.shogi-controls-separator {
    width: 1px;
    height: 20px;
    background: #ddd;
    margin: 0 0.3rem;
}

/* コピーボタン（別色） */
.shogi-controls button.shogi-btn-copy {
    border-color: #5a9bd4;
    color: #5a9bd4;
}

.shogi-controls button.shogi-btn-copy:hover {
    background: #5a9bd4;
    color: white;
}

/* ===== 手順表示（コメント内上部） ===== */
.shogi-move-display {
    font-size: 0.95rem;
    font-weight: bold;
    color: #333;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #f0e0d0;
    flex-shrink: 0;
}

/* ===== 棋譜一覧ポップアップ ===== */
.shogi-move-list-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.shogi-move-list-overlay.show {
    display: flex;
}

.shogi-move-list-popup {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 80vh;
    width: 320px;
    display: flex;
    flex-direction: column;
}

.shogi-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    font-weight: bold;
    color: #333;
}

.shogi-popup-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    padding: 0 4px;
    line-height: 1;
}

.shogi-popup-close:hover {
    color: #333;
}

.shogi-move-list {
    flex: 1;
    overflow-y: auto;
    background: #fff;
    font-size: 0.9rem;
}

.shogi-move-list table {
    width: 100%;
    border-collapse: collapse;
}

.shogi-move-list tr {
    cursor: pointer;
}

.shogi-move-list tr:hover {
    background: #faf8f6;
}

.shogi-move-list tr.active {
    background: #fff3e8;
    font-weight: bold;
}

.shogi-move-list td {
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid #f0f0f0;
}

.shogi-move-list .move-num {
    width: 40px;
    text-align: right;
    color: #888;
}

/* ===== コメント表示 ===== */
.shogi-comment {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
    background: #fffaf5;
    border-left: 4px solid #d4813a;
    border-radius: 0 6px 6px 0;
    font-size: 0.9rem;
    line-height: 1.7;
    overflow: hidden;
    min-height: 100px;
}

.shogi-comment-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.shogi-comment-body p {
    margin: 6px 0;
    color: #555;
}

.shogi-comment-body p:first-child {
    margin-top: 0;
}

.shogi-comment-title {
    font-weight: bold;
    color: #cf7a48;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

/* ===== 段・筋の表示 ===== */
.shogi-board-with-labels {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.shogi-file-labels {
    display: grid;
    grid-template-columns: repeat(9, 27px);
    width: calc(27px * 9);
    font-size: 0.75rem;
    color: #666;
    text-align: center;
    margin-bottom: 2px;
    margin-left: 2px;
}

.shogi-rank-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    height: calc(30px * 9 + 4px);
    font-size: 0.75rem;
    color: #666;
    padding: 0 4px;
}

/* ===== コピー通知 ===== */
.shogi-copy-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.shogi-copy-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== レスポンシブ ===== */
@media (max-width: 700px) {
    /* モバイル: 縦並び */
    .shogi-main-layout {
        flex-direction: column;
        align-items: center;
    }
    
    .shogi-comment-section {
        width: 100%;
        min-width: 0;
        height: 180px;
        min-height: 180px;
        max-height: 180px;
    }
    
    .shogi-comment {
        min-height: 0;
    }
}

@media (max-width: 600px) {
    .shogi-container {
        padding: 12px;
        margin: 16px 0;
    }
    
    .shogi-board {
        grid-template-columns: repeat(9, 23px);
        grid-template-rows: repeat(9, 26px);
        width: calc(23px * 9 + 4px);
        height: calc(26px * 9 + 4px);
    }
    
    .shogi-file-labels {
        grid-template-columns: repeat(9, 23px);
        width: calc(23px * 9);
    }
    
    .shogi-rank-labels {
        height: calc(26px * 9 + 4px);
    }
    
    .shogi-cell {
        font-size: 0.9rem;
    }
    
    .shogi-piece {
        font-size: 0.85rem;
    }
    
    .shogi-hand {
        width: 36px;
        min-width: 36px;
        padding: 0.3rem;
        font-size: 0.8rem;
    }
    
    .shogi-controls {
        gap: 0.3rem;
        margin-top: 8px;
    }
    
    .shogi-controls button {
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .shogi-move-display {
        font-size: 0.85rem;
        padding-bottom: 6px;
        margin-bottom: 6px;
    }
    
    .shogi-comment-section {
        height: 150px;
        min-height: 150px;
        max-height: 150px;
    }
    
    .shogi-comment {
        padding: 10px 12px;
        font-size: 0.85rem;
    }
    
    .shogi-controls-separator {
        height: 16px;
        margin: 0 0.2rem;
    }
}
