:root {
    --bg-color: #121212;
    --panel-bg: rgba(30, 30, 35, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: #e0e0e0;
    --text-secondary: #9e9e9e;
    --accent: #6c5ce7;
    --accent-hover: #8073eb;
    --danger: #ff7675;
    --success: #55efc4;
    --font-family: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 15% 50%, rgba(108, 92, 231, 0.15), transparent 25%),
                      radial-gradient(circle at 85% 30%, rgba(85, 239, 196, 0.1), transparent 25%);
    color: var(--text-primary);
    font-family: var(--font-family);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app-container {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    grid-template-rows: minmax(0, 60%) minmax(40%, 1fr);
    gap: 20px;
    width: 95vw;
    height: 95vh;
    max-width: 1600px;
}

/* Glassmorphism Panel */
.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    min-height: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 10px;
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Specific Panels */
.opening-selector {
    grid-column: 1;
    grid-row: 1;
}

.board-container {
    grid-column: 2;
    grid-row: 1;
    align-items: center;
}

.board {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.board-status {
    margin-top: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
}

.opening-navigator {
    grid-column: 3;
    grid-row: 1;
}

.tree-container {
    grid-column: 1 / 4;
    grid-row: 2;
    overflow: hidden;
}

.tree-canvas {
    flex: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Buttons */
button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: var(--font-family);
    transition: all 0.2s ease;
}

.btn-icon {
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.1rem;
    padding: 8px;
    border-radius: 8px;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon.active {
    color: var(--danger);
    background: rgba(255, 118, 117, 0.2);
}

.btn-primary {
    background: var(--accent);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.nav-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.btn-nav {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--panel-border);
    padding: 10px 15px;
    border-radius: 8px;
}

.btn-nav:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Lists */
.list-group {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.list-item {
    padding: 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.list-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--panel-border);
}

.list-item.selected {
    background: rgba(108, 92, 231, 0.2);
    border-color: var(--accent);
}

.item-info {
    display: flex;
    flex-direction: column;
}

.item-name {
    font-weight: 500;
}

.item-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.btn-delete-node {
    color: var(--danger);
    background: transparent;
    padding: 4px;
}

.btn-delete-node:hover {
    color: white;
    background: var(--danger);
}

.lichess-section {
    margin-top: auto;
    border-top: 1px solid var(--panel-border);
    padding-top: 15px;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 8px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-family: var(--font-family);
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

.tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
}

.tab-content.active {
    display: flex;
}

.move-stat {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 0.9rem;
}

.stat-bar {
    display: flex;
    height: 4px;
    width: 100%;
    border-radius: 2px;
    margin-top: 5px;
    overflow: hidden;
}

.stat-white { background: #e0e0e0; }
.stat-draw { background: #9e9e9e; }
.stat-black { background: #2d3436; }

/* SVG Tree styling */
.node circle {
    fill: var(--panel-bg);
    stroke: var(--accent);
    stroke-width: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.node circle:hover {
    fill: var(--accent);
}

.node text {
    font-family: var(--font-family);
    font-size: 12px;
    fill: var(--text-primary);
}

.link {
    fill: none;
    stroke: var(--panel-border);
    stroke-width: 2px;
}

.node.active circle {
    fill: var(--accent);
    stroke: #fff;
    stroke-width: 3px;
    filter: drop-shadow(0 0 5px var(--accent));
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: 300px;
}

.modal-content h3 {
    margin-bottom: 15px;
}

.modal-content input {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--panel-border);
    color: white;
    border-radius: 8px;
    margin-bottom: 15px;
    outline: none;
    font-family: var(--font-family);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Board Highlights */
.highlight-selected {
    background-color: rgba(108, 92, 231, 0.5) !important;
}

.highlight-move {
    position: relative;
}
.highlight-move::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30%;
    height: 30%;
    background-color: rgba(0, 0, 0, 0.25);
    border-radius: 50%;
    pointer-events: none;
    z-index: 2;
}

.highlight-capture {
    position: relative;
}
.highlight-capture::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border: 6px solid rgba(0, 0, 0, 0.25);
    border-radius: 50%;
    pointer-events: none;
    z-index: 2;
}

.highlight-check {
    background: radial-gradient(circle, rgba(255, 71, 87, 0.8) 0%, rgba(255, 71, 87, 0) 80%) !important;
}
