/* ===== 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 CHAT ===== */
.game-layout-with-chat {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1rem;
    height: calc(100vh - 72px);
    padding: 1rem;
}

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

/* ===== CHAT SIDEBAR ===== */
.chat-sidebar {
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    overflow: hidden;
    height: 100%;
}

.chat-sidebar-header {
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.chat-sidebar-header:hover {
    background: rgba(0, 0, 0, 0.3);
}

.chat-sidebar.collapsed {
    width: 48px;
    min-width: 48px;
    flex-shrink: 0;
}

.chat-sidebar.collapsed .chat-sidebar-header h3 {
    display: none;
}

.chat-sidebar.collapsed .chat-messages,
.chat-sidebar.collapsed .chat-input-area {
    display: none;
}

/* Expand board when chat is collapsed */
.game-layout-with-chat:has(.chat-sidebar.collapsed) {
    grid-template-columns: 1fr 48px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Chat messages */
.chat-message {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
}

.chat-message.own {
    background: rgba(102, 126, 234, 0.3);
    align-self: flex-end;
    border: 1px solid rgba(102, 126, 234, 0.5);
}

.chat-message.opponent {
    background: rgba(255, 255, 255, 0.1);
    align-self: flex-start;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-message-sender {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.8;
    margin-bottom: 0.25rem;
    color: white;
}

.chat-message-text {
    font-size: 0.875rem;
    line-height: 1.4;
    color: white;
}

/* Scrollbar styling for chat */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 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);
}

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

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

.game-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 72px); /* Account for header height */
}

/* Board area */
.board-area {
    display: flex;
    flex-direction: column;
    background: #2d5016;
    padding: 0;
    min-width: 0;
    min-height: 0;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 72px); /* Account for header height */
}

.board-wrapper-game {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0;
    gap: 8px;
    width: min(80vw, 100%);
    max-width: 80vw;
    max-height: calc(100vh - 72px - 20px); /* Fit within viewport minus header and padding */
}

.board-canvas {
    width: 100%;
    height: calc(80vw * 0.566);
    max-width: 80vw;
    max-height: 80vh;
    border-radius: 1.2vw;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: filter 0.2s;
    background: #2d5016;
    display: block;
}

.board-canvas:hover {
    filter: brightness(1.05);
}

.board-placeholder {
    position: absolute;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.5em;
    text-align: center;
    pointer-events: none;
}

/* 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 name labels on board */
.player-name-top,
.player-name-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.player-name-label {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 24px;
    border-radius: 8px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    min-width: 150px;
    justify-content: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

/* Highlight active player's turn */
.player-name-label.active {
    background: rgba(76, 175, 80, 0.3);
    border: 2px solid rgba(76, 175, 80, 0.8);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.4);
    animation: subtle-pulse 2s infinite;
}

.player-name-label span {
    color: #ffffff;
    font-weight: 600;
    font-size: 1em;
    text-align: center;
    white-space: nowrap;
}

.player-color-indicator {
    font-size: 1.3em;
    line-height: 1;
}

.player-color-indicator.white {
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.5));
}

.player-color-indicator.red {
    filter: drop-shadow(0 0 3px rgba(255, 0, 0, 0.5));
}

/* 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 */
/* Chat sidebar stacks below board on tablets/mobile */
@media (max-width: 1024px) {
    .game-layout-with-chat {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
        gap: 0.5rem;
    }

    .chat-sidebar {
        max-height: 300px;
    }
}

@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: min(80vw, 1200px);
    max-height: min(calc(80vw * 0.5), calc(100vh - 350px)); /* Leave room for header, player names, controls */
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    display: block;
    background: #4A3728;
}

/* Board background */
.board-background {
    fill: #4A3728;
}

.board-border {
    stroke: #2D1F15;
}

/* 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: pointer;
}

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

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

/* Checker hover effect */
.checker: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;
}

/* 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;
}
