body .nl-container,
body .nl-container * {
    box-sizing: border-box !important;
}

.nl-container {
    display: flex;
    flex-wrap: nowrap !important;
    align-items: flex-start;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    margin: 20px auto;
    background: #1e1e1e;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #fff;
}

.nl-board-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
}

.cg-wrap {
    width: 100%;
    max-width: 100%;
    max-width: min(100%, 55vh, 600px);
    margin: 0 auto;
    position: relative;
    aspect-ratio: 1/1;
    /* Allow spare pieces to show outside the board. */
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    background: transparent;
}

.nl-spare-pieces.cg-wrap {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 15px 0 !important;
    user-select: none;
    width: 100% !important;
    max-width: none !important;
    aspect-ratio: auto !important;
    box-shadow: none !important;
    background: none !important;
    height: auto !important;
    min-height: 45px;
}

.nl-spare-pieces piece {
    position: relative !important;
    width: 45px !important;
    height: 45px !important;
    cursor: grab !important;
    display: inline-block !important;
    background-size: cover !important;
    pointer-events: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    transition: transform 0.1s ease;
}

/* Black pieces are hard to see on a dark #1e1e1e background, add a glow */
.nl-spare-pieces piece.black {
    filter: drop-shadow(0px 0px 3px rgba(255, 255, 255, 0.4));
}

.nl-spare-pieces piece.selected {
    transform: scale(1.15) !important;
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.8));
    z-index: 10;
}

.nl-eraser {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    transition: all 0.2s;
    pointer-events: auto !important;
}

.nl-eraser.selected {
    background: rgba(255, 99, 71, 0.4);
    transform: scale(1.15) !important;
    filter: drop-shadow(0 0 8px rgba(255, 99, 71, 0.8));
    border: 1px solid #ff6b6b;
    z-index: 10;
}

.nl-eraser:hover {
    background: rgba(255, 255, 255, 0.2);
}

.cg-wrap.editor-board {
    margin-top: 10px !important;
    margin-bottom: 10px !important;
}

@supports (aspect-ratio: 1/1) {
    .cg-wrap {
        height: auto;
    }

    .nl-spare-pieces.cg-wrap {
        height: 45px;
    }
}

.nl-sidebar {
    flex: 0 0 300px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
}

.nl-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: #d1d5db;
}

body .nl-container .nl-controls {
    display: block !important;
    white-space: nowrap !important;
    font-size: 0 !important;
    text-align: center !important;
    width: 100% !important;
    max-width: min(100%, 55vh, 600px) !important;
    margin: 10px auto 0 auto !important;
    clear: both !important;
}

body .nl-container .nl-controls span.nl-btn-ctrl {
    background: #4b5563 !important;
    color: #fff !important;
    border: none !important;
    padding: 8px 0 !important;
    margin: 0 1% !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-size: 18px !important;
    line-height: 1.2 !important;
    font-weight: 600 !important;
    width: 18% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    transition: all 0.2s;
    clear: none !important;
    float: none !important;
    vertical-align: top !important;
}

body .nl-container .nl-controls span.nl-btn-ctrl.tact-hidden {
    display: none !important;
}

body .nl-container .nl-controls span.nl-btn-ctrl:hover {
    background: #374151 !important;
    transform: translateY(-1px);
}

.nl-engine-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #2d2d2d;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    color: #d1d5db;
}

.nl-engine-btn {
    background: #374151;
    border: 1px solid #4b5563;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    transition: all 0.2s;
}

.nl-engine-btn.on {
    background: #047857;
    border-color: #059669;
}

.nl-engine-eval {
    font-weight: bold;
    font-family: monospace;
    font-size: 15px;
    color: #fff;
}

.nl-engine-depth {
    font-size: 11px;
    color: #9ca3af;
    margin-left: 5px;
}

.nl-controls button:active {
    transform: translateY(1px);
}

.nl-moves {
    flex: 1;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
    font-size: 15px;
    line-height: 1.6;
    min-height: 250px;
    max-height: 400px;
    overflow-y: auto;
    color: #1f2937;
    position: relative;
    scroll-behavior: smooth;
}

.nl-moves.no-comments .move-comment {
    display: none !important;
}

.nl-moves.no-variations .pgn-variation {
    display: none !important;
}

.move-comment {
    font-size: 14px;
    padding: 6px 10px;
    background: #f5ebe0;
    border-left: 3px solid #d4c1ad;
    color: #000000;
    margin: 6px 0 10px 0;
    border-radius: 0 4px 4px 0;
    display: block;
    word-wrap: break-word;
}

.pgn-variation {
    display: block;
    color: #4b5563;
    font-style: italic;
    margin-top: 4px;
    padding-left: 8px;
    border-left: 2px solid #9ca3af;
    font-size: 13px;
}

.nl-moves .move-row {
    display: block;
    margin-bottom: 2px;
}

.nl-moves .move-row strong {
    color: #6b7280;
    display: inline-block;
    width: 35px;
}

.nl-moves .move-item {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
    transition: background 0.1s;
}

.nl-moves .move-item:hover {
    background: #e5e7eb;
    color: #111827;
}

.nl-moves .move-item.active {
    background: #3b82f6;
    color: #fff;
    font-weight: bold;
}

@media(max-width: 800px) {
    body .nl-container {
        display: block !important;
        padding: 10px !important;
    }

    body .nl-container .nl-board-wrap {
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
        margin-bottom: 20px !important;
        min-width: 0 !important;
    }

    body .nl-container .cg-wrap {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }

    body .nl-container .nl-sidebar {
        width: 100% !important;
        display: flex;
    }

    body .nl-container .nl-moves {
        min-height: 200px !important;
        height: 200px !important;
    }
}

/* Stack board and move list when the board sits in a narrow column (e.g. a two-column page layout). */
*:has(> .nl-container) {
    container-type: inline-size;
}

@container (max-width: 760px) {
    body .nl-container {
        display: block !important;
        padding: 12px !important;
    }

    body .nl-container .nl-board-wrap {
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
        margin-bottom: 16px !important;
        min-width: 0 !important;
    }

    body .nl-container .cg-wrap {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }

    body .nl-container .nl-controls {
        max-width: 100% !important;
    }

    body .nl-container .nl-sidebar {
        width: 100% !important;
        display: flex;
    }

    body .nl-container .nl-moves {
        min-height: 160px !important;
        height: 200px !important;
    }
}

/* Board-Only Mode Styling Override */
.nl-container.mode-board_only {
    max-width: 450px;
}
