:root {
    --board-bg: #f3cfa2;
    --cell-border: #5d4037;
    --highlight: rgba(255, 255, 0, 0.4);
    --last-move: rgba(255, 0, 0, 0.2);
    --selected: rgba(0, 200, 255, 0.5);
}

body {
    font-family: "Helvetica Neue", Arial, sans-serif;
    background-color: #fafafa;
    color: #333;
    display: flex;
    justify-content: center;
    margin: 0;
    padding: 20px;
}

#game-container {
    text-align: center;
}

header {
    margin-bottom: 10px;
}

.controls {
    margin: 10px 0;
}

#status {
    font-weight: bold;
    font-size: 1.2em;
    height: 1.5em;
    color: #d32f2f;
}

#main-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* 持ち駒エリア */
.hand-area {
    width: 100%;
    max-width: 500px;
    background: #e0e0e0;
    border-radius: 4px;
    padding: 5px;
    min-height: 60px;
    text-align: left;
}

.hand-label {
    font-size: 0.8em;
    margin-bottom: 4px;
    font-weight: bold;
}

.hand-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.hand-piece {
    cursor: pointer;
    position: relative;
}

.hand-piece img {
    width: 40px;
    height: 40px;
}

.count-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    background: black;
    color: white;
    font-size: 10px;
    padding: 1px 3px;
    border-radius: 3px;
}

/* 将棋盤 */
#board {
    display: grid;
    grid-template-columns: repeat(9, 50px);
    grid-template-rows: repeat(9, 50px);
    border: 3px solid #3e2723;
    background-color: var(--board-bg);
    margin: 10px auto;
    user-select: none;
}

.cell {
    width: 50px;
    height: 50px;
    border: 1px solid var(--cell-border);
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.cell img {
    width: 46px;
    height: 46px;
    cursor: pointer;
    transition: transform 0.2s;
}

/* 後手の駒は逆さま */
.gote-piece {
    transform: rotate(180deg);
}

/* ハイライト系 */
.cell.selected {
    background-color: var(--selected);
}

.cell.legal-move {
    position: relative;
}

.cell.legal-move::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    background-color: var(--highlight);
    border-radius: 50%;
    pointer-events: none;
}

.cell.last-move {
    background-color: var(--last-move);
}

/* 成り判定モーダル */
.hidden { display: none !important; }

#promote-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.modal-content button {
    margin: 0 10px;
    padding: 10px 20px;
    cursor: pointer;
}