:root {
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --accent-hover: #0ea5e9;
    --board-light: #e2e8f0;
    --board-dark: #64748b;
    --board-highlight: rgba(56, 189, 248, 0.5);
    --board-last-move: rgba(251, 191, 36, 0.4);
    --glass-border: rgba(255, 255, 255, 0.1);
    --radius-lg: 1rem;
    --radius-md: 0.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    gap: 2rem;
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Board Container */
.board-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(80vh, 600px);
    height: min(80vh, 600px);
    border: 8px solid #1e293b;
    border-radius: 4px;
    position: relative;
    user-select: none;
}

.square {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
}

.square.light {
    background-color: #f1f5f9;
}

.square.dark {
    background-color: #475569;
}

.square.highlight {
    background-color: rgba(56, 189, 248, 0.4) !important;
    box-shadow: inset 0 0 15px rgba(56, 189, 248, 0.6);
}

.square.last-move {
    background-color: rgba(251, 191, 36, 0.3) !important;
}

.piece {
    width: 85%;
    height: 85%;
    z-index: 10;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: grab;
}

.piece:active {
    cursor: grabbing;
}

.piece:hover {
    transform: scale(1.1);
}

/* Info Section */
.info-section {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.status-card {
    padding: 1.5rem;
}

.turn-indicator {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.turn-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--text-secondary);
}

.turn-dot.active {
    background-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
}

.game-status-text {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Move History */
.history-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow: hidden;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    margin-top: 1rem;
    padding-right: 0.5rem;
    max-height: 300px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) var(--board-dark);
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: var(--board-dark);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 4px;
}

.move-row {
    display: flex;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--glass-border);
    font-variant-numeric: tabular-nums;
}

.move-num {
    width: 30px;
    color: var(--text-secondary);
}

.move-white {
    flex: 1;
}

.move-black {
    flex: 1;
}

/* Buttons */
.controls {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--accent-color);
    color: white;
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
        align-items: center;
    }

    .info-section {
        width: 100%;
        max-width: 600px;
    }

    .chess-board {
        width: min(95vw, 500px);
        height: min(95vw, 500px);
    }
}

/* Modal System */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-backdrop.hidden {
    display: none;
    opacity: 0;
}

.modal-content {
    width: 90%;
    max-width: 400px;
    padding: 2rem;
    text-align: center;
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-backdrop.hidden .modal-content {
    transform: translateY(20px);
}

.modal-title {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.modal-text {
    margin-bottom: 2rem;
    color: var(--text-secondary);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Board Rotation */
.chess-board.rotated {
    transform: rotate(180deg);
}

.chess-board.rotated .piece svg {
    transform: rotate(180deg);
}

/* Settings Controls / Switch */
.settings-control {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
    width: 100%;
    text-align: left;
}

.switch-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.switch-label input {
    display: none;
}

.switch-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background-color: var(--board-dark);
    border-radius: 20px;
    transition: 0.3s;
}

.switch-slider::before {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked+.switch-slider {
    background-color: var(--accent-color);
}

input:checked+.switch-slider::before {
    transform: translateX(16px);
}

.label-text {
    user-select: none;
    display: block;
    margin-bottom: 0.5rem;
}

/* Dropdown styling */
.select-dropdown {
    width: 100%;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.select-dropdown:hover {
    border-color: var(--accent-color);
}

.select-dropdown:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.select-dropdown option {
    background: var(--bg-color);
    color: var(--text-primary);
}

/* Home Menu Styles */
.home-layout {
    display: flex;
    justify-content: center;
    align-items: center;
}

.main-menu {
    width: 100%;
    max-width: 800px;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.menu-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    transition: opacity 0.3s;
}

.menu-section.hidden {
    display: none;
}

.btn-large {
    font-size: 1.25rem;
    padding: 1rem 3rem;
    width: 60%;
    max-width: 300px;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.text-input {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.text-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.online-split {
    display: flex;
    gap: 2rem;
    width: 100%;
    margin-top: 1rem;
}

.glass-panel-inner {
    flex: 1;
    background: rgba(15, 23, 42, 0.5);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid var(--glass-border);
}

.tables-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.table-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.05);
    padding: 0.75rem;
    border-radius: var(--radius-md);
}

.table-item span {
    font-weight: 600;
}

.status-msg {
    text-align: center;
    font-style: italic;
    color: var(--text-secondary);
}

.loader {
    border: 4px solid var(--glass-border);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 1rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}