:root {
    --bg-color: #1a1a2e;
    /* 背景色 (Background Color) */
    --board-bg: #000000;
    /* 盤面の背景色：黒 (Board Black) */
    --cell-bg: #e0e6ed;
    /* マスの色：薄いグレー (Cell Light Grey) */
    --p1-color: #00fff5;
    /* プレイヤー1の色：水色 (Cyan) */
    --p2-color: #ff007f;
    /* プレイヤー2の色：ピンク (Pink) */
    --text-color: #e94560;
    /* テキストの基本色 (Text Color) */
    --highlight: #ff00f2;
    /* 強調表示の色：黄色 (Highlight Yellow) */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: white;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

#app {
    width: 100%;
    max-width: 400px;
    /* Reduced from 500px to ensure fit */
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

h1 {
    color: var(--p1-color);
    text-shadow: 0 0 10px rgba(0, 255, 245, 0.5);
    margin-bottom: 10px;
}

#game-status {
    font-size: 1.2rem;
    font-weight: bold;
    min-height: 1.5em;
    color: #fff;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* Hands */
.hand {
    display: flex;
    justify-content: center;
    gap: 10px;
    height: 70px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    width: 100%;
}

.hand.active-turn {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

/* Board */
/* Board */
/* Board */
.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px;
    /* Black lines via gap */
    width: 100%;
    aspect-ratio: 1;
    min-height: 300px;
    /* Prevent collapse */
    background-color: #707070;
    /* Black grid lines */
    padding: 5px;
    border: 4px solid #ffffff;
    /* Thicker border */
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.cell {
    background-color: #e0e6ed;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
    border: 1px solid #ccc;
}

/* Light orange background for cells with stacked pieces */
.has-stack {
    background-color: #ffcc99;
    /* light orange */
}

.cell.valid-move:hover {
    background-color: #1a4b8c;
}

/* Pieces */
.piece {
    border-radius: 50%;
    display: flex;
    /* Flex used for centering text label */
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: #000;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.piece.p1 {
    background: linear-gradient(135deg, #00fff5, #00cccc);
}

.piece.p2 {
    background: linear-gradient(135deg, #ff007f, #cc0066);
    color: white;
}

/* Board Context - Pieces stack */
.board .piece {
    /* Removed position: absolute; letting flex center it */
    position: relative;
    pointer-events: none;
    /* KEY FIX: Let clicks pass through to the .cell */
}

.board .piece.large {
    width: 85%;
    height: 85%;
    z-index: 3;
    /* font-size handled in ::after */
}

.board .piece.medium {
    width: 60%;
    height: 60%;
    z-index: 2;
}

.board .piece.small {
    width: 35%;
    height: 35%;
    z-index: 1;
}

/* Hand Context - Pieces sit side-by-side */
.hand .piece {
    position: relative;
}

.hand .piece.large {
    width: 50px;
    height: 50px;
}

.hand .piece.medium {
    width: 40px;
    height: 40px;
}

.hand .piece.small {
    width: 30px;
    height: 30px;
}

/* Text Labels */
.piece::after {
    content: attr(data-label);
    /* Flex parent (.piece) centers this */
    font-size: 2em;
    /* Significantly larger */
    opacity: 1;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* Selection and Stacking Styling */
.selected {
    box-shadow: 0 0 15px 5px var(--highlight);
    transform: scale(1.1);
    z-index: 10 !important;
}

.stack-marker {
    /* Dotted marker disabled; visual handled by cell background */
    display: none;
}

/* Removed dotted stack marker; use cell background instead */
/* .has-stack .stack-marker { display: block; } */

@keyframes blink {
    0% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.3;
    }
}

/* UI Controls */
#restart-btn {
    padding: 10px 20px;
    font-size: 1rem;
    background-color: var(--p1-color);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    color: #000;
    font-weight: bold;
}

#restart-btn:hover {
    filter: brightness(0.9);
}

.hidden {
    display: none;
}

#rules {
    font-size: 0.9rem;
    color: #aaa;
    margin-top: 10px;
    line-height: 1.4;
}

/* Menu Styling */
.menu {
    width: 100%;
    max-width: 400px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 30px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.name-inputs {
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: left;
}

.name-inputs label {
    font-size: 0.9rem;
    color: #aaa;
}

.name-inputs input {
    padding: 10px;
    border-radius: 5px;
    border: none;
    background-color: #e0e6ed;
    color: #333;
    font-size: 1rem;
}

#start-btn,
#menu-back-btn {
    padding: 12px 20px;
    font-size: 1.1rem;
    background-color: var(--p1-color);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    color: #000;
    font-weight: bold;
    margin-top: 10px;
    transition: filter 0.2s;
}

#start-btn:hover,
#menu-back-btn:hover {
    filter: brightness(0.9);
}

#menu-back-btn {
    background-color: #aaa;
    /* Different color for back button */
    font-size: 0.9rem;
    padding: 8px 15px;
    margin-left: 10px;
}