:root {
    --bg-color: #1a1a24;
    --board-bg: #8c5a35;
    --point-dark: #4a2c11;
    --point-light: #d2b48c;
    --checker-white: #f0f0f0;
    --checker-black: #222222;
    --highlight: rgba(0, 255, 100, 0.4);
    --text-light: #ecf0f1;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-light);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

.hidden { display: none !important; }

/* Menus */
.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.menu-box {
    background: #2c3e50;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.menu-box h1 { margin-bottom: 20px; color: #f1c40f; }
.mode-selectors { margin: 20px 0; display: flex; gap: 10px; }
.mode-btn, .start-game-btn, button {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: 0.2s;
}
.mode-btn { background: #34495e; color: white; }
.mode-btn.active { background: #3498db; }
.start-game-btn { background: #2ecc71; color: white; width: 100%; }
.start-game-btn:hover, button:hover { opacity: 0.9; transform: scale(1.02); }
button:disabled { background: #7f8c8d; cursor: not-allowed; transform: none; }

/* Game Container */
#game-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 10px;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2c3e50;
    padding: 10px 20px;
    border-radius: 8px;
}
.player-info { display: flex; align-items: center; gap: 10px; font-weight: bold; }
.checker-icon { width: 20px; height: 20px; border-radius: 50%; box-shadow: inset -2px -2px 5px rgba(0,0,0,0.5); }
.white-checker { background: var(--checker-white); border: 2px solid #ccc; }
.black-checker { background: var(--checker-black); border: 2px solid #000; }
.turn-indicator { font-size: 1.2rem; font-weight: bold; color: #f1c40f; }

/* AI Thinking */
#ai-thinking {
    text-align: center;
    color: #e74c3c;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}
.spinner {
    width: 20px; height: 20px;
    border: 3px solid rgba(231, 76, 60, 0.3);
    border-top: 3px solid #e74c3c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Board Layout */
.board-layout {
    display: flex;
    background: #5c3a21;
    border: 10px solid #3e2723;
    border-radius: 8px;
    height: 60vh;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
    position: relative;
}
.board-half {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--board-bg);
    position: relative;
}
.left-half { border-right: 5px solid #3e2723; }
.right-half { border-left: 5px solid #3e2723; }
.middle-gap { flex: 0.1; }

/* Points (Triangles) */
.top-row, .bottom-row {
    display: flex;
    flex: 1;
    width: 100%;
}
.point {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}
.top-row .point { justify-content: flex-start; }
.bottom-row .point { justify-content: flex-end; }

/* CSS Triangles */
.point::before {
    content: '';
    position: absolute;
    width: 100%; height: 100%;
    z-index: 0;
}
.top-row .point:nth-child(odd)::before { background: var(--point-dark); clip-path: polygon(0 0, 100% 0, 50% 90%); }
.top-row .point:nth-child(even)::before { background: var(--point-light); clip-path: polygon(0 0, 100% 0, 50% 90%); }
.bottom-row .point:nth-child(odd)::before { background: var(--point-light); clip-path: polygon(50% 10%, 0 100%, 100% 100%); }
.bottom-row .point:nth-child(even)::before { background: var(--point-dark); clip-path: polygon(50% 10%, 0 100%, 100% 100%); }

.point.highlight::after {
    content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--highlight); z-index: 1; pointer-events: none;
}

/* Checkers */
.checker {
    width: 80%;
    aspect-ratio: 1;
    border-radius: 50%;
    z-index: 2;
    margin: 2px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5), inset -2px -2px 6px rgba(0,0,0,0.4);
    transition: transform 0.2s;
}
.checker.white { background: var(--checker-white); border: 2px solid #aaa; }
.checker.black { background: var(--checker-black); border: 2px solid #000; }
.checker.selected { transform: scale(1.1); box-shadow: 0 0 10px 3px #f1c40f; }
.point .checker-count { position: absolute; z-index: 3; color: white; font-weight: bold; top: 50%; text-shadow: 1px 1px 2px black; }

/* The Bar & Bear Off */
.board-bar {
    width: 50px;
    background: #3e2723;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}
#bar-top, #bar-bottom { flex: 1; display: flex; flex-direction: column; width: 100%; align-items: center; }
.cube-container { padding: 10px 0; }
#btn-double { font-size: 10px; padding: 5px; background: white; color: black; border-radius: 4px; border: 2px solid black;}

.bear-off-area {
    width: 60px;
    background: #2c3e50;
    border-left: 5px solid #3e2723;
    display: flex;
    flex-direction: column;
}
.bear-off-zone {
    flex: 1; display: flex; flex-direction: column; align-items: center; padding: 5px; gap: 2px;
}
.bear-off-zone .checker { width: 90%; height: 10px; border-radius: 2px; } /* Flatten borne off checkers */

/* Controls */
.controls { display: flex; justify-content: space-between; align-items: center; background: #2c3e50; padding: 15px; border-radius: 8px; }
.dice-display { display: flex; gap: 10px; }
.die {
    width: 40px; height: 40px; background: white; color: black;
    display: flex; justify-content: center; align-items: center;
    font-size: 20px; font-weight: bold; border-radius: 8px;
    box-shadow: inset -2px -2px 5px rgba(0,0,0,0.2);
}
.die.used { opacity: 0.3; }
.actions { display: flex; gap: 10px; }
#btn-roll { background: #e67e22; }
#btn-hint { background: #9b59b6; }

/* Mobile optimization */
@media (max-width: 600px) {
    .board-layout { height: 50vh; }
    .status-bar { flex-direction: column; text-align: center; gap: 5px; }
    .controls { flex-direction: column; gap: 15px; }
    .checker { width: 90%; margin: 1px 0; }
}