:root {
            --bg-color: #0d0d0d; --text-color: #ecf0f1; --board-bg: #1a1a1a;
            --cell-light: #bdc3c7; --cell-dark: #2c3e50; --panel-bg: rgba(255, 255, 255, 0.08);
            --log-bg: #000000; --log-text: #2ecc71; --p1-color: #c0392b; --p2-color: #2980b9;
            --accent: #e67e22; --modal-bg: #1e272e; --drawer-bg: #1a1a1a;
        }
        body.light-mode {
            --bg-color: #f5f6fa; --text-color: #2f3640; --board-bg: #dcdde1;
            --cell-light: #ffffff; --cell-dark: #7f8fa6; --panel-bg: rgba(0, 0, 0, 0.05);
            --log-bg: #ffffff; --log-text: #1b1464; --modal-bg: #ffffff; --drawer-bg: #ffffff;
        }
        body { font-family: 'Segoe UI', Tahoma, sans-serif; background-color: var(--bg-color); color: var(--text-color); display: flex; flex-direction: column; align-items: center; margin: 0; padding: 0; min-height: 100dvh; touch-action: manipulation; transition: background 0.3s; overflow: hidden; }
        #menu-btn { position: fixed; top: 15px; left: 15px; z-index: 10001; background: var(--accent); color: white; border: none; padding: 12px; border-radius: 8px; cursor: pointer; font-size: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }
        
        /* Sidebar Menu */
        #side-drawer { position: fixed; top: 0; left: -300px; width: 270px; height: 100%; box-sizing: border-box; background: var(--drawer-bg); z-index: 10000; padding: 80px 20px 40px; box-shadow: 5px 0 25px rgba(0,0,0,0.6); transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; flex-direction: column; gap: 6px; overflow-y: auto;}
        #side-drawer.open { left: 0; }
        #side-drawer button { width: 100%; padding: 14px; border: none; border-radius: 6px; background: #333; color: white; font-weight: bold; cursor: pointer; text-align: left; font-size: 14px; transition: 0.2s; }
        #side-drawer button:hover { background: #444; padding-left: 20px; }
        
        .main-container { width: 100%; max-width: 100%; padding: 10px; display: flex; flex-direction: column; align-items: center; height: 100dvh; box-sizing: border-box; justify-content: center; position: relative; overflow-y: auto; }
        .player-panel { width: 100%; max-width: 800px; padding: 15px; margin-bottom: 10px; border-radius: 12px; background: var(--panel-bg); text-align: center; }
        .active-label { color: var(--accent); font-weight: 900; letter-spacing: 2px; font-size: 1.4em; }
        
        /* Board UI */
        #board-wrapper { width: 100%; max-width: min(800px, 95vw, 60dvh); position: relative; background-color: var(--board-bg); padding: 8px; border-radius: 10px; box-shadow: 0 15px 45px rgba(0,0,0,0.8); transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1); }
        .flipped { transform: rotate(180deg); }
        #board { display: grid; grid-template-columns: repeat(8, 1fr); gap: 0px; width: 100%; border: 2px solid var(--accent); }
        .cell { aspect-ratio: 1 / 1; display: flex; justify-content: center; align-items: center; position: relative; }
        .cell.light { background-color: var(--cell-light); }
        .cell.dark { background-color: var(--cell-dark); cursor: pointer; }
        .cell.selected { box-shadow: inset 0 0 0 4px #f1c40f; background-color: rgba(243, 156, 18, 0.5); }
        .cell.highlight-move { box-shadow: inset 0 0 0 4px #2ecc71; background-color: rgba(46, 204, 113, 0.3); }
        .cell.highlight-jump { box-shadow: inset 0 0 0 4px #e74c3c; background-color: rgba(231, 76, 60, 0.4); }
        
        /* Previous Move Indicators */
        .cell.last-move-start { box-shadow: inset 0 0 0 3px rgba(149, 165, 166, 0.6); opacity: 0.8; }
        .cell.last-move-end { box-shadow: inset 0 0 0 4px #3498db; background-color: rgba(52, 152, 219, 0.3); }
        .cell.jumped-cell { background-image: radial-gradient(circle, rgba(231, 76, 60, 0.5) 20%, transparent 25%); }

        .piece { width: 80%; height: 80%; border-radius: 50%; display: flex; justify-content: center; align-items: center; color: white; box-shadow: inset 0 -4px 8px rgba(0,0,0,0.4), 0 4px 6px rgba(0,0,0,0.5); z-index: 2; transition: transform 0.2s; }
        .player1-piece { background-color: var(--p1-color); border: 2px solid rgba(0,0,0,0.3); }
        .player2-piece { background-color: var(--p2-color); border: 2px solid rgba(0,0,0,0.3); }
        .dama-icon { width: 60%; height: 60%; fill: #f1c40f; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5)); }

        #activity-log { width: 100%; max-width: 800px; height: 110px; background-color: var(--log-bg); color: var(--log-text); margin: 15px 0 5px 0; padding: 15px; border-radius: 8px; font-size: 15px; font-weight: bold; overflow-y: auto; border: 2px solid var(--text-color); line-height: 1.5; box-sizing: border-box; }
        .log-num { color: #f1c40f; margin-right: 10px; }
        
        /* Modals */
        .modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 10005; justify-content: center; align-items: center; padding: 20px; box-sizing: border-box; }
        .modal-content { background: var(--modal-bg); color: var(--text-color); padding: 30px; border-radius: 15px; max-width: 550px; max-height: 85vh; overflow-y: auto; border: 3px solid var(--accent); width: 100%; }
        
        #win-overlay { display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 100; padding: 20px 40px; border-radius: 15px; background: rgba(0, 0, 0, 0.9); border: 3px solid var(--accent); text-align: center; pointer-events: none; width: 80%; }
        #win-overlay.show { display: block; pointer-events: auto; }
        .flipped #win-overlay { transform: translate(-50%, -50%) rotate(180deg); }
        #win-overlay h2 { margin: 0 0 8px 0; font-size: clamp(18px, 4vw, 32px); letter-spacing: 3px; }
        #win-overlay p { margin: 0; font-size: clamp(12px, 2.5vw, 18px); opacity: 0.85; }
        
        /* Scoreboard & Replay Specifics */
        .score-section { margin-bottom: 18px; }
        .score-section h3 { margin: 0 0 10px 0; font-size: 1.05em; letter-spacing: 1px; }
        .score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
        .score-card { background: rgba(128,128,128,0.1); padding: 12px 8px; border-radius: 8px; text-align: center; }
        .score-card .score-val { font-size: 1.4em; font-weight: 900; color: var(--accent); white-space: nowrap; }
        .score-card .score-lbl { font-size: 0.7em; opacity: 0.6; text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
        .score-pts { color: #f1c40f; font-weight: 900; font-size: clamp(11px, 2.5vw, 16px); letter-spacing: 1px; margin-top: 4px; }
        
        #replay-controls { display:none; position:absolute; bottom: 10px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.85); padding: 10px 20px; border-radius: 20px; border: 2px solid var(--accent); z-index: 10002; gap: 10px; align-items: center; box-shadow: 0 5px 15px rgba(0,0,0,0.5); }
        
        @keyframes captureBurst { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: 0.5; filter: brightness(2); } 100% { transform: scale(0); opacity: 0; } }
        .capturing { animation: captureBurst 0.4s ease-out forwards; }