:root {
    --board-bg: #e6cca0;
    --line-color: #333;
    --piece-bg: #fdf5e6;
    --piece-shadow: #d4b888;
    --highlight-color: rgba(255, 215, 0, 0.5);
    --last-move-color: rgba(200, 0, 0, 0.2);
    --selected-color: rgba(0, 100, 255, 0.4);
}

body {
    font-family: 'Noto Serif JP', serif;
    background-color: #2c2c2c;
    color: #f0f0f0;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

header {
    text-align: center;
}

.controls {
    margin: 10px 0;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

select,
button {
    padding: 8px 16px;
    font-size: 1rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
}

button {
    background-color: #4CAF50;
    color: white;
    font-weight: bold;
}

button:hover {
    background-color: #45a049;
}

#status {
    font-size: 1.2rem;
    margin-top: 10px;
    font-weight: bold;
    color: #ffd700;
}

.board-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.shogi-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    width: 450px;
    height: 450px;
    background-color: var(--board-bg);
    border: 2px solid #000;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

.cell {
    border: 1px solid var(--line-color);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    user-select: none;
}

.cell.highlight {
    background-color: var(--highlight-color);
}

.cell.last-move {
    background-color: var(--last-move-color);
}

.cell.selected {
    background-color: var(--selected-color);
}

.piece {
    width: 90%;
    height: 90%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    font-weight: 900;
    color: #1a1a1a;
    background: linear-gradient(135deg, #fdfaf3 0%, #f5e6d3 50%, #e8d4b8 100%);
    clip-path: polygon(50% 0%, 95% 12%, 90% 100%, 10% 100%, 5% 12%);
    box-shadow:
        2px 3px 0 rgba(180, 140, 90, 0.6),
        inset -1px -2px 3px rgba(0, 0, 0, 0.1),
        inset 1px 1px 2px rgba(255, 255, 255, 0.8);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    text-shadow:
        1px 1px 0 rgba(255, 255, 255, 0.5),
        -1px -1px 0 rgba(0, 0, 0, 0.1);
    font-family: 'Noto Serif JP', serif;
    letter-spacing: -0.05em;
}

.piece::before {
    content: '';
    position: absolute;
    top: 5%;
    left: 15%;
    right: 15%;
    height: 20%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.4), transparent);
    clip-path: polygon(50% 0%, 95% 15%, 85% 100%, 15% 100%, 5% 15%);
    pointer-events: none;
}

.piece:hover {
    transform: translateY(-2px);
    box-shadow:
        3px 5px 0 rgba(180, 140, 90, 0.7),
        inset -1px -2px 3px rgba(0, 0, 0, 0.1),
        inset 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.piece.gote {
    transform: rotate(180deg);
}

.piece.gote:hover {
    transform: rotate(180deg) translateY(-2px);
}

.piece.promoted {
    color: #c41e3a;
    font-size: 1.8rem;
    text-shadow:
        1px 1px 0 rgba(255, 200, 200, 0.5),
        -1px -1px 0 rgba(100, 0, 0, 0.2);
    background: linear-gradient(135deg, #fff5f5 0%, #ffe8e8 50%, #ffd4d4 100%);
}

.hand-container {
    width: 450px;
    background-color: #3a3a3a;
    padding: 10px;
    border-radius: 8px;
    min-height: 60px;
}

.hand-container h3 {
    margin: 0 0 5px 0;
    font-size: 1rem;
    border-bottom: 1px solid #555;
}

.hand-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.hand-piece {
    width: 30px;
    height: 35px;
    font-size: 1rem;
    font-weight: 900;
    background: linear-gradient(135deg, #fdfaf3 0%, #f5e6d3 50%, #e8d4b8 100%);
    color: #1a1a1a;
    display: flex;
    justify-content: center;
    align-items: center;
    clip-path: polygon(50% 0%, 95% 12%, 90% 100%, 10% 100%, 5% 12%);
    cursor: pointer;
    box-shadow:
        1px 2px 0 rgba(180, 140, 90, 0.6),
        inset -1px -1px 2px rgba(0, 0, 0, 0.1),
        inset 1px 1px 1px rgba(255, 255, 255, 0.8);
    transition: transform 0.2s, box-shadow 0.2s;
    text-shadow:
        0.5px 0.5px 0 rgba(255, 255, 255, 0.5),
        -0.5px -0.5px 0 rgba(0, 0, 0, 0.1);
    font-family: 'Noto Serif JP', serif;
}

.hand-piece:hover {
    transform: translateY(-1px);
    box-shadow:
        2px 3px 0 rgba(180, 140, 90, 0.7),
        inset -1px -1px 2px rgba(0, 0, 0, 0.1),
        inset 1px 1px 1px rgba(255, 255, 255, 0.8);
}

.hand-piece.selected {
    background: linear-gradient(135deg, #fff9e6 0%, #ffeaa7 50%, #fdcb6e 100%);
    box-shadow:
        2px 3px 0 rgba(200, 160, 50, 0.8),
        inset 0 0 5px rgba(255, 215, 0, 0.5);
}

/* Responsive */
@media (max-width: 500px) {
    .shogi-board {
        width: 340px;
        height: 340px;
    }

    .piece {
        font-size: 1.4rem;
    }

    .hand-container {
        width: 340px;
    }
}