:root {
    --bg-dark: #0f1216;
    --bg-card: #191f28;
    --bg-card-header: #212936;
    --border-gold: #c69b4e;
    --border-gold-glow: rgba(198, 155, 78, 0.4);
    --gold-text: #e6ca85;
    --gold-light: #fbecc5;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --accent-red: #c53030;
    --accent-red-glow: rgba(197, 48, 48, 0.5);
    --accent-cyan: #0ea5e9;
    --accent-cyan-glow: rgba(14, 165, 233, 0.5);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.4);
    
    /* Board colors */
    --sq-light: #d8c29d;
    --sq-dark: #4b3621;
    --sq-dark-highlight: #704f2f;
    --sq-hint-src: #0284c7;
    --sq-hint-dst: #10b981;
    --sq-hint-jump: #f59e0b;
    --sq-selected: #eab308;
    
    --font-heading: 'Cinzel', 'Trajan Pro', 'Georgia', serif;
    --font-ui: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 50% 20%, rgba(30, 41, 59, 0.7) 0%, rgba(15, 18, 22, 0.95) 80%),
        radial-gradient(circle at 10% 80%, rgba(198, 155, 78, 0.08) 0%, transparent 40%);
    color: var(--text-main);
    font-family: var(--font-ui);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header */
header {
    background: linear-gradient(180deg, #161c24 0%, #0f1216 100%);
    border-bottom: 2px solid var(--border-gold);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pirate-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 8px var(--border-gold));
}

.title-group h1 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: var(--gold-text);
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.title-group p {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

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

/* Container & Layout */
.app-container {
    flex: 1;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 960px) {
    .app-container {
        grid-template-columns: 1fr;
        padding: 12px;
    }
}

/* Board Area */
.board-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* Game Status Banner */
.status-banner {
    width: 100%;
    max-width: 580px;
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: 8px;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.status-text-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.turn-indicator-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

.dot-user {
    background: #e53e3e;
    box-shadow: 0 0 12px var(--accent-red-glow);
}

.dot-opponent {
    background: #2d3748;
    border-color: #cbd5e0;
    box-shadow: 0 0 12px rgba(200, 200, 200, 0.3);
}

.turn-title {
    font-size: 1.05rem;
    font-weight: 700;
    font-family: var(--font-heading);
    letter-spacing: 1px;
}

.turn-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.badge-user-turn {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid #ef4444;
}

.badge-opp-turn {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid #3b82f6;
}

/* Board Wrapper & Board */
.board-wrapper {
    position: relative;
    padding: 16px;
    background: #2a1c10;
    background-image: 
        repeating-linear-gradient(45deg, rgba(0,0,0,0.1) 0, rgba(0,0,0,0.1) 10px, transparent 10px, transparent 20px),
        linear-gradient(135deg, #3d2917 0%, #20140a 100%);
    border-radius: 12px;
    box-shadow: 
        0 15px 35px rgba(0,0,0,0.8),
        inset 0 0 15px rgba(0,0,0,0.8),
        0 0 0 2px #5a3d24,
        0 0 0 6px #1a0f07;
}

.checkers-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 540px;
    height: 540px;
    max-width: 90vw;
    max-height: 90vw;
    border: 3px solid #1a0f07;
    position: relative;
    user-select: none;
}

@media (max-width: 600px) {
    .checkers-board {
        width: 340px;
        height: 340px;
    }
}

/* Board Squares */
.square {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.15s ease;
}

.square.light {
    background-color: var(--sq-light);
    background-image: radial-gradient(circle, rgba(255,255,255,0.15) 0%, rgba(0,0,0,0.05) 100%);
}

.square.dark {
    background-color: var(--sq-dark);
    background-image: radial-gradient(circle, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.3) 100%);
    cursor: pointer;
}

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

/* Square Annotations / Badges */
.sq-number {
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

/* Visual Highlights */
.square.highlight-selected {
    background-color: #854d0e !important;
    box-shadow: inset 0 0 0 3px #facc15;
}

.square.highlight-legal-dest {
    position: relative;
}

.square.highlight-legal-dest::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: rgba(16, 185, 129, 0.7);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.9);
    pointer-events: none;
}

/* AI Move Suggestion Glow */
.square.suggest-source {
    background-color: #1e3a8a !important;
    box-shadow: inset 0 0 0 3px #38bdf8, 0 0 15px rgba(56, 189, 248, 0.6) !important;
    animation: pulse-source 1.6s infinite ease-in-out;
}

.square.suggest-dest {
    background-color: #064e3b !important;
    box-shadow: inset 0 0 0 3px #34d399, 0 0 15px rgba(52, 211, 153, 0.7) !important;
    animation: pulse-dest 1.6s infinite ease-in-out;
}

.square.suggest-waypoint {
    background-color: #78350f !important;
    box-shadow: inset 0 0 0 3px #fbbf24, 0 0 12px rgba(251, 191, 36, 0.6) !important;
}

@keyframes pulse-source {
    0%, 100% { box-shadow: inset 0 0 0 3px #38bdf8, 0 0 12px rgba(56, 189, 248, 0.5); }
    50% { box-shadow: inset 0 0 0 4px #bae6fd, 0 0 22px rgba(56, 189, 248, 0.9); }
}

@keyframes pulse-dest {
    0%, 100% { box-shadow: inset 0 0 0 3px #34d399, 0 0 12px rgba(52, 211, 153, 0.5); }
    50% { box-shadow: inset 0 0 0 4px #a7f3d0, 0 0 22px rgba(52, 211, 153, 0.9); }
}

/* Checkers Pieces */
.piece {
    width: 78%;
    height: 78%;
    border-radius: 50%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    transition: transform 0.15s ease, filter 0.15s ease;
    z-index: 10;
}

.piece:active {
    cursor: grabbing;
    transform: scale(1.08);
}

/* Red / User Pieces */
.piece.red {
    background: radial-gradient(circle at 35% 30%, #ef4444 0%, #b91c1c 60%, #7f1d1d 100%);
    border: 2px solid #fca5a5;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.6),
        inset 0 -3px 5px rgba(0,0,0,0.5),
        inset 0 3px 5px rgba(255,255,255,0.4);
}

.piece.red::before {
    content: '';
    width: 60%;
    height: 60%;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.3);
}

/* Black / Opponent Pieces */
.piece.black {
    background: radial-gradient(circle at 35% 30%, #475569 0%, #1e293b 60%, #090d16 100%);
    border: 2px solid #94a3b8;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.8),
        inset 0 -3px 5px rgba(0,0,0,0.8),
        inset 0 3px 5px rgba(255,255,255,0.3);
}

.piece.black::before {
    content: '';
    width: 60%;
    height: 60%;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.2);
}

/* Kings */
.piece.king::after {
    content: '👑';
    font-size: 1.5rem;
    position: absolute;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.9));
}

@media (max-width: 600px) {
    .piece.king::after {
        font-size: 1.1rem;
    }
}

/* Move Path Overlay SVG */
.board-svg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
}

/* Bottom Quick Action Bar */
.board-quick-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 580px;
    justify-content: center;
}

/* Side Panel */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card {
    background: var(--bg-card);
    border: 1px solid #334155;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.card-header {
    background: var(--bg-card-header);
    border-bottom: 1px solid #334155;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: var(--gold-text);
    letter-spacing: 1px;
}

.card-body {
    padding: 16px;
}

/* Suggestion Card */
.suggestion-card {
    border: 1px solid var(--border-gold);
    background: linear-gradient(180deg, #1e2632 0%, #151a22 100%);
}

.suggestion-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.engine-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.engine-eval-badge {
    background: #0f172a;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--accent-green);
    border: 1px solid #1e293b;
}

.move-instruction-box {
    background: rgba(14, 165, 233, 0.1);
    border: 1px solid rgba(14, 165, 233, 0.3);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.move-icon-badge {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--accent-cyan);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 0 12px var(--accent-cyan-glow);
    flex-shrink: 0;
}

.move-text-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.move-text-details {
    font-size: 0.85rem;
    color: #93c5fd;
    margin-top: 2px;
}

.apply-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(180deg, #10b981 0%, #059669 100%);
    border: 1px solid #34d399;
    border-radius: 8px;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px var(--accent-green-glow);
    transition: transform 0.15s, filter 0.15s;
}

.apply-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

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

/* History / Move Log */
.move-history-list {
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    padding-right: 4px;
}

.history-entry {
    display: grid;
    grid-template-columns: 32px 1fr 1fr;
    padding: 6px 10px;
    background: #11161f;
    border-radius: 4px;
    align-items: center;
}

.history-entry:nth-child(even) {
    background: #161d28;
}

.history-num {
    color: var(--text-muted);
    font-weight: 600;
}

.history-player {
    color: #f87171;
    font-weight: 500;
}

.history-opp {
    color: #94a3b8;
}

/* Buttons and Controls */
.btn {
    background: #2d3748;
    color: var(--text-main);
    border: 1px solid #4a5568;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
    background: #3a475c;
    border-color: var(--border-gold);
}

.btn-gold {
    background: linear-gradient(180deg, #d97706 0%, #b45309 100%);
    border: 1px solid var(--border-gold);
    color: #fff;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
}

.btn-gold:hover {
    filter: brightness(1.15);
}

.btn-danger {
    background: #7f1d1d;
    border-color: #ef4444;
    color: #fee2e2;
}

.btn-danger:hover {
    background: #991b1b;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.8rem;
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Modal Windows */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

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

.modal-content {
    background: #19202a;
    border: 2px solid var(--border-gold);
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 20px var(--border-gold-glow);
    text-align: center;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.25s ease;
}

.modal-backdrop.active .modal-content {
    transform: scale(1);
}

.modal-title {
    font-family: var(--font-heading);
    color: var(--gold-text);
    font-size: 1.5rem;
    margin-bottom: 8px;
}

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

/* Coin Toss Animation */
.coin-stage {
    perspective: 800px;
    width: 100px;
    height: 100px;
    margin: 0 auto 24px auto;
}

.coin {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.coin.flipping {
    animation: flip-coin 1.5s ease-out forwards;
}

@keyframes flip-coin {
    0% { transform: rotateY(0deg) translateY(0); }
    50% { transform: rotateY(1080deg) translateY(-80px); }
    100% { transform: rotateY(2160deg) translateY(0); }
}

.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: var(--font-heading);
    font-weight: bold;
    border: 4px solid #fef08a;
    box-shadow: 0 0 15px rgba(234, 179, 8, 0.5), inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.coin-heads {
    background: radial-gradient(circle, #eab308 0%, #a16207 100%);
    color: #451a03;
}

.coin-tails {
    background: radial-gradient(circle, #94a3b8 0%, #475569 100%);
    color: #0f172a;
    transform: rotateY(180deg);
}

.coin-face-icon {
    font-size: 32px;
}

.toss-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toss-btn {
    padding: 16px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.15s, border-color 0.15s;
}

.toss-btn:hover {
    transform: translateY(-2px);
}

.toss-btn-user {
    background: linear-gradient(90deg, #991b1b 0%, #7f1d1d 100%);
    border: 2px solid #ef4444;
    color: #fff;
}

.toss-btn-opp {
    background: linear-gradient(90deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid #64748b;
    color: #e2e8f0;
}

/* Edit Mode Bar */
.edit-mode-indicator {
    display: none;
    background: #854d0e;
    color: #fef08a;
    border: 1px solid #facc15;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
}

.edit-mode-indicator.active {
    display: block;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #0f172a;
    border: 1px solid var(--border-gold);
    color: var(--gold-light);
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    font-weight: 600;
    z-index: 2000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}
