/* --- Single Column Layout (Mobile-First) --- */
body {
    font-family: sans-serif;
    margin: 0;
    padding: 0;
}

.main-content {
    padding: 0.5rem;
    max-width: 800px; /* Constrain width on large monitors */
    margin: 0 auto; /* Center the column */
}

#game-container, #session-review-view {
    text-align: center;
}

/* New Game Header Styles */
#game-header {
    margin-bottom: 1rem;
}
#game-prompt {
    font-size: 2.5rem;
    margin: 0;
}
#round-counter {
    margin: 0.25rem 0 0 0;
    color: #666;
    font-size: 1.1rem;
}
.words-wrapper {
    display: flex;
    flex-direction: column; /* Stack words vertically */
    justify-content: center;
    align-items: center;
    margin: 1rem 0;
    position: relative; /* Needed for flash message positioning */
    width: 100%; /* Ensure wrapper takes full width in column layout */
}
.word-card {
    border: 2px solid #ccc;
    border-radius: 8px;
    padding: 2rem 1rem;
    margin: 0.5rem 0; /* Keep vertical margin, remove horizontal */
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    box-sizing: border-box; /* Ensure padding/border is inside the width */
    width: 100%; /* Make cards take full width in mobile/stacked view */
    transition: all 0.2s;
}
.word-card:hover {
    background-color: #f4f4f4;
}
.vs-divider {
    font-size: 1.5rem;
    color: #888;
    margin: 0.5rem 0;
}


#history-header h3 {
    margin: 0.5rem 0;
}

/* --- Path Container --- */
#path-stats-container {
    width: 100%;
    height: 150px; /* Fixed height */
    overflow-y: auto; /* Container will scroll */
    border-bottom: 2px solid #eee;
    background: #f9f9f9;
    margin-top: 1rem;
    box-sizing: border-box; /* Fixes width issue */
}
#path-list {
    list-style: none;
    padding-left: 1rem;
    margin: 0.5rem 0;
    text-align: left;
}
#path-list li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #555;
    padding-left: 1.2em; /* Create space for the icon */
    padding: 0.5rem 0 0.5rem 1.2em; /* Add padding on all sides */
    box-shadow: 0 1px 0 #eee; /* Use box-shadow for the bottom border */
}
#path-list .round-num {
    font-weight: bold;
    color: #333;
}
#path-list li b {
    color: inherit; /* Remove blue color, just be bold */
}


/* Quiz Path Styling */
.quiz-path-correct {
    /* Use a light green background for correct answers */
    background-color: #e6f4e6;
    border-color: #cce8cc;
}
.quiz-path-incorrect {
    /* Use a light red background for incorrect answers */
    background-color: #f9e6e6;
    border-color: #f2cccc;
}
.quiz-path-correct::before,
.quiz-path-incorrect::before {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: 0.3em; /* Space between icon and text */
    text-indent: -1.2em; /* Pull icon into the padding space */
    content: ''; /* Remove text content */
    background-size: contain;
    background-repeat: no-repeat;
    vertical-align: -0.15em; /* Nudge icon down slightly to prevent text clipping */
}
.quiz-path-correct::before { /* This selector is now generic */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2328a745'%3E%3Cpath d='M12.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L.22 8.28a.75.75 0 0 1 1.06-1.06L5 10.94l6.72-6.72a.75.75 0 0 1 1.06 0z'/%3E%3C/svg%3E"); /* Show checkmark */
}
.quiz-path-incorrect::before { /* This selector is now generic */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23dc3545'%3E%3Cpath d='M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.75.75 0 1 1 1.06 1.06L9.06 8l3.22 3.22a.75.75 0 1 1-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 0 1-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E"); /* Show X */
}

/* --- Active Filter Display Bar --- */
#active-filters-display {
    background-color: #e7f3fe; /* Light blue background */
    border: 1px solid #b3d7f7;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin: 1rem 0 0 0; /* Add margin top, remove bottom */
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}
/* When no filters are active, make the <p> tag grow to push the link to the right */
#active-filters-display p {
    flex-grow: 1;
    margin: 0; /* Remove default paragraph margin */
    text-align: left;
}
#active-filters-display a {
    cursor: pointer;
    font-weight: bold;
    color: #0066cc;
    text-decoration: none;
    white-space: nowrap; /* Prevent link from wrapping */
}
#active-filters-display a:hover {
    text-decoration: underline;
}

.filter-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-grow: 1;
}

.filter-pill {
    background-color: #fff;
    border: 1px solid #0066cc;
    color: #0066cc;
    border-radius: 15px;
    padding: 4px 8px 4px 12px;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
}

.remove-filter-btn {
    all: unset;
    cursor: pointer;
    margin-left: 6px;
    font-size: 1.2rem;
    line-height: 1;
    font-weight: bold;
}


/* --- Nav Buttons --- */
nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px; /* Increased gap */
    margin-top: 1rem;
}

/* --- Primary Button Class --- */
.btn-primary {
    font-size: 1rem;
    padding: 0.8rem 1rem; /* Standardized padding */
    cursor: pointer;
    flex-grow: 1;
    min-width: 150px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f0f0f0;
    font-weight: bold;
}
.btn-primary:hover {
    background-color: #e0e0e0;
}

/* Secondary button for things like "Cancel" */
.btn-secondary {
    all: unset;
    box-sizing: border-box;
    font-size: 1rem;
    padding: 0.8rem 1rem;
    cursor: pointer;
    border-radius: 5px;
    color: #333;
    background-color: transparent;
}
.btn-secondary:hover {
    background-color: #f0f0f0; /* Light grey background on hover */
    text-decoration: underline;
}

/* Apply to nav buttons */
nav button {
    all: unset; /* Remove default button styles */
    box-sizing: border-box; /* Include padding in width */
}
nav .btn-primary {
    margin: 0; /* Override old nav button margin */
}

/* Make secondary buttons in nav grow like primary ones */
nav .btn-secondary {
    flex-grow: 1;
}

/* --- Admin & History Controls --- */
#admin-controls {
    margin-top: 1rem;
    padding: 0.5rem;
    border: 1px dashed #ccc;
    border-radius: 4px;
    text-align: right;
}
#admin-controls label {
    margin-right: 0.5rem;
}

/* --- Other Elements --- */
#quiz-result {
    font-size: 1.2rem;
    font-weight: bold;
    padding: 1rem;
}
#quiz-result.correct { color: green; }
#quiz-result.incorrect { color: red; }

/* --- Flash Message for Quiz --- */
#flash-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 1rem 2rem;
    border-radius: 10px;
    color: white;
    font-size: 1.8rem;
    font-weight: bold;
    z-index: 10; /* Above the word cards */
    text-align: center;
}
#flash-message.correct {
    background-color: rgba(40, 167, 69, 0.85); /* Lighter, more transparent green */
}
#flash-message.incorrect {
    background-color: rgba(220, 53, 69, 0.85); /* Lighter, more transparent red */
}


.hidden {
    display: none;
}

/* --- Session Review Page Styles --- */
#session-review-view {
    text-align: left;
    max-width: 600px;
    margin: 1rem auto;
}
#session-review-path ul,
#review-modal-path ul {
    list-style: none;
    padding-left: 0;
}
#session-review-path li,
#review-modal-path li {
    font-size: 1.2rem;
    padding: 1rem;
    border-bottom: 1px solid #eee;
}
#session-review-path li b,
#review-modal-path li b {
    color: #0066cc; /* Highlight winner */
}

/* --- Stats Page Styles --- */
#stats-view {
    text-align: left;
    max-width: 700px;
    margin: 1rem auto;
}
#stats-view h3 {
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 0.5rem;
    margin-top: 2rem;
}
#stats-view ul {
    list-style: none;
    padding-left: 0;
}
#stats-view li {
    background: #f9f9f9;
    padding: 0.8rem;
    border-bottom: 1px solid #eee;
}
.stats-history-links {
    margin-top: 0.5rem;
}
.stats-history-links a {
    margin-right: 1rem;
    font-weight: bold;
    text-decoration: none;
    color: #0066cc;
}
.stats-history-links a:hover { text-decoration: underline; }

/* --- Modal Styles --- */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 100;
}
.modal-view {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 1.5rem 2rem;
    z-index: 101;
    min-width: 300px;
    width: 90vw;
    max-width: 500px;
    text-align: center;
    padding-top: 3rem; /* More space for X button */
}

/* Custom position for game-over modals */
.modal-view.modal-view-top {
    top: 15vh;
    transform: translate(-50%, 0);
}

/* Larger modal for session review */
.modal-view-lg {
    max-width: 700px;
}
#review-modal-path {
    max-height: 60vh;
    overflow-y: auto;
    text-align: left;
    margin-bottom: 1rem;
}
/* Make stats modal content align left like other pages */
#stats-view {
    max-height: 60vh;
    overflow-y: auto;
    text-align: left;
    margin-bottom: 1rem;
}

#category-filter-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
    max-height: 40vh;
    overflow-y: auto;
    border: 1px solid #f0f0f0;
    padding: 1rem;
    background: #f9f9f9;
    text-align: left;
    border-radius: 6px;
}
#category-filter-container label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

/* Controls for select/unselect all in category modal */
#category-select-all-controls {
    grid-column: 1 / -1; /* Make it span all columns in the grid */
    text-align: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}
#category-select-all-controls a {
    color: #666; /* More subtle grey color */
    font-size: 0.9rem;
}
.link-divider {
    color: #ccc;
    margin: 0 0.5rem;
}

/* --- Share Modal Styles --- */
.share-input-group {
    margin-bottom: 1rem;
    text-align: left;
}
.share-input-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}
.share-input-wrapper {
    display: flex;
    gap: 0.5rem;
}
.share-input-wrapper input {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 0.5rem;
    font-size: 0.9rem;
    background-color: #f9f9f9;
}
.share-input-wrapper button {
    flex-shrink: 0; /* Prevent button from shrinking */
    padding: 0.5rem 1rem;
}

/* --- Specific Modal Styles --- */

/* Game over modal winner text */
#game-over-winner-text {
    background-color: #e7f3fe; /* Light blue, matches filter bar */
    color: #0066cc; /* Darker blue text */
    padding: 0.5rem 1.5rem;
    border-radius: 20px; /* Pill shape */
    display: inline-block; /* To make padding and background work correctly */
    margin-top: 0.5rem;
    font-size: 1.8rem;
}

/* Standardize modal input fields */
.add-word-form,
#modal-body input[type="text"] {
    width: 100%;
    box-sizing: border-box;
}
.add-word-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#modal-body input {
    font-size: 1rem;
    padding: 0.8rem; /* Standardized padding */
    border: 1px solid #ccc;
    border-radius: 5px;
}

/* --- Close Button & Modal Form Styles --- */

.close-modal-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2rem; /* Standardized size */
    font-weight: bold;
    color: #888;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    padding: 0.5rem; /* Make it easier to click */
}
.close-modal-btn:hover {
    color: #000;
}

/* Modal footer button layout */
#modal-footer {
    margin-top: 1.5rem;
    display: flex;
    justify-content: stretch; /* Stretch buttons to fill width */
    gap: 10px;
}
/* Make buttons in the footer grow to fill space */
#modal-footer button {
    flex-grow: 1;
}

/* --- Media Queries for Responsiveness --- */

/* Desktop layout (side-by-side words) */
@media (min-width: 768px) {
    .words-wrapper {
        flex-direction: row; /* Words side-by-side */
        align-items: stretch; /* Make cards equal height */
    }

    .word-card {
        flex-grow: 1; /* Allow cards to grow and fill space */
        width: auto; /* Override the 100% width for side-by-side layout */
    }

    .vs-divider {
        margin: auto 1rem; /* Vertical center, horizontal margin */
    }
}

/* On desktop screens (when words are side-by-side), align content 1/3 down the page */
@media (min-width: 768px) {
    body {
        /* Use padding to push the content down. 15vh is a good starting point. */
        /* vh = viewport height unit */
        padding-top: 15vh;
    }
}