* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-main: #0b0f19;
    --board-light: #f5deb3;
    --board-dark: #6d3b14;
    --board-bezel: #381d09;
    --red-piece: linear-gradient(135deg, #ef4444, #991b1b);
    --black-piece: linear-gradient(135deg, #334155, #0f172a);
    --accent: #38bdf8;
    --accent-gradient: linear-gradient(135deg, #0ea5e9, #6366f1);
    --gold: #fbbf24;
    --text: #f8fafc;
    --text-muted: #94a3b8;
}

body {
    background: radial-gradient(circle at 50% 15%, #2a1607, var(--bg-main) 75%);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: 75px; /* Space for bottom banner ad */
}

/* Header & HUD */
header {
    width: 100%;
    max-width: 500px;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    z-index: 50;
}

.title-group h1 {
    font-size: 1.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hud-turn-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
}

.turn-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.turn-dot.red {
    background: #ef4444;
    box-shadow: 0 0 12px #ef4444;
}

.turn-dot.black {
    background: #475569;
    border: 1px solid #94a3b8;
    box-shadow: 0 0 12px #64748b;
}

/* Score / Piece Count Bar */
.score-bar {
    width: 100%;
    max-width: 480px;
    display: flex;
    justify-content: space-around;
    padding: 8px 12px 4px;
    gap: 10px;
}

.score-card {
    flex: 1;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 6px 8px;
    text-align: center;
}

.score-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.score-val {
    font-size: 1.1rem;
    font-weight: 800;
}

.score-card.red .score-val { color: #f87171; }
.score-card.black .score-val { color: #cbd5e1; }
.score-card.draw .score-val { color: #94a3b8; }

/* Control Toolbar */
.toolbar {
    width: 100%;
    max-width: 480px;
    padding: 4px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bar-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pill-btn {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pill-btn:hover {
    color: #fff;
    background: rgba(245, 158, 11, 0.2);
    border-color: #f59e0b;
}

.pill-btn.active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

/* Board Outer Wrapper */
.board-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    width: 100%;
    max-width: 480px;
}

/* 8x8 Wooden Checkerboard */
.checker-board {
    background: var(--board-bezel);
    border: 8px solid var(--board-bezel);
    border-radius: 16px;
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.7), inset 0 2px 6px rgba(255, 255, 255, 0.15);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    max-width: 420px;
    aspect-ratio: 1;
    overflow: hidden;
}

/* Board Cells */
.cell {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cell.light {
    background: var(--board-light);
}

.cell.dark {
    background: var(--board-dark);
}

/* Valid Move Target Highlight Dot */
.cell.valid-move::after {
    content: '';
    position: absolute;
    width: 32%;
    height: 32%;
    background: rgba(52, 211, 153, 0.85);
    border-radius: 50%;
    box-shadow: 0 0 12px #34d399;
    animation: movePulse 0.8s infinite alternate ease-in-out;
    z-index: 10;
    pointer-events: none;
}

@keyframes movePulse {
    from { transform: scale(0.85); opacity: 0.7; }
    to { transform: scale(1.15); opacity: 1; }
}

/* Checker Pieces */
.piece {
    position: relative;
    width: 82%;
    height: 82%;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 3px 6px rgba(255, 255, 255, 0.4), inset 0 -4px 6px rgba(0, 0, 0, 0.6), 0 4px 8px rgba(0, 0, 0, 0.5);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    z-index: 5;
}

.piece.red {
    background: var(--red-piece);
    border: 3px solid #f87171;
}

.piece.black {
    background: var(--black-piece);
    border: 3px solid #64748b;
}

.piece.selected {
    transform: scale(1.12);
    box-shadow: 0 0 16px #38bdf8, inset 0 2px 6px #fff;
    border-color: #38bdf8;
    animation: selectBob 0.6s infinite alternate ease-in-out;
}

@keyframes selectBob {
    from { transform: scale(1.08); }
    to { transform: scale(1.16); }
}

.piece.king::after {
    content: '👑';
    font-size: 1.3rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 20px;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-box {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 28px 24px;
    text-align: center;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-box h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.win-title {
    color: var(--gold);
    text-shadow: 0 0 15px rgba(251, 191, 36, 0.5);
}

.modal-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.action-btn {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.6);
}

.action-btn:active {
    transform: translateY(1px);
}
