:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    
    /* Classic Board colors */
    --light-square: #ebecd0;
    --dark-square: #739552;
    --highlight: rgba(255, 255, 0, 0.4);
    --last-move: rgba(155, 199, 0, 0.41);
    
    --font-main: 'Inter', sans-serif;
    --font-display: 'Outfit', sans-serif;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.2) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.2) 0, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

#app-container {
    width: 100%;
    max-width: 1200px;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

#main-menu {
    padding: 3rem 4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 400px;
    animation: fadeIn 0.4s ease;
}

.title {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

input[type="text"] {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.8rem;
    font-family: var(--font-main);
    transition: all 0.2s;
}
input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-color);
}

.btn {
    font-family: var(--font-main);
    font-weight: 600;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.btn.primary {
    background: var(--accent-color);
    color: white;
}
.btn.primary:hover {
    background: var(--accent-hover);
}
.btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
}
.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}
.btn.danger {
    background: var(--danger-color);
    color: white;
}
.btn.danger:hover {
    background: var(--danger-hover);
}
.btn.text-btn {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
}
.btn.text-btn:hover {
    color: white;
    transform: none;
    box-shadow: none;
}
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }

#ai-options, #online-options {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    animation: fadeIn 0.3s ease;
}
#ai-options h3, #online-options h3 {
    margin-bottom: 1.5rem;
}

.difficulty-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    width: 100%;
}
.btn-diff {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-diff.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

#game-screen {
    display: flex;
    gap: 2rem;
    height: 100%;
    max-height: 800px;
    width: 100%;
    max-width: 1200px;
    animation: fadeIn 0.5s ease;
}

.game-layout {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
    min-width: 0;
}

.sidebar {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
    height: 100%;
    min-width: 300px;
}

.player-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    height: 60px;
}
.player-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-family: var(--font-display);
}
.name-time h3 {
    font-size: 1rem;
    margin-bottom: 0.2rem;
}
.timer {
    font-family: monospace;
    font-size: 1.2rem;
    color: var(--text-secondary);
    background: rgba(0,0,0,0.3);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}
.timer.active {
    color: white;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid var(--accent-color);
}
.captured-pieces {
    display: flex;
    align-items: center;
    height: 30px;
}

.board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    min-height: 0;
}

#chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.square {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}
.square.light { background-color: var(--light-square); }
.square.dark { background-color: var(--dark-square); }
.square.highlight { background-color: var(--highlight) !important; }
.square.last-move { background-color: var(--last-move) !important; }

.piece {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    cursor: grab;
    z-index: 10;
    position: relative;
    user-select: none;
}
.piece:active { cursor: grabbing; }
.piece.dragging { opacity: 0.5; }

.valid-move-indicator {
    width: 30%;
    height: 30%;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    position: absolute;
    pointer-events: none;
    z-index: 5;
}
.valid-capture-indicator {
    width: 100%;
    height: 100%;
    border: 4px solid rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    position: absolute;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 5;
}

.status-box {
    background: rgba(0,0,0,0.2);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}
.status-box h2 {
    font-size: 1.2rem;
}

.move-history-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.move-history-container h3 {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
}

#move-history {
    flex: 1;
    overflow-y: auto;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 1rem;
    display: grid;
    grid-template-columns: 2rem 1fr 1fr;
    gap: 0.5rem;
    align-content: flex-start;
}
#move-history::-webkit-scrollbar { width: 8px; }
#move-history::-webkit-scrollbar-track { background: transparent; }
#move-history::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.move-num { color: var(--text-secondary); font-size: 0.9rem; }
.move-text { font-family: monospace; font-size: 1rem; }

.game-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#promotion-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 2rem;
    z-index: 100;
    text-align: center;
}
#promotion-modal h3 { margin-bottom: 1rem; }
.promo-options { display: flex; gap: 1rem; }
.promo-piece {
    width: 60px;
    height: 60px;
    cursor: pointer;
    transition: transform 0.2s;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
}
.promo-piece:hover {
    transform: scale(1.1);
    background: rgba(255,255,255,0.2);
}

.hidden { display: none !important; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
    #game-screen { flex-direction: column; height: auto; max-height: none; }
    .board-container { padding: 0; }
    #move-history { max-height: 200px; }
}
