:root {
    --bg-color: #2c3e50;
    --board-border: #34495e;
    --light-square: #ecf0f1;
    --dark-square: #95a5a6;
    --highlight-color: #f1c40f; /* Yellow for selected/last move */
    --possible-move-color: rgba(46, 204, 113, 0.5); /* Greenish dot */
    --capture-color: rgba(231, 76, 60, 0.5); /* Reddish ring */
    --text-color: #ecf0f1;
    --sidebar-bg: #34495e;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
    width: 100%;
    max-width: 1000px;
}

header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 800px;
}

h1 {
    margin: 0;
}

.status-bar {
    font-size: 1.2rem;
    font-weight: bold;
}

#check-indicator {
    background-color: #e74c3c;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 10px;
}

.hidden {
    display: none;
}

.game-area {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.board-container {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1;
    border: 10px solid var(--board-border);
    border-radius: 4px;
    user-select: none;
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
}

.square {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem; /* Adjust based on board size usually, but rem is fine */
    cursor: pointer;
    position: relative;
}

/* Responsive font size for pieces */
@media (max-width: 500px) {
    .square {
        font-size: 1.8rem;
    }
}

.square.light {
    background-color: var(--light-square);
    color: black; /* For white pieces outline if needed, but unicode handles it */
}

.square.dark {
    background-color: var(--dark-square);
    color: black;
}

/* Selected piece highlight */
.square.selected {
    background-color: var(--highlight-color) !important;
}

/* Last move highlight */
.square.last-move {
    background-color: rgba(241, 196, 15, 0.6) !important;
}

/* Possible move indicator */
.square.possible-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background-color: var(--possible-move-color);
    border-radius: 50%;
}

.square.capture-move::after {
    content: '';
    position: absolute;
    width: 80%;
    height: 80%;
    border: 4px solid var(--capture-color);
    border-radius: 50%;
}

.piece {
    cursor: grab;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Coloring Unicode pieces */
.piece.white {
    color: #fff;
    text-shadow: 0 0 2px #000, 0 0 2px #000; /* Outline for visibility on light squares */
}

.piece.black {
    color: #000;
}

.sidebar {
    width: 300px;
    background-color: var(--sidebar-bg);
    padding: 20px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 500px;
}

.move-history {
    flex-grow: 1;
    overflow-y: auto;
    background-color: rgba(0,0,0,0.1);
    padding: 10px;
    border-radius: 4px;
}

.move-history ul {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    font-family: monospace;
}

.move-history li {
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.controls {
    display: flex;
    gap: 10px;
}

button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    background-color: #2ecc71;
    color: white;
    font-weight: bold;
    cursor: pointer;
}

button:hover {
    background-color: #27ae60;
}

button.secondary {
    background-color: #7f8c8d;
}

button.secondary:hover {
    background-color: #95a5a6;
}
