/* thai_checkers_style.css */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-radius: 15px;
    --soft-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --dark-square: #764ba2;
    --light-square: #f8f9fa;
    --piece-p1: #dc3545; 
    --piece-p2: #0d6efd; 
    --theme-board-dark: #764ba2;
    --theme-board-light: #f8f9fa;
    --theme-board-border: #333333;
}

body { font-family: 'Sarabun', sans-serif; background-color: var(--bs-body-bg); }
.card-custom { border-radius: var(--card-radius); box-shadow: var(--soft-shadow); border: none; background-color: var(--bs-body-bg); }
.card-header-gradient { background: var(--primary-gradient); color: white; padding: 1.25rem; }
.btn-gradient { background: var(--primary-gradient); color: white; border-radius: 50px; border: none; transition: transform 0.2s, box-shadow 0.2s; }

.checkers-board {
    position: relative;
    display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
    width: 100%; max-width: 600px; aspect-ratio: 1 / 1; margin: 0 auto;
    border: 4px solid var(--theme-board-border, #333); border-radius: 8px; box-shadow: 0 10px 20px rgba(0,0,0,0.2); 
    background-color: var(--theme-board-light, var(--light-square));
}

.square { display: flex; align-items: center; justify-content: center; position: relative; }
.square.dark { background-color: var(--theme-board-dark, var(--dark-square)) !important; }
.square.light { background-color: var(--theme-board-light, var(--light-square)) !important; }

[data-bs-theme="dark"] .square.dark { background-color: var(--theme-board-dark, #2b3035); }
[data-bs-theme="dark"] .square.light { background-color: var(--theme-board-light, #4a2f66); }

.square.highlight-move::after {
    content: ''; width: 35%; height: 35%; background-color: #28a745; border-radius: 50%; position: absolute; z-index: 5; cursor: pointer; box-shadow: 0 0 10px rgba(40, 167, 69, 0.8);
}
.square.highlight-capture::after {
    content: ''; width: 35%; height: 35%; background-color: #ffc107; border-radius: 50%; position: absolute; z-index: 5; cursor: pointer; box-shadow: 0 0 15px rgba(255, 193, 7, 0.9);
}
.square.selected { background-color: rgba(255, 193, 7, 0.4) !important; }

.square.last-move-highlight { 
    background-color: rgba(23, 162, 184, 0.4) !important; 
    box-shadow: inset 0 0 12px rgba(23, 162, 184, 0.6);
}
[data-bs-theme="dark"] .square.last-move-highlight { 
    background-color: rgba(23, 162, 184, 0.5) !important; 
    box-shadow: inset 0 0 12px rgba(23, 162, 184, 0.8);
}

@keyframes pulse-hint { 
    0% { box-shadow: 0 0 0 0 rgba(255, 0, 255, 0.7); } 
    70% { box-shadow: 0 0 0 18px rgba(255, 0, 255, 0); } 
    100% { box-shadow: 0 0 0 0 rgba(255, 0, 255, 0); } 
}
.square.highlight-hint::after {
    content: ''; width: 40%; height: 40%; background-color: #ff00ff; border-radius: 50%; position: absolute; z-index: 20;
    cursor: pointer; box-shadow: 0 0 20px rgba(255, 0, 255, 0.9);
    animation: pulse-hint 1.5s infinite;
}

.piece {
    width: 75%; height: 75%; border-radius: 50%; box-shadow: inset 0 -5px 5px rgba(0,0,0,0.3), 0 4px 6px rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center; font-size: 1.3rem; color: white; transition: transform 0.2s, box-shadow 0.2s; z-index: 10;
}
.piece.p1 { background-color: var(--piece-p1); border: 2px solid #b02a37; }
.piece.p2 { background-color: var(--piece-p2); border: 2px solid #0a58ca; }

@keyframes pulse-playable { 0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.6); } 70% { box-shadow: 0 0 0 12px rgba(40, 167, 69, 0); } 100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); } }
@keyframes pulse-must-capture { 0% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.8); } 70% { box-shadow: 0 0 0 15px rgba(255, 193, 7, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0); } }

.piece.playable { animation: pulse-playable 1.5s infinite; border: 2px solid #28a745 !important; cursor: pointer; }
.piece.playable.must-capture { animation: pulse-must-capture 1s infinite; border: 2px solid #ffc107 !important; cursor: pointer; }
.piece.disabled { cursor: not-allowed; }
.piece.playable:hover { transform: scale(1.1); }

.piece.playable.hint-piece {
    animation: pulse-hint 1.5s infinite !important;
    border: 3px solid #ff00ff !important;
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.7), inset 0 -5px 5px rgba(0,0,0,0.3) !important;
}

.active-turn-card { transform: scale(1.05); box-shadow: 0 10px 25px rgba(0,0,0,0.15) !important; opacity: 1 !important; transition: all 0.3s ease; z-index: 10; }
.active-turn-card.p1 { border: 2px solid #dc3545 !important; }
.active-turn-card.p2 { border: 2px solid #0d6efd !important; }
.inactive-turn-card { opacity: 0.5 !important; transform: scale(0.95); transition: all 0.3s ease; border: 1px solid transparent !important; }

.blur-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.8); backdrop-filter: blur(4px);
    z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: var(--card-radius);
}
[data-bs-theme="dark"] .blur-overlay { background: rgba(0,0,0,0.8); }

.terminal-box {
    background-color: #0d1117;
    color: #2ea043;
    font-family: 'Courier New', Courier, monospace;
    border-left: 4px solid #2ea043;
    font-size: 0.8rem;
    text-align: left;
    line-height: 1.4;
    height: 120px;
    overflow: hidden;
    display: flex !important;
    flex-direction: column;
}
.terminal-content {
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 5px;
}
.terminal-content::-webkit-scrollbar { width: 5px; }
.terminal-content::-webkit-scrollbar-thumb { background: #2ea043; border-radius: 5px; }
.terminal-log-line { margin-bottom: 5px; border-bottom: 1px dashed rgba(46, 160, 67, 0.3); padding-bottom: 3px; }

@keyframes neon-blink {
    0%, 100% { opacity: 1; color: #ff00ff; text-shadow: 0 0 8px rgba(255, 0, 255, 0.8); }
    50% { opacity: 0.4; color: inherit; text-shadow: none; }
}
.glitch-char {
    display: inline-block;
    animation: neon-blink linear infinite;
}
[data-bs-theme="light"] .glitch-char {
    animation-name: color-blink-light;
}
@keyframes color-blink-light {
    0%, 100% { opacity: 1; color: #764ba2; text-shadow: 0 0 8px rgba(118, 75, 162, 0.6); }
    50% { opacity: 0.6; color: inherit; text-shadow: none; }
}
@keyframes dev-color-blink {
    0%, 100% { opacity: 1; color: var(--dev-blink, #E72020); text-shadow: 0 0 8px rgba(231, 32, 32, 0.55); }
    50% { opacity: 0.85; color: var(--dev-base, #223057); text-shadow: none; }
}
.dev-blink-char {
    display: inline-block;
    color: var(--dev-base, #223057);
    animation: dev-color-blink linear infinite;
}

.list-group-item-action { transition: background-color 0.2s; cursor: pointer; }
.square-number { position: absolute; top: 2px; right: 4px; font-size: 0.75rem; color: rgba(255, 255, 255, 0.4); font-weight: bold; pointer-events: none; z-index: 5; user-select: none; }

/* Theme Selector Styles */
.theme-card {
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease-in-out;
    position: relative;
    border-radius: 12px;
}
.theme-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}
.theme-card.active {
    border-color: #0d6efd !important;
    background-color: rgba(13, 110, 253, 0.06) !important;
}
.theme-active-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #0d6efd;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    z-index: 5;
}
.mini-board-preview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    width: 52px;
    height: 52px;
    border: 2px solid #333;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}
.mini-piece-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    box-shadow: inset 0 -3px 3px rgba(0,0,0,0.35), 0 3px 5px rgba(0,0,0,0.3);
    color: white;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}
.mini-piece-circle:hover {
    transform: scale(1.1);
}

/* Enhanced Contrast & Glowing Outlines for Dark Mode */
[data-bs-theme="dark"] .checkers-board {
    border-color: var(--theme-board-border, #00f2fe) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(255, 255, 255, 0.08);
}
[data-bs-theme="dark"] .square.dark { 
    background-color: var(--theme-board-dark, #2b3035) !important; 
}
[data-bs-theme="dark"] .square.light { 
    background-color: var(--theme-board-light, #4a2f66) !important; 
}
[data-bs-theme="dark"] .piece {
    box-shadow: inset 0 -4px 6px rgba(0, 0, 0, 0.5), 0 0 10px rgba(255, 255, 255, 0.2), 0 4px 8px rgba(0, 0, 0, 0.9);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.9));
}
[data-bs-theme="dark"] .square-number {
    color: rgba(255, 255, 255, 0.65);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* Custom Shaped PNG Pieces (e.g. Bottle Caps ฝาเบียร์, Tokens, Shield) */
.piece.piece-custom-img {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}
.piece-img-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.piece-img {
    width: 90%;
    height: 90%;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
    transition: transform 0.2s, filter 0.2s;
    user-select: none;
    -webkit-user-drag: none;
}
.piece.playable .piece-img {
    filter: drop-shadow(0 0 8px rgba(40, 167, 69, 0.85)) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
}
.piece.playable.must-capture .piece-img {
    filter: drop-shadow(0 0 10px rgba(255, 193, 7, 0.95)) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
}
.piece.playable.hint-piece .piece-img {
    filter: drop-shadow(0 0 14px rgba(255, 0, 255, 0.95)) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
}
.piece-img-crown {
    position: absolute;
    top: -8px;
    right: -4px;
    font-size: 1.25rem;
    color: #ffd700 !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.85));
    animation: bounce-crown 2s infinite ease-in-out;
    z-index: 15;
}
@keyframes bounce-crown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}
[data-bs-theme="dark"] .piece.piece-custom-img .piece-img {
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.25)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.9));
}
.mini-piece-circle.mini-piece-custom {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

/* Admin Online Users Tooltip */
.admin-online-tooltip .tooltip-inner {
    max-width: 320px !important;
    text-align: left !important;
    padding: 10px 14px !important;
    background-color: rgba(20, 24, 33, 0.96) !important;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
    border-radius: 10px !important;
    font-size: 0.82rem !important;
    line-height: 1.4 !important;
}
.admin-online-tooltip .tooltip-arrow::before {
    border-bottom-color: rgba(20, 24, 33, 0.96) !important;
}

/* Elo Split-Flap Flip Counter */
.elo-flip-panel {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 14px;
    background: var(--bs-body-bg);
    border: 1.5px solid var(--bs-border-color);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
    min-width: 215px;
}
.elo-flip-panel.is-gain {
    border-color: rgba(25, 135, 84, 0.45);
    box-shadow: 0 8px 24px rgba(25, 135, 84, 0.18);
}
.elo-flip-panel.is-loss {
    border-color: rgba(220, 53, 69, 0.45);
    box-shadow: 0 8px 24px rgba(220, 53, 69, 0.18);
}
.elo-flip-panel.is-draw {
    border-color: rgba(108, 117, 125, 0.4);
}
.elo-flip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
    font-size: 0.8rem;
    font-weight: 700;
}
.elo-flip-delta {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
}
.elo-flip-digits {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    perspective: 500px;
}
.elo-flip-card {
    width: 42px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.85rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #f8fafc;
    background: linear-gradient(180deg, #2b3240 0%, #1d222c 49%, #141820 50%, #202632 100%);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    position: relative;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    user-select: none;
}
.elo-flip-card::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1.5px;
    background: rgba(0, 0, 0, 0.55);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
    pointer-events: none;
}
.elo-flip-card.flipping {
    animation: eloSplitFlip 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes eloSplitFlip {
    0%   { transform: rotateX(-80deg); }
    65%  { transform: rotateX(12deg); }
    100% { transform: rotateX(0deg); }
}
.elo-badge-pulse {
    animation: eloBadgePulse 0.65s ease;
}
@keyframes eloBadgePulse {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.16); }
    100% { transform: scale(1); }
}

/* Floating Chat Unread Preview Tooltip */
.chat-unread-tooltip {
    max-width: 240px;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border: 1px solid rgba(13, 110, 253, 0.35);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    font-size: 0.78rem;
    line-height: 1.35;
}
.chat-unread-close {
    background: none;
    border: none;
    color: var(--bs-secondary-color);
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
}
.chat-unread-preview-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* Mobile In-Game Focus Mode (Phone / Small Screens) */
@media (max-width: 767.98px) {
    body.mobile-in-game .pm-mobile-hide-ingame,
    body.mobile-in-game #darkModeToggle {
        display: none !important;
    }
    body.mobile-in-game > .container-fluid {
        padding-top: 8px !important;
        padding-bottom: 64px !important;
    }
    body.mobile-in-game #chatFabWrap {
        bottom: 12px !important;
        right: 12px !important;
    }
    body.mobile-in-game #game-controls:not(.d-none) {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }
    body.mobile-in-game #game-controls .btn {
        margin-right: 0 !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        font-size: 0.82rem;
    }
}

/* CLS Prevention: reserve icon & button dimensions before async Font Awesome / Sarabun load */
i.fa-solid, i.fa-regular, i.fa-brands, i.fas, i.far, i.fab {
    display: inline-block;
    min-width: 1em;
    min-height: 1em;
    line-height: 1;
    vertical-align: -0.125em;
}
i.fa-2x { font-size: 2em; }
i.fa-3x { font-size: 3em; }
#overlay-icon { min-width: 1em; min-height: 1em; }
#lobby-action-buttons .btn { min-height: 118px; }
main > .d-flex .btn.rounded-circle {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
