/* ===== GAME-SPECIFIC STYLES ===== */
/* These styles are for the canvas board and game controls that aren't covered by DaisyUI */

/* ===== SHARED HEADER ===== */
#appHeader {
    background: linear-gradient(135deg, var(--p) 0%, var(--s) 100%);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ===== GAME INFO BAR ===== */
.game-info-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 1rem;
    color: white;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== MODERN GAME CONTROLS ===== */
.game-controls-modern {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    margin-top: 1rem;
}

.game-controls-modern button:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.game-controls-modern button:not(:disabled):active {
    transform: translateY(0);
}

/* Turn indicator glow when active */
#turnIndicator.active {
    color: #4CAF50;
    text-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
    animation: subtle-pulse 2s infinite;
}

/* ===== GAME LAYOUT WITH PLAYER SIDEBAR ===== */
.game-layout-with-chat {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1rem;
    height: calc(100vh - 72px);
    padding: 1rem;
}

.board-section {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent grid blowout */
    width: 100%;
    height: 100%;
}

/* ===== PLAYER SIDEBAR ===== */
.player-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 1rem;
    height: 100%;
    overflow-y: auto;
}

.player-card {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.player-card.active {
    border-color: rgba(76, 175, 80, 0.8);
    background: rgba(76, 175, 80, 0.2);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.3);
    animation: subtle-pulse 2s infinite;
}

.player-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    border: 3px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
}

.player-avatar.red {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.1);
}

.player-avatar.white {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

.player-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
}

.player-name {
    color: #ffffff;
    font-weight: 700;
    font-size: 1.1em;
    text-align: center;
    word-wrap: break-word;
}

.player-id {
    font-size: 0.75em;
    opacity: 0.6;
    font-family: monospace;
    color: #ffffff;
}

.pip-count {
    font-size: 0.85em;
    opacity: 0.8;
    color: #ffffff;
    margin-top: 0.25rem;
}

.match-score {
    text-align: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    margin: auto 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.score-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
}

.score-label span {
    color: #ffffff;
    font-weight: 700;
    font-size: 1.1em;
}


/* Spectator mode */
body.spectator-mode #turnIndicator::after {
    content: ' (Spectating)';
    color: #4299e1;
    font-size: 0.9em;
    margin-left: 8px;
}

body.spectator-mode .move-controls,
body.spectator-mode .dice-section-compact,
body.spectator-mode .btn-move,
body.spectator-mode .btn-roll {
    pointer-events: none;
    opacity: 0.5;
    filter: grayscale(0.5);
}

/* Disable most controls in spectator mode (but allow Leave button) */
body.spectator-mode .game-controls button,
body.spectator-mode #abandonBtn,
body.spectator-mode #exportBtn,
body.spectator-mode #importBtn {
    pointer-events: none !important;
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    filter: grayscale(0.7) !important;
}

body.spectator-mode .board-point {
    cursor: default !important;
}

#spectatorBadge {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Page structure */
.page {
    min-height: 100vh;
}

/* ===== GAME PAGE ===== */

.game-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* Board area */
.board-area {
    display: flex;
    flex-direction: column;
    background: #1a1f2e;
    padding: 1rem;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.board-wrapper-game {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    height: 100%;
    gap: 8px;
}

.board-placeholder {
    position: absolute;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.2em;
    text-align: center;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Secondary game controls */
.game-controls-secondary {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 8px;
}

/* Dice section */
.dice-section-compact {
    display: flex;
    gap: 2vw;
    justify-content: center;
    align-items: center;
    margin-top: 2vw;
}

.dice-info label {
    display: none;
}

.dice-display {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}

.die {
    width: 5vw;
    height: 5vw;
    min-width: 48px;
    min-height: 48px;
    max-width: 96px;
    max-height: 96px;
    background: white;
    border: 0.4vw solid #667eea;
    border-radius: 1vw;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5vw;
    font-weight: bold;
    color: #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

/* Game controls */
.game-controls {
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

/* Player color indicator */
.player-color-indicator {
    font-size: 1em;
    line-height: 1;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.3));
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes subtle-pulse {
    0%, 100% { box-shadow: 0 0 0 rgba(72, 187, 120, 0); }
    50% { box-shadow: 0 0 8px rgba(72, 187, 120, 0.3); }
}

@keyframes button-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Responsive */
/* Player sidebar stacks on top on tablets/mobile */
@media (max-width: 1024px) {
    .game-layout-with-chat {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        gap: 0.5rem;
    }

    .player-sidebar {
        flex-direction: row;
        height: auto;
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .player-card {
        flex: 1;
        padding: 0.75rem;
    }

    .player-avatar {
        width: 50px;
        height: 50px;
        font-size: 2em;
    }

    .match-score {
        flex: 0 1 auto;
        padding: 0.75rem;
        margin: 0;
    }
}

@media (max-width: 768px) {
    .board-wrapper-game {
        width: 95vw;
        max-width: 95vw;
        padding-bottom: 140px; /* Space for fixed controls */
    }

    .board-canvas,
    .board-svg {
        max-width: 95vw;
    }

    .die {
        min-width: 40px;
        min-height: 40px;
    }

    /* Sticky controls at bottom on mobile */
    .game-controls-modern {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin-top: 0;
        border-radius: 12px 12px 0 0;
        z-index: 100;
        max-height: 120px;
        overflow-y: auto;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    }
}

/* ===== SVG BOARD STYLES ===== */

/* SVG Board container */
.board-svg {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: calc(100vh - 72px - 4rem);
    aspect-ratio: 1020 / 500; /* Match viewBox aspect ratio to prevent distortion */
    object-fit: contain; /* Maintain aspect ratio within container */
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    cursor: default; /* Changed from pointer - only draggable checkers get grab cursor */
    display: block;
    background: #5d4e37;
}

/* Board background */
.board-background {
    fill: #5d4e37;
}

.board-border {
    stroke: #4a7c4e;
    stroke-width: 8;
}

/* Point triangles - flat design */
.point-triangle {
    transition: filter 0.15s ease;
}

.point-triangle.point-light {
    fill: #D4C4B0;
}

.point-triangle.point-dark {
    fill: #8B7355;
}

.point:hover .point-triangle {
    filter: brightness(1.1);
}

/* Point highlights */
.point-highlight {
    fill: transparent;
    opacity: 0;
    transition: opacity 0.2s ease, fill 0.2s ease;
    pointer-events: none;
}

.point.valid-source .point-highlight {
    fill: rgba(255, 213, 79, 0.5);
    opacity: 1;
}

.point.selected .point-highlight {
    fill: rgba(76, 175, 80, 0.6);
    opacity: 1;
}

.point.valid-destination .point-highlight {
    fill: rgba(33, 150, 243, 0.5);
    opacity: 1;
}

.point.valid-destination.capture .point-highlight {
    fill: rgba(244, 67, 54, 0.5);
    opacity: 1;
}

/* Bar styling */
.bar-background {
    fill: #3D2E22;
}

#bar.valid-source .bar-background {
    fill: rgba(255, 213, 79, 0.4);
}

#bar.selected .bar-background {
    fill: rgba(76, 175, 80, 0.5);
}

/* Bear-off styling */
.bearoff-background {
    fill: #3D2E22;
}

.bearoff-divider {
    stroke: #5D4037;
    stroke-width: 2;
}

#bearoff.valid-destination .bearoff-background {
    fill: rgba(33, 150, 243, 0.4);
}

/* Checker styling - flat modern design */
.checker {
    transition: transform 0.15s ease, filter 0.15s ease;
    cursor: default; /* Changed from pointer - only draggable checkers get grab cursor */
}

.checker-white {
    fill: #F5F5F5;
    stroke: #BDBDBD;
    stroke-width: 2;
}

.checker-red {
    fill: #D32F2F;
    stroke: #B71C1C;
    stroke-width: 2;
}

/* Checker hover effect - only for draggable checkers */
.checker.draggable:hover {
    filter: brightness(1.15);
}

/* Checker selection highlight */
.checker.selected {
    filter: drop-shadow(0 0 12px rgba(76, 175, 80, 0.9));
    stroke: #4CAF50;
    stroke-width: 3;
}

/* Checker count text */
.checker-count {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 700;
    font-size: 18px;
    pointer-events: none;
}

.checker-count.count-dark {
    fill: #37474F;
}

.checker-count.count-light {
    fill: #FFFFFF;
}

/* Bear-off count */
.bearoff-count {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 700;
    font-size: 24px;
    fill: #FFFFFF;
}

/* Animation for moving pieces */
.checker.animating {
    pointer-events: none;
    z-index: 100;
}

/* Drag and drop styles */
.checker.draggable {
    cursor: grab !important;
}

.checker.draggable:hover {
    filter: brightness(1.25);
    stroke-width: 3;
}

.checker.dragging {
    cursor: grabbing !important;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
    z-index: 1000;
}

/* Point number labels (optional, for debugging) */
.point-label {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 10px;
    fill: rgba(255, 255, 255, 0.3);
    text-anchor: middle;
    pointer-events: none;
}

/* Smooth transitions for all highlights */
.point, #bar, #bearoff {
    transition: all 0.2s ease;
}

/* ===== SVG DICE ON BOARD ===== */

.board-die {
    transition: opacity 0.3s ease;
}

.die-face {
    fill: #FFFFFF;
    stroke: #5C6BC0;
    stroke-width: 3;
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.3));
    transition: fill 0.3s ease, stroke 0.3s ease, opacity 0.3s ease;
}

.die-value {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 24px;
    font-weight: 700;
    fill: #5C6BC0;
    transition: fill 0.3s ease;
}

/* Used die state - greyed out with reduced opacity */
.board-die.used {
    opacity: 0.4;
}

.board-die.used .die-face {
    fill: #E0E0E0;
    stroke: #9E9E9E;
}

.board-die.used .die-value {
    fill: #757575;
}

/* ===== CUBE SIDEBAR ===== */
.cube-sidebar {
    fill: rgba(0, 0, 0, 0.3);
    stroke: rgba(0, 0, 0, 0.5);
    stroke-width: 1;
}

/* ===== DOUBLING CUBE ===== */
.doubling-cube {
    fill: #3D3D3D;
    stroke: #FFD700;
    stroke-width: 3;
    transition: all 0.3s ease;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
}

.doubling-cube:hover {
    filter: brightness(1.1) drop-shadow(2px 2px 6px rgba(0, 0, 0, 0.7));
    stroke-width: 4;
}

.cube-value {
    font-size: 36px;
    font-weight: bold;
    fill: #FFD700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.cube-owner {
    font-size: 11px;
    fill: #FFD700;
    opacity: 0.8;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

/* ===== BOARD FLIP FEATURE ===== */

/* Flip the entire board 180 degrees */
.board-svg.flipped {
    transform: rotate(180deg);
    transition: transform 0.6s ease-in-out;
}

/* Counter-rotate all visual elements to keep them upright */
.board-svg.flipped .checker,
.board-svg.flipped .checker-count,
.board-svg.flipped .bearoff-count {
    transform: rotate(-180deg);
    transform-box: fill-box;
    transform-origin: center;
}

/* Counter-rotate dice and cube groups (not individual elements) */
.board-svg.flipped #dice,
.board-svg.flipped #cube {
    transform: rotate(-180deg);
    transform-box: fill-box;
    transform-origin: center;
}

/* Smooth transition for flip animation */
.board-svg {
    transition: transform 0.6s ease-in-out;
}

/* Flip button active state */
#flipBoardBtn.active {
    background-color: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.8);
}
