/*START PGN Viewer CSS*/
    /* Reset and clean layout */
    * {
        box-sizing: border-box;
    }

    html, body {
        margin: 0;
        padding: 0;
        overflow: hidden;
        height: 100vh;
    }

    /* Enable scrolling on mobile */
    @media (max-width: 1024px) {
        html, body {
            overflow: auto;
            overflow-x: hidden;
            height: auto;
            min-height: 100vh;
        }

        /* Hide desktop move buttons on mobile (use mobile-nav-controls instead) */
        .right-buttons {
            display: none !important;
        }
    }

    .viewer-container {
        display: flex;
        width: 100%;
        height: 100vh;
        background-color: #191E3B;
        margin: 0;
        padding: 0;
        gap: 0;
    }

    .viewer-left {
        flex: 1;
        min-width: 280px;
        background-color: #1a1f3a;
        padding: 24px;
        display: flex;
        flex-direction: column;
        border-right: 1px solid rgba(240, 217, 181, 0.1);
    }

    .viewer-center {
        flex: 0 0 auto;
        background-color: #191E3B;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding: 20px;
        padding-right: 0;
        max-height: 100vh;
        overflow: hidden;
    }

    /* Constrain board size to fit viewport with room for buttons */
    #board {
        max-width: calc(100vh - 180px);
        max-height: calc(100vh - 180px);
    }

    .viewer-right {
        flex: 1;
        min-width: 350px;
        background-color: #191E3B;
        padding: 20px;
        padding-left: 10px;
        display: flex;
        flex-direction: column;
    }

    .left-header {
        color: #f0d9b5;
        margin-bottom: 24px;
        font-size: 20px;
        font-weight: 600;
        letter-spacing: 0.5px;
        padding-bottom: 12px;
        border-bottom: 2px solid rgba(240, 217, 181, 0.3);
    }
    .left-header-title {
        color: #f0d9b5 !important;
    }

    /* Back button in left header - smaller size */
    .left-header .genric-blog-btn {
        line-height: 28px;
        padding: 0 12px;
        font-size: 12px !important;
        width: auto !important;
    }

    .left-content {
        color: #f0d9b5;
        list-style: none;
        padding: 0;
        overflow-y: auto;
        overflow-x: hidden;
        max-height: 80vh;
    }

    .game-item {
        padding: 14px 16px;
        cursor: pointer;
        border-bottom: 1px solid rgba(240, 217, 181, 0.15);
        transition: all 0.2s ease;
        font-size: 15px;
        border-radius: 6px;
        margin-bottom: 4px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .game-item:hover {
        background-color: rgba(240, 217, 181, 0.12);
        transform: translateX(4px);
        border-left: 3px solid #b58863;
        padding-left: 13px;
    }

    .game-item.selected {
        background-color: rgba(181, 136, 99, 0.25);
        font-weight: 600;
        border-left: 3px solid #f0d9b5;
        padding-left: 13px;
    }
    .puzzle-item {
        padding: 14px 16px;
        cursor: pointer;
        border-bottom: 1px solid rgba(240, 217, 181, 0.15);
        transition: all 0.2s ease;
        font-size: 15px;
        border-radius: 6px;
        margin-bottom: 4px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .puzzle-item:hover {
        background-color: rgba(240, 217, 181, 0.12);
        transform: translateX(4px);
        border-left: 3px solid #b58863;
        padding-left: 13px;
    }

    .puzzle-item.selected {
        background-color: rgba(181, 136, 99, 0.25);
        font-weight: 600;
        border-left: 3px solid #f0d9b5;
        padding-left: 13px;
    }
    .checkmark {
        float: right;
        color: #f0d9b5;
        font-weight: bold;
        opacity: 1;
        transition: opacity 0.2s ease;
    }

    .crossmark {
        float: right;
        font-weight: bold;
        opacity: 1;
        transition: opacity 0.2s ease;
    }

    .game-item.selected .checkmark {
        opacity: 1;
    }

    .puzzle-item.selected .checkmark {
        opacity: 1;
    }
    /* Custom scrollbar for game list */
    .left-content::-webkit-scrollbar {
        width: 8px;
    }

    .left-content::-webkit-scrollbar-track {
        background: rgba(240, 217, 181, 0.1);
        border-radius: 4px;
    }

    .left-content::-webkit-scrollbar-thumb {
        background: rgba(240, 217, 181, 0.3);
        border-radius: 4px;
    }

    .left-content::-webkit-scrollbar-thumb:hover {
        background: rgba(240, 217, 181, 0.5);
    }

    .board-wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        padding-right: 40px;
        padding-bottom: 15px;
        position: relative;
    }
    .right-wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        position: relative;
    }

    .viewer-center {
        max-height: 100vh;
        overflow: visible;
    }

    .button-group {
        margin-top: 8px;
        margin-bottom: 30px;
        flex-wrap: wrap;
        justify-content: center;
    }

    #arrow-canvas {
        position: absolute;
        top: 0;
        left: 0;
        pointer-events: none;
        z-index: 10;
    }

    .arrow {
        stroke-width: 15;
        fill: none;
    }

    .arrow.green {
        stroke: rgba(90, 160, 90, 0.9);
        marker-end: url(#arrowhead-green);
    }

    .arrow.red {
        stroke: rgba(160, 90, 90, 0.9);
        marker-end: url(#arrowhead-red);
    }

    .arrow.blue {
        stroke: rgba(80, 110, 160, 0.9);
        marker-end: url(#arrowhead-blue);
    }

    .circle-marker {
        fill: none;
        stroke-width: 4;
    }

    .circle-marker.green {
        stroke: rgba(90, 160, 90, 0.9);
    }

    .circle-marker.red {
        stroke: rgba(160, 90, 90, 0.9);
    }

    .circle-marker.blue {
        stroke: rgba(80, 110, 160, 0.9);
    }

    .board-status {
        color: #f0d9b5;
        font-size: 18px;
        font-weight: 600;
        margin-top: 12px;
        margin-bottom: 16px;
        text-align: center;
        letter-spacing: 0.5px;
    }

    .button-group {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
    }

    .btn-copy,
    .btn-nav {
        padding: 10px 20px !important;
        background-color: #b58863 !important;
        color: #fff !important;
        border: none !important;
        border-radius: 6px !important;
        cursor: pointer !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        text-decoration: none !important;
        text-align: center !important;
        transition: all 0.2s ease !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
        white-space: nowrap !important;
        font-family: inherit !important;
        line-height: 20px !important;
        margin: 0 !important;
        width: auto !important;
        min-width: 110px !important;
        height: 40px !important;
        display: inline-block !important;
        vertical-align: middle !important;
    }

    .btn-copy:hover,
    .btn-nav:hover {
        background-color: #a07855 !important;
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    }

    /* Navigation buttons - unified styling */
    .puzzle-nav-btn {
        padding: 10px 20px !important;
        background-color: #b58863 !important;
        color: #fff !important;
        border: none !important;
        border-radius: 6px !important;
        cursor: pointer !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        font-family: inherit !important;
        line-height: 20px !important;
        text-decoration: none !important;
        text-align: center !important;
        transition: all 0.2s ease !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
        white-space: nowrap !important;
        display: inline-block !important;
        vertical-align: middle !important;
        width: auto !important;
        min-width: 110px !important;
        height: 40px !important;
        margin: 0 !important;
    }

    .puzzle-nav-btn:hover {
        background-color: #a07855 !important;
        transform: translateY(-1px) !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3) !important;
    }

    .right-status {
        color: #f0d9b5;
        margin-bottom: 12px;
        flex-shrink: 0;
        font-size: 16px;
        font-weight: 500;
    }

    .pgn-spacer {
        height: 48px;
        flex-shrink: 0;
    }

    .right-pgn {
        height: calc(100vh - 180px);
        overflow-y: auto;
        background-color: #f0d9b5;
        padding: 16px;
        border-radius: 8px;
        margin-top: 0;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.08);
        border: 1px solid #d4c4a8;
        width: 23vw;
    }

    .right-buttons {
        display: flex;
        gap: 10px;
        margin-top: 5px;
        justify-content: center;
        flex-shrink: 0;
        flex-wrap: wrap;
    }

    .btn-nav-inline {
        display: none !important;
    }

    .games-toggle-btn {
        display: none;
        background-color: #b58863;
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 16px;
        padding: 6px 10px;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        transition: all 0.2s ease;
        /*margin-top: 10px;*/
    }

    .games-toggle-btn:hover {
        background-color: #a07855;
    }

    /* Mobile back button - hidden on desktop */
    .mobile-back-btn {
        display: none;
        position: fixed;
        top: 60px;
        left: 10px;
        z-index: 1000;
        background: #2c5a87;
        color: white !important;
        border: none;
        border-radius: 6px;
        font-size: 14px;
        font-weight: 600;
        padding: 8px 12px;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        transition: background-color 0.2s;
        text-decoration: none;
    }

    .mobile-back-btn:hover {
        background: #3d6f9e;
        transform: scale(1.05);
    }

    .games-dropdown {
        display: none;
        position: absolute;
        background-color: #1a1f3a;
        border: 2px solid rgba(240, 217, 181, 0.3);
        border-radius: 8px;
        padding: 10px;
        max-height: 300px;
        overflow-y: auto;
        width: 100%;
        max-width: 400px;
        z-index: 1000;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
        margin-top: 5px;
    }

    .games-dropdown.show {
        display: block;
    }

    .games-dropdown .game-item {
        color: #f0d9b5;
        padding: 12px;
        cursor: pointer;
        border-bottom: 1px solid rgba(240, 217, 181, 0.15);
        transition: all 0.2s ease;
        font-size: 14px;
        border-radius: 4px;
        margin-bottom: 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .games-dropdown .game-item:hover {
        background-color: rgba(240, 217, 181, 0.12);
        transform: translateX(4px);
        border-left: 3px solid #b58863;
        padding-left: 9px;
    }

    .games-dropdown .game-item.selected {
        background-color: rgba(181, 136, 99, 0.25);
        font-weight: 600;
        border-left: 3px solid #f0d9b5;
        padding-left: 9px;
    }

    /* PGN Display Styling */
    #pgn {
        line-height: 1.8;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        font-size: 14px;
        position: relative;
        background: linear-gradient(to right, #b58863 0%, #b58863 45px, transparent 45px);
    }

    .move-pair {
        display: flex;
        align-items: flex-start;
        margin: 2px 0;
        padding: 2px 0;
        position: relative;
        z-index: 1;
    }

    .move-number {
        font-weight: 600;
        color: #f0d9b5;
        display: flex;
        justify-content: center;
        align-items: center;
        width: 45px;
        min-width: 45px;
        padding: 0;
        margin: 0;
        margin-left: -17px;
        font-size: 16px;
        background-color: transparent;
        flex-shrink: 0;
        line-height: 1.5;
    }

    .move-content {
        flex: 1;
        display: block;
        margin: 0;
        position: relative;
    }

    .move-columns {
        display: flex;
        gap: 4px;
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .move-white,
    .move-black {
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 60px;
    }

    .pgn-move {
        display: inline-block;
        padding: 3px 6px;
        cursor: pointer;
        border-radius: 3px;
        background-color: transparent;
        transition: background-color 0.15s ease;
        user-select: none;
        line-height: 1.5;
        white-space: nowrap;
        font-size: 16px;
        color: #f0d9b5;
    }

    .pgn-move.non-interactive {
        cursor: default;
    }

    .pgn-move:hover {
        background-color: rgba(181, 136, 99, 0.3);
    }

    .pgn-move.non-interactive:hover {
        background-color: transparent;
    }

    .pgn-move.active {
        background-color: #b58863;
        color: #f0d9b5;
        font-weight: 600;
    }

    .comment, .pgn-comment {
        color: #90ee90;
        font-style: italic;
        font-size: 15px;
        margin: 4px 0;
        padding-left: 6px;
        line-height: 1.6;
    }

    .pgn-comment-intro {
        margin-left: 28px;
    }

    .variation {
        margin: 6px 0 6px 12px;
        padding: 4px 8px;
        background-color: #f9f9f9;
        border-left: 3px solid #ddd;
        border-radius: 0 4px 4px 0;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .variation:hover {
        background-color: #f0f0f0;
        border-left-color: #b58863;
    }

    .variation.active {
        background-color: rgba(181, 136, 99, 0.2);
        border-left-color: #b58863;
    }

    /* Nested variations */
    .variation .variation {
        margin-left: 16px;
        background-color: #fafafa;
        border-left-color: #bbb;
    }

    .variation .variation:hover {
        background-color: #f5f5f5;
    }

    /* Variation container */
    .pgn-variation {
        margin: 6px 0 6px 12px;
        padding: 8px;
        background-color: #f9f9f9;
        border-left: 3px solid #ddd;
        border-radius: 0 4px 4px 0;
    }

    /* Inline variation format */
    .pgn-variation-inline {
        display: inline;
        margin-left: 8px;
        font-style: italic;
    }

    .var-paren {
        color: #888;
        font-weight: normal;
        font-style: normal;
        font-size: 16px;
    }

    .var-move-num {
        color: #999;
        font-size: 14px;
        font-style: normal;
        font-weight: normal;
    }

    .var-comment-inline {
        color: #90ee90;
        font-size: 13px;
        font-style: italic;
    }

    .variation-symbol {
        color: #666;
        font-weight: 600;
        margin-right: 6px;
    }

    /* Variation move pairs */
    .var-move-pair {
        display: flex;
        align-items: center;
        margin: 2px 0;
        padding: 2px 0;
    }

    .var-move-number {
        font-weight: 600;
        color: #999;
        font-size: 12px;
        min-width: 35px;
        width: 35px;
        text-align: center;
        flex-shrink: 0;
    }

    .var-move-columns {
        display: flex;
        gap: 8px;
        flex: 1;
    }

    .var-move-white,
    .var-move-black {
        display: flex;
        gap: 4px;
        width: 80px;
        min-width: 80px;
    }

    .var-move {
        font-size: 13px;
        display: inline-block;
        padding: 2px 4px;
        cursor: pointer;
        border-radius: 3px;
        background-color: transparent;
        transition: background-color 0.15s ease;
        color: #c0c0c0;
    }

    .var-move:hover {
        background-color: rgba(181, 136, 99, 0.3);
    }

    .var-move.active {
        background-color: #b58863;
        color: #f0d9b5;
        font-weight: 600;
    }

    .var-comment-block {
        color: #90ee90;
        font-style: italic;
        font-size: 12px;
        margin: 4px 0;
        padding-left: 35px;
    }

    .move-placeholder {
        color: #ccc;
        display: inline-block;
        padding: 3px 6px;
    }

    /* Sideline header (opening bracket) */
    .sideline-start {
        color: #666;
        font-weight: 600;
        margin-right: 4px;
    }

    .sideline-end {
        color: #666;
        font-weight: 600;
        margin-left: 4px;
    }

    /* Move annotations (!, ?, !!, etc.) */
    .annotation {
        color: #d32f2f;
        font-weight: bold;
        margin-left: 2px;
    }

    /* Evaluation symbols */
    .evaluation {
        color: #1976d2;
        margin-left: 4px;
        font-size: 12px;
    }

    #pgn::-webkit-scrollbar {
        width: 8px;
    }

    #pgn::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }

    #pgn::-webkit-scrollbar-thumb {
        background: #c5d940;
        border-radius: 4px;
    }

    #pgn::-webkit-scrollbar-thumb:hover {
        background: #a0b840;
    }

    /* Promotion Modal Styles */
    #promotionModal {
        display: none;
        position: absolute;
        z-index: 1000;
        background-color: rgba(25, 30, 59, 0.95);
        border: 2px solid #b58863;
        border-radius: 8px;
        padding: 10px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    }

    .promotion-options {
        display: flex;
        justify-content: space-around;
        gap: 8px;
    }

    .promotion-choice {
        width: 50px;
        height: 50px;
        cursor: pointer;
        transition: transform 0.2s;
        border-radius: 4px;
    }

    .promotion-choice:hover {
        transform: scale(1.1);
        background-color: rgba(181, 136, 99, 0.3);
    }

    /* User-created variation styling */
    .user-variation {
        background-color: rgba(144, 238, 144, 0.08) !important;
        border-left-color: #90ee90 !important;
    }

    .user-variation:hover {
        background-color: rgba(144, 238, 144, 0.15) !important;
    }

    /* Navigation Controls - hidden on desktop, shown on mobile */
    .mobile-nav-controls {
        display: none;
        flex-direction: column;
        gap: 8px;
        margin-top: 12px;
        padding: 10px;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 8px;
    }

    .mobile-nav-row {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
    }

    .mobile-nav-label {
        font-size: 12px;
        font-weight: 600;
        color: #666;
        min-width: 40px;
        text-align: center;
    }

    .btn-mobile-nav {
        padding: 8px 16px;
        font-size: 14px;
        font-weight: 600;
        border: none;
        border-radius: 6px;
        background: #2c5a87;
        color: white;
        cursor: pointer;
        min-width: 60px;
        transition: background-color 0.2s;
    }

    .btn-mobile-nav:hover {
        background: #3d6f9e;
    }

    .btn-mobile-nav:active {
        background: #1e4060;
    }

    .btn-mobile-nav:disabled {
        background: #ccc;
        color: #888;
        cursor: not-allowed;
    }

    .btn-move-nav {
        min-width: 50px;
        font-size: 18px;
        padding: 8px 14px;
    }

    /* Show mobile nav on tablet/mobile screens */
    @media (max-width: 1024px) {
        .mobile-nav-controls {
            display: flex;
        }
    }

    @media (max-width: 430px) {
        .mobile-nav-controls {
            gap: 6px;
            padding: 8px;
        }

        .mobile-nav-row {
            gap: 8px;
        }

        .btn-mobile-nav {
            padding: 6px 12px;
            font-size: 12px;
            min-width: 50px;
        }

        .btn-move-nav {
            min-width: 40px;
            font-size: 16px;
            padding: 6px 10px;
        }

        .mobile-nav-label {
            font-size: 11px;
            min-width: 35px;
        }
    }

    /* Responsive styles for smaller screens */
    @media (min-width: 1180px) and (max-width: 1367px) and (orientation: landscape) {
        .viewer-left {
            padding-left: 10px;
        }
        .board-wrapper {
            padding-right: 0;
        }
        .button-group {
            margin-top: 0;
        }
        .right-wrapper {
            align-items: start;
        }
        .right-pgn {
            width: 17vw;
        }
        .right-buttons {
            margin-top: 0;
        }
        .btn-nav,
        .btn-copy {
            height: 35px !important;
            line-height: 12px !important;
        }

    }
    /* iPad Pro */
    @media (min-width: 1023px) and (max-width: 1025px) and (orientation: portrait) {
        .viewer-container {
            flex-direction: column;
            height: auto;
            min-height: 100vh;
            overflow-y: auto;
        }
        .games-toggle-btn {
            display: inline-block !important;
            font-size: 16px;
            padding: 6px 10px;
        }

        .viewer-left {
        /*    display: none !important;*/
            align-items: flex-end;
            margin-right: 0;
            padding-right: 0;
            z-index: 2;
            top: 60px;
            margin-top: 2px;
            width: 250px;
            min-width: 240px;
            height: 120vh;
            position: fixed;
            padding-bottom: 500px;
            display: flex;
            justify-content: flex-end;
            align-items: center;
            top: 0;
            left: 0;
            transform: translateX(450%);
            pointer-events: none;
            transition: transform 0.3s;
        }
        .viewer-left.active {
            transform: translateX(310%) !important;
            position: fixed;
            pointer-events: initial;
        }
        .viewer-center {
            padding: 0;
        }
        .board-wrapper {
            max-width: 90vw;
            padding-bottom: 0;
            padding-right: 0;
        }

        #board {
            max-width: 100%;
        }

        .button-group {
            margin-bottom: 8px;
            gap: 6px;
        }

        .viewer-right {
            padding: 0 10px 0 10px;

        }
        .pgn-spacer {
            display: none !important;
        }
        .right-wrapper {
            flex-direction: column;
        }
        .right-pgn {
            height: 15vh;
            min-width: 90vw;
        }
        .right-buttons {
            margin-top: 0;
        }

        .btn-copy,
        .btn-nav-inline,
        .btn-nav {
            padding: 5px !important;
            font-size: 12px !important;
            height: 25px !important;
            line-height: 13px !important;
        }

        .games-dropdown {
            max-width: 400px;
        }

    }
    /* iPad Air */
    @media (min-width: 819px) and (max-width: 821px) and (orientation: portrait) {
        .viewer-container {
            flex-direction: column;
            height: auto;
            min-height: 100vh;
            overflow-y: auto;
        }
        .games-toggle-btn {
            display: inline-block !important;
            font-size: 16px;
            padding: 6px 10px;
        }

        .viewer-left {
        /*    display: none !important;*/
            align-items: flex-start;
            margin-right: 0;
            padding-right: 0;
            z-index: 2;
            width: 250px;
            min-width: 240px;
            height: 100vh;
            max-height: 100vh;
            position: fixed;
            padding: 20px;
            padding-bottom: 100px;
            display: flex;
            flex-direction: column;
            top: 0;
            left: 0;
            transform: translateX(350%);
            pointer-events: none;
            transition: transform 0.3s;
            overflow-y: auto;
            overflow-x: hidden;
        }
        .viewer-left.active {
            transform: translateX(230%) !important;
            position: fixed;
            pointer-events: initial;
        }
        .viewer-center {
            padding: 0;
        }
        .board-wrapper {
            max-width: 90vw;
            padding-bottom: 0;
            padding-right: 0;
        }

        #board {
            max-width: 100%;
        }

        .button-group {
            margin-bottom: 8px;
            gap: 6px;
        }

        .viewer-right {
            padding: 0 10px 0 10px;

        }
        .pgn-spacer {
            display: none !important;
        }
        .right-wrapper {
            flex-direction: column;
        }
        .right-pgn {
            height: 15vh;
            min-width: 90vw;
        }
        .right-buttons {
            margin-top: 0;
        }

        .btn-copy,
        .btn-nav-inline,
        .btn-nav {
            padding: 5px !important;
            font-size: 12px !important;
            height: 25px !important;
            line-height: 13px !important;
        }

        .games-dropdown {
            max-width: 400px;
        }

    }

    /* iPad Pro and smaller - start making layout more compact */
    @media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
        .viewer-container {
            flex-direction: row;
            height: auto;
            min-height: 100vh;
            overflow-y: auto;
        }

        .games-toggle-btn {
            display: inline-block !important;
            font-size: 16px;
            padding: 6px 10px;
        }

        .viewer-left {
        /*    display: none !important;*/
            align-items: flex-start;
            margin-right: 0;
            padding-right: 0;
            z-index: 2;
            width: 250px;
            min-width: 240px;
            height: 100vh;
            max-height: 100vh;
            position: fixed;
            padding: 20px;
            padding-bottom: 100px;
            display: flex;
            flex-direction: column;
            top: 0;
            left: 0;
            transform: translateX(430%);
            pointer-events: none;
            transition: transform 0.3s;
            overflow-y: auto;
            overflow-x: hidden;
        }
        .viewer-left.active {
            transform: translateX(310%) !important;
            position: fixed;
            pointer-events: initial;
        }

        .viewer-center {
            width: 90vh;
            padding: 0;
        }

        .board-wrapper {
            padding-right: 0;
        }
        .viewer-right {
            width: 100%;
            min-width: auto;
            padding: 20px 0 0 0;

        }

        .right-wrapper {
            flex-direction: column;
            gap: 5px;
        }

        .right-pgn {
            height: 80vh;
            min-width: 30vw;
        }
        #pgn {
            margin-top: 0;
        }
        .pgn-spacer {
         /*   display: none;*/
         height: 36px;
        }

        /* Hide desktop navigation buttons */
        .right-buttons {
            /*display: none !important;*/
            margin-top: 8px;
        }

        /* Show inline navigation buttons */
        .btn-nav-inline {
            display: inline-block !important;
            padding: 5px !important;
            font-size: 13px !important;
        }
        .btn-nav,
        .btn-copy {
            padding: 5px !important;
            font-size: 13px !important;
            height: 25px !important;
            line-height: 12px !important;
        }

        .games-dropdown {
            max-width: 500px;
            max-height: 400px;
        }
    }

    /* iPad and smaller tablets in portrait */
    @media (max-width: 768px) {
        .viewer-container {
            flex-direction: column;
            height: auto;
            min-height: 100vh;
            overflow-y: auto;
        }
        .games-toggle-btn {
            display: inline-block !important;
        }

        .mobile-back-btn {
            display: block !important;
        }

        .viewer-left {
        /*    display: none !important;*/
            align-items: flex-start;
            margin-right: 0;
            padding-right: 0;
            z-index: 2;
            width: 250px;
            min-width: 240px;
            height: 100vh;
            max-height: 100vh;
            position: fixed;
            padding: 20px;
            padding-bottom: 100px;
            display: flex;
            flex-direction: column;
            top: 0;
            left: 0;
            transform: translateX(320%);
            pointer-events: none;
            transition: transform 0.3s;
            overflow-y: auto;
            overflow-x: hidden;
        }
        .viewer-left.active {
            transform: translateX(210%) !important;
            position: fixed;
            pointer-events: initial;
        }
        .viewer-center {
            padding: 0;
        }
        .board-wrapper {
            max-width: 90vw;
            padding-bottom: 0;
            padding-right: 0;
        }

        #board {
            max-width: 100%;
        }

        .button-group {
            margin-bottom: 8px;
            gap: 6px;
        }

        .viewer-right {
            padding: 0 10px 0 10px;

        }
        .pgn-spacer {
            display: none !important;
        }
        .right-wrapper {
            flex-direction: column;
        }
        .right-pgn {
            height: 15vh;
            min-width: 90vw;
        }
        .right-buttons {
            margin-top: 0;
        }

        .btn-copy,
        .btn-nav-inline,
        .btn-nav {
            padding: 5px !important;
            font-size: 12px !important;
            height: 25px !important;
            line-height: 13px !important;
        }

        .games-dropdown {
            max-width: 400px;
        }
    }

    /* Large phones and small tablets */
    @media (max-width: 600px) {
        .btn-text-full {
            display: none;
        }

        .viewer-center,
        .viewer-right {
            padding: 15px;
        }

        .board-wrapper {
            max-width: 350px;
        }

        .right-pgn {
            height: 200px;
            padding: 12px;
        }

        .btn-copy,
        .btn-nav-inline {
            padding: 5px 8px !important;
            font-size: 11px !important;
        }

        .button-group {
            gap: 5px;
        }

        .board-status {
            font-size: 16px;
        }

        .games-dropdown {
            max-width: 350px;
            font-size: 13px;
        }
    }

    /* Standard phones (iPhone 12/13/14) */
    @media (max-width: 430px) {
        .viewer-container {
            flex-direction: column;
            height: auto;
            min-height: 100vh;
            overflow-y: auto;
        }
        .viewer-left {
            align-items: flex-end;
            margin-right: 0;
            padding-right: 0;
            z-index: 2;
            top: 60px;
            margin-top: 2px;
            width: 250px;
            min-width: 240px;
            height: 100vh;
            position: fixed;
            padding-bottom: 100px;
            display: flex;
            justify-content: flex-end;
            align-items: center;
            top: 0;
            left: 0;
            transform: translateX(180%);
            pointer-events: none;
            transition: transform 0.3s;
        }
        .viewer-left.active {
            transform: translateX(75%) !important;
            position: fixed;
            pointer-events: initial;
        }
        .games-toggle-btn {
            display: inline-block !important;
            font-size: 16px;
            padding: 6px 10px;
        }
        .mobile-back-btn {
            display: block !important;
        }
        .board-wrapper {
            padding-right: 0;
            padding-bottom: 0;
        }
        .viewer-center {
            padding: 10px;
        }

        .viewer-right {
            padding: 15px;
        }

        .board-wrapper {
            max-width: 100%;
        }

        .right-pgn {
            height: 180px;
            padding: 10px;
            margin-bottom: 10px;
        }

        .btn-copy,
        .btn-nav-inline,
        .btn-nav,
        .puzzle-nav-btn {
            padding: 5px 7px !important;
            font-size: 10px !important;
            height: 22px !important;
            min-width: 85px !important;
            width: auto !important;
            line-height: 12px !important;
        }

        .button-group {
            gap: 4px;
            margin-bottom: 10px;
        }
        .pgn-spacer {
            display: none !important;
        }
        .right-pgn {
            height: 30vh;
        }
    }
    @media (max-width: 933px) and (orientation: landscape) {
        .viewer-container {
            flex-direction: row;
            height: auto;
            min-height: 100vh;
            overflow-y: auto;
        }
        .viewer-left {
            align-items: flex-end;
            margin-right: 0;
            padding-right: 0;
            z-index: 2;
            top: 60px;
            margin-top: 2px;
            width: 250px;
            min-width: 240px;
            height: 130vh;
            position: fixed;
            padding-bottom: 100px;
            display: flex;
            justify-content: flex-end;
            align-items: center;
            top: -50px;
            left: 0;
            transform: translateX(380%);
            pointer-events: none;
            transition: transform 0.3s;
        }
        .viewer-left.active {
            transform: translateX(275%) !important;
            position: fixed;
            pointer-events: initial;
        }
        .games-toggle-btn {
            display: inline-block !important;
            font-size: 16px;
            padding: 6px 10px;
        }

        .viewer-center {
            padding: 0;
            flex-direction: none;
            max-width: 140vh;
            width: 110vh;
            margin-right: 15px;
        }
        .board-status {
            display: none !important;
        }
        .board-wrapper {
            width: 100vh;
            max-width: 130vh;
            max-height: 100vh;
            padding-right: 0;
            gap: 10px;
            flex-direction: row;
        }
        #board {
            max-width: 100%;
            width: 100vh;
        }
        .btn-copy,
        .btn-nav-inline,
        .btn-nav,
        .puzzle-nav-btn {
            padding: 5px 7px !important;
            font-size: 10px !important;
            height: 22px !important;
            min-width: 85px !important;
            width: auto !important;
            line-height: 12px !important;
        }
        .button-group {
            /*display: none !important;*/
            flex-direction: column;
        }
        .viewer-right {
            flex: 1;
            min-width: 30vh;
            width: 30vh;
            max-width: auto;
            padding: 0 10px 0 0;
        }
        .right-wrapper {
            align-items: center;
        }
        .pgn-spacer {
            display: none !important;
        }
        .right-pgn {
            height: 70vh;
            min-width: 37vw;
        }
        .right-buttons {
            display: block !important;
        }
    }
   /* Small phones (iPhone SE) */
    @media (max-width: 376px) {
        .viewer-container {
            flex-direction: column;
            height: auto;
            min-height: 100vh;
            overflow-y: auto;
        }
        .viewer-left {
            align-items: flex-end;
            margin-right: 0;
            padding-right: 0;
            z-index: 2;
            top: 60px;
            margin-top: 2px;
            width: 250px;
            min-width: 240px;
            height: 120vh;
            position: fixed;
            padding-bottom: 130px;
            display: flex;
            justify-content: flex-end;
            align-items: center;
            top: 0;
            left: 0;
            transform: translateX(200%);
            pointer-events: none;
            transition: transform 0.3s;
        }
        .viewer-left.active {
            transform: translateX(50%) !important;
            position: fixed;
            pointer-events: initial;
        }
        .games-toggle-btn {
            display: inline-block !important;
            font-size: 16px;
            padding: 6px 10px;
        }
        .mobile-back-btn {
            display: block !important;
        }

        .games-dropdown {
            max-width: 100%;
            font-size: 12px;
        }

        .btn-copy,
        .btn-nav-inline{
            padding: 4px 6px !important;
            font-size: 9px !important;
        }

        .button-group {
            gap: 3px;
            margin-bottom: 10px;
        }
        .viewer-right {
            flex: 1;
            min-width: 80vw;
            padding: 0 10px 0 10px;
        }
        .right-wrapper {
            align-items: center;
        }
        .right-pgn {
            height: 15vh;
            font-size: 11px;
        }

        .board-status {
            font-size: 14px;
        }

        .pgn-spacer {
            display: none !important;
        }
    }

    @media (max-width: 668px) and (orientation: landscape) {
        .viewer-left {
            align-items: flex-end;
            margin-right: 0;
            padding-right: 0;
            z-index: 2;
            top: 60px;
            margin-top: 2px;
            width: 250px;
            min-width: 240px;
            height: 120vh;
            position: fixed;
            padding-bottom: 100px;
            display: flex;
            justify-content: flex-end;
            align-items: center;
            top: 0;
            left: 0;
            transform: translateX(270%);
            pointer-events: none;
            transition: transform 0.3s;
        }
        .viewer-left.active {
            transform: translateX(170%) !important;
            position: fixed;
            pointer-events: initial;
        }
        .games-toggle-btn {
            display: inline-block !important;
            font-size: 16px;
            padding: 6px 10px;
        }

        .viewer-center {
            padding: 0;
            flex-direction: column;
            margin-right: 0;
        }
        .board-status {
            display: none !important;
        }
        .board-wrapper {
            width: 100vh;
            max-width: 100vh;
            padding-right: 0;
            gap: 5px;
        }
        .btn-copy,
        .btn-nav-inline,
        .btn-nav,
        .puzzle-nav-btn {
            padding: 5px 7px !important;
            font-size: 10px !important;
            height: 22px !important;
            min-width: 85px !important;
            width: auto !important;
            line-height: 12px !important;
        }
        #board {
            max-width: 100%;
            width: 80vh;
        }
        .button-group {
            /*display: none !important;*/
        }
        .viewer-right {
            flex: 1;
            min-width: 80vh;
            padding: 0 20px 0 0;
        }
        .right-wrapper {
            align-items: start;
        }
        .pgn-spacer {
            display: none !important;
        }
        .right-pgn {
            height: 70vh;
            min-width: 37vw;
        }
        #pgn {
            max-width: 37vh;
        }
    }
/*END PGN Viewer CSS*/
