/* lab_chess.css - V2 */
:root {
    --chess-light-sq: #f1f5f9;
    --chess-dark-sq: #64748b;
    --chess-board-bg: #ffffff;
    --chess-panel-bg: rgba(255, 255, 255, 0.9);
    --chess-text: #1e293b;
    --chess-border: #e2e8f0;
}

[data-theme="dark"] {
    --chess-light-sq: #334155;
    --chess-dark-sq: #0f172a;
    --chess-board-bg: #1e293b;
    --chess-panel-bg: rgba(30, 41, 59, 0.95);
    --chess-text: #f1f5f9;
    --chess-border: rgba(255, 255, 255, 0.2);
}

/* Zen Mode overrides */
.zen-mode {
    --chess-light-sq: #e5e7eb;
    --chess-dark-sq: #9ca3af;
    --chess-board-bg: #f3f4f6;
    --chess-panel-bg: rgba(243, 244, 246, 0.95);
    --chess-text: #374151;
    --chess-border: #d1d5db;
}

[data-theme="dark"] .zen-mode {
    --chess-light-sq: #374151;
    --chess-dark-sq: #1f2937;
    --chess-board-bg: #111827;
    --chess-panel-bg: rgba(17, 24, 39, 0.95);
    --chess-text: #d1d5db;
    --chess-border: rgba(255, 255, 255, 0.1);
}

.zen-mode .chess-board-container {
    border-color: #9ca3af !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.lab-chess-panel {
    width: 440px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 620px;
    align-self: stretch;
}

.lab-chess-view {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    width: 100%;
    color: var(--chess-text);
    background: transparent;
}

.lab-chess-view.modal-mode {
    width: auto;
    height: auto;
    max-width: none;
    padding: 1.5rem;
    background: transparent;
    box-sizing: border-box;
}

.lab-chess-view.modal-mode .chess-layout {
    margin: 0;
}

.chess-center-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
}

.chess-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.chess-layout {
    display: flex;
    gap: 1.5rem;
    width: 100%;
    max-width: 1550px;
    justify-content: center;
    align-items: stretch;
    flex-wrap: nowrap;
}

@media (max-width: 1350px) {
    .chess-layout {
        flex-wrap: wrap;
        gap: 2rem;
    }
}

/* ============================================================
   HISTORY LEFT PANEL
   ============================================================ */
.chess-history-panel {
    width: 380px;
    background: var(--chess-panel-bg);
    border: 1px solid var(--chess-border);
    border-radius: 16px;
    padding: 0.75rem;
    backdrop-filter: blur(12px);
    color: var(--chess-text);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 620px;
    /* Better default */
    align-self: stretch;
    /* Attempt to match center panel */
}

@media (max-width: 900px) {
    .chess-history-panel {
        display: none;
    }
}

.history-panel-title {
    font-size: 0.75rem;
    font-weight: 700;
    opacity: 0.6;
    display: flex;
    align-items: center;
    gap: 4px;
    border-bottom: 1px solid var(--chess-border);
    padding-bottom: 6px;
}

.history-panel-grid {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-height: 100px;
}

.history-panel-grid::-webkit-scrollbar {
    width: 3px;
}

.history-panel-grid::-webkit-scrollbar-thumb {
    background: var(--chess-border);
    border-radius: 3px;
}

/* ============================================================
   INCOMING INVITE BANNER
   ============================================================ */
.invite-incoming {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(59, 130, 246, 0.1));
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 14px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    animation: invite-slide-in 0.3s ease;
}

@keyframes invite-slide-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.invite-incoming-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    margin-bottom: 0.6rem;
    color: var(--chess-text);
}

.invite-incoming-text i {
    color: #10b981;
    font-size: 1.1rem;
}

.invite-incoming-actions {
    display: flex;
    gap: 0.5rem;
}

.invite-accept-btn {
    flex: 1;
    padding: 6px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.invite-accept-btn:hover {
    background: #059669;
}

.invite-refuse-btn {
    flex: 1;
    padding: 6px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.invite-refuse-btn:hover {
    background: #ef4444;
    color: white;
}

/* ============================================================
   BOARD
   ============================================================ */
.chess-board-container {
    background: var(--chess-board-bg);
    padding: 0.75rem;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.5);
    border: 3px solid var(--chess-border);
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.chess-board-container.border-my-turn {
    border-color: #22c55e;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.2), 0 20px 25px -5px rgb(0 0 0 / 0.5);
}

.chess-board-container.border-paused {
    border-color: #eab308;
    box-shadow: 0 0 20px rgba(234, 179, 8, 0.2), 0 20px 25px -5px rgb(0 0 0 / 0.5);
}

.chess-board-container.border-check {
    border-color: #ef4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3), 0 20px 25px -5px rgb(0 0 0 / 0.5);
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 60px);
    grid-template-rows: repeat(8, 60px);
    border: 2px solid var(--chess-border);
    user-select: none;
    position: relative;
}

@media (max-width: 600px) {
    .chess-board {
        grid-template-columns: repeat(8, 40px);
        grid-template-rows: repeat(8, 40px);
    }
}

.chess-square {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: background-color 0.15s;
    border: 1px solid rgba(0, 0, 0, 0.05);
    /* Subtle border for visibility */
    box-sizing: border-box;
}

.chess-square.light {
    background-color: var(--theme-light, var(--chess-light-sq));
}

.chess-square.dark {
    background-color: var(--theme-dark, var(--chess-dark-sq));
}

.chess-piece {
    width: 80%;
    height: 80%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2;
    transition: transform 0.1s ease;
}

.chess-piece.is-hidden {
    opacity: 0 !important;
}

.chess-animated-piece {
    pointer-events: none;
    background-repeat: no-repeat;
    background-position: center;
}

.chess-piece.is-dragging {
    opacity: 0 !important;
    pointer-events: none !important;
}

.chess-floating-piece {
    position: fixed;
    width: 65px;
    height: 65px;
    margin-left: -32.5px;
    margin-top: -32.5px;
    z-index: 999999;
    pointer-events: none;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.5));
    transform: scale(0.9);
}

.chess-square.selected {
    background-color: #fde047 !important;
}

.chess-square.last-move {
    background-color: rgba(251, 191, 36, 0.35) !important;
}

.chess-square.in-check {
    background-color: #ef4444 !important;
    box-shadow: inset 0 0 25px #b91c1c !important;
    animation: chess-pulse 1.5s infinite;
}

@keyframes chess-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.03);
        opacity: 0.85;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.valid-move {
    position: absolute;
    width: 20px;
    height: 20px;
    background: rgba(34, 197, 94, 0.4);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.chess-square:has(.chess-piece) .valid-move {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(34, 197, 94, 0.4);
    background: transparent;
    border-radius: 50%;
}

@media (max-width: 600px) {
    .valid-move {
        width: 14px;
        height: 14px;
    }

    .chess-square:has(.chess-piece) .valid-move {
        width: 40px;
        height: 40px;
    }
}

/* Pause Overlay */
.pause-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    gap: 0.5rem;
    color: white;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    backdrop-filter: blur(3px);
    border-radius: 2px;
}

.pause-overlay i {
    font-size: 3rem;
    opacity: 0.8;
}

/* ============================================================
   PLAYER BARS (above and below board)
   ============================================================ */
.chess-player-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--chess-text);
    height: 48px;
    /* Slightly taller for comfort */
    min-height: 48px;
    box-sizing: border-box;
}

.player-bar-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-bar-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.captured-pieces {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 20px;
    overflow: hidden;
}

.captured-piece-icon {
    width: 13px;
    height: 13px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    margin-right: -2px;
    opacity: 0.8;
}

.captured-score {
    font-size: 0.65rem;
    font-weight: 700;
    margin-left: 4px;
    opacity: 0.6;
}

.player-bar-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    font-size: 0.85rem;
}

.pbar-first {
    font-weight: 700;
    text-transform: uppercase;
}

.pbar-last {
    opacity: 0.8;
}

.pname-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-bar-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    border: 2px solid var(--chess-border);
}

.player-bar-color.white-dot {
    background: #fff;
}

.player-bar-color.black-dot {
    background: #1e293b;
}

[data-theme="dark"] .player-bar-color.black-dot {
    background: #0f172a;
    border-color: #475569;
}

[data-theme="dark"] .player-bar-color.white-dot {
    background: #e2e8f0;
    border-color: #475569;
}

/* ============================================================
   TIMER
   ============================================================ */
.chess-timer {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 8px;
    background: rgba(128, 128, 128, 0.1);
    border: 1px solid var(--chess-border);
    min-width: 70px;
    text-align: center;
    transition: all 0.3s;
}

.chess-timer.my-turn {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.chess-timer.low {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #ef4444 !important;
    animation: timer-blink 1s ease-in-out infinite;
}

@keyframes timer-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* ============================================================
   PANEL
   ============================================================ */
.chess-panel {
    flex: none;
    width: 440px;
    max-width: 100%;
    background: var(--chess-panel-bg);
    border: 1px solid var(--chess-border);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    backdrop-filter: blur(12px);
    color: var(--chess-text);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.panel-title {
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

/* ============================================================
   MODE SELECTOR
   ============================================================ */
.mode-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 1rem;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    border-radius: 10px;
    border: 2px solid var(--chess-border);
    background: transparent;
    color: var(--chess-text);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.mode-btn i {
    font-size: 1.1rem;
}

.mode-btn small {
    opacity: 0.5;
    font-weight: 400;
    font-size: 0.65rem;
}

.mode-btn:hover {
    opacity: 0.85;
    background: rgba(128, 128, 128, 0.08);
}

.mode-btn.active {
    opacity: 1;
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

/* ============================================================
   PLAYER LIST
   ============================================================ */
.online-players {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
}

.online-players::-webkit-scrollbar {
    width: 4px;
}

.online-players::-webkit-scrollbar-track {
    background: transparent;
}

.online-players::-webkit-scrollbar-thumb {
    background: var(--chess-border);
    border-radius: 4px;
}

.player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: rgba(128, 128, 128, 0.05);
    border-radius: 8px;
    border: 1px solid var(--chess-border);
}

.player-name-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hub-match-badge {
    font-size: 0.65rem;
    font-weight: 800;
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    padding: 1px 6px;
    border-radius: 4px;
    width: fit-content;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hub-other-badge {
    font-size: 0.6rem;
    font-weight: 600;
    color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
    padding: 1px 6px;
    border-radius: 4px;
    width: fit-content;
}

[data-theme="dark"] .hub-other-badge {
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.15);
}

.player-name-line {
    display: flex;
    align-items: center;
    gap: 6px;
}

.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.online-dot.online {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.online-dot.offline {
    background: #94a3b8;
    opacity: 0.5;
}

.invite-btn {
    padding: 4px 12px;
    font-size: 0.8rem;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.invite-btn:hover {
    background: #059669;
}

.chess-empty-msg {
    text-align: center;
    color: var(--chess-text);
    opacity: 0.5;
    padding: 1rem;
}

/* ============================================================
   GAME INFO
   ============================================================ */
.players-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    background: rgba(128, 128, 128, 0.05);
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--chess-border);
    position: relative;
    overflow: hidden;
}

.players-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, transparent 100%);
    pointer-events: none;
}

.player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0.5;
    z-index: 1;
}

.player.active {
    opacity: 1;
    transform: scale(1.05);
}

.pname-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    line-height: 1.1;
}

.pname-block span:first-child {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--chess-text);
    word-break: break-word;
}

.pname-block span:last-child {
    font-size: 0.8rem;
    font-weight: 700;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.player .badge {
    padding: 3px 10px;
    font-size: 0.65rem;
    text-transform: uppercase;
    border-radius: 6px;
    font-weight: 900;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.player.white .badge {
    background: #fff;
    color: #000;
}

.player.black .badge {
    background: #1f2937;
    color: #fff;
}

.vs {
    font-weight: 900;
    opacity: 0.15;
    font-size: 1.5rem;
    font-style: italic;
    color: var(--chess-text);
}

.game-result {
    text-align: center;
    padding: 1rem;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    font-weight: 800;
    color: #fbbf24;
}

/* ============================================================
   GAME CONTROLS (Action Buttons)
   ============================================================ */
.game-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 1.25rem;
}

.game-controls button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 10px;
    border-radius: 14px;
    font-weight: 800;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.game-controls button i {
    font-size: 1.1rem;
}

.btn-resign {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
}

.btn-resign:hover {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(239, 68, 68, 0.3);
}

.btn-pause {
    background: linear-gradient(135deg, #fef9c3, #fef08a);
    color: #a16207;
    border: 1px solid rgba(202, 138, 4, 0.2) !important;
}

.btn-pause:hover {
    background: linear-gradient(135deg, #facc15, #eab308);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(234, 179, 8, 0.3);
}

.btn-pip {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #2563eb;
    border: 1px solid rgba(37, 99, 235, 0.2) !important;
}

.btn-pip:hover {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(37, 99, 235, 0.3);
}

/* Tool Toggles Row */
.game-tools-row {
    display: flex;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.tool-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--chess-border);
    background: rgba(128, 128, 128, 0.05);
    color: var(--chess-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tool-btn.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    color: #3b82f6;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.1);
}

/* PRIVACY TOGGLES */
.privacy-toggles {
    flex: 1;
    display: flex;
    gap: 6px;
    padding: 5px;
    background: rgba(128, 128, 128, 0.05);
    border-radius: 12px;
    border: 1px solid var(--chess-border);
}

.privacy-toggles button {
    flex: 1;
    height: 34px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--chess-text);
    opacity: 0.3;
    cursor: pointer;
    transition: all 0.2s;
}

.privacy-toggles button.active {
    opacity: 1;
    background: #3b82f6;
    color: #fff;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}



.privacy-toggles button.btn-public.active {
    background: #10b981;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.4);
}

.privacy-toggles button.btn-private.active {
    background: #ef4444;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.4);
}

.privacy-toggles button.btn-public i {
    color: #10b981;
}

.privacy-toggles button.btn-private i {
    color: #ef4444;
}

.privacy-toggles button.active i {
    color: #fff !important;
}

/* ============================================================
   TURN INDICATOR
   ============================================================ */
.turn-indicator {
    text-align: center;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.turn-indicator.my-turn {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.turn-indicator.opponent-turn {
    background: rgba(128, 128, 128, 0.05);
    color: var(--chess-text);
    opacity: 0.7;
    border: 1px solid var(--chess-border);
}

.status-ended {
    color: #fbbf24;
}

.status-paused {
    color: #eab308;
}

/* ============================================================
   MOVE HISTORY
   ============================================================ */
.move-history {
    background: rgba(128, 128, 128, 0.05);
    border: 1px solid var(--chess-border);
    border-radius: 12px;
    padding: 0.75rem;
}

.move-history-title {
    font-weight: 700;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    opacity: 0.7;
}

.move-history-grid {
    max-height: 140px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.move-history-grid::-webkit-scrollbar {
    width: 3px;
}

.move-history-grid::-webkit-scrollbar-thumb {
    background: var(--chess-border);
    border-radius: 3px;
}

.move-row {
    display: grid;
    grid-template-columns: 28px 1fr 1fr;
    gap: 4px;
    font-size: 0.78rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    padding: 2px 4px;
    border-radius: 4px;
}

.move-row:nth-child(odd) {
    background: rgba(128, 128, 128, 0.04);
}

.move-num {
    opacity: 0.4;
    font-weight: 700;
}

.move-white,
.move-black {
    cursor: pointer;
    transition: color 0.2s;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.move-white:hover,
.move-black:hover {
    color: #fff;
}

.move-white.active,
.move-black.active {
    color: #fff;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 0 4px;
}

.history-navigation {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    padding: 0 4px;
}

.nav-btn {
    flex: 1;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--chess-text);
    padding: 6px 0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.nav-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .nav-btn {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: #fff;
}

[data-theme="dark"] .nav-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

.chess-board-navigation {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 10px;
    padding: 6px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .chess-board-navigation {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.05);
}

.nav-btn-mini {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #333;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .nav-btn-mini {
    background: #334155;
    border-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.nav-btn-mini:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.nav-btn-mini i {
    font-size: 1.2rem;
}

.btn-return-live.mini {
    margin-top: 5px;
    padding: 4px 8px;
    font-size: 0.8rem;
}

.btn-return-live {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    background: #3b82f6;
    color: #fff;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    animation: pulse-blue 2s infinite;
}

@keyframes pulse-blue {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

.overlay-btns {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    width: 100%;
}

.overlay-review-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.overlay-review-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.overlay-back-btn {
    flex: 1;
}

.move-white {
    font-weight: 600;
}

.move-black {
    font-weight: 600;
    opacity: 0.8;
}

/* ============================================================
   OTHERS
   ============================================================ */
.chess-btn {
    width: 100%;
    padding: 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--chess-border);
    background: rgba(128, 128, 128, 0.1);
    color: var(--chess-text);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
}

.chess-btn:hover:not(:disabled) {
    background: rgba(128, 128, 128, 0.2);
}

/* Info Box Refined */
.chess-info-box {
    background: rgba(128, 128, 128, 0.05);
    border: 1px solid var(--chess-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.info-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--chess-text);
    opacity: 0.8;
}

.info-item i {
    font-size: 1.1rem;
    color: #3b82f6;
    flex-shrink: 0;
}

/* Personalization layout */
.perso-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.perso-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    opacity: 0.6;
}

.theme-mini-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.theme-mini-swatch,
.piece-mini-swatch {
    width: 28px;
    height: 28px;
    padding: 2px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--chess-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-mini-swatch:hover,
.piece-mini-swatch:hover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.theme-mini-swatch.active,
.piece-mini-swatch.active {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.2);
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.3);
}

.sw-preview {
    width: 100%;
    height: 100%;
    border-radius: 4px;
}

.piece-mini-swatch img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

/* Solo Mode & Stockfish */
/* Tabs system */
.chess-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 1.5rem;
    background: rgba(128, 128, 128, 0.05);
    padding: 6px;
    border-radius: 14px;
    border: 1px solid var(--chess-border);
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--chess-text);
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.6;
}

.tab-btn i {
    font-size: 1.1rem;
}

.tab-btn.active {
    opacity: 1;
    background: var(--chess-board-bg);
    color: #3b82f6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tab-content {
    min-height: 520px;
}

.section-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    opacity: 0.5;
    margin-bottom: 0.75rem;
    letter-spacing: 0.05em;
}

/* AI Difficulty Grid */
.ai-grid-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 1.5rem;
}

.ai-lv-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 4px;
    background: rgba(128, 128, 128, 0.05);
    border: 2px solid var(--chess-border);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--chess-text);
}

.ai-lv-card:nth-child(9),
.ai-lv-card:nth-child(10) {
    grid-column: span 2;
}

.ai-lv-card .lv-badge {
    font-size: 0.65rem;
    font-weight: 800;
    opacity: 0.5;
    text-transform: uppercase;
}

.ai-lv-card .lv-label {
    font-size: 0.8rem;
    font-weight: 800;
    margin: 4px 0;
    text-align: center;
    line-height: 1.1;
}

.ai-lv-card .lv-elo {
    font-size: 0.65rem;
    font-weight: 900;
    color: #3b82f6;
    letter-spacing: 0.02em;
}

.ai-lv-card:hover {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.4);
}

.ai-lv-card.active {
    background: rgba(59, 130, 246, 0.12);
    border-color: #3b82f6;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

/* Premium Solo Start Button */
.solo-btn.principal {
    margin-top: 1.5rem;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 900;
    border-radius: 16px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #ffffff;
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.1);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.solo-btn.principal i {
    font-size: 1.4rem;
    color: #3b82f6;
}

.solo-btn.principal:active {
    transform: scale(0.98);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.ai-thinking-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 20;
    backdrop-filter: blur(4px);
    font-size: 0.9rem;
    pointer-events: none;
}

.chess-spinner.small {
    width: 24px;
    height: 24px;
}

/* Status variants */
.status-paused {
    color: #eab308;
    font-weight: 700;
}

.status-ended {
    color: #ef4444;
    font-weight: 700;
}

/* Game Over Overlay */
.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    border-radius: 8px;
}

.game-over-content {
    text-align: center;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.game-over-content i {
    font-size: 3rem;
    color: #f59e0b;
}

.game-over-content h3 {
    font-size: 1.4rem;
    font-weight: 900;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.overlay-back-btn {
    margin-top: 8px;
    padding: 12px 24px;
    font-size: 0.9rem;
    font-weight: 800;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.overlay-back-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

/* Saved Solo Games */
.saved-solo-section {
    margin-top: 1rem;
}

.saved-solo-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.saved-solo-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(128, 128, 128, 0.06);
    border: 1px solid var(--chess-border);
    border-radius: 12px;
}

.saved-solo-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.saved-solo-level {
    font-weight: 800;
    font-size: 0.85rem;
}

.saved-solo-date {
    font-size: 0.7rem;
    opacity: 0.5;
}

/* Personalization Preview */
.personalization-main-layout {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
}

.personalization-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: rgba(128, 128, 128, 0.05);
    border-radius: 16px;
    border: 1px solid var(--chess-border);
    min-width: 100px;
}

.mini-preview-board {
    display: grid;
    grid-template-columns: repeat(2, 40px);
    grid-template-rows: repeat(2, 40px);
    border: 2px solid var(--chess-border);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.mini-square {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-square.light {
    background-color: var(--theme-light);
}

.mini-square.dark {
    background-color: var(--theme-dark);
}

.mini-piece {
    width: 34px;
    height: 34px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.preview-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    opacity: 0.5;
    letter-spacing: 0.1em;
}

/* ============================================================
   ENHANCED GAME-OVER OVERLAY
   ============================================================ */
.game-over-icon {
    font-size: 56px;
    background: linear-gradient(135deg, #f59e0b, #f97316);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 12px rgba(249, 115, 22, 0.5));
    display: block;
    text-align: center;
    margin-bottom: 4px;
}

.game-over-title {
    font-size: 1.8rem;
    font-weight: 900;
    margin: 0;
    text-align: center;
    background: linear-gradient(135deg, #fff 60%, rgba(255, 255, 255, 0.7));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-over-subtitle {
    font-size: 0.9rem;
    opacity: 0.65;
    text-align: center;
    margin: 4px 0 0 0;
    color: #fff;
}

/* ============================================================
   GAME RESULT FINISHED (sidebar badge)
   ============================================================ */
.game-result-finished {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 50px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    margin-bottom: 4px;
    animation: glow-green 2s ease-in-out infinite;
}

@keyframes glow-green {

    0%,
    100% {
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    }

    50% {
        box-shadow: 0 4px 20px rgba(16, 185, 129, 0.7);
    }
}

/* ============================================================
   BTN-QUIT-FINISHED
   ============================================================ */
.btn-quit-finished {
    flex: 1;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(118, 75, 162, 0.3);
}

.btn-quit-finished:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(118, 75, 162, 0.5);
}

/* ============================================================
   HISTORY EMPTY STATE
   ============================================================ */
.history-empty-msg {
    text-align: center;
    font-size: 0.75rem;
    opacity: 0.4;
    padding: 20px 10px;
    font-style: italic;
}

/* ============================================================
   EVAL BAR
   ============================================================ */
.eval-bar {
    position: absolute;
    left: -18px;
    top: 0;
    bottom: 0;
    width: 12px;
    border-radius: 6px;
    overflow: hidden;
    background: #1a1a2e;
    display: flex;
    flex-direction: column-reverse;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.eval-bar-white {
    width: 100%;
    background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
    transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 0 6px 6px;
    flex-shrink: 0;
}

.eval-bar-black {
    flex: 1;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
}

.eval-label {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.5rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    white-space: nowrap;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    padding: 2px;
    pointer-events: none;
    transition: top 0.5s ease, bottom 0.5s ease;
}

.eval-label-bottom {
    bottom: 4px;
    color: #1e293b;
}

.eval-label-top {
    top: 4px;
    color: #f8fafc;
}

.eval-label:not(.eval-label-top):not(.eval-label-bottom) {
    top: 50%;
    transform: translateX(-50%) translateY(-50%);
    color: #64748b;
}

/* ============================================================
   MOVE QUALITY BADGES
   ============================================================ */
.move-badge {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
    flex-shrink: 0;
    position: relative;
    top: -1px;
}

.badge-brilliant {
    background: #1bb8af;
}

.badge-excellent {
    background: #8ab522;
}

.badge-inaccuracy {
    background: #eab308;
}

.badge-mistake {
    background: #f97316;
}

.badge-blunder {
    background: #dc2626;
}

.badge-theoretical {
    background: #92400e;
}

/* ============================================================
   BEST MOVE HINT
   ============================================================ */
.best-move-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: rgba(59, 130, 246, 0.08);
    border-left: 2px solid #3b82f6;
    border-radius: 0 6px 6px 0;
    font-size: 0.75rem;
    margin: 2px 0 4px 28px;
    animation: fadeInSlide 0.2s ease;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   ANALYSIS SUMMARY
   ============================================================ */
.analysis-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 8px 16px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.analysis-merged-table {
    margin: 8px 4px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.analysis-table-header {
    display: grid;
    grid-template-columns: 1fr 60px 60px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.analysis-table-header span {
    font-size: 0.65rem;
    font-weight: 800;
    color: #64748b;
    letter-spacing: 0.05em;
}

.analys.history-panel-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 0.5rem 0.25rem;
    overflow-y: auto;
    max-height: 100%;
}

.analysis-table-row {
    display: grid;
    grid-template-columns: 1fr 60px 60px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    align-items: center;
}

.analysis-table-row:last-child {
    border-bottom: none;
}

.col-quality {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--chess-text);
}

.col-count {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--chess-text);
}

.col-count.blancs {
    color: #475569;
}

.col-count.noirs {
    color: #1e293b;
}

.col-quality .move-badge {
    width: 14px;
    height: 14px;
}

/* No overreaching - keeping it clean */


.best-move-hint i {
    color: #3b82f6;
    flex-shrink: 0;
}

.hint-delta {
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: auto;
    opacity: 0.8;
}

/* ============================================================
   ANALYSIS LOADING
   ============================================================ */
.analysis-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 8px;
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 4px;
}

.analysis-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

/* ============================================================
   ANALYSIS SUMMARY
   ============================================================ */
.analysis-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px;
    border-top: 1px solid var(--chess-border);
    margin-top: 8px;
    flex-wrap: wrap;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    opacity: 0.8;
}

/* ============================================================
   ANALYSIS CHOICE OVERLAY
   ============================================================ */
.analysis-choice-label {
    font-size: 0.8rem;
    opacity: 0.6;
    margin: 12px 0 10px;
    text-align: center;
}

.analysis-choice-btns {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
    margin-bottom: 10px;
}

.analysis-choice-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 10px;
    border-radius: 12px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    color: #ffffff;
    font-family: inherit;
    max-width: 130px;
}

.analysis-choice-btn i {
    font-size: 1.6rem;
    margin-bottom: 2px;
}

.analysis-choice-btn .choice-title {
    font-weight: 700;
    font-size: 0.85rem;
}

.analysis-choice-btn .choice-desc {
    font-size: 0.7rem;
    color: #94a3b8;
    text-align: center;
    line-height: 1.3;
}

.analysis-choice-btn.manual {
    border-color: rgba(34, 211, 238, 0.3);
}

.analysis-choice-btn.manual:hover {
    background: rgba(15, 23, 42, 1);
    border-color: #22d3ee;
    transform: translateY(-2px);
}

.analysis-choice-btn.manual i,
.analysis-choice-btn.manual .choice-title {
    color: #22d3ee;
}

.analysis-choice-btn.ai {
    border-color: rgba(168, 85, 247, 0.3);
}

.analysis-choice-btn.ai:hover {
    background: rgba(15, 23, 42, 1);
    border-color: #a855f7;
    transform: translateY(-2px);
}

.analysis-choice-btn.ai i,
.analysis-choice-btn.ai .choice-title {
    color: #a855f7;
}

.overlay-exit-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    margin-top: 8px;
}

.overlay-exit-btn:hover {
    opacity: 1;
    background: rgba(15, 23, 42, 1);
}

/* ============================================================
   PANEL SECTION TABS (Explorer / Config)
   ============================================================ */
.panel-section-tabs {
    display: flex;
    gap: 4px;
    margin: 10px 0 6px;
    background: rgba(128, 128, 128, 0.08);
    border-radius: 10px;
    padding: 3px;
}

.psec-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 8px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--chess-text);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s;
}

.psec-tab.active {
    background: var(--chess-panel-bg);
    opacity: 1;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.psec-tab:hover:not(.active) {
    opacity: 0.8;
}

/* ============================================================
   OPENING EXPLORER PANEL
   ============================================================ */
.explorer-panel {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.explorer-opening-name {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid #3b82f6;
    border-radius: 0 6px 6px 0;
    font-size: 0.72rem;
    line-height: 1.3;
}

.opening-eco {
    font-weight: 900;
    font-family: 'JetBrains Mono', monospace;
    color: #3b82f6;
    font-size: 0.7rem;
    flex-shrink: 0;
    background: rgba(59, 130, 246, 0.15);
    padding: 1px 5px;
    border-radius: 4px;
}

.opening-name-text {
    font-weight: 600;
    opacity: 0.9;
}

.explorer-total-games {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    opacity: 0.5;
    padding: 0 2px;
}

.explorer-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    font-size: 0.75rem;
    opacity: 0.6;
    justify-content: center;
}

.explorer-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.explorer-error,
.explorer-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 20px 8px;
    font-size: 0.75rem;
    opacity: 0.5;
    text-align: center;
}

.explorer-empty i,
.explorer-error i {
    font-size: 1.4rem;
    opacity: 0.6;
}

.explorer-moves {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.explorer-moves-header {
    display: grid;
    grid-template-columns: 46px 1fr 50px 38px;
    gap: 4px;
    font-size: 0.62rem;
    opacity: 0.4;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0 2px 4px;
    border-bottom: 1px solid var(--chess-border);
}

.explorer-move-row {
    display: grid;
    grid-template-columns: 46px 1fr 50px 38px;
    gap: 4px;
    align-items: center;
    padding: 4px 2px;
    border-radius: 6px;
    transition: background 0.15s;
    cursor: default;
}

.explorer-move-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.explorer-move-san {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--chess-text);
}

.explorer-wdl-bar {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    gap: 1px;
    background: rgba(128, 128, 128, 0.15);
}

.wdl-white {
    background: #f1f5f9;
    min-width: 2px;
    transition: width 0.4s ease;
}

.wdl-draw {
    background: #64748b;
    min-width: 2px;
    transition: width 0.4s ease;
}

.wdl-black {
    background: #1e293b;
    min-width: 2px;
    transition: width 0.4s ease;
}

.explorer-move-games {
    font-size: 0.68rem;
    opacity: 0.6;
    font-variant-numeric: tabular-nums;
}

.explorer-move-elo {
    font-size: 0.68rem;
    font-weight: 600;
    opacity: 0.7;
    text-align: right;
    color: #f59e0b;
}

/* Global W/D/L summary bar */
.explorer-global-wdl {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.global-wdl-bar {
    display: flex;
    height: 18px;
    border-radius: 9px;
    overflow: hidden;
    gap: 1px;
}

.global-wdl-bar .wdl-white,
.global-wdl-bar .wdl-draw,
.global-wdl-bar .wdl-black {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 800;
    min-width: 16px;
    transition: width 0.5s ease;
}

.global-wdl-bar .wdl-white {
    color: #1e293b;
}

.global-wdl-bar .wdl-draw {
    color: #fff;
}

.global-wdl-bar .wdl-black {
    color: #94a3b8;
}

.global-wdl-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.62rem;
    opacity: 0.5;
}

.global-wdl-labels span {
    display: flex;
    align-items: center;
    gap: 3px;
}

/* ============================================================
   BEST-MOVE ARROW (SVG OVERLAY)
   ============================================================ */
.best-move-arrow-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 8;
}

/* Removed duplicate move badges that overrode previous styles */

/* ============================================================
   EXPLORER THEORY CHIPS
   ============================================================ */
.explorer-header-line {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.explorer-theory-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.explorer-theory-chip.out {
    background: rgba(100, 116, 139, 0.12);
    color: #94a3b8;
    border-color: rgba(100, 116, 139, 0.25);
}

/* ============================================================
   CONFIRM MODAL Z-INDEX FIX
   ============================================================ */
.confirm-overlay {
    z-index: 9999999 !important;
}