/* Animal Chess Game Board and Component Styles */

/* Game Container */
.game-container {
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* Player Info */
.players-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 700px;
    margin-bottom: 5px;
}

.player-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    border-radius: 25px;
    background: rgba(0, 0, 0, 0.1);
    font-weight: bold;
}

.player-card.red-player {
    background: rgba(229, 115, 115, 0.2);
}

.player-card.blue-player {
    background: rgba(100, 181, 246, 0.2);
}

.player-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #333;
}

.player-color.red {
    background: #e57373;
}

.player-color.blue {
    background: #64b5f6;
}

/* Player name styling */
.player-card .player-name {
    transition: all 0.3s;
}

.player-card .player-name.disconnected {
    color: #e74c3c;
    font-style: italic;
    opacity: 0.7;
}

/* Score display removed for cleaner pill design */

/* Animal Chess Board */
.board-container {
    display: flex;
    justify-content: center;
    margin: 10px 0;
    position: relative;
    background: #2c3e50;
    border: 2px solid #2c3e50;
    border-radius: 10px;
    overflow: hidden;
    box-sizing: border-box;
}

.animal-chess-board {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 1px;
    background: #2c3e50;
    padding: 8px;
    border-radius: 6px;
    width: 420px;
    height: 540px;
    max-width: 95vw;
    max-height: 95vh;
}

.square {
    background: #DEB887;
    border: 1px solid #8B7355;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    aspect-ratio: 1;
    min-height: 0;
    min-width: 0;
}

.square:hover {
    box-shadow: inset 0 0 0 3px #F0E68C, inset 0 0 10px rgba(240, 230, 140, 0.5);
}

.square:hover::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    background: rgba(240, 230, 140, 0.3);
    border-radius: 2px;
    pointer-events: none;
    z-index: 1;
}

.square.possible-move:hover::after {
    width: 16px;
    height: 16px;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}

.square.possible-move:hover {
    box-shadow: inset 0 0 0 3px #4CAF50, inset 0 0 15px rgba(76, 175, 80, 0.5);
}

/* Special terrain squares */
.square.water {
    background: linear-gradient(135deg, #87CEEB, #4682B4);
    border-color: #4682B4;
}

.square.trap {
    border: 3px solid;
    background: radial-gradient(circle, rgba(255,255,255,0.3), transparent);
}

.square.red-trap {
    border-color: #e57373;
    background: radial-gradient(circle, rgba(229,115,115,0.3), #DEB887);
}

.square.blue-trap {
    border-color: #64b5f6;
    background: radial-gradient(circle, rgba(100,181,246,0.3), #DEB887);
}

.square.den {
    border: 6px solid;
    background: radial-gradient(circle, rgba(255,255,255,0.8), rgba(255,223,0,0.2));
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5), inset 0 0 20px rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: visible;
}

.square.den::before {
    content: '🏰';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    opacity: 0.4;
    z-index: 1;
    pointer-events: none;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.square.den::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 3px solid transparent;
    border-radius: 8px;
    background: linear-gradient(45deg, transparent 25%, rgba(255,255,255,0.3) 25%, rgba(255,255,255,0.3) 50%, transparent 50%, transparent 75%, rgba(255,255,255,0.3) 75%);
    background-size: 8px 8px;
    animation: den-shimmer 3s ease-in-out infinite;
    z-index: 0;
}

.square.red-den {
    border-color: #b71c1c;
    background: radial-gradient(circle, rgba(183,28,28,0.6), rgba(255,223,0,0.3), rgba(183,28,28,0.2));
    box-shadow: 0 0 20px rgba(183, 28, 28, 0.7), inset 0 0 25px rgba(255, 255, 255, 0.2);
}

.square.red-den::before {
    color: #b71c1c;
}

.square.blue-den {
    border-color: #0d47a1;
    background: radial-gradient(circle, rgba(13,71,161,0.6), rgba(255,223,0,0.3), rgba(13,71,161,0.2));
    box-shadow: 0 0 20px rgba(13, 71, 161, 0.7), inset 0 0 25px rgba(255, 255, 255, 0.2);
}

.square.blue-den::before {
    color: #0d47a1;
}

/* Den Hover Effects */
.square.den:hover {
    transform: scale(1.02);
    transition: all 0.3s ease;
}

.square.den:hover::before {
    font-size: 2.7rem;
    animation: den-pulse 0.8s ease-in-out infinite alternate;
    transition: font-size 0.3s ease;
}

.square.red-den:hover {
    box-shadow: 0 0 30px rgba(183, 28, 28, 0.9), inset 0 0 35px rgba(255, 255, 255, 0.3);
}

.square.blue-den:hover {
    box-shadow: 0 0 30px rgba(13, 71, 161, 0.9), inset 0 0 35px rgba(255, 255, 255, 0.3);
}

/* Den hover animation for rotated board */
.animal-chess-board.rotated-for-red .square.den:hover::before {
    transform: translate(-50%, -50%) rotate(180deg);
    font-size: 2.7rem;
    animation: den-pulse-rotated 0.8s ease-in-out infinite alternate;
}

/* Selection and move indicators */
.square.selected {
    box-shadow: inset 0 0 0 4px #FFD700, inset 0 0 15px rgba(255, 215, 0, 0.4), 0 0 15px rgba(255, 215, 0, 0.7);
    animation: glow 1s ease-in-out infinite alternate;
}

.square.selected::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    background: rgba(255, 215, 0, 0.2);
    border-radius: 2px;
    pointer-events: none;
    z-index: 1;
    animation: selected-inner-glow 1s ease-in-out infinite alternate;
}

@keyframes glow {
    from { 
        box-shadow: inset 0 0 0 4px #FFD700, inset 0 0 15px rgba(255, 215, 0, 0.4), 0 0 15px rgba(255, 215, 0, 0.7);
    }
    to { 
        box-shadow: inset 0 0 0 4px #FFA500, inset 0 0 25px rgba(255, 165, 0, 0.6), 0 0 25px rgba(255, 215, 0, 1);
    }
}

@keyframes selected-inner-glow {
    from { 
        background: rgba(255, 215, 0, 0.2);
    }
    to { 
        background: rgba(255, 165, 0, 0.3);
    }
}

@keyframes den-shimmer {
    0%, 100% {
        background-position: 0% 0%;
        opacity: 0.3;
    }
    50% {
        background-position: 100% 100%;
        opacity: 0.6;
    }
}

@keyframes den-pulse {
    0% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }
}

@keyframes den-pulse-rotated {
    0% {
        opacity: 0.6;
        transform: translate(-50%, -50%) rotate(180deg) scale(1);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(180deg) scale(1.05);
    }
}

.square.possible-move {
    box-shadow: inset 0 0 0 3px #4CAF50, inset 0 0 10px rgba(76, 175, 80, 0.3);
}

.square.possible-move::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    background: rgba(76, 175, 80, 0.4);
    border-radius: 2px;
    pointer-events: none;
    z-index: 1;
}

.square.possible-move::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
    z-index: 2;
    transition: all 0.2s ease;
}

/* Animal pieces */
.piece {
    font-size: 42px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    font-weight: bold;
    line-height: 1;
    z-index: 10;
}

.piece:hover {
    transform: scale(1.1);
    z-index: 20;
}

.red-piece {
    background: radial-gradient(circle, #ffcdd2, #e57373);
    border: 3px solid #c62828;
    color: #8b0000;
}

.blue-piece {
    background: radial-gradient(circle, #bbdefb, #64b5f6);
    border: 3px solid #1565c0;
    color: #0d47a1;
}

/* Board Rotation for Red Player */
.animal-chess-board.rotated-for-red {
    transform: rotate(180deg);
}

.animal-chess-board.rotated-for-red .piece {
    transform: rotate(180deg);
}

.animal-chess-board.rotated-for-red .piece:hover {
    transform: rotate(180deg) scale(1.1);
    z-index: 20;
}

.animal-chess-board.rotated-for-red .square.den::before {
    transform: translate(-50%, -50%) rotate(180deg);
}

/* Game Controls */
.game-controls {
    display: flex;
    gap: 15px;
    margin-top: 5px;
}

/* New Game Button States */
.btn.requested {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    animation: pulse 2s infinite;
}

.btn.pending {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: white;
    animation: glow 2s ease-in-out infinite alternate;
}

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

@keyframes glow {
    from { box-shadow: 0 0 5px rgba(39, 174, 96, 0.5); }
    to { box-shadow: 0 0 20px rgba(39, 174, 96, 0.8); }
}

/* Game Messages */
.game-messages {
    max-height: 150px;
    overflow-y: auto;
    padding: 8px 15px;
    background: #f8f9fa;
    border-radius: 10px;
    margin: 8px 15px;
}

.game-message {
    padding: 5px 0;
    border-bottom: 1px solid #dee2e6;
}

.game-message:last-child {
    border-bottom: none;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.8rem;
}

.modal-content p {
    color: #34495e;
    margin-bottom: 25px;
    font-size: 1.1rem;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Enhanced modal styles for winner/loser */
.modal-content.winner {
    background: linear-gradient(135deg, #fff, #f8f9fa);
    border: 3px solid #28a745;
    position: relative;
    overflow: hidden;
}

.modal-content.winner::before {
    content: '🏆';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 3rem;
    opacity: 0.3;
    animation: winner-pulse 2s ease-in-out infinite;
}

.modal-content.loser {
    background: linear-gradient(135deg, #fff, #f8f9fa);
    border: 3px solid #6c757d;
    position: relative;
}

.modal-content.loser::before {
    content: '💪';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 2.5rem;
    opacity: 0.3;
    animation: motivate-pulse 2s ease-in-out infinite;
}

.winner-title {
    color: #28a745 !important;
    text-shadow: 2px 2px 4px rgba(40, 167, 69, 0.3);
    animation: winner-glow 2s ease-in-out infinite, winner-bounce 0.6s ease-in-out 3;
}

@keyframes winner-bounce {
    0%, 100% { 
        transform: translateY(0) scale(1);
    }
    50% { 
        transform: translateY(-10px) scale(1.1);
    }
}

.loser-title {
    color: #6c757d !important;
    text-shadow: 1px 1px 2px rgba(108, 117, 125, 0.3);
}

.consolation-message {
    color: #495057;
    font-style: italic;
    font-weight: 600;
    margin-top: 10px;
    padding: 10px;
    background: rgba(108, 117, 125, 0.1);
    border-radius: 8px;
    border-left: 4px solid #6c757d;
}

@keyframes winner-pulse {
    0%, 100% { 
        transform: scale(1) rotate(0deg);
        opacity: 0.3;
    }
    50% { 
        transform: scale(1.2) rotate(10deg);
        opacity: 0.5;
    }
}

@keyframes motivate-pulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 0.3;
    }
    50% { 
        transform: scale(1.1);
        opacity: 0.5;
    }
}

@keyframes winner-glow {
    0%, 100% { 
        text-shadow: 2px 2px 4px rgba(40, 167, 69, 0.3);
    }
    50% { 
        text-shadow: 2px 2px 8px rgba(40, 167, 69, 0.6), 0 0 10px rgba(40, 167, 69, 0.4);
    }
}

/* Turn Order Modal */
.turn-order-modal {
    max-width: 500px;
    padding: 40px;
}

.turn-order-modal h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 2rem;
}

.turn-order-modal p {
    color: #7f8c8d;
    margin-bottom: 30px;
    font-size: 1.2rem;
}

.turn-order-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.turn-option {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    transition: all 0.3s ease;
    cursor: pointer;
    text-align: left;
    min-height: 80px;
    color: #2c3e50;
}

.turn-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-color: #3498db;
}

.turn-option.btn-primary:hover {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border-color: #2980b9;
}

.turn-option.btn-secondary:hover {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    color: white;
    border-color: #7f8c8d;
}

.turn-option-icon {
    font-size: 2rem;
    flex-shrink: 0;
    color: #34495e;
}

.turn-option-text {
    font-size: 1.3rem;
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
    color: #2c3e50;
}

.turn-option-desc {
    font-size: 0.95rem;
    opacity: 0.9;
    display: block;
    color: #34495e;
}

.turn-option:hover .turn-option-text,
.turn-option:hover .turn-option-desc {
    color: inherit;
}

/* Focus and active states for better accessibility */
.turn-option:focus {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

.turn-option:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Disabled state styling */
.turn-option:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.turn-option:disabled:hover {
    transform: none;
    box-shadow: none;
    border-color: transparent;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.turn-option:disabled .turn-option-text,
.turn-option:disabled .turn-option-desc,
.turn-option:disabled .turn-option-icon {
    color: #7f8c8d;
}

/* Rules Modal */
.rules-modal {
    max-width: 600px;
}

.rules-content {
    text-align: left;
    max-height: 60vh;
    overflow-y: auto;
}

.rules-content h3 {
    color: #4CAF50;
    margin: 20px 0 10px 0;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 5px;
}

.rules-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.rules-content li {
    margin: 8px 0;
    line-height: 1.5;
}

.animal-hierarchy {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 15px 0;
}

.animal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #4CAF50;
}

.animal-icon {
    font-size: 1.5rem;
}

/* Confetti Animation */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0.8;
    animation: confetti-fall linear forwards;
}

.confetti-piece:nth-child(odd) {
    background: #ff6b6b;
    transform: rotate(45deg);
}

.confetti-piece:nth-child(even) {
    background: #4ecdc4;
    border-radius: 50%;
}

.confetti-piece:nth-child(3n) {
    background: #45b7d1;
    transform: rotate(90deg);
}

.confetti-piece:nth-child(4n) {
    background: #f9ca24;
    border-radius: 50%;
}

.confetti-piece:nth-child(5n) {
    background: #f0932b;
    transform: rotate(135deg);
}

.confetti-piece:nth-child(6n) {
    background: #eb4d4b;
    border-radius: 50%;
}

.confetti-piece:nth-child(7n) {
    background: #6c5ce7;
    transform: rotate(180deg);
}

.confetti-piece:nth-child(8n) {
    background: #a29bfe;
    border-radius: 50%;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }
    
    .players-info {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    .player-card {
        width: 100%;
        max-width: 300px;
    }
    
    .board-container {
        width: auto;
        height: auto;
    }
    
    .animal-chess-board {
        width: 350px;
        height: 450px;
        max-width: 90vw;
        max-height: 90vh;
        gap: 1px;
    }
    
    .square {
        aspect-ratio: 1;
        min-height: 0;
        min-width: 0;
    }
    
    .piece {
        font-size: 32px;
    }
    
    .game-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .modal-content {
        padding: 20px;
        margin: 20px;
    }
    
    /* Mobile responsiveness for turn order modal */
    .turn-order-modal {
        max-width: 90%;
        padding: 30px 20px;
    }

    .turn-order-modal h2 {
        font-size: 1.7rem;
    }

    .turn-order-options {
        gap: 10px;
    }
    
    .turn-option {
        min-height: 70px;
        padding: 15px;
        gap: 12px;
        color: #2c3e50;
    }

    .turn-option-icon {
        font-size: 1.8rem;
        color: #34495e;
    }

    .turn-option-text {
        font-size: 1.1rem;
        color: #2c3e50;
    }

    .turn-option-desc {
        font-size: 0.9rem;
        color: #34495e;
    }
    
    .animal-hierarchy {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .board-container {
        width: auto;
        height: auto;
    }
    
    .animal-chess-board {
        width: 262px;
        height: 338px;
        max-width: 85vw;
        max-height: 85vh;
        gap: 1px;
    }
    
    .square {
        aspect-ratio: 1;
        min-height: 0;
        min-width: 0;
    }
    
    .piece {
        font-size: 26px;
    }
    
    .modal-content {
        padding: 15px;
        margin: 10px;
    }
    
    .modal-content h2 {
        font-size: 1.4rem;
    }
    
    .game-controls .btn {
        width: 100%;
    }
}