/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    background-color: #f5f5dc; /* Beige background for farm theme */
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 8px;
}

h1 {
    color: #6b8e23; /* Olive green for farm theme */
    text-align: center;
    margin-bottom: 5px;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

h2 {
    color: #556b2f; /* Darker green */
    margin-bottom: 3px;
}

h3 {
    color: #2e8b57; /* Sea green */
    margin-bottom: 5px;
}

button {
    background-color: #6b8e23;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #556b2f;
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

input, select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

/* Game sections */
.game-section {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 10px;
    margin-bottom: 20px;
}

.hidden {
    display: none;
}

/* Game menu styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.join-game-section {
    display: flex;
    gap: 10px;
}

/* Lobby styles */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background-color: #f0f8ff;
    padding: 10px;
    border-radius: 5px;
}

.players-list {
    margin-bottom: 20px;
}

.players-list ul {
    list-style: none;
}

.players-list li {
    padding: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
}

.players-list li:last-child {
    border-bottom: none;
}

.player-ready {
    color: #2e8b57;
    font-weight: bold;
}

/* Game board styles */
.game-status {
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    margin-bottom: 5px;
}

.game-area {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 900px) {
    .game-area {
        grid-template-columns: 1fr;
    }
}

/* Dice section styles */
.dice-container {
    display: flex;
    justify-content: space-around;
}

.dice {
    background-color: #fff;
    border: 2px solid #6b8e23;
    border-radius: 10px;
    padding: 15px;
    width: 120px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dice-label {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    color: #333;
    font-weight: bold;
}

.dice {
    position: relative;
    margin-top: 25px;  /* Add space for the label above */
}

/* Dice animation styles */
.dice.rolling {
    animation: diceRoll 0.5s ease-in-out;
}

@keyframes diceRoll {
    0% { transform: rotate(0deg) translateX(0); }
    10% { transform: rotate(-5deg) translateX(-5px); }
    20% { transform: rotate(5deg) translateX(5px); }
    30% { transform: rotate(-10deg) translateX(-7px); }
    40% { transform: rotate(10deg) translateX(7px); }
    50% { transform: rotate(-7deg) translateX(-5px); }
    60% { transform: rotate(7deg) translateX(5px); }
    70% { transform: rotate(-3deg) translateX(-3px); }
    80% { transform: rotate(3deg) translateX(3px); }
    90% { transform: rotate(-1deg) translateX(-1px); }
    100% { transform: rotate(0deg) translateX(0); }
}

.dice-result {
    min-height: 30px;
    font-size: 2rem;  /* Increased from 1.2rem */
    display: flex;
    align-items: center;
    justify-content: center;
}

.dice-result p {
    font-size: 32px;  /* Make the animal emoji bigger */
}

/* Animal inventory styles */
.animal-inventory {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.animal-card {
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 10px;
    min-width: 120px;
}

.animal-emoji {
    font-size: 2.5em;
    display: block;
    margin-bottom: 10px;
}

.animal-info {
    margin-top: 10px;
}

.animal-name {
    font-weight: bold;
    text-transform: capitalize;
    margin-bottom: 5px;
}

.animal-value {
    color: #666;
    font-size: 0.9em;
}

.animal-count {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 5px 0;
}

.animal-count .animal-emoji {
    font-size: 84px !important;
    margin: 0;
}

.animal-count .count {
    font-weight: bold;
    min-width: 24px;
    text-align: left;
}

/* Trade section styles */
.trade-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.trade-give, .trade-receive {
    background-color: #f9f9f9;
    padding: 10px;
    border-radius: 5px;
}

.trade-form select, .trade-form input {
    margin-top: 5px;
    width: 100%;
}

/* Players status styles */
.all-players {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.player-status-card {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.player-status-card h4 {
    color: #6b8e23;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

/* Add animation keyframes */
@keyframes acquire-pulse {
    0% { transform: scale(1.5) translate(-50%, -50%); opacity: 0.8; }
    50% { transform: scale(0.8) translate(-50%, -50%); opacity: 1; }
    100% { transform: scale(1.1) translate(-50%, -50%); opacity: 0; }
}

@keyframes cell-highlight {
    0% { background-color: rgba(107, 142, 35, 0); } /* Start transparent */
    50% { background-color: rgba(107, 142, 35, 0.3); } /* Highlight color */
    100% { background-color: rgba(107, 142, 35, 0); } /* End transparent */
}

/* Class for the "+x / -x" text indicator */
.acquire-indicator {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%); /* Center it */
    font-weight: bold;
    font-size: 1.2em; /* Make it slightly larger */
    pointer-events: none;
    animation: acquire-pulse 1.5s ease-out forwards;
    z-index: 10;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2); /* Add slight shadow */
}

/* Class for the cell highlight effect */
.cell-highlight-effect {
    animation: cell-highlight 1s ease-out;
    /* Ensure highlight appears on top of default background */
    position: relative; 
    z-index: 1;
}

/* Ensure table cells can contain the absolutely positioned indicator */
.farm-animals-table td {
    position: relative;
}

/* AI player styling */
.player-status-card.ai-player {
    background-color: #f5f5ff;
    border-left: 3px solid #4a6eb0;
}

.players-list li .ai-name {
    color: #4a6eb0;
    font-style: italic;
}

.player-animals {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

.player-animal-item {
    display: flex;
    justify-content: space-between;
}

.current-player {
    border: 2px solid #6b8e23;
}

/* Dice result section */
.dice-section h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.current-roller {
    font-size: 0.9em;
    color: #666;
    font-style: italic;
}

.current-turn {
    border: 2px solid #6b8e23;
}

.current-player {
    background-color: #f8f8f8;
}

.animal-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.animal-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.animal-slot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background-color: #f0f0f0;
}

.animal-slot.empty {
    opacity: 0.3;
}

.animal-slot.filled {
    opacity: 1;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.overflow-counter {
    background-color: #6b8e23;
    color: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    margin-left: 5px;
}

/* Make player cards display side by side */
#all-players-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin: 0 auto;
}

/* Player card animal styles with smaller emojis for better mobile compatibility */
.player-card .token-circle {
    background: white;
    border-radius: 50%;
    width: 55px !important;  /* Reduced from 75px */
    height: 55px !important; /* Reduced from 75px */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 0 5px;
}

.player-card .token-circle.empty {
    background: #d0d0d0;
    opacity: 0.5;
}

.player-card .token-circle .animal-emoji {
    font-size: 32px !important; /* Reduced from 48px */
    line-height: 1;
    margin: 0;
    display: flex;
}

.player-card .animal-row {
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-start;
    gap: 8px; /* Reduced from 12px */
    margin-bottom: 12px; /* Reduced from 18px */
    flex-wrap: nowrap;
}

/* Make player cards narrower to fit mobile better */
.player-card {
    flex: 1 0 200px !important; /* Reduced from 500px */
    min-width: 200px !important; /* Reduced from 500px */
    width: 100% !important;
    max-width: 500px !important; /* Reduced from 650px */
    background: #fff;
    border-radius: 8px;
    padding: 10px; /* Reduced from 25px */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 10px;
}

.player-header {
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.animal-slot {
    width: 55px !important;
    height: 55px !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px !important;
    background-color: #f0f0f0;
}

.animal-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.overflow-counter {
    background-color: #ffd700;
    color: #333;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 15px;
    margin-left: 5px;
    font-size: 18px;
    align-self: center;
    width: auto !important;
    height: auto !important;
    min-width: 30px;
    text-align: center;
}

/* Make player header larger too */
.player-header {
    font-weight: bold;
    font-size: 20px; /* Larger font */
    margin-bottom: 20px; /* More spacing */
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

/* Bank column styles */
.bank-header {
    background-color: #8b4513;
    color: white;
}

.bank-cell {
    font-weight: bold;
    background-color: #fff8e7;
}

.bank-empty {
    color: #ff0000;
    background-color: #ffeeee;
}

.bank-low {
    color: #ff6600;
    background-color: #fff5ee;
}

.farm-animals-table-container {
    width: 100%;
    overflow-x: auto;
}

.farm-animals-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.farm-animals-table th,
.farm-animals-table td {
    padding: 6px 5px;
    text-align: center;
    border: 1px solid #eee;
}

.farm-animals-table th {
    background-color: #6b8e23;
    color: white;
    font-weight: bold;
}

.farm-animals-table th:first-child {
    text-align: left;
}

.farm-animals-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.farm-animals-table tr:hover {
    background-color: #f0f8ff;
}

.farm-animals-table .animal-name-cell {
    display: flex;
    gap: 0px;
    text-align: left;
}

.farm-animals-table .animal-emoji {
    font-size: 24px;
}

.current-player-header, .current-player-cell {
    background-color: #f0f8e0;
    font-weight: bold;
}

/* Remove these styles */
.current-turn-header, .current-turn-cell {
    border-left: 3px solid #6b8e23;
}

/* Keep other styles */
/* Add these styles for the turn timer */
.turn-timer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    background-color: transparent;
    display: flex;
    flex-direction: column;  /* Stack elements vertically */
    align-items: center;
    gap: 4px;
}

.turn-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
}

#roll-dice-btn {
    width: auto;
    min-width: 60px;
    padding: 8px 16px;
    background-color: rgba(107, 142, 35, 0.1) !important; /* Very light olive background */
    color: #6b8e23;
    border: 2px solid #6b8e23;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Subtle shadow */
}

#roll-dice-btn:hover:not(:disabled) {
    background-color: rgba(107, 142, 35, 0.2) !important; /* Slightly darker on hover */
    transform: translateY(-1px); /* Slight lift effect */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); /* Enhanced shadow on hover */
}

#roll-dice-btn:active:not(:disabled) {
    transform: translateY(1px); /* Press effect */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); /* Reduced shadow when pressed */
}

#roll-dice-btn:disabled {
    background-color: rgba(107, 142, 35, 0.05) !important;
    border-color: rgba(107, 142, 35, 0.4);
    color: rgba(107, 142, 35, 0.4);
    cursor: not-allowed;
    box-shadow: none;
}

.current-roller {
    margin: 0;
    font-size: 14px;
    color: #666;
    text-align: center;
}

/* Make timer circle slightly smaller to fit better */
.timer-circle {
    position: relative;
    width: 80px;
    height: 80px;
    background-color: rgba(255, 255, 255, 0.4); /* Changed from solid white to semi-transparent */
    border-radius: 50%;
    backdrop-filter: blur(4px); /* Add blur effect for better visibility */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* Add subtle shadow for depth */
    animation: subtle-pulse 1.5s infinite ease-in-out;
}

.timer-circle-inner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    background-color: rgba(255, 255, 255, 0.4); /* Add semi-transparent background */
    border-radius: 50%; /* Keep it circular */
}

#timer-count {
    font-size: 28px;
    font-weight: bold;
    color: #333;
}

.timer-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-circle-bg {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 8;
}

.timer-circle-progress {
    fill: none;
    stroke: #6b8e23;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.1s linear;
}

/* Add a pulsing animation for the last 3 seconds */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.timer-urgent {
    animation: pulse 0.5s infinite;
}

.timer-urgent #timer-count {
    color: #d9534f;
}

.timer-urgent .timer-circle-progress {
    stroke: #d9534f;
}

/* Add these styles for different player timers */
.timer-other-player .timer-circle-progress {
    stroke: #4a6eb0; /* Blue for other human players */
}

.timer-other-player #timer-count {
    color: #4a6eb0;
}

.timer-ai-player .timer-circle-progress {
    stroke: #d9534f; /* Red for AI players */
}

.timer-ai-player #timer-count {
    color: #d9534f;
}

/* When timer is urgent for other players */
.timer-other-player.timer-urgent .timer-circle-progress {
    stroke: #4a6eb0;
}

.timer-ai-player.timer-urgent .timer-circle-progress {
    stroke: #d9534f;
}

/* Add pulsing animation for roll button and timer circle */
@keyframes subtle-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* Apply animation to the roll button when enabled */
#roll-dice-btn:not(:disabled) {
    animation: subtle-pulse 1.5s infinite ease-in-out;
}

/* Make the urgent animation more pronounced than the regular pulse */
.timer-urgent {
    animation: pulse 0.5s infinite;
}

/* Footer styles */
.game-footer {
    margin-top: 30px;
    padding: 15px 0;
    text-align: center;
    border-top: 1px solid #ddd;
    font-size: 14px;
    color: #666;
}

.game-footer a {
    color: #4a8522;
    text-decoration: none;
}

.game-footer a:hover {
    text-decoration: underline;
}

.copyright {
    margin-top: 5px;
    font-size: 12px;
}

/* QR Code styles */
.qr-code-container {
    margin: 20px auto;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 8px;
    text-align: center;
    max-width: 250px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
}

.qr-code-container h4 {
    margin-top: 0;
    color: #6b8e23;
    font-size: 16px;
    margin-bottom: 10px;
}

.qr-image {
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
}

.qr-image img {
    display: block; /* Ensure the QR code image is displayed correctly */
    border: 1px solid #e0e0e0;
}

.game-url-display {
    margin-top: 12px;
    font-size: 13px;
    color: #555;
    word-break: break-all;
    padding: 0 5px;
}

.game-url-text {
    display: block;
    padding: 5px;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 11px;
    color: #666;
    font-family: monospace;
}

/* Make the QR code container responsive */
@media (max-width: 480px) {
    .qr-code-container {
        max-width: 90%;
    }
}