/* --- Google Fonts Import (already linked in HTML) --- */

/* --- Variables (Easy to change colors later) --- */
:root {
    --bg-dark: #2c3e50; /* Dark blue-grey */
    --bg-medium: #34495e; /* Slightly lighter blue-grey */
    --text-light: #ecf0f1; /* Light grey/off-white */
    --text-dark: #2c3e50; /* Dark text for light backgrounds */
    --accent-primary: #1abc9c; /* Teal */
    --accent-secondary: #16a085; /* Darker Teal */
    --accent-warn: #e74c3c; /* Red */
    --accent-info: #3498db; /* Blue */
    --tile-revealed-bg: #7f8c8d; /* Grey for revealed */
    --font-headings: 'Poppins', sans-serif;
    --font-body: 'Roboto', sans-serif;
    --shadow-light: 0 3px 6px rgba(0, 0, 0, 0.16);
    --shadow-medium: 0 5px 10px rgba(0, 0, 0, 0.2);
}

/* --- General Reset & Body Styles --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    color: var(--text-light);
    line-height: 1.6;
    padding: 20px;
}

h1, h2, h3 {
    font-family: var(--font-headings);
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 0.8em;
    text-align: center;
}

h1 {
    font-size: 2.5em;
    margin-bottom: 1em;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

h2 {
    font-size: 1.8em;
}

label {
     font-weight: bold;
     color: var(--text-light);
}

small {
    color: #bdc3c7; /* Lighter grey for hints */
}

/* --- Screen Styles --- */
.screen {
    display: none; /* Hidden by default */
    background-color: var(--bg-medium);
    padding: 30px 40px;
    margin: 30px auto;
    border-radius: 12px;
    box-shadow: var(--shadow-medium);
    max-width: 800px; /* Slightly wider */
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.screen.active {
    display: block;
    /* Add a subtle fade-in */
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Setup Screen Specific Styles --- */
#setup-screen div {
    margin-bottom: 20px;
    display: flex; /* Use flex for better alignment */
    flex-wrap: wrap; /* Allow wrapping */
    align-items: center;
    gap: 10px; /* Space between label and input/stepper */
}

#setup-screen label {
    flex-basis: 200px; /* Fixed width for labels */
    flex-shrink: 0; /* Prevent label from shrinking */
    text-align: right;
    margin-right: 10px;
    align-self: center; /* Vertically center label with input/stepper */
}

/* General styling for number/text inputs in setup */
#setup-screen input[type="number"],
#setup-screen input[type="text"] {
    padding: 10px 12px;
    border: 1px solid #7f8c8d; /* Grey border */
    background-color: var(--bg-dark); /* Dark background for inputs */
    color: var(--text-light); /* Light text */
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 1em;
    flex-grow: 1; /* Allow input to take remaining space */
    max-width: 250px; /* Limit max width */
}

/* Style for the read-only player count input within stepper */
#setup-screen .number-input-stepper input[type="number"]#player-count {
    text-align: center;
    font-weight: bold;
    width: 50px; /* Fixed width for the number display */
    padding: 10px 5px; /* Adjust padding */
    -webkit-appearance: none; margin: 0; -moz-appearance: textfield; /* Remove spinners */
    background-color: var(--bg-medium); /* Make it look less like an active input */
    border: 1px solid var(--bg-dark);
    flex-grow: 0; /* Don't allow it to grow */
}

/* Max shots & Initial Alts inputs specific width */
#setup-screen input#max-shots,
#setup-screen input#initial-alts {
    max-width: 100px; /* Make these inputs smaller */
    flex-grow: 0; /* Prevent growing */
}


/* Container for dynamically added player names */
#player-names-container {
     display: flex;
     flex-direction: column;
     gap: 10px; /* Space between name input rows */
     width: 100%; /* Take full width within its parent */
     margin-bottom: 20px; /* Consistent margin */
}
/* Wrapper for each Label + Input pair */
#player-names-container > div {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%; /* Make wrapper take full width if needed */
}

/* Style the labels within the dynamic container */
#player-names-container label.player-label {
    flex-basis: 200px; /* Match other labels */
    flex-shrink: 0;
    text-align: right;
    margin-right: 10px;
    font-weight: bold;
    color: var(--text-light);
    align-self: center;
}
/* Style the input fields within the dynamic container */
#player-names-container input[type="text"] {
    padding: 10px 12px;
    border: 1px solid #7f8c8d;
    background-color: var(--bg-dark);
    color: var(--text-light);
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 1em;
    max-width: 300px; /* Wider for names */
    flex-grow: 1; /* Allow input to grow */
    width: auto; /* Let flexbox determine width */
    /* margin-left: 210px; /* Remove fixed margin, rely on flex gap */
}


/* --- Input Stepper Styles --- */
.number-input-stepper {
    display: flex;
    align-items: center;
    gap: 5px; /* Space between buttons and input */
    flex-grow: 0; /* Do not allow the stepper itself to grow */
    justify-content: flex-start; /* Align items to start (usually left) */
}

.stepper-btn {
    background-color: var(--accent-primary);
    color: white; border: none; padding: 8px 12px; font-size: 1.1em;
    line-height: 1; border-radius: 6px; cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    font-weight: bold; appearance: none; margin: 0; display: inline-flex;
    justify-content: center; align-items: center; min-width: 40px;
}
.stepper-btn:hover { background-color: var(--accent-secondary); }
.stepper-btn:disabled { background-color: var(--bg-medium); color: var(--tile-revealed-bg); cursor: not-allowed; opacity: 0.6; }


/* --- Button Styles --- */
/* General Buttons (Start Game, Play Again) */
button#start-game-btn, button#play-again-btn {
    background-color: var(--accent-primary); color: white; padding: 12px 25px; border: none;
    border-radius: 25px; cursor: pointer; font-size: 1.1em; font-family: var(--font-headings);
    font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    display: block; margin: 25px auto 10px auto; box-shadow: var(--shadow-light);
}
button#start-game-btn:hover, button#play-again-btn:hover {
    background-color: var(--accent-secondary); transform: translateY(-2px); box-shadow: var(--shadow-medium); }
button#start-game-btn:active, button#play-again-btn:active { transform: translateY(0px); box-shadow: var(--shadow-light); }
#play-again-btn { background-color: var(--accent-warn); }
#play-again-btn:hover { background-color: #c0392b; }

/* Secondary Button (How to Play) */
.secondary-btn {
    background-color: var(--bg-medium); color: var(--text-light); border: 2px solid var(--accent-primary);
    padding: 10px 20px; border-radius: 25px; cursor: pointer; font-size: 1em;
    font-family: var(--font-headings); font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
    display: block; margin: 15px auto 10px auto; box-shadow: none;
}
.secondary-btn:hover { background-color: var(--accent-primary); color: white; transform: translateY(-1px); }


/* --- Game Screen Styles --- */
#turn-indicator {
    font-size: 1.6em; font-weight: 700; margin-bottom: 25px; color: var(--text-light);
    text-align: center; padding: 10px; background-color: rgba(0,0,0,0.1); border-radius: 8px;
}
#turn-indicator span { color: var(--accent-primary); font-weight: 700; }

#player-info-container { display: flex; flex-wrap: wrap; justify-content: center; gap: 15px; margin-bottom: 30px; }

.player-info {
    background-color: var(--bg-dark); padding: 12px 18px; border-radius: 8px; border: 1px solid var(--bg-medium);
    min-width: 150px; text-align: center; box-shadow: var(--shadow-light); transition: all 0.3s ease;
}
.player-info-name { font-weight: bold; display: block; margin-bottom: 4px; color: var(--text-light); }
.player-info-shots { font-size: 0.9em; color: #bdc3c7; display: block; /* Put on new line */ margin-bottom: 4px;}
.player-info-alts { font-size: 0.9em; color: var(--accent-info); display: block;} /* Style for Alts Left (NEW) */
.player-info-status { font-size: 0.8em; font-weight: bold; margin-left: 5px; display: inline; /* Keep status inline */ }
.player-info-status.immune { color: var(--accent-info); }
.player-info-status.out { color: var(--accent-warn); }


.player-info.current-player {
    background-color: var(--accent-primary); border-color: var(--accent-secondary); transform: scale(1.05);
}
.player-info.current-player .player-info-name,
.player-info.current-player .player-info-shots,
.player-info.current-player .player-info-alts { color: white; } /* Make alts text white too */
.player-info.current-player .player-info-status.immune { color: #2980b9; } /* Darker blue on teal */

.player-info.player-out { opacity: 0.5; background-color: var(--bg-medium); border-color: var(--bg-dark); }
.player-info.player-out.current-player { transform: none; background-color: var(--bg-medium); border-color: var(--bg-dark); }
.player-info.player-out .player-info-name { color: var(--text-light); }
.player-info.player-out .player-info-shots { color: #bdc3c7; }
.player-info.player-out .player-info-alts { color: var(--accent-info); } /* Keep alts color consistent when out */


/* --- Tile Grid & Tile Styles --- */
#tile-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 12px;
    margin: 20px auto; max-width: 900px; padding: 15px; background-color: rgba(0,0,0,0.1); border-radius: 8px;
}
.tile {
    aspect-ratio: 1 / 1; background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white; display: flex; justify-content: center; align-items: center; font-family: var(--font-headings);
    font-size: 2em; font-weight: 700; border-radius: 8px; cursor: pointer; box-shadow: var(--shadow-light);
    position: relative; transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    user-select: none; -webkit-user-select: none; -moz-user-select: none;
}
.tile:not(.revealed):hover { transform: scale(1.08); box-shadow: var(--shadow-medium); }

/* --- Tile Reveal Animation --- */
.tile.revealed {
    cursor: default; transform: rotateY(180deg); transition: transform 0.6s ease, background-color 0.6s ease, color 0.6s ease;
    background: var(--tile-revealed-bg); color: var(--text-light); font-family: var(--font-body); font-size: 0.8em;
    font-weight: bold; padding: 8px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.3); line-height: 1.3;
    display: flex; justify-content: center; align-items: center; text-align: center;
}
.tile.reveal-animation { transform: rotateY(180deg); }
.tile.revealed span { display: inline-block; transform: rotateY(180deg); }
.tile.revealed:hover { transform: rotateY(180deg) scale(1.02); box-shadow: inset 0 2px 4px rgba(0,0,0,0.3); }


/* --- Action Display Area --- */
#action-display {
    min-height: 50px; margin: 30px auto; padding: 15px 20px; background-color: var(--bg-medium);
    border: 1px solid var(--accent-primary); border-left-width: 5px; border-radius: 6px; font-size: 1.2em;
    font-weight: normal; color: var(--text-light); text-align: center; max-width: 700px; box-shadow: var(--shadow-light);
}

/* --- Game Over Screen Styles --- */
#game-over-screen { text-align: center; }
#results {
    margin-top: 20px; padding: 20px; background-color: var(--bg-dark); border: 1px solid var(--bg-medium);
    border-radius: 8px; text-align: left; font-size: 1.1em; box-shadow: var(--shadow-light);
}
#results h3 { color: var(--accent-secondary); text-align: left; margin-bottom: 1em; }
#results span { color: var(--accent-primary); font-weight: bold; }
#results p { margin-bottom: 0.6em; line-height: 1.4; }
#results .player-info-status.out { color: var(--accent-warn); font-size: 0.9em; font-weight: bold; margin-left: 5px; }
/* Style for showing alts left in results */
#results .alts-left-results { font-size: 0.85em; color: #bdc3c7; margin-left: 10px; }


/* --- Modal Styles (General) --- */
.modal {
    display: none; position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%;
    overflow: auto; background-color: rgba(0, 0, 0, 0.75); animation: fadeInModal 0.3s ease-out;
}
@keyframes fadeInModal { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
    background-color: var(--bg-medium); margin: 10% auto; padding: 30px; border: 1px solid var(--accent-primary);
    width: 90%; max-width: 500px; border-radius: 10px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    position: relative; color: var(--text-light); animation: slideInModal 0.4s ease-out;
}
@keyframes slideInModal { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.close-btn {
    color: #aaa; position: absolute; top: 10px; right: 20px; font-size: 32px; font-weight: bold;
    line-height: 1; padding: 0; background: none; border: none; cursor: pointer;
}
.close-btn:hover, .close-btn:focus { color: var(--text-light); text-decoration: none; }

/* --- Choice Modal Specifics --- */
.choice-modal-content #modal-text { margin-bottom: 20px; font-size: 1.2em; text-align: center; }
.choice-modal-content #modal-options { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.choice-modal-content #modal-options button {
    width: 80%; margin: 5px 0; padding: 10px 15px; font-size: 1em; background-color: var(--accent-info);
    color: white; border: none; border-radius: 20px; cursor: pointer; font-family: var(--font-headings);
    font-weight: 600; text-transform: uppercase; letter-spacing: 1px; transition: background-color 0.2s ease, transform 0.1s ease;
}
.choice-modal-content #modal-options button:hover { background-color: #2980b9; transform: translateY(-1px); }
.choice-modal-content #modal-options button[style*="--accent-secondary"] { background-color: var(--accent-secondary); }
.choice-modal-content #modal-options button[style*="--accent-secondary"]:hover { background-color: var(--accent-primary); }
.choice-modal-content #modal-options button[style*="--accent-warn"] { background-color: var(--accent-warn); }
.choice-modal-content #modal-options button[style*="--accent-warn"]:hover { background-color: #c0392b; }


/* --- Rules Modal Specifics --- */
.rules-modal-content { max-width: 700px; margin: 5% auto; }
#rules-content { max-height: 70vh; overflow-y: auto; text-align: left; padding-right: 15px; margin-top: 15px; }
#rules-content h3 { color: var(--accent-secondary); margin-top: 1.5em; margin-bottom: 0.5em; text-align: left; font-size: 1.3em; border-bottom: 1px solid var(--bg-dark); padding-bottom: 0.3em; }
#rules-content h3:first-of-type { margin-top: 0.5em; }
#rules-content p, #rules-content li { margin-bottom: 0.8em; line-height: 1.5; color: var(--text-light); }
#rules-content ul, #rules-content ol { margin-left: 25px; margin-bottom: 1em; }
#rules-content ul ul, #rules-content ol ol { margin-left: 20px; margin-bottom: 0.5em; }
#rules-content strong { color: var(--accent-primary); font-weight: 600; }
#rules-content code { background-color: var(--bg-dark); padding: 2px 5px; border-radius: 4px; font-family: monospace; color: var(--accent-secondary); }
#rules-content em { font-style: italic; color: #bdc3c7; }


/* --- Responsiveness --- */
@media (max-width: 768px) {
    h1 { font-size: 2em; } h2 { font-size: 1.5em; }
    .screen { padding: 20px; }
    #setup-screen label { flex-basis: 100px; text-align: left; margin-right: 5px; }
    #setup-screen input[type="number"]:not(#player-count), #setup-screen input[type="text"] { max-width: none; flex-grow: 1; }
    .number-input-stepper { max-width: 160px; flex-grow: 0; }
    #setup-screen .number-input-stepper input[type="number"]#player-count { width: 45px; }
    .stepper-btn { padding: 10px 14px; }
    #player-names-container label.player-label { flex-basis: 100px; }
    #player-names-container input[type="text"] { margin-left: 0; /* Remove left margin, let wrapper handle spacing */ max-width: none; }
    #player-names-container > div { gap: 5px; /* Reduce gap in wrapper */ } /* Adjust gap in player name wrapper */

    #tile-grid { grid-template-columns: repeat(auto-fit, minmax(65px, 1fr)); gap: 8px; }
    .tile { font-size: 1.5em; } .tile.revealed { font-size: 0.65em; }
    #player-info-container { gap: 10px; } .player-info { min-width: 120px; padding: 8px 12px; }
    .modal-content { margin: 15% auto; width: 90%; padding: 20px; }
    .rules-modal-content { margin: 10% auto; } #rules-content { max-height: 75vh; }
    .choice-modal-content #modal-options button { width: 90%; }
}

@media (max-width: 480px) {
    body { padding: 10px; } .screen { padding: 15px; margin: 15px auto; } h1 { font-size: 1.8em; }
    #setup-screen div { flex-direction: column; align-items: stretch; gap: 5px; }
    #setup-screen label { text-align: left; margin-bottom: 3px; margin-right: 0; flex-basis: auto; width: 100%; }
    .number-input-stepper { justify-content: flex-start; margin-top: 5px; max-width: none; width: auto; flex-grow: 0; }
    #player-names-container { align-items: stretch; }
    #player-names-container > div { flex-direction: column; align-items: stretch; gap: 3px; } /* Stack label/input */
    #player-names-container label.player-label { display: none; } /* Hide label */
    #player-names-container input[type="text"] { margin-left: 0; width: 100%; max-width: none; }
    #setup-screen input#max-shots, #setup-screen input#initial-alts { max-width: 150px; /* Allow slightly wider */ }

    button#start-game-btn, button#play-again-btn, .secondary-btn { font-size: 1em; padding: 10px 20px; }
    .secondary-btn { padding: 8px 15px; }
    #tile-grid { grid-template-columns: repeat(auto-fit, minmax(55px, 1fr)); gap: 6px; }
    .tile { font-size: 1.2em; } #turn-indicator { font-size: 1.3em; } #action-display { font-size: 1em; padding: 10px; }
    .modal-content { margin: 20% auto; } .rules-modal-content { margin: 15% auto; }
}
