:root {
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --text-main: #e0e0e0;
    --text-muted: #aaaaaa;
    
    --board-light-classic: #f0d9b5;
    --board-dark-classic: #b58863;
    --board-light-wood: #d18b47;
    --board-dark-wood: #ffce9e;
    --board-light-marble: #e8e5df;
    --board-dark-marble: #8a969b;
    --board-light-ocean: #a0c4d6;
    --board-dark-ocean: #4e6a82;
    
    --highlight-last-move: rgba(155, 199, 0, 0.41);
    --highlight-selected: rgba(20, 85, 30, 0.5);
    --highlight-legal: rgba(0, 0, 0, 0.2);
    --danger-glow: rgba(255, 0, 0, 0.6);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

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

header {
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(90deg, #bb86fc, #3700b3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
}

#app-title { cursor: pointer; transition: opacity 0.2s; }
#app-title:hover { opacity: 0.8; }

#room-info {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.hidden {
    display: none !important;
}

/* Main Menu */
.menu-container {
    background-color: var(--bg-panel);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    margin-top: 20px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 300px;
}

.menu-buttons button {
    padding: 15px;
    font-size: 1.1rem;
}

.customization-panel {
    border-top: 1px solid #333;
    padding-top: 20px;
    width: 100%;
    text-align: center;
}

.customization-panel h3 {
    margin-bottom: 15px;
    color: var(--text-muted);
}

.custom-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.custom-controls label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-weight: 600;
}

.custom-controls select {
    padding: 8px;
    background-color: #333;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    font-size: 1rem;
}

.checkbox-label {
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px !important;
    cursor: pointer;
}

.checkbox-label input {
    width: 20px;
    height: 20px;
}

.game-area {
    display: flex;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

/* Evaluation Bar */
.evaluation-bar-container {
    width: 20px;
    height: 560px; /* matches board height approx */
    background-color: #333;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    margin-top: 25px; /* Offset to align with board */
}

#evaluation-fill {
    width: 100%;
    height: 50%;
    background-color: #eee;
    transition: height 0.5s ease-in-out;
}

/* Board Area */
.board-cont.player-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px;
    background: var(--bg-panel);
    border-radius: 8px;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    object-fit: cover;
}

.timer {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.2rem;
    font-weight: bold;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    color: #ffd700;
}

.timer.active {
    background: rgba(255, 215, 0, 0.2);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.button:hover {
    background: #6a11cb;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(106, 17, 203, 0.4);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #444 !important;
}

#btn-suggest.hint-ready {
    background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
    animation: hintPulse 2s infinite;
}

@keyframes hintPulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 210, 255, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(0, 210, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 210, 255, 0); }
}

.player-name {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

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

.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.captured-pieces {
    display: flex;
    gap: 2px;
    min-height: 24px;
    font-size: 1.2rem;
}

.board-wrapper {
    position: relative;
    user-select: none;
    margin: 0 auto;
}

.arrows-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50; /* Above squares and pieces */
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 70px);
    grid-template-rows: repeat(8, 70px);
    border: 4px solid var(--bg-panel);
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.square {
    width: 70px;
    height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Themes */
.theme-classic .square.light { background-color: var(--board-light-classic); }
.theme-classic .square.dark { background-color: var(--board-dark-classic); }
.theme-wood .square.light { background-color: var(--board-light-wood); }
.theme-wood .square.dark { background-color: var(--board-dark-wood); }
.theme-marble .square.light { background-color: var(--board-light-marble); }
.theme-marble .square.dark { background-color: var(--board-dark-marble); }
.theme-ocean .square.light { background-color: var(--board-light-ocean); }
.theme-ocean .square.dark { background-color: var(--board-dark-ocean); }

/* Highlights */
.square.selected::after {
    content: '';
    position: absolute;
    inset: 0;
    background-color: var(--highlight-selected);
}
.square.last-move::after {
    content: '';
    position: absolute;
    inset: 0;
    background-color: var(--highlight-last-move);
}
.square.legal-move::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--highlight-legal);
    z-index: 2;
}
.square.in-check {
    box-shadow: inset 0 0 15px var(--danger-glow);
}
.square.in-danger {
    box-shadow: inset 0 0 10px rgba(255, 50, 50, 0.5);
    background-color: rgba(255, 50, 50, 0.15);
}
.square.hint-move::after {
    content: '';
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 15px rgba(0, 255, 255, 0.8);
    background-color: rgba(0, 255, 255, 0.3);
    z-index: 5;
}

/* Pieces */
.piece {
    width: 60px;
    height: 60px;
    background-size: cover;
    z-index: 10;
    cursor: grab;
    will-change: transform;
}
.piece:active {
    cursor: grabbing;
}
.piece.dragging {
    z-index: 100;
    position: absolute;
    pointer-events: none;
    transition: none; /* Disable transition while dragging */
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 300px;
}

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

button {
    flex: 1;
    padding: 10px 15px;
    background-color: #3700b3;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover:not(:disabled) {
    background-color: #6200ea;
}

button:disabled {
    background-color: #444;
    color: #888;
    cursor: not-allowed;
}

.sidebar-settings {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 4px;
    display: flex;
    justify-content: center;
}

.move-history {
    background-color: var(--bg-panel);
    padding: 15px;
    border-radius: 8px;
    flex-grow: 1;
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
}

.move-history h3 {
    margin-bottom: 10px;
    font-size: 1.1rem;
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
}

#move-list {
    list-style: none;
    display: grid;
    grid-template-columns: 30px 1fr 1fr;
    gap: 5px;
    font-family: monospace;
    font-size: 1.1rem;
}

#move-list li {
    display: contents;
}

.move-number { color: var(--text-muted); text-align: right; padding-right: 5px; }
.move-white, .move-black { padding-left: 5px; }

.status-panel {
    background-color: var(--bg-panel);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    font-size: 1.2rem;
    color: #ffb300;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--bg-panel);
    padding: 30px;
    border-radius: 8px;
    text-align: center;
}

.promotion-pieces {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.promotion-piece {
    width: 70px;
    height: 70px;
    background-size: cover;
    background-color: var(--board-light-classic);
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s;
}

.promotion-piece:hover {
    transform: scale(1.1);
    background-color: var(--highlight-selected);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--bg-panel);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

#btn-about {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
}

.about-content {
    text-align: center;
}

.about-info {
    margin: 20px 0;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.btn-icon {
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.btn-icon:hover {
    transform: scale(1.1);
}

.save-slots-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
    max-height: 400px;
    overflow-y: auto;
    width: 100%;
    min-width: 350px;
    padding: 5px;
}

.save-slot {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
    text-align: left;
}

.save-slot:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #6a11cb;
    transform: translateY(-2px);
}

.save-slot-info {
    flex-grow: 1;
}

.save-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-play-save {
    background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
    border: none;
    color: white;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: transform 0.2s;
}

.btn-play-save:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.btn-delete-save {
    background: rgba(255, 50, 50, 0.2);
    color: #ff5252;
    border: none;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.2rem;
}

.btn-delete-save:hover {
    background: #ff5252;
    color: white;
}

.save-slot-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    align-items: center;
}

.save-title {
    font-weight: bold;
    color: #bb86fc;
}

.save-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.save-details {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.btn-secondary {
    background-color: #444;
    width: 100%;
    margin-top: 10px;
}

.piece.danger-glow {
    filter: drop-shadow(0 0 8px rgba(255, 0, 0, 0.8)) drop-shadow(0 0 15px rgba(255, 50, 50, 0.4));
    animation: danger-pulse 1.5s infinite;
}

@keyframes danger-pulse {
    0% { filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.6)); }
    50% { filter: drop-shadow(0 0 15px rgba(255, 0, 0, 0.9)); }
    100% { filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.6)); }
}

.hint-move {
    box-shadow: inset 0 0 20px 5px rgba(0, 210, 255, 0.8) !important;
    animation: hintSquarePulse 1s infinite alternate;
    z-index: 5;
}

@keyframes hintSquarePulse {
    from { opacity: 0.7; box-shadow: inset 0 0 10px rgba(0, 210, 255, 0.5); }
    to { opacity: 1; box-shadow: inset 0 0 30px rgba(0, 210, 255, 1); }
}

.feature-list {
    text-align: left;
    margin: 20px 0;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px;
}

.feature-list h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
}

.feature-list ul {
    list-style: none;
}

.feature-list li {
    margin-bottom: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.feature-list li strong {
    color: #bb86fc;
}

.about-content {
    max-width: 450px;
}

@media (max-width: 800px) {
    .chessboard {
        grid-template-columns: repeat(8, 11vw);
        grid-template-rows: repeat(8, 11vw);
    }
    .square { width: 11vw; height: 11vw; }
    .piece { width: 9vw; height: 9vw; }
    .evaluation-bar-container { display: none; }
}
