:root {
    --square-light: #f0d9b5;
    --square-dark: #b58863;
    --square-highlight: rgba(255, 255, 0, 0.4);
    --bg-color: #f4f4f9;
    --text-color: #333;
}

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

.container {
    text-align: center;
    width: 90%;
    max-width: 900px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 10px;
}

h1 {
    margin: 0;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#user-email {
    font-weight: bold;
    font-size: 1rem;
}

#status {
    margin-bottom: 15px;
    font-weight: bold;
    font-size: 1.2rem;
}

.game-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 60px);
    grid-template-rows: repeat(8, 60px);
    border: 4px solid #333;
    user-select: none;
}

.square {
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 40px;
    cursor: pointer;
    position: relative;
}

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

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

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

.square.selected {
    background-color: rgba(0, 150, 255, 0.4);
}

.rank-label {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
}

.file-label {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
}

/* Ensure labels contrast with square color */
.square.light .rank-label,
.square.light .file-label {
    color: var(--square-dark);
}

.square.dark .rank-label,
.square.dark .file-label {
    color: var(--square-light);
}

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

.info-panel {
    flex: 1;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.game-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.game-actions button {
    flex: 1;
}

button {
    padding: 10px 20px;
    background-color: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #555;
}

select {
    padding: 5px;
    border-radius: 4px;
}

.move-history {
    max-height: 300px;
    overflow-y: auto;
    text-align: left;
}

#move-list {
    list-style: none;
    padding: 0;
    font-family: monospace;
}

#move-list li {
    padding: 4px 0;
    border-bottom: 1px solid #eee;
}

@media (max-width: 600px) {
    .board {
        grid-template-columns: repeat(8, 40px);
        grid-template-rows: repeat(8, 40px);
    }
    .square {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }
}

/* Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgb(0,0,0); 
    background-color: rgba(0,0,0,0.4); 
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto; 
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#games-list {
    list-style-type: none;
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
}

#games-list li {
    background: #f9f9f9;
    margin: 5px 0;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#games-list li:hover {
    background-color: #e9e9e9;
}

