:root {
    color-scheme: dark;
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #09090b;
    color: #f4f4f5;
    min-height: 100vh;
}

.font-mono,
.clock-display {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-variant-numeric: tabular-nums;
}

/* Chessboard container & responsive sizing */
#myBoard {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    touch-action: none;
    user-select: none;
}

#myBoard .board-b72b1 {
    border: 2px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.75);
}

/* Full Screen Board Mode (native Fullscreen API on <html> + CSS Theater container) */
body.board-fullscreen-active {
    overflow: hidden;
}

#boardStage.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 45;
    width: 100vw;
    height: 100dvh;
    background: radial-gradient(circle at center, #111827 0%, #09090b 75%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    overflow: hidden;
}

#boardStage.is-fullscreen .board-stage-inner {
    width: 100%;
    max-width: min(94vw, 880px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

#boardStage.is-fullscreen #myBoard {
    max-width: none;
}

#boardStage.is-fullscreen #topPlayerBar,
#boardStage.is-fullscreen #bottomPlayerBar {
    width: 100%;
}

/* Neutralize default harsh yellow chessboard.js drag border */
#myBoard .highlight1-32417,
#myBoard .highlight2-9c5d2 {
    box-shadow: none;
}

/* Floating piece while dragging */
body > img.piece-417db {
    transform: scale(1.13);
    filter: drop-shadow(0 14px 20px rgba(0, 0, 0, 0.7));
    cursor: grabbing !important;
    z-index: 60 !important;
    pointer-events: none;
}

/* Square base & piece hover/selection micro-interactions */
#myBoard .square-55d63 {
    position: relative;
    transition: box-shadow 0.18s ease, filter 0.15s ease;
}

#myBoard .square-55d63 img.piece-417db {
    position: relative;
    z-index: 2;
    transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), filter 0.16s ease;
}

#myBoard .sq-movable {
    cursor: grab;
}

#myBoard .sq-movable:hover {
    box-shadow: inset 0 0 0 100px rgba(255, 255, 255, 0.08);
}

#myBoard .sq-movable:hover img.piece-417db {
    transform: translateY(-2px) scale(1.06);
    filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.45));
}

/* Last move highlight */
#myBoard .sq-last-move {
    box-shadow: inset 0 0 0 100px rgba(250, 204, 21, 0.32);
}

/* Selected square highlight & piece pop */
#myBoard .sq-selected {
    box-shadow: inset 0 0 0 3px rgba(16, 185, 129, 0.9), inset 0 0 0 100px rgba(16, 185, 129, 0.34) !important;
}

#myBoard .sq-selected img.piece-417db {
    transform: translateY(-2px) scale(1.08);
    filter: drop-shadow(0 6px 12px rgba(16, 185, 129, 0.55));
    animation: pieceSelectPop 0.18s ease-out;
}

@keyframes pieceSelectPop {
    0% {
        transform: scale(0.96);
    }
    60% {
        transform: translateY(-3px) scale(1.11);
    }
    100% {
        transform: translateY(-2px) scale(1.08);
    }
}

/* Check pulse highlight */
#myBoard .sq-in-check {
    background: radial-gradient(circle, rgba(239, 68, 68, 0.92) 0%, rgba(185, 28, 28, 0.68) 60%, transparent 100%) !important;
    animation: checkPulse 1.3s ease-in-out infinite;
}

@keyframes checkPulse {
    0%, 100% {
        box-shadow: inset 0 0 14px rgba(239, 68, 68, 0.75);
    }
    50% {
        box-shadow: inset 0 0 24px rgba(248, 113, 113, 0.95);
    }
}

/* Legal move dots & capture rings */
#myBoard .sq-legal-dot,
#myBoard .sq-legal-capture {
    cursor: pointer;
}

#myBoard .sq-legal-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28%;
    height: 28%;
    border-radius: 9999px;
    background: rgba(15, 23, 42, 0.36);
    transform: translate(-50%, -50%) scale(1);
    pointer-events: none;
    z-index: 3;
    transition: transform 0.14s ease, background-color 0.14s ease;
    animation: dotPopIn 0.14s cubic-bezier(0.22, 1, 0.36, 1);
}

#myBoard .sq-legal-dot:hover::after {
    transform: translate(-50%, -50%) scale(1.25);
    background: rgba(16, 185, 129, 0.65);
}

#myBoard .sq-legal-capture::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 84%;
    height: 84%;
    border-radius: 9999px;
    border: 4px solid rgba(15, 23, 42, 0.38);
    transform: translate(-50%, -50%) scale(1);
    pointer-events: none;
    z-index: 3;
    transition: transform 0.14s ease, border-color 0.14s ease;
    animation: ringPopIn 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

#myBoard .sq-legal-capture:hover::after {
    transform: translate(-50%, -50%) scale(1.06);
    border-color: rgba(239, 68, 68, 0.75);
}

@keyframes dotPopIn {
    from {
        transform: translate(-50%, -50%) scale(0.35);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes ringPopIn {
    from {
        transform: translate(-50%, -50%) scale(0.75);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Drag-over valid target highlight */
#myBoard .sq-drag-legal-hover {
    box-shadow: inset 0 0 0 4px rgba(16, 185, 129, 0.92), inset 0 0 0 100px rgba(16, 185, 129, 0.25) !important;
}

/* Move landing ripple effect */
#myBoard .sq-move-impact::before,
#myBoard .sq-capture-impact::before {
    content: '';
    position: absolute;
    inset: 8%;
    border-radius: 9999px;
    pointer-events: none;
    z-index: 4;
}

#myBoard .sq-move-impact::before {
    border: 3px solid rgba(250, 204, 21, 0.85);
    animation: moveImpactRipple 0.42s ease-out forwards;
}

#myBoard .sq-capture-impact::before {
    border: 4px solid rgba(244, 63, 94, 0.9);
    background: radial-gradient(circle, rgba(244, 63, 94, 0.35), transparent 70%);
    animation: moveImpactRipple 0.46s ease-out forwards;
}

@keyframes moveImpactRipple {
    0% {
        transform: scale(0.45);
        opacity: 0.95;
    }
    100% {
        transform: scale(1.22);
        opacity: 0;
    }
}

/* Lobby pill selector buttons */
.pill-btn {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #d4d4d8;
    transition: all 0.15s ease;
    cursor: pointer;
}

.pill-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.pill-btn.pill-selected {
    background-color: rgba(16, 185, 129, 0.16);
    border-color: rgba(16, 185, 129, 0.6);
    color: #6ee7b7;
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.25);
}

/* Clocks */
.clock-display {
    transition: all 0.2s ease;
    background-color: #18181b;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #a1a1aa;
}

.clock-display.clock-active {
    background-color: rgba(16, 185, 129, 0.16);
    border-color: rgba(16, 185, 129, 0.5);
    color: #ffffff;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.18);
}

.clock-display.clock-low {
    background-color: rgba(244, 63, 94, 0.22);
    border-color: rgba(244, 63, 94, 0.65);
    color: #fecdd3;
}

/* Confirmation modal */
.custom-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-content {
    background-color: #18181b;
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 1.75rem;
    border-radius: 1.5rem;
    width: 100%;
    max-width: 390px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    animation: modalScaleIn 0.2s ease-out;
}

@keyframes modalScaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content h3 {
    color: #fff;
    font-size: 1.15rem;
    margin-bottom: 0.6rem;
    font-weight: 700;
}

.modal-content p {
    color: #a1a1aa;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.modal-btn {
    padding: 0.6rem 1.35rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    min-width: 100px;
}

.modal-btn.cancel {
    background-color: #27272a;
    color: #e4e4e7;
}

.modal-btn.cancel:hover {
    background-color: #3f3f46;
}

.modal-btn.confirm {
    background-color: #ef4444;
    color: #fff;
}

.modal-btn.confirm:hover {
    background-color: #dc2626;
}

/* Subtle custom scrollbars */
.thin-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.thin-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.thin-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 9999px;
}

.thin-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.24);
}
