/* Spades Game Specific Styling */

.game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 auto 20px; /* centered with bottom margin */
    width: 100%;
    max-width: 900px;
    min-height: 550px; /* Increased minimum height */
}

#gameCanvas {
    touch-action: none;
    background: url('https://www.transparenttextures.com/patterns/asfalt-light.png') repeat, #228B22;
    background-size: 100px 100px;
    aspect-ratio: 4/3;
    max-height: 75vh; /* Updated from 80vh */
    width: 100%;
    border-radius: 10px;
    border: 2px solid #ffffff;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4); /* Enhanced shadow */
    position: relative;
    z-index: 1;
    min-height: 400px; /* Updated from 480px */
    background-color: rgba(0, 50, 0, 0.7);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

/* Control buttons styling - ENHANCED */
#controlButtons {
    position: relative;
    z-index: 10; /* Ensure buttons are clickable */
    margin-bottom: 15px; /* Space between buttons and canvas */
    display: flex;
    justify-content: center;
    width: 100%;
}

#controlButtons button {
    transition: transform 0.2s, box-shadow 0.2s; /* Smooth hover effect */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    font-size: 1.125rem; /* Increased size */
    padding: 0.75rem 1.5rem; /* Increased padding */
    margin: 0 10px; /* Added horizontal margin */
}

#controlButtons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.4);
}

/* Player label styling - NEW */
#playerLabels {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 5;
    pointer-events: none;
}

/* Updated player labels - more compact and positioned correctly */
.player-label {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.7); /* Darker background */
    color: white;
    padding: 5px 10px; /* Larger padding */
    border-radius: 5px;
    font-family: 'Roboto', sans-serif;
    font-size: 16px; /* Larger font */
    font-weight: bold;
    text-align: center;
    z-index: 20; /* Increased z-index to ensure visibility */
    border: 1px solid rgba(255, 255, 255, 0.4); /* More visible border */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3); /* Stronger shadow */
    pointer-events: none; /* Make sure they don't interfere with clicks */
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 12px;
    border-radius: 4px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
    z-index: 10;
}

.player-north {
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
}

.player-south {
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
}

.player-west {
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
}

.player-east {
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
}

/* Simpler active player highlight */
.active-player {
    background-color: rgba(255, 215, 0, 0.8); /* Near-solid gold background */
    color: black;
    box-shadow: 0 0 8px gold;
    animation: pulse-player 1.5s infinite;
    border: 3px solid white;
    font-weight: bold;
}

@keyframes pulse-player {
    0% { box-shadow: 0 0 5px gold; }
    50% { box-shadow: 0 0 20px gold; }
    100% { box-shadow: 0 0 5px gold; }
}

/* Game stats styling */
#gameStats {
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 15px;
    font-family: 'Roboto', sans-serif;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Added shadow */
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 500;
}

#gameStats div {
    font-family: 'Roboto', sans-serif !important;
    font-size: 16px !important; /* Increased font size */
    color: white !important;
    font-weight: bold !important;
    margin: 0 8px; /* Added spacing between stats */
}

#gameStatsTable {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 8px;
    padding: 5px;
    font-size: 0.875rem;
    opacity: 0.85;
    transition: opacity 0.3s;
}

/* Current trick area styling */
.trick-area {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Bidding styles */
.bid-amount {
    display: inline-block;
    padding: 2px 6px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    margin-top: 4px;
    font-weight: bold;
}

.nil-bid {
    background-color: rgba(255, 0, 0, 0.3);
    color: white;
}

/* Card animation classes - ENHANCED */
.card-animate {
    transition: transform 0.3s ease, top 0.3s ease, left 0.3s ease, box-shadow 0.3s ease;
}

.card-played {
    animation: card-to-center 0.5s forwards;
}

@keyframes card-to-center {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 0.8;
        box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
    }
    50% {
        transform: scale(1.2) rotate(5deg);
        opacity: 1;
        box-shadow: 0 15px 20px rgba(0, 0, 0, 0.3);
    }
    100% {
        transform: scale(1.1) rotate(3deg);
        opacity: 1;
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.3);
    }
}

/* Trick winner animation */
@keyframes trick-winner {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(255, 215, 0, 0);
    }
    50% {
        transform: scale(1.2);
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(255, 215, 0, 0);
    }
}

.trick-winner {
    animation: trick-winner 1s;
}

/* Enhanced modal styling */
#biddingOverlay .bg-white, 
#roundResultsOverlay .bg-white,
#gameStatusOverlay .bg-white,
#rulesModal .bg-white {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #gameCanvas {
        aspect-ratio: 3/4;
        max-height: 65vh;
        min-height: 400px;
    }
    
    .player-label {
        font-size: 14px;
        padding: 6px 12px;
    }
    
    #gameStats div {
        font-size: 12px !important;
        margin: 0 4px;
    }
    
    .bid-btn {
        padding: 6px 10px;
        margin: 2px;
    }
    
    /* Make buttons more visible on mobile */
    #controlButtons {
        margin-bottom: 10px;
    }
    
    #controlButtons button {
        font-size: 0.9rem;
        padding: 8px 12px;
    }

    .speech-bubble {
        padding: 8px 14px;
        max-width: 180px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    #gameCanvas {
        max-height: 60vh;
    }
    
    .player-label {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    #controlButtons button {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
}

/* Turn indicator animation */
@keyframes turn-pulse {
    0% { box-shadow: 0 0 0 rgba(255, 255, 255, 0.7); }
    50% { box-shadow: 0 0 15px rgba(255, 255, 255, 0.7); }
    100% { box-shadow: 0 0 0 rgba(255, 255, 255, 0.7); }
}

.turn-active {
    animation: turn-pulse 2s infinite;
}

/* Rules modal scrollbar styling */
#rulesModal::-webkit-scrollbar {
    width: 8px;
}

#rulesModal::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#rulesModal::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#rulesModal::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Cleaner speech bubbles */
.speech-bubble {
    position: absolute;
    background-color: white; /* More opaque */
    border-radius: 8px;
    padding: 6px 12px;
    max-width: 160px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    font-family: 'Roboto', sans-serif;
    font-size: 14px; /* Increased font size */
    font-weight: 500; /* Medium weight for better readability */
    color: #333;
    text-align: center;
    animation: fadeInOut 2.5s ease;
    z-index: 25; /* Higher z-index to ensure visibility */
    border: 1px solid #ddd; /* Subtle border */
}

.speech-bubble::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 8px solid transparent;
}

.speech-south {
    bottom: 130px;
    left: 50%;
    transform: translateX(-50%);
}

.speech-south::after {
    top: 100%;
    left: 50%;
    margin-left: -8px;
    border-top-color: white;
}

.speech-north {
    top: 130px;
    left: 50%;
    transform: translateX(-50%);
}

.speech-north::after {
    bottom: 100%;
    left: 50%;
    margin-left: -8px;
    border-bottom-color: white;
}

.speech-west {
    left: 110px;
    top: 50%;
    transform: translateY(-50%);
}

.speech-west::after {
    top: 50%;
    right: 100%;
    margin-top: -8px;
    border-right-color: white;
}

.speech-east {
    right: 110px;
    top: 50%;
    transform: translateY(-50%);
}

.speech-east::after {
    top: 50%;
    left: 100%;
    margin-top: -8px;
    border-left-color: white;
}

/* Simplified fade animation */
@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(10px) scale(0.9); }
    15% { opacity: 1; transform: translateY(0) scale(1); }
    85% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-10px) scale(0.9); }
}

/* Added current trick highlight */
.current-trick-area {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.15);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.2);
    pointer-events: none;
    z-index: 2;
}

/* Enhanced card highlighting for south player */
.highlighted-card {
    box-shadow: 0 0 25px rgba(255, 255, 0, 0.8) !important;
    transform: translateY(-20px) !important;
    z-index: 10 !important;
}

/* Difficulty badge styling */
.difficulty-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 9999px;
    color: white;
    text-transform: uppercase;
}

.difficulty-easy {
    background-color: #10B981;
}

.difficulty-medium {
    background-color: #F59E0B;
}

.difficulty-hard {
    background-color: #EF4444;
}

/* Content section specific styles */
.content-section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.content-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Add animation to make content appear after game loads */
document.addEventListener('DOMContentLoaded', function() {
    setTimeout(function() {
        const contentSection = document.querySelector('.content-section');
        if (contentSection) {
            contentSection.classList.add('visible');
        }
    }, 1500);
});

/* Game-specific styles */
.font-press-start {
    font-family: 'Press Start 2P', cursive;
}

/* Content section styling */
#content-container {
    padding: 1rem 0;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.collapsible-header {
    font-weight: 600;
}

.collapsible-content {
    transition: max-height 0.3s ease-in-out;
    overflow: hidden;
}

/* Add some space between the game and content */
main {
    margin-bottom: 1rem;
}