/* game.css */

/* Base Styles and Colors */
:root {
    --bg-color: #0f172a; 
    --primary-color: #14b8a6; 
    --accent-color: #f59e0b; 
    --danger-color: #ef4444; 
    --text-color: #e2e8f0; 
}

body {
    margin: 5px;
    height: 80vh; 
    display: flex;
    flex-direction: column;
    align-items: center;
    /* FIX: Back to space-evenly, but reduced padding */
    justify-content: space-evenly; 
    background: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-align: center;
    touch-action: manipulation; 
    transition: background 0.5s, box-shadow 0.1s;
    /* FIX: Very minimal padding, rely on internal margins */
    padding: 5px 0 5px 0; 
    box-sizing: border-box;
    overflow: hidden; /* FIX: Prevent scrolling */
}

/* --- Reveal Effects --- */

.flash-reveal {
    box-shadow: 0 0 30px 10px var(--primary-color) !important;
    background: linear-gradient(135deg, #14b8a6, #0f172a);
}
.flash-impostor {
    box-shadow: 0 0 30px 10px var(--danger-color) !important;
    background: linear-gradient(135deg, #ef4444, #0f172a);
}

/* --- Discussion Mode UI --- */

.discussion-mode {
    background: linear-gradient(135deg, #0f172a 0%, #374151 100%) !important;
    color: #fff;
}
.discussion-mode #display {
    font-size: 40px;
    color: var(--accent-color);
    text-transform: uppercase;
    animation: pulse 1.5s infinite;
}
.discussion-mode #actionBtn {
    background: var(--danger-color);
    color: #fff;
    animation: none !important; 
}

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

/* --- Action Button Animation --- */

.pulse-button {
    animation: buttonPulse 1.5s infinite;
}

.pulse-button.no-pulse {
    animation: none;
}

@keyframes buttonPulse {
    0% { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(20, 184, 166, 0); }
    100% { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0); }
}


/* --- Final Reveal UI --- */

.final-reveal {
    display: flex;
    flex-direction: column;
    /* FIX: Use space-between to push h2 and button content apart */
    justify-content: space-around; 
    align-items: center;
    text-align: center;
    flex-grow: 1; 
    width: 90%;
    /* FIX: Allow element to stretch between top/bottom boundaries of the flex container (body) */
    height: 100%; 
    max-height: 75vh; /* Max height to ensure it fits with other elements */
}
.final-reveal h2 {
    color: var(--accent-color);
    font-size: 30px;
    margin-bottom: 5px; /* Reduced margin */
    flex-shrink: 0;
}
.result-box {
    margin: 8px 0; /* Reduced margin */
    padding: 15px;
    border-radius: 10px;
    width: 100%;
    max-width: 300px;
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
}
.result-box span {
    display: block;
    font-size: 28px;
    margin-top: 5px;
    font-weight: 900;
}
.major {
    background: rgba(20, 184, 166, 0.2); 
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}
.minor {
    background: rgba(245, 158, 11, 0.2); 
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
}
.impostor-info {
    font-size: 20px;
    font-weight: bold;
    color: var(--danger-color);
    margin-top: 10px; /* Reduced margin */
    flex-shrink: 0;
}
.new-round-btn {
    background: var(--primary-color) !important;
    color: var(--bg-color) !important;
    animation: none !important;
}

/* --- Player Select Screen Adjustments --- */

h1 {
    font-size: 32px;
    /* FIX: Minimized margin for more vertical space */
    margin: 0 0 5px 0; 
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(20, 184, 166, 0.5);
    flex-shrink: 0;
}
p {
    /* FIX: Minimized margin for more vertical space */
    margin: 0 0 10px 0; 
    font-size: 16px;
    color: var(--text-color);
    flex-shrink: 0;
}
.player-select-grid {
    display: flex;
    flex-wrap: wrap; 
    justify-content: center;
    /* FIX: Reduced gap */
    gap: 10px; 
    /* Max-width remains the same for 3-column layout */
    max-width: 290px; 
    margin: 5px auto; /* Reduced margin */
    /* FIX: Crucial change - allow grid to take maximum possible space */
    flex-grow: 1; 
    align-items: center; 
    /* FIX: Allow its content to scroll if needed, but not the body */
    overflow-y: auto; 
    padding: 5px 0;
}
.player-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Card size remains same */
    width: 85px; 
    height: 85px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    flex-shrink: 0; /* Important to prevent shrinking in the flex container */
}
.player-card:hover {
    background: rgba(20, 184, 166, 0.2);
    border-color: var(--accent-color);
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}
.player-card:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.player-card-icon {
    font-size: 30px;
    margin-bottom: 5px;
    color: var(--accent-color);
}
.player-card-text {
    font-size: 14px; 
    font-weight: bold;
    color: var(--text-color);
}

/* --- Game Screen (General Elements) --- */

#display {
    font-size: 36px; 
    font-weight: 800;
    padding: 10px;
    min-height: 40px; 
    transition: opacity 0.3s, transform 0.3s;
    flex-shrink: 0; 
}
.img-box {
    width: 170px; 
    height: 170px;
    margin: 5px auto; 
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}
.img-box img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 12px;
    display: none;
    transition: transform 0.5s ease-out, opacity 0.5s;
    transform: rotateY(0deg);
}
.loader {
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid var(--primary-color);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    100% { transform: rotate(360deg); }
}
#actionBtn {
    margin: 5px 0 5px 0; 
    padding: 14px 28px; 
    font-size: 18px; 
    font-weight: bold;
    background: var(--primary-color);
    color: var(--bg-color);
    border: none;
    border-radius: 10px; 
    cursor: pointer;
    min-width: 240px; 
    transition: transform 0.1s ease-in-out, background 0.3s;
    flex-shrink: 0;
}
#actionBtn:active { transform: scale(0.97); }
#reset {
    position: absolute;
    top: 10px; 
    right: 10px; 
    background: var(--danger-color);
    color: #fff;
    padding: 5px 8px; 
    border: none;
    border-radius: 6px; 
    cursor: pointer;
    font-size: 12px; 
    transition: background 0.3s;
    z-index: 10;
}
.progress-container {
    width: 80%;
    max-width: 400px;
    height: 7px; 
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin-bottom: 5px; 
    flex-shrink: 0;
}
#progressBar {
    height: 100%;
    width: 0%;
    background: var(--accent-color);
    border-radius: 4px;
    transition: width 0.3s ease-out;
}