/* --- General Game & Tool Page Styles --- */

body, html {
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Added specificity */
.game-container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 2rem;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.game-header, .tools-header { /* tools-header likely not needed here, but kept for consistency */
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

.game-header h1, .tools-header h1 {
    color: #333;
    margin-bottom: 0.5rem;
}

.game-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 1rem;
}

/* Added specificity - Apply btn styles within game context */
.game-container .btn {
    display: inline-block;
    background: #007bff;
    color: #ffffff;
    padding: 10px 18px; /* Slightly larger buttons */
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 0 5px;
}

.game-container .btn:hover {
    background-color: #0056b3;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.game-container .btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.game-container .btn:disabled {
    background-color: #c0c0c0;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.game-message {
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
    min-height: 2em;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #eee;
}

/* --- Tool Card Styles (for tonys-time-traps.html specifically inside game-container) --- */
/* Added specificity */
.game-container .tool-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

/* --- Specific War Game Styles --- */
/* The general .card styles below conflict with the main styles.css */
/* We will only apply these specific styles within the .war-game context */

.war-game .game-board {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

/* On larger screens, show side-by-side */
@media (min-width: 768px) {
    .war-game .game-board {
        grid-template-columns: 1fr 1fr;
    }
}

.player-area {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.player-info {
    text-align: center;
    min-height: 100px; /* Increased space for stats */
    margin-bottom: 15px;
}

.player-info h2 {
    margin: 0 0 5px 0; /* Reduced bottom margin */
    color: #444;
}

.card-count {
    font-size: 1.1rem;
    color: #333;
    font-weight: bold;
    margin-bottom: 2px; /* Added spacing */
}

/* New "Cards Left" Stat Style */
.cards-left-stat {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px; /* Space before main stats */
}

/* New Stats Container */
.stats-container {
    display: flex;
    justify-content: center;
    gap: 10px; /* Reduced gap */
    margin-top: 5px; /* Reduced top margin */
    flex-wrap: wrap;
}

.stat-item {
    font-size: 0.85rem; /* Slightly smaller */
    color: #555;
    background: rgba(255, 255, 255, 0.6);
    padding: 2px 6px; /* Adjusted padding */
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    white-space: nowrap; /* Prevent wrapping */
}

/* --- Card Piles --- */
.deck-pile { /* Removed discard-pile-area */
    min-height: 140px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.play-pile-area {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 150px; /* Ensure space for staggered cards */
    gap: 10px;
    margin-bottom: 10px;
}

.card-pile {
    width: 100px;
    height: 140px;
    position: relative;
    border: 2px dashed #ccc;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Removed styles for .card-pile.discard and .discard-pile-area .card */

/* Updated War Pile styles */
.war-pile {
    width: 180px; /* Widen to show staggered cards */
    height: 140px;
    position: relative;
    margin-top: 0; /* Align with play pile */
}

.war-pile .card { /* Apply card styles only within war-pile for this context */
    position: absolute;
    top: 0;
    left: 0;
    /* Copied necessary card styles here */
    width: 100px;
    height: 140px;
    border-radius: 8px;
    background-color: #fff;
    border: 1px solid #aaa;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    font-weight: bold;
    user-select: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    padding: 5px 0;
    box-sizing: border-box;
}


/* --- Card Visuals (Updated) Specific to .war-game --- */
/* Added specificity .war-game */
.war-game .card {
    width: 100px;
    height: 140px;
    border-radius: 8px;
    background-color: #fff;
    border: 1px solid #aaa;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    font-weight: bold;
    user-select: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    padding: 5px 0;
    box-sizing: border-box;
    /* IMPORTANT: Reset styles inherited from general .card definition */
    padding: 5px 0; /* Keep game card padding */
    text-align: center; /* Keep game card text align */
    cursor: default; /* Game cards not clickable like tool cards */
}

/* Added specificity .war-game */
.war-game .card .card-value {
    font-size: 2.5rem; /* Main value size */
    line-height: 1.1;
    color: inherit; /* Ensure color is inherited from .red/.black */
    margin: 0; /* Reset margin */
}

/* Added specificity .war-game */
.war-game .card .card-suit {
    font-size: 1.8rem; /* Suit size */
    line-height: 1;
    color: inherit; /* Ensure color is inherited from .red/.black */
    margin: 0; /* Reset margin */
}

/* Added specificity .war-game */
.war-game .card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

/* Added specificity .war-game */
.war-game .card-back {
    background: linear-gradient(135deg, #0d6efd, #0d47a1);
    color: transparent; /* Hide text */
    position: relative; /* For pseudo-element */
    overflow: hidden;
}

/* Added specificity .war-game */
.war-game .card-back::after {
    content: '';
    position: absolute;
    width: 80%;
    height: 80%;
    border: 3px dashed rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Added specificity .war-game */
.war-game .card.red {
    color: #dc3545; /* Red */
}

/* Added specificity .war-game */
.war-game .card.black {
    color: #212529; /* Black */
}

/* Added specificity .war-game */
/* Highlight for Aces/Kings in war */
.war-game .card.highlight-power-card {
    box-shadow: 0 0 15px 5px #ffeb3b; /* Yellow glow */
    border: 2px solid #fbc02d;
    z-index: 100; /* Bring to front */
}

/* Green highlight for winning decision card */
.war-game .card.highlight-win {
    box-shadow: 0 0 15px 5px #4CAF50, 0 0 10px 3px rgba(0, 0, 0, 0.5); /* Green Glow */
    transform: scale(1.05);
    transition: all 0.2s ease-in-out;
}

/* Red highlight for losing decision card */
.war-game .card.highlight-lose {
    box-shadow: 0 0 15px 5px #F44336, 0 0 10px 3px rgba(0, 0, 0, 0.5); /* Red Glow */
    transform: scale(0.95);
    transition: all 0.2s ease-in-out;
}

/* --- Auto Play Button Style --- */
/* Added specificity .game-container */
.game-container #auto-play.playing {
    background-color: #dc3545; /* Red when active */
    border-color: #dc3545;
}

.game-container #auto-play.playing:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

/* --- Mobile View Adjustments --- */
/* Ensure these only apply within .war-game context */
@media (max-width: 767px) {
    
    .game-container { /* General padding adjustment is fine */
        padding: 1rem;
    }

    /* Request 1: Make player tiles smaller */
    .war-game .player-area {
        padding: 10px;
    }

    .war-game .player-info {
        min-height: 80px; /* Reduced min-height */
        margin-bottom: 10px;
    }

    /* Request 2: Flip Player 2's (Tony's) layout */
    .war-game #player-1-area {
        display: flex;
        flex-direction: column-reverse; /* This flips the order */
    }
    
    .war-game #player-1-area .player-info {
        margin-bottom: 0; /* Remove bottom margin */
        margin-top: 10px;   /* Add top margin to space it from cards */
    }

    /* --- Make cards 50% smaller --- */
    .war-game .card,
    .war-game .card-pile {
        width: 50px;
        height: 70px;
        /* Adjust border radius for smaller size if needed */
        border-radius: 4px;
    }

    .war-game .war-pile {
        width: 90px; /* 180px * 0.5 */
        height: 70px;
    }
    
    /* Adjust staggering for smaller war cards */
    .war-game .war-pile .card {
        width: 50px; /* Match smaller card size */
        height: 70px; /* Match smaller card size */
    }
    .war-game .war-pile .card:nth-child(1) { left: 0px; }
    .war-game .war-pile .card:nth-child(2) { left: 10px; } /* Adjust staggering */
    .war-game .war-pile .card:nth-child(3) { left: 20px; } /* Adjust staggering */
    .war-game .war-pile .card:nth-child(4) { left: 30px; } /* Adjust staggering */


    .war-game .deck-pile {
        min-height: 70px;
    }

    .war-game .play-pile-area {
        min-height: 75px;
    }

    .war-game .card .card-value {
        font-size: 1.25rem; /* 2.5rem * 0.5 */
    }

    .war-game .card .card-suit {
        font-size: 0.9rem; /* 1.8rem * 0.5 */
    }
    
    /* Adjust card back design for smaller size */
    .war-game .card-back::after {
        border-width: 2px;
        border-radius: 4px;
    }
}

/* --- NEW MODAL STYLES (for war_lobby.html) --- */

.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.6); /* Black w/ opacity */
}

.modal-content {
    background-color: #fefefe;
    color: #333; /* Darker text for readability */
    margin: 15% auto; /* 15% from the top and centered */
    padding: 30px;
    border: 1px solid #888;
    width: 80%; /* Could be more or less, depending on screen size */
    max-width: 500px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center; /* Center content inside */
}

.modal-content h2 {
    margin-top: 0;
    color: #007bff;
}

.modal-content p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.modal-content pre {
    background-color: #eee;
    padding: 15px;
    border-radius: 5px;
    text-align: left;
    white-space: pre-wrap; /* Wrap long lines */
    word-wrap: break-word; /* Break long words */
    margin-bottom: 1.5rem;
}

.modal-content .btn-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 1.5rem;
}

/* Modal buttons will use these styles */
.modal-content .btn {
     display: inline-block;
    background: #007bff;
    color: #ffffff;
    padding: 10px 18px; 
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 0 5px;
}
.modal-content .btn:hover {
    background-color: #0056b3;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

 .modal-content .btn-secondary {
    background-color: #6c757d;
 }
 .modal-content .btn-secondary:hover {
    background-color: #5a6268;
 }
/* --- Additions for War 2-Player --- */

/* Make secondary buttons (like speed) less prominent */
.game-container .btn-secondary {
    background-color: #6c757d;
}
.game-container .btn-secondary:hover {
    background-color: #5a6268;
}

/* Container for war pile cards */
#war-pile-container {
    width: 180px; /* Widen to show staggered cards */
    height: 140px;
    position: relative;
    margin-top: 0;
}

/* Style for cards inside the war pile container */
#war-pile-container .card {
    position: absolute;
    top: 0;
    left: 0;
    /* Copy of card styles from .war-game .card */
    width: 100px;
    height: 140px;
    border-radius: 8px;
    background-color: #fff;
    border: 1px solid #aaa;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    font-weight: bold;
    user-select: none;
    padding: 5px 0;
    box-sizing: border-box;
}

/* Ensure mobile styles also apply to new war pile container */
@media (max-width: 767px) {
    #war-pile-container {
        width: 90px; /* 180px * 0.5 */
        height: 70px;
    }
    
    #war-pile-container .card {
        width: 50px; /* Match smaller card size */
        height: 70px; /* Match smaller card size */
        border-radius: 4px;
    }
}
