:root {
    --bg-color: #0f172a;
    --text-color: #e2e8f0;
    --accent-color: #38bdf8;
    --board-light: #e2e8f0;
    --board-dark: #475569;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --highlight: rgba(56, 189, 248, 0.5);
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    background-image: radial-gradient(circle at top right, #1e293b, #0f172a);
}

header {
    margin-top: 2rem;
    margin-bottom: 2rem;
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-container {
    display: flex;
    gap: 2rem;
    padding: 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    /* Align top so captured pieces sit nicely */
}

#chess-board-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    /* Wrapper to handle zoom without affecting layout flow too much */
    overflow: visible;
}

#chess-board {
    width: 400px;
    height: 400px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border: 5px solid #334155;
    border-radius: 4px;
    user-select: none;
    transform-origin: top center;
    transition: transform 0.2s ease-out;
}

.square {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    cursor: pointer;
    position: relative;
}

.square.light {
    background-color: var(--board-light);
    color: var(--board-dark);
    /* For pieces if using text, but we use images/unicode */
}

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

.square.selected {
    background-color: rgba(255, 255, 0, 0.5) !important;
}

.square.possible-move::after {
    content: '';
    width: 15px;
    height: 15px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
}

.piece {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-position: center;
    cursor: grab;
    transition: transform 0.2s;
    /* background-color: rgba(255, 0, 0, 0.2); Debugging red background */
}

.player-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 1rem;
}

.player-label {
    color: #e2e8f0;
    font-weight: bold;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.piece:hover {
    transform: scale(1.1);
}

.sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.status-panel {
    background: rgba(15, 23, 42, 0.5);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--glass-border);
}

.status-panel h2 {
    margin-top: 0;
    font-size: 1.2rem;
    color: var(--accent-color);
}

#status-text {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

#last-move-time {
    font-size: 0.8rem;
    color: #94a3b8;
}

.controls {
    display: flex;
    gap: 1rem;
}

button {
    background: linear-gradient(to right, #38bdf8, #818cf8);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    flex: 1;
}

button:hover {
    opacity: 0.9;
}

button.secondary {
    background: #475569;
}

/* Responsive */
@media (max-width: 800px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }

    #chess-board {
        width: 80vw;
        height: 80vw;
        max-width: 400px;
        max-height: 400px;
    }
}

/* Modal Styles */
.modal {
    display: flex;
    /* Hidden by default via class, but flex when shown */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-color);
    border: 1px solid var(--glass-border);
    padding: 2rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #94a3b8;
}

.close-modal:hover {
    color: white;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.setting-item label {
    font-weight: 600;
}

/* Toggle Switch */
input[type="checkbox"] {
    transform: scale(1.5);
    cursor: pointer;
}

/* Navigation Menu */
.mn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 2rem;
    width: 100%;
    box-sizing: border-box;
}

.mn .nav-left a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    transition: color 0.2s;
}

.mn .nav-left a:hover {
    color: var(--accent-color);
}

/* Captured Pieces */
.captured-pieces {
    display: flex;
    flex-wrap: wrap;
    width: 150px;
    /* Fixed width for side display */
    gap: 5px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    min-height: 50px;
}

.captured-piece {
    width: 30px;
    height: 30px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Game End Overlay */
.game-end-content {
    text-align: center;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 2px solid var(--accent-color);
}

#game-end-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    /* Standard property */
}

#game-end-message {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

/* Slider Style */
input[type="range"] {
    width: 100px;
}

/* Profile Forms */
.profile-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.profile-form input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-family: inherit;
}

.profile-form input:focus {
    outline: none;
    border-color: var(--accent-color);
}

h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: #94a3b8;
}

.mn .nav-right {
    display: flex;
    gap: 1rem;
}

.mn button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    flex: initial;
    /* Don't stretch like sidebar buttons */
}