:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-red: #ef4444;
    --accent-red-hover: #dc2626;
    --accent-black: #3b82f6;
    --accent-black-hover: #2563eb;
    --dark-square: #713f12;
    --light-square: #fef3c7;
    --highlight-move: rgba(34, 197, 94, 0.6);
    --highlight-jump: rgba(239, 68, 68, 0.7);
    --selected-square: rgba(234, 179, 8, 0.6);
    --board-border: #451a03;
    --gold-crown: #f59e0b;
    --shadow-color: rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

body {
    color: var(--text-primary) !important;
}

/* HEADER & NAVBAR */
header {
    width: 100%;
    max-width: 900px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 12px;
}

.brand-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #f8fafc 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-controls {
    display: flex;
    gap: 8px;
}

.btn2 {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 14px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn2:hover {
    background-color: #475569;
    transform: translateY(-1px);
}

.btn2:active {
    transform: translateY(1px);
}

.btn-primary2 {
    background-color: #2563eb;
    border: none;
}

.btn-primary2:hover {
    background-color: #1d4ed8;
}

.btn-danger {
    background-color: #dc2626;
    border: none;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-icon {
    padding: 8px;
    border-radius: 50%;
}

/* MAIN CONTAINER */
.game-container {
    width: 100%;
    max-width: 900px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    background: var(--bg-primary);
    padding: 16px;
    border-radius: 12px;
}

@media (min-width: 850px) {
    .game-container {
        grid-template-columns: 1fr 300px;
    }
}

/* STATUS & INFO PANEL */
.info-bar {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px var(--shadow-color);
    margin-bottom: 12px;
}

.player-score {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.piece-badge {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.piece-badge.red {
    background: radial-gradient(circle at 30% 30%, #f87171, #dc2626);
    border: 1px solid #fee2e2;
}

.piece-badge.black {
    background: radial-gradient(circle at 30% 30%, #60a5fa, #1d4ed8);
    border: 1px solid #dbeafe;
}

.turn-indicator {
    font-weight: 700;
    font-size: 1rem;
    padding: 6px 14px;
    border-radius: 20px;
    background-color: var(--bg-card);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.turn-indicator.thinking {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.banner-forced {
    background-color: #991b1b;
    color: #fef2f2;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 10px;
    display: none;
    animation: fadeIn 0.3s ease;
}

/* CHECKERBOARD WRAPPER & BOARD */
.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.board-container {
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1 / 1;
    background-color: var(--board-border);
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.7);
    position: relative;
}

.checkerboard {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.square {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: default;
}

.square.light {
    background-color: var(--light-square);
}

.square.dark {
    background-color: var(--dark-square);
}

.square.selected {
    background-color: #a16207 !important;
}

/* HIGHLIGHT DOTS & RINGS FOR MOVES */
.move-indicator {
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background-color: var(--highlight-move);
    box-shadow: 0 0 8px var(--highlight-move);
    cursor: pointer;
    z-index: 5;
    transition: transform 0.2s ease;
}

.move-indicator:hover {
    transform: scale(1.3);
}

.jump-indicator {
    width: 70%;
    height: 70%;
    border-radius: 50%;
    border: 4px solid var(--accent-red);
    background-color: rgba(239, 68, 68, 0.2);
    box-shadow: 0 0 12px var(--highlight-jump);
    cursor: pointer;
    z-index: 5;
    animation: pulse-ring 1.2s infinite;
}

@keyframes pulse-ring {
    0% { transform: scale(0.9); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.8; }
}

/* CHECKER PIECES */
.piece {
    width: 82%;
    height: 82%;
    border-radius: 50%;
    position: absolute;
    cursor: pointer;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.25s ease-out, box-shadow 0.2s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4), inset 0 2px 4px rgba(255,255,255,0.3), inset 0 -3px 6px rgba(0,0,0,0.5);
}

.piece:hover {
    transform: scale(1.05);
}

.piece.red-piece {
    background: radial-gradient(circle at 35% 35%, #ef4444, #991b1b);
    border: 2px solid #fca5a5;
}

.piece.black-piece {
    background: radial-gradient(circle at 35% 35%, #3b82f6, #1e3a8a);
    border: 2px solid #93c5fd;
}

.piece.must-jump {
    animation: jump-glow 1s infinite alternate;
}

@keyframes jump-glow {
    from { box-shadow: 0 0 4px #f59e0b, inset 0 2px 4px rgba(255,255,255,0.4); }
    to { box-shadow: 0 0 16px #f59e0b, 0 0 8px #f59e0b, inset 0 2px 4px rgba(255,255,255,0.4); }
}

/* KING CROWN SVG */
.crown-icon {
    width: 55%;
    height: 55%;
    fill: var(--gold-crown);
    filter: drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.7));
}

/* SIDE PANEL / STATS / LOG */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card2 {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 6px -1px var(--shadow-color);
}

.card-title2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.stat-box {
    background-color: var(--bg-card);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.move-history {
    height: 180px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
}

.move-entry {
    padding: 4px 8px;
    background-color: var(--bg-card);
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
}

.move-entry:nth-child(even) {
    background-color: rgba(255,255,255,0.03);
}

/* MODAL OVERLAYS */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background-color: var(--bg-secondary);
    width: 90%;
    max-width: 420px;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    text-align: center;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.modal-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.option-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.option-btn {
    background-color: var(--bg-card);
    border: 2px solid transparent;
    padding: 10px;
    border-radius: 8px;
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn.selected {
    border-color: #2563eb;
    background-color: rgba(37, 99, 235, 0.2);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.modal-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 12px;
}

/* CUSTOM SCROLLBAR */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 3px;
}