/* General Body and Container Styles (Common to all Catan pages) */
body {
    font-family: 'Inter', sans-serif;
    background-color: #f0f2f5;
    display: flex;
    flex-direction: column; /* Changed to column to allow content flow */
    justify-content: center;
    align-items: center;
    min-height: max-content;
    margin: 20px !important;
    padding: 50px !important;;
    box-sizing: border-box;
    
}
html, body {
    height: 100%; /* Ensure html and body take full viewport height */
    margin: 0;
    padding: 0;
    overflow: auto; /* Allow scrolling if content overflows */
}

canvas {
    background-color: #e0e7ff; /* Light blue background for the sea */
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
    display: block;
    
    max-width: 950px; /* Increased from 800px to 950px */
    height: auto; /* Maintain aspect ratio */
    aspect-ratio: 1.2 / 1; /* Approximate aspect ratio for a Catan board */
    border: 2px solid #a78bfa; /* Purple border */
     /*flex-grow: 1; Allow canvas to take available space */
    /*max-height: calc(100vh - 120px);*/
    width: 950px;
    
}
.canvas-wrapper {
    height: auto;               /* Big visible board */
    border: 2px solid #a78bfa;
    border-radius: 12px;
    background: #e0e7ff;
    margin-bottom: 20px;        /* Push decks further below */
    flex-shrink: 0;             /* Prevent flexbox from collapsing it */
    z-index: 1;                 /* Always on top of following sections */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}




#catanBoard {
    background: white !important;
}
.container {
    max-width: none!important;
    border-radius: 16px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    padding: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 100vh; 
    box-sizing: border-box;
    margin: 20px;
}
.main-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    gap: 10px;
    padding: 10px;
    box-sizing: border-box;
}

.left-column {
    flex: 4;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Allow flex item to shrink */
}

.right-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 300px;
    max-width: 400px;
}

.right-section {
    flex: 1;
    padding: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 10px;
    overflow-y: auto;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.right-section:last-child {
    margin-bottom: 0;
}
.middle-column {
    flex: 2; /* This column will take 3 parts of the available space, making it wider */
    display: flex;
    flex-direction: column; /* Content inside stacks vertically */
    min-width: 0; /* Allows the column to shrink */
    /* Optional: You might want a minimum width for the main content area */
    /* min-width: 400px; */
}
/* NEW: Styling for sections within the Middle Column (similar to right-section) */
.middle-section {
    flex: 1; /* Each section takes equal vertical space within the middle column */
    padding: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 10px; /* Space between sections if multiple are stacked */
    overflow-y: auto;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Remove bottom margin from the last section in the middle column */
.middle-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: #1f2937;
    margin-bottom: 10px;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 5px;
}

.tag {
    display: inline-block;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    margin: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: opacity 0.3s ease;
}

.fade-out {
    opacity: 0;
}
/* Control Group for Labels and Dropdowns (Used in catan_game.html) */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}
.control-group label {
    font-weight: 600;
    color: #4b5563;
}
.dropdown {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background-color: #f9fafb;
    font-size: 1em;
    color: #374151;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s ease-in-out;
}
.dropdown:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

/* Message Box Styles (Common to all Catan pages) */
.message-box {
    background-color: #fffbeb;
    color: #92400e;
    padding: 12px 20px;
    border-radius: 8px;
    border: 1px solid #fed7aa;
    margin-top: 15px;
    font-size: 0.9em;
    text-align: center;
    width: 100%;
    max-width: 600px;
}

/* Button Group Styles (Common for builder and player pages) */


    .button-group {
        display: flex;
        gap: 5px;
        flex-wrap: wrap;
        justify-content: center;
    }
    .btn, .btn-tool {
        
        font-size: 1em;
        flex: 1 1 100px; /* A flexible way to set item width. It will grow and shrink, with a base of 200px. */
      padding: 7px;
      border: 1px solid #ccc;
      text-align: center;
    }

.button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    width:100%;
}
.btn {
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 2px solid transparent;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
}

/* Tool Button Styles (Used in builder and player pages for actions) */
.btn-tool {
    background-color: #6366f1; /* Indigo 500 */
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, transform 0.1s ease-in-out;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: none;
}
.btn-tool:hover {
    background-color: #4f46e5; /* Indigo 600 */
    transform: translateY(-1px);
}
.btn-tool.selected {
    background-color: #4338ca; /* Indigo 700 */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(0);
}
.btn-tool:active {
    background-color: #3730a3; /* Indigo 800 */
    transform: translateY(1px);
}

/* Specific Styles for catan_game.html */
.game-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    width: 100%;
    max-width: 800px;
    margin-top: 20px;
}

/* Specific Styles for catan.html (Board Builder) */
.controls { /* This class is used in catan.html for the button group */
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    width: 100%;
    
}
/* Color selection buttons for the builder page (if implemented) */
.btn-color {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid transparent;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.btn-color.selected {
    border-color: #6d28d9; /* Deep purple for selected color */
    box-shadow: 0 0 0 4px rgba(109, 40, 217, 0.4);
}
.card-item.selected {
    border: 5px solid #a78bfa; /* Optional: A slightly stronger border */
    box-shadow: 0 0 15px rgba(237, 039, 20, 0.8); /* Blue-purple glow */
    /* You can adjust the color (RGBA value), blur radius (15px), and spread (0) as desired. */
    /* The last value (0.8) is the opacity. */
}

/* New Styles for catan_player.html */
.player-page-container {
    padding-top: 30px; /* Adjust padding for player page */
    padding-bottom: 30px;
}

.player-info-section {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.player-name-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.input-field {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background-color: #f9fafb;
    font-size: 1em;
    color: #374151;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s ease-in-out;
    width: 200px; /* Adjust width as needed */
}
.input-field:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.game-actions-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.player-decks-section {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    width: 100%;
     
}

.deck-display {
    background-color: #f8fafc;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    padding: 15px;
    min-width: 280px;
    flex: 1;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.deck-display h3 {
    margin-bottom: 10px;
    color: #334155;
}

.card-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    min-height: 50px; /* Ensure some height even if empty */
    padding: 5px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background-color: #f0f4f8;
}

.card-item {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9em;
    font-weight: 500;
    color: #475569;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 5px;
}

/* NEW: Card Acquisition Section Styles */
.card-acquisition-section {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #e0e7ff;
    border-radius: 12px;
    background-color: #f9fafb;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.resource-card-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px; /* Space between resource cards */
}

.dev-card-button {
    margin-top: 10px; /* Space between resource and dev card buttons */
}

.card-btn {
    width: 70px; /* Fixed width for card buttons */
    height: 100px; /* Fixed height for card buttons */
    background-image: url('http://googleusercontent.com/file_content/7'); /* Your uploaded image */
    background-size: 500% 100%; /* 5 cards horizontally, 100% height */
    background-repeat: no-repeat;
    border: 2px solid #a78bfa; /* Purple border */
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out;
    cursor: pointer;
    background-color: transparent; /* Ensure background image is visible */
    padding: 0; /* Remove default padding from button */
}

.card-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}


/* Style for the Development Card button */
.dev-card-btn {
    background-image: url('https://placehold.co/70x100/6A5ACD/ffffff?text=Dev+Card'); /* Placeholder for Dev Card back */
    background-size: cover; /* Cover the button area */
    background-position: center;
    font-size: 0.8em; /* Smaller font for text */
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}
.resource-card-group {
    display: flex;
    flex-wrap: nowrap; /* Forces cards into a single row */
    gap: 10px;
    margin-bottom: 15px;
    overflow-x: auto; /* Enables horizontal scrolling if content overflows */
    padding-bottom: 5px; /* Space for scrollbar */
    justify-content: center; /* Center the cards if there's space */
}

/* Base Card Styles for both resource and dev cards */
.resource-card, .dev-card {
    width: 80px; /* Card width */
    height: 110px; /* Card height */
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
    transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
    background-size: cover;
    background-position: center;
    border: 2px solid rgba(255, 255, 255, 0.8);
    flex-shrink: 0; /* Prevent cards from shrinking */
}

.resource-card:hover, .dev-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}

.resource-card:active, .dev-card:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Hide card text as background images are used */
.card-text {
    display: none; /* Hide the text */
}


/* Background Images for Resource Cards */
.resource-card[data-resource-type="wood"] {
    background-image: url('/static/images/catan/wood.jpg');
}
.resource-card[data-resource-type="brick"] {
    background-image: url('/static/images/catan/brick.jpg');
}
.resource-card[data-resource-type="sheep"] {
    background-image: url('/static/images/catan/sheep.jpg');
}
.resource-card[data-resource-type="hay"] {
    background-image: url('/static/images/catan/hay.jpg');
}
.resource-card[data-resource-type="rock"] {
    background-image: url('/static/images/catan/rock.jpg');
}
.dev-card[data-resource-type="development"] { /* This was for the button, now for the actual card */
    background-image: url('/static/images/catan/dev_card.jpg');
}
.dev-card[data-card-type="knight"] {
    background-image: url('/static/images/catan/Knight.jpg');
}
.dev-card[data-card-type="victory_point"] {
    background-image: url('/static/images/catan/victory_point.jpg');
}
.dev-card[data-card-type="road_building"] {
    background-image: url('/static/images/catan/Road_Building.jpg');
}
.dev-card[data-card-type="year_of_plenty"] {
    background-image: url('/static/images/catan/Year_of_Plenty.jpg');
}
.dev-card[data-card-type="monopoly"] {
    background-image: url('/static/images/catan/Monopoly.jpg');
}


/* Animation for "getting card" effect */
@keyframes card-animate-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card-item.animate-in {
    animation: card-animate-in 0.3s ease-out forwards;
}
/* NEW: Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-content {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-message {
    font-size: 1.1em;
    color: #374151;
    margin-bottom: 15px;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.btn-confirm {
    background-color: #22c55e; /* Green */
    color: white;
    padding: 10px 20px;
    border: none;
}
.btn-confirm:hover {
    background-color: #16a34a;
}

.btn-cancel {
    background-color: #ef4444; /* Red */
    color: white;
    padding: 10px 20px;
    border: none;
}
.btn-cancel:hover {
    background-color: #dc2626;
}


/* roll dice */
.dice-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6rem; /* Space between dice */
    font-size: 10rem; /* Large dice display */
    min-height: 120px; /* Ensure container has height during animation */
    transition: transform 0.2s ease-out;
}

.dice-face {
    width: 100px;
    height: 100px;
    font-size: 8rem;
    background-color: #fbd500;
    color: #c20c61;
    border: 3px solid #141313;
    border-radius: 18px; /* Rounded corners for dice */
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: roll-animation 0.5s ease-in-out infinite alternate; /* Initial animation */
}

/* Keyframes for a simple rolling animation */
@keyframes roll-animation {
    0% { transform: rotateY(0deg); opacity: 1; }
    50% { transform: rotateY(180deg); opacity: 0.7; }
    100% { transform: rotateY(360deg); opacity: 1; }
}

.rolling .dice-face {
    animation: roll-animation 0.1s ease-in-out infinite alternate; /* Faster animation during roll */
}

.final-roll .dice-face {
    animation: none; /* Stop animation after final roll */
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .dice-container {
        font-size: 6rem;
        gap: 1.5rem;
    }
    .dice-face {
        width: 750px;
        height: 75px;
        border-radius: 12px;
    }
    .roll-button {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}
        

/* Responsive adjustments */
@media (max-width: 768px) {
    body{
            
        width: 950px;
    }
    .container {
        width: 950px!important;
        padding: 10px;
    }
    .canvas-wrapper {
        /* On small screens, the wrapper takes full width, and the canvas inside overflows */
        width: 850px;
        max-width: unset; /* Let it be as wide as the canvas */
        height: auto;
    }
    #catanBoard {
    
    }
    canvas {
        /* Set a large, fixed size for the canvas on mobile, forcing the wrapper to scroll */
        width: 850px; /* Example fixed width, adjust as needed */
        height: auto;
        align-items: center;
    }
    .game-controls, .controls, .player-info-section, .game-actions-section, .player-decks-section, .card-acquisition-section {
        flex-direction: column;
        align-items: center;
    }
    .button-group {
        flex-direction: row; /* Stack buttons vertically on small screens */
        width: 100%;
        
    }
    .btn, .btn-tool {
        width: 50%; /* Make buttons full width */
        padding: 10px 10px;
        font-size: 1em;
    }
    .card-btn {
        width: 100px; /* Adjust card button size for better touch on mobile */
        height: 140px;
    }
    .resource-card-buttons {
        flex-direction: row; /* Keep resource cards in a row, but allow wrap */
        justify-content: center;
        gap: 8px;
    }
    .input-field {
        width: 100%; /* Make input full width */
    }
    .deck-display {
        min-width: unset; /* Remove min-width on small screens */
        width: 100%;
    }
}
@media (max-width: 480px) {
    .card-btn {
        width: 80px; /* Even smaller for very small screens */
        height: 110px;
    }
    .resource-card-buttons {
        gap: 5px;
    }
}
