/* Base Styles - v1.0.8 */
.reset-confirm-dialog {
    width: min(420px, calc(100vw - 32px));
    margin: auto;
    padding: 24px;
    color: var(--light-text);
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.reset-confirm-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.reset-confirm-dialog h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    padding: 0;
}

.reset-confirm-actions {
    display: flex;
    gap: 12px;
}

.reset-confirm-actions button {
    flex: 1;
}

:root {
    /* Light Theme (Default) */
    --primary-color: hsl(var(--accent-hue, 218) 90% 61%);
    --secondary-color: hsl(var(--accent-hue, 218) 67% 54%);
    --accent-color: hsl(var(--accent-hue, 218) 92% 66%);
    --dark-bg: #ffffff; /* White */
    --darker-bg: #f9f9f9; /* Slightly off-white for hover */
    --light-text: #333333; /* Dark text */
    --medium-gray: #777777; /* Medium gray */
    --border-color: #e0e0e0; /* Light gray border */
    --success-color: #28a745; /* Success color */
    --warning-color: #ffc107; /* Warning color */
    --danger-color: #dc3545; /* Danger color */
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.05); /* Lighter shadow */
    --border-radius: 0px; /* No border radius for seamless design */
}

/* Dark Theme */
[data-theme="dark"] {
    --primary-color: hsl(var(--accent-hue, 218) 90% 61%);
    --secondary-color: hsl(var(--accent-hue, 218) 67% 54%);
    --accent-color: hsl(var(--accent-hue, 218) 92% 66%);
    --dark-bg: #1e1e1e; /* Slightly lighter dark for hover */
    --darker-bg: #121212; /* Dark background */
    --light-text: #ffffff; /* White text */
    --medium-gray: #999999; /* Medium gray */
    --border-color: #333333; /* Dark border */
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3); /* Darker shadow */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--darker-bg);
    color: var(--light-text);
    line-height: 1.6;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1, h2, h3 {
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

h1 {
    font-size: 2.2rem;
    color: var(--accent-color);
    letter-spacing: -0.5px;
}

h2 {
    font-size: 1.6rem;
    color: var(--light-text);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Left-align title specifically on daily/index page - REMOVED to allow general h2 centering */
/* #dailySection > h2 { 
    text-align: left; 
} */

/* Increase solve page title size */
#solvePuzzleTitle {
    font-size: 1.8rem; /* Increased from 1.6rem */
}


h3 {
    font-size: 1.2rem;
    color: var(--accent-color);
}

p {
    margin-bottom: 1rem;
}

/* Layout */
header {
    background-color: var(--dark-bg);
    padding: 0.8rem 1.5rem; /* Default padding */
    border-bottom: 1px solid var(--border-color); /* Line across where header ends */
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 800px; /* Reduced width */
    margin: 0 auto;
}

/* Authentication Styles */
.auth-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.auth-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: auto;
    height: auto;
}

.auth-btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-1px);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#userDisplay {
    color: var(--light-text);
    font-weight: 500;
    font-size: 0.9rem;
}

/* Admin Controls */
.admin-only {
    display: none;
}

.admin-controls {
    /* margin-top: 1rem; */ 
    padding: 15px; /* Restore padding for the overall panel */
    background-color: #f5f5f5; /* Restore background for the panel */
    border-radius: 8px; /* Restore border-radius for the panel */
    border: none; 
    /* display: flex; /* Remove flex from main container, header div will handle its items */
    /* gap: 0.5rem; */
    /* align-items: center; */
    position: relative; 
    z-index: 1010; /* Ensure admin panel is above login button */
}

/* Style for the header div within admin controls */
#dailyPuzzleAdminControls > div:first-child { /* This is the header div for the title */
    display: flex; /* Use flex to center the title easily */
    justify-content: center;
    align-items: center;
    margin-bottom: 5px; /* Keep small margin as per new HTML */
    width: 100%;
}

#adminPanelTitle { /* Target the h3 title specifically */
    color: var(--accent-color);
    margin: 0; 
    text-align: center; /* Ensure title text is centered */
    /* padding-right: 0; /* Remove padding related to absolute button */
    /* padding-left: 0; /* Remove padding related to absolute button */
}

/* Styling for the div containing the HIDE button */
#dailyPuzzleAdminControls > div:nth-child(2) { /* Targets the new div for the button */
    text-align: center;
    margin-bottom: 15px; /* Keep margin as per new HTML */
}

#toggleAdminControlsBtn { /* The HIDE button */
    /* Revert to standard button appearance, rely on .secondary-btn and inline styles */
    width: auto; /* Let content and padding define width */
    height: auto; /* Let content and padding define height */
    padding: 5px 15px; /* From inline style */
    border-radius: 20px; /* From inline style */
    /* background-color: var(--dark-bg); /* From .secondary-btn */
    /* border: 1px solid var(--border-color); /* From .secondary-btn */
    /* color: var(--light-text); /* From .secondary-btn */
    font-size: 1rem; /* Default button font size or adjust as needed */
    /* display: inline-block; /* Default for button or use flex if icon was present */
    /* align-items: center; */
    /* justify-content: center; */
    cursor: pointer;
    position: static; /* Ensure it's not absolute */
    /* top: auto; */
    /* right: auto; */
}

/* #toggleAdminControlsBtn:hover { */
    /* Hover effects will come from .secondary-btn:hover */
    /* background-color: var(--darker-bg); */
    /* color: var(--light-text); */
/* } */

/* General admin buttons (like Generate, Save) */
.admin-controls .form-group button, 
#showAdminControlsBtn { /* Include the show button styling here too */
    /* Styles for Generate, Save, Show Admin Panel buttons */
    /* width: auto; /* Let content define width */
    /* height: auto; /* Let content define height */
    /* padding: 0.7rem 1.4rem; /* Restore original padding */
    /* border-radius: 20px; /* Restore original border-radius */
    /* These are mostly handled by their specific classes like primary-btn, secondary-btn */
}


.admin-controls .btn-icon { /* Icon inside general admin buttons */
    font-size: 1rem; 
}


.logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--light-text);
    margin: 0;
}

.plus {
    color: var(--accent-color);
}

nav {
    margin: 0;
    margin-left: auto; /* Push nav to the right */
}

nav ul {
    display: flex;
    list-style: none;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
    justify-content: flex-end; /* Align items to the right */
}

nav a {
    text-decoration: none;
    color: var(--light-text);
    font-weight: 500;
    padding: 0.3rem 0;
    transition: all 0.2s ease;
    position: relative;
}

nav a:hover {
    color: var(--accent-color);
}

nav a.active {
    color: var(--accent-color);
}

nav a.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent-color);
}

main {
    flex: 1;
    padding: 2rem 1.5rem; /* Increased top padding */
    max-width: 100%; /* Full width for seamless design */
    margin: 0 auto;
    width: 100%;
}

section {
    background-color: var(--dark-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    max-width: 800px; /* Reduced content width */
    margin-left: auto;
    margin-right: auto;
}

/* Community section width reverted to default section max-width */


footer {
    background-color: var(--dark-bg);
    color: var(--light-text);
    text-align: center;
    padding: 0.8rem;
    margin-top: auto;
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
    display: flex; /* Make form-group a flex container */
    flex-wrap: wrap; /* Allow wrapping of elements within */
    align-items: center;
    gap: 1rem; /* Default gap for form elements */
}

/* Reduce spacing specifically within the daily puzzle admin controls */
#dailyPuzzleAdminControls .form-group {
    margin-bottom: 0.5rem !important; /* More aggressive reduction */
    gap: 0.4rem !important; /* More aggressive reduction */
}
/* Ensure all direct children divs that are form-groups get this margin */
#dailyPuzzleAdminControls > div.form-group {
    margin-bottom: 0.5rem !important;
}

/* Target specific labels if general one is too broad */
#dailyPuzzleAdminControls label[for="dailyOriginalMessage"],
#dailyPuzzleAdminControls label[for="dailyScrambledMessage"],
#dailyPuzzleAdminControls label[for="dailyOriginalScrambled"],
#dailyPuzzleAdminControls .form-group > label:first-child { /* Catches "Puzzle Type:" */
    margin-bottom: 0.2rem !important; /* Tighter */
}

/* Adjust Puzzle Type radio button spacing */
#dailyPuzzleAdminControls .form-group div[style*="display: flex"] { /* Targets the radio button flex container */
    gap: 0.4rem !important; 
    margin-bottom: 0.1rem !important; 
    flex-wrap: nowrap; /* Prevent radio button groups from wrapping if container is too narrow */
}
#dailyPuzzleAdminControls .form-group div[style*="display: flex"] label { 
    margin-bottom: 0 !important; 
    padding-bottom: 0 !important; 
    display: flex; /* Ensure label itself is flex to align input and span */
    align-items: center;
}
#dailyPuzzleAdminControls .form-group div[style*="display: flex"] label span {
    white-space: nowrap; /* Prevent text like "Pre-scrambled" from wrapping */
}


/* Adjust Hint section's "auto-generated" paragraph */
#dailyPuzzleAdminControls .admin-hint-group { /* The hint group itself */
    margin-bottom: 0.25rem !important; /* Reduce space after the hint inputs */
}
#dailyPuzzleAdminControls .admin-hint-group + p { /* The paragraph after hint group */
    font-size: 0.7rem !important; /* Even smaller */
    margin-top: 0.1rem !important;  
    margin-bottom: 0.4rem !important; 
}

/* Adjust Preview Container margins */
#generatedPreviewContainer {
    margin-top: 0.4rem !important;
    margin-bottom: 0.4rem !important;
}
#generatedPreviewContainer > label {
    margin-bottom: 0.2rem !important;
}

/* Styling for the new action buttons group */
#dailyPuzzleAdminControls .admin-action-buttons {
    display: flex;
    flex-direction: row; 
    gap: 0.75rem; 
    justify-content: center; 
    align-items: stretch; /* Make buttons equal height if padding differs */
    margin-top: 0.5rem; 
    margin-bottom: 0.25rem !important; 
}

#dailyPuzzleAdminControls .admin-action-buttons button {
    /* Remove flex-grow and flex-basis */
    width: 240px; /* Fixed width for both buttons */
    /* The inline styles for padding and border-radius will be kept from the HTML */
    /* Buttons are already display:flex from general button rule, so justify-content: center works for their content */
    text-align: center; /* Explicitly center text, though flex justify should handle icon+text */
    flex-shrink: 0; /* Prevent shrinking if container is too narrow */
    /* min-width: 0; /* Not needed if not using flex-grow/shrink extensively */
}


label {
    display: block;
    margin-bottom: 0.5rem; /* General label margin */
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--accent-color);
}

input, textarea, select {
    width: 100%;
    max-width: 600px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 1rem;
}

/* How to Play Popup Styles */
.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.4); /* Black w/ opacity */
}

/* General Modal Content/Box - keep this for other modals if any, or as a base */
.modal-content {
    background-color: var(--dark-bg);
    margin: 5% auto; /* 5% from the top and centered */
    padding: 15px; /* Reduced padding */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius); /* Default border-radius from variable */
    width: 95%; /* Adjusted width for mobile */
    max-width: 700px;
    box-shadow: var(--shadow);
}

/* Specific styling for How to Play Popup Content */
#howToPlayPopup .modal-content {
    position: absolute;
    top: 5%; /* Position it 5% from the top */
    left: 50%;
    transform: translateX(-50%);
    margin: 0; /* Override general .modal-content margin */
    padding: 25px; /* Consistent padding */
    border-radius: 10px; /* Rounded corners */
    width: 80%;    /* Consistent width */
    max-width: 700px; /* Consistent max-width */
    color: var(--light-text);
    /* background-color, border, box-shadow, color will be inherited or can be re-specified if needed */
}

/* The Close Button */
.close-button {
    color: var(--medium-gray);
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: var(--light-text);
    text-decoration: none;
    cursor: pointer;
}

/* Styles for the puzzle display */
.puzzle-display {
    font-family: 'Arial', 'Helvetica', sans-serif; /* Changed from monospace */
    font-size: 1.2rem;
    line-height: 1.8;
    margin-bottom: 20px;
    white-space: pre-wrap;
}

/* Checkbox Styles */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--light-text);
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
    cursor: pointer;
}

/* Buttons */
button {
    cursor: pointer;
    padding: 0.7rem;
    border: none;
    border-radius: 50%;
    width: 2.8rem;
    height: 2.8rem;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
}

.primary-btn:hover {
    background-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

.secondary-btn {
    background-color: var(--dark-bg);
    color: var(--light-text);
    border: 1px solid var(--border-color);
}

.secondary-btn:hover {
    background-color: var(--darker-bg);
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Button Icons */
.btn-icon {
    font-size: 1.2rem;
}

/* Load Puzzle Button (not an icon) */
#loadPuzzleBtn {
    border-radius: 20px;
    width: auto;
    height: auto;
    padding: 0.7rem 1.4rem;
}

/* Utility Classes */
.hidden {
    display: none;
}

.hidden-section {
    display: none;
}

.active-section {
    display: block;
}

/* Puzzle Display */
.puzzle-display {
    background-color: var(--darker-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
    font-family: 'Arial', 'Helvetica', sans-serif; /* Changed from monospace */
    font-size: 1.2rem;
    line-height: 1.8;
    min-height: 100px;
    white-space: pre-wrap;
    word-break: normal;
    hyphens: none; /* Prevent automatic hyphenation */
    color: var(--light-text);
    border: 1px solid var(--border-color);
}

/* Interactive Puzzle */
#interactivePuzzleContainer, #dailyPuzzleContainer {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* .puzzle-controls defined later in specific layout section */

.interactive-puzzle {
    font-family: 'Arial', 'Helvetica', sans-serif; /* Changed from monospace to sans-serif */
    font-size: 1.6rem; /* Increased from 1.3rem for bigger text */
    line-height: 1.6; /* Reduced line height for closer spacing */
    background-color: var(--darker-bg);
    padding: 1.5rem; /* Slightly reduced padding */
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    overflow-x: hidden; /* Hide horizontal scrollbar */
    white-space: normal; /* Allow normal wrapping */
    max-width: 100%;
    text-align: center; /* Center the lines */
    word-break: normal; /* Default word breaking */
    overflow-wrap: break-word; /* Allow breaking long words if necessary */
    width: 100%; /* Ensure it takes full width */
}

/* Wrapper for all puzzle words (replaces puzzle-line) */
.puzzle-lines-wrapper {
    display: flex;
    flex-wrap: wrap; /* Allow words to wrap */
    justify-content: center; /* Center the lines of words */
    width: 100%; /* Take full width for centering */
    gap: 0.5rem 1rem; /* Add row (0.5rem) and column (1rem) gap */
    position: relative; /* For absolute positioning of trailing punctuation */
}

/* Container for a single word in the puzzle */
.puzzle-word {
    display: flex; /* Keep using flex for letters within the word */
    flex-wrap: nowrap; /* Keep letters of a word together */
    margin-right: 0.5em; /* Add space after each word */
    align-items: flex-start; /* Align items (letters, punctuation) to the top */
    /* margin-bottom: 0.5rem; /* Removed - using gap on wrapper now */
}

/* Simple puzzle letter container */
.puzzle-letter-container {
    display: inline-flex; /* Use flexbox */
    flex-direction: column; /* Stack solution and letter vertically */
    align-items: center; /* Center items horizontally */
    margin: 0 3px; /* Adjusted margin */
    width: 2rem;
    height: 4.5rem; /* Increased height to prevent overlap */
    vertical-align: bottom; /* Align containers along their bottom edge */
}

/* Simple puzzle letter */
.puzzle-letter {
    /* position: absolute; removed */
    /* bottom: 0; removed */
    /* left: 0; removed */
    /* right: 0; removed */
    font-weight: bold;
    color: var(--light-text);
    text-transform: uppercase;
    /* margin-top: 3rem; removed */
    height: 2rem; /* Give it height */
    line-height: 2rem; /* Vertically center */
}

/* Simple puzzle solution */
.puzzle-solution {
    /* position: absolute; removed */
    /* top: 0; removed */
    /* left: 0; removed */
    /* right: 0; removed */
    width: 100%; /* Take full width of container */
    height: 2rem; /* Give it height */
    border-bottom: 2px solid var(--primary-color);
    color: var(--accent-color);
    font-weight: bold;
    cursor: pointer;
    display: flex; /* Restore flex properties */
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    margin-bottom: 0.5rem; /* Space between solution and letter */
}

.puzzle-solution.filled {
    background-color: hsl(var(--accent-hue, 218) 90% 61% / 0.1);
}

.puzzle-solution.active {
    background-color: hsl(var(--accent-hue, 218) 90% 61% / 0.2);
    box-shadow: 0 0 0 2px var(--accent-color);
    border-radius: 2px;
}

/* Styles for non-letter characters in the puzzle */
.puzzle-other {
    display: inline-flex; /* Use flexbox like container */
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Align content (punctuation) to top */
    width: 1rem; /* Reduced width for punctuation */
    height: 4.5rem; /* Match container height */
    text-align: center;
    font-size: 1.6rem;
    line-height: 2rem; /* Match letter line-height */
    color: var(--light-text);
    margin: 0 1px; /* Reduced horizontal margin globally */
    vertical-align: bottom; /* Keep container aligned at bottom, content aligned at top */
}

/* Removed #dailySection .puzzle-other and .is-trailing-punctuation rules as they are no longer needed */


/* Settings Menu */
.settings-menu {
    position: absolute; /* Change from fixed */
    top: 100%; /* Position below the parent */
    right: 0; /* Align to the right of the parent */
    margin-top: 5px; /* Add a small gap */
    background-color: var(--dark-bg);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    min-width: 240px;
    max-width: calc(100vw - 32px);
    display: none;
    border: 1px solid var(--border-color);
    z-index: 1000;
}

.settings-menu.active {
    display: block;
}

.accent-color-settings {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

.accent-color-heading,
.accent-color-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
}

.accent-color-heading label {
    margin: 0;
    font-weight: 500;
}

.accent-color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 1px solid var(--border-color);
}

.settings-menu input[type="range"] {
    appearance: none;
    width: 100%;
    height: 28px;
    padding: 0;
    margin: 8px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    cursor: pointer;
}

.settings-menu input[type="range"]::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #f54242, #f5f542, #42f542, #42f5f5, #4242f5, #f542f5, #f54242);
}

.settings-menu input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    margin-top: -6px;
    border: 3px solid var(--dark-bg);
    border-radius: 50%;
    background: var(--primary-color);
    box-shadow: 0 0 0 1px var(--medium-gray);
}

.settings-menu input[type="range"]::-moz-range-track {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #f54242, #f5f542, #42f542, #42f5f5, #4242f5, #f542f5, #f54242);
}

.settings-menu input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 3px solid var(--dark-bg);
    border-radius: 50%;
    background: var(--primary-color);
}

.accent-color-footer {
    color: var(--medium-gray);
}

.settings-menu .accent-color-reset {
    width: auto;
    height: auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--light-text);
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    box-shadow: none;
    cursor: pointer;
}

.accent-color-settings :focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 4px;
}

/* Container for the settings button to position the menu relative to it */
.settings-button-container {
    position: relative; /* Establish positioning context for the absolute menu */
    display: inline-block; /* Keep it inline with other controls */
}

/* No specific styles needed for #settingsBtn itself for positioning */

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.theme-toggle-label {
    color: var(--light-text);
    font-weight: 500;
    margin-right: 1rem;
}

.theme-toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px; /* Explicit width */
    height: 24px;
    flex-shrink: 0; /* Prevent switch from shrinking */
}

.theme-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--medium-gray);
    transition: .4s;
    border-radius: 24px;
}

.theme-toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .theme-toggle-slider {
    background-color: var(--primary-color);
}

input:checked + .theme-toggle-slider:before {
    transform: translateX(26px);
}

/* Login Button at Bottom */
.login-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
}

/* Letter Keyboard */
.keyboard-container {
    margin: 0.5rem auto 1.5rem; /* Centered horizontally */
    width: 100%;
    max-width: 600px;
}

.letter-keyboard {
    display: flex;
    flex-direction: column; /* Stack rows vertically */
    gap: 0.4rem;
    width: 100%;
}



.keyboard-row {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping */
    justify-content: center; /* Center keys horizontally */
    width: 100%;
}


.letter-key {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    height: 2.2rem;
    margin: 0 0.1rem; /* Add small margin between keys */
    background-color: var(--darker-bg); /* Background grey */
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    color: var(--light-text);
}

.letter-key:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

.letter-key.used {
    background-color: #e3e5e8;
    color: #737982;
    border-color: #d0d4da;
    box-shadow: none;
    transform: none;
}

[data-theme="dark"] .letter-key.used {
    background-color: #30343a;
    color: #9299a2;
    border-color: #454b54;
}

/* .letter-key.selected {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--accent-color);
} */

/* New styles for Title, Author, Hint, Controls layout */
.title-line {
    padding-left: 1rem; /* Indent title */
    margin-bottom: 0.25rem; /* Consistent spacing */
}

.title-line #solvePuzzleTitle {
    text-align: left; /* Override h2 default center */
    margin: 0; /* Remove default h2 margin */
}

.author-line {
    padding-left: 1rem; /* Indent author */
    margin-bottom: 0.25rem; /* Consistent spacing */
}

.author-line .author {
    font-size: 1rem; /* Increased author text size */
    color: var(--medium-gray);
    display: block; /* Ensure it takes its own line */
}

.hint-line { /* Simplified: Hint is now a simple block inside the flex container */
    padding-left: 1rem; /* Align with title/author */
    font-weight: normal; 
    font-size: 1rem; 
    color: var(--medium-gray); 
    /* Removed all flex, overflow, text-overflow, white-space properties */
}


/* Original Puzzle Meta container (now holds hint, hidden date, controls) */
.puzzle-meta {
    display: flex; /* Use Flexbox */
    justify-content: space-between; /* Push hint left, controls right */
    align-items: center; /* Vertically center items */
    margin-bottom: 1rem; 
    width: 100%;
    gap: 1rem; /* Space between hint and controls */
}

/* Hide the date */
.puzzle-meta .date {
   display: none;
}

/* Hide author line specifically on daily page */
#dailySection .author-line {
    display: none;
}

/* Remove old rules that targeted author/hint within puzzle-meta */
/*
.puzzle-meta .author { ... }
.puzzle-meta .hint { ... }
.puzzle-meta .hint strong { ... }
*/

/* Ensure controls take remaining space and align right */
.puzzle-controls {
    display: flex; /* Keep flex for internal button layout */
    gap: 0.5rem; 
    flex-shrink: 0; /* Prevent controls from shrinking */
}

/* Puzzle Filters */
.puzzle-filters {
    margin-bottom: 1.5rem;
    max-width: 600px; /* Match list container width */
    margin-left: auto; /* Center the filters */
    margin-right: auto; /* Center the filters */
}

.search-filter {
    margin-bottom: 1rem;
}

.sort-filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.sort-filters select {
    max-width: 200px;
}

/* Puzzles List */
.puzzles-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.puzzle-list-item {
    background-color: var(--darker-bg);
    border-radius: var(--border-radius);
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s ease;
    gap: 1rem;
    text-decoration: none;
    color: var(--light-text);
    justify-content: space-between; /* Align items to start and end */
}

.puzzle-list-item:hover {
    background-color: var(--dark-bg);
    color: var(--accent-color); /* Change text color on hover */
    text-decoration: underline; /* Add underline on hover */
    cursor: pointer; /* Show pointer cursor */
}

.puzzle-list-item:active { /* Style for active state */
    background-color: var(--primary-color);
    color: white;
}

/* Container to constrain the width of the community list */
.community-list-container {
    max-width: 600px; /* Make the list area narrower */
    margin: 1rem auto; /* Center the narrower container and add vertical margin */
    padding-left: 1rem; /* Add padding inside the container */
    padding-right: 1rem; /* Add padding inside the container */
}

/* --- Default (Logged Out) Community List Layout --- */
.puzzle-list-header {
    display: grid;
    /* Columns: Title | Author (aligned right) */
    grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); 
    gap: 1rem;
    font-weight: bold;
    color: var(--medium-gray);
    padding: 0 0.75rem 0.5rem;
    border-bottom: 2px solid var(--border-color);
    align-items: center;
}
.puzzle-list-header span:nth-child(2) { /* Author header */
    text-align: right; 
}
/* Hide Solved header when logged out (already handled by logged-in-only class) */
/* .puzzle-list-header .logged-in-only { display: none; } */

.puzzle-list-item {
    display: grid; 
    /* Columns: Title | Author (aligned right) */
    grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); 
    gap: 1rem;
    align-items: center;
}

.puzzle-info { /* Now only contains title */
    /* Remove old grid styles */
    /* display: grid; */
    /* grid-template-columns: 1fr 1fr; */
    /* gap: 0.5rem; */
   /* flex: 1; */ /* No longer needed */
   overflow: hidden; /* Prevent long text overflow */
}

/* New style for the author column */
.puzzle-author-col {
    text-align: right; /* Right align author by default */
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 0.9rem;
    color: var(--medium-gray);
}
.puzzle-author-col .author {
    /* Remove any specific display/margin styles if they existed */
}

/* Style for the solved column (hidden by default via JS/HTML class) */
.puzzle-solved-col {
    text-align: center; 
    font-size: 1.1rem; 
    justify-self: center; 
    display: none; /* Ensure hidden if JS fails */
}
/* Hide Button placeholder/Admin controls when logged out */
.puzzle-list-item > div:last-child:not(.admin-controls), /* Empty placeholder */
.puzzle-list-item .admin-controls:not(.user-logged-in .admin-controls) { /* Admin controls when not logged in */
     display: none;
}


/* --- Logged-In Community List Layout Overrides --- */
.user-logged-in .puzzle-list-header {
    /* Columns: Title | Author | Solved | Button/Admin */
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 60px auto; 
}
/* Remove right alignment for author header when logged in */
.user-logged-in .puzzle-list-header span:nth-child(2) { text-align: left; } 

.user-logged-in .puzzle-list-item {
    /* Columns: Title | Author | Solved | Button/Admin */
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 60px auto; 
}
.user-logged-in .puzzle-author-col {
    text-align: left; /* Left align author when logged in */
}
/* Show Solved column and Button placeholder/Admin controls when logged in */
.user-logged-in .puzzle-solved-col,
.user-logged-in .puzzle-list-item > div:last-child:not(.admin-controls), /* Empty placeholder */
.user-logged-in .puzzle-list-item .admin-controls {
    display: block; /* Or flex for admin controls */
}
.user-logged-in .puzzle-list-item .admin-controls {
    display: flex; 
}

.puzzle-info h3 {
    margin-bottom: 0.1rem; /* Tighter margin */
    font-size: 1.1rem;
    text-align: left; /* Ensure left alignment */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Remove old puzzle-info .puzzle-meta styles */
/*
.puzzle-info .puzzle-meta { ... }
.puzzle-info .puzzle-meta span.author { ... }
*/


.puzzle-list-item .solve-btn, 
.puzzle-list-item .admin-controls { /* Style both solve button and admin controls container */
    width: auto; /* Let content determine width */
    flex-shrink: 0; /* Prevent shrinking */
    margin-left: 0; /* Remove margin, rely on grid gap */
    justify-self: end; /* Align to the right of the grid cell */
}
.puzzle-list-item .solve-btn { /* Specific solve button styles */
     border-radius: 20px;
     padding: 0.5rem 1rem;
     background-color: var(--primary-color);
     color: white;
}
.puzzle-list-item .admin-controls { /* Specific admin controls container styles */
     /* Keep existing flex styles for buttons inside */
     gap: 0.3rem; /* Slightly reduce gap */
}

/* Style for the "Admin Panel" (Show) button */
.show-admin-panel-btn {
    width: 150px; /* Fixed width */
    height: 40px;  /* Fixed height */
    padding: 0.5rem 1rem; /* Adjust padding */
    border-radius: 6px; /* Rounded square corners */
    font-size: 0.9rem; 
    /* Inherits background/color from .primary-btn */
    /* display: block; and margin: auto; are handled by inline styles in daily.js */
}

.puzzle-list-item .admin-controls button { /* Ensure admin buttons inside are styled correctly */
     width: 1.8rem; /* Slightly smaller */
     height: 1.8rem;
     padding: 0.3rem;
}

/* Override for admin buttons within the community puzzle list items for horizontal layout */
#communitySection .puzzle-list-item .admin-controls {
    justify-self: end !important; /* Align the grid item itself to the end of its cell */
    width: auto; /* Allow the container to be only as wide as its content */
    
    /* Internal flex layout for buttons */
    flex-direction: row !important; 
    gap: 0.5rem !important; 
    align-items: center !important; 
    justify-content: flex-end !important; /* Aligns buttons to the right within this container */
}

.puzzle-list-item .admin-controls .btn-icon {
     font-size: 0.9rem; /* Smaller icon */
}


/* Adjust admin controls for the new layout */
.admin-controls.admin-only {
    /* margin-left: auto; */
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-direction: column; /* Align items to center vertically */
    align-items: center; /* Align items to center horizontally */
}

#dailyPuzzleAdminControls  { /* Specific styles for daily puzzle admin controls */
    text-align: center; /* Center text within admin controls */
}

#dailyPuzzleAdminControls .form-group {
    display: flex;
    flex-direction: column; /* Align form elements vertically */
    align-items: center; /* Center horizontally */
    width: 100%; /* Take full width */
}

#dailyPuzzleAdminControls label,
#dailyPuzzleAdminControls input,
#dailyPuzzleAdminControls textarea,
#dailyPuzzleAdminControls select,
#dailyPuzzleAdminControls button,
#dailyPuzzleAdminControls .puzzle-display {
    text-align: center; /* Center text within form elements */
    width: 100%; /* Ensure full width for elements */
    max-width: 600px; /* Limit max-width */
    margin: 0 auto; /* Center using auto margins */
}

#dailyPuzzleAdminControls  .form-group {
    margin-bottom: 1rem; /* Adjust margin as needed */
    justify-content: center; /* Center buttons within the group */
}

.admin-hint-group {
    flex-direction: row !important; /* Override default column for form-group */
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end; /* Align items to the bottom for a cleaner look with labels above */
    gap: 1rem; /* Space between the two hint input groups */
}

.admin-hint-input-container {
    display: flex;
    flex-direction: column; /* Stack label above input */
    align-items: flex-start; /* Align label to the start of the input */
}

.admin-hint-label {
    font-size: 0.85rem;
    color: var(--medium-gray);
    margin-bottom: 0.25rem; /* Space between label and input */
    display: block; /* Ensure it takes its own line */
}

.admin-hint-input {
    width: 50px !important; /* Significantly reduce width for single character */
    padding: 0.5rem 0.25rem !important; /* Adjust padding for single char */
    font-size: 1rem !important; /* Keep font size readable */
    text-align: center;
    /* Remove pointer-events and z-index from here, should be on the input element itself if needed */
}

.admin-hint-equals {
    margin-bottom: 0.7rem; /* Align with bottom of input boxes roughly */
    font-weight: 500;
}


/* Style for the Generate/Save button group */
.admin-button-group button {
    flex: 1; /* Allow buttons to grow equally */
    max-width: 200px; /* Optional: prevent buttons from becoming too wide */
    border-radius: 20px; /* Restore button style */
    width: auto; /* Override default button width */
    height: auto; /* Override default button height */
    padding: 0.7rem 1.4rem; /* Restore button style */
}

.admin-controls button { /* General admin buttons (like HIDE) */
    width: 2rem;
    height: 2rem;
    padding: 0.4rem;
    font-size: 1rem; /* Restore icon font size */
}



/* Puzzles Grid (for backward compatibility) */
.puzzles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.puzzle-card {
    background-color: var(--dark-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
    border: 1px solid var(--border-color);
}

.puzzle-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.puzzle-card h3 {
    margin-bottom: 0.5rem;
    color: var(--light-text);
}

.puzzle-card .preview {
    font-family: 'Arial', 'Helvetica', sans-serif;
    background-color: var(--darker-bg);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--light-text);
    border: 1px solid var(--border-color);
}

.puzzle-card .solve-btn {
    width: 100%;
    margin-top: 0.5rem;
    border-radius: 20px;
    background-color: var(--primary-color);
    color: white;
}

.puzzle-card .solve-btn:hover {
    background-color: var(--accent-color);
}

/* Filters (for backward compatibility) */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.filters select, .filters input {
    flex: 1;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 2rem;
    gap: 1rem;
}

.pagination button {
    padding: 0.5rem 1rem;
}

#pageIndicator, #archivePageIndicator, #communityPageIndicator {
    font-weight: 500;
}

/* Create Page Styles */
#createSection {
    display: flex;
    flex-direction: column;
    align-items: center; /* Center form elements horizontally */
}

#createSection .form-group {
    width: 100%; /* Allow form groups to take width */
    max-width: 600px; /* Limit max width */
    justify-content: center; /* Center items within form group if needed */
}

#createSection #savePuzzleBtn {
    margin-top: 1rem; /* Add space above save button */
    margin-bottom: 1rem; /* Add space below save button */
}

/* Ensure generated puzzle display is also centered */
#generatedPuzzleContainer {
     width: 100%;
     max-width: 600px; /* Match form width */
     display: flex;
     flex-direction: column;
     align-items: center;
}


/* Responsive Design */
@media (max-width: 768px) {

    .letter-keyboard {
        grid-template-columns: repeat(10, 1fr); /* Ensure correct display on tablets */
        gap: 0.25rem;
    }
    
    nav ul {
        justify-content: space-around;
        width: 100%;
    }
    
    .puzzle-workspace {
        grid-template-columns: 1fr;
    }
    
    .sort-filters {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .puzzle-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .puzzle-list-item .solve-btn {
        width: 100%;
    }
    
    .interactive-puzzle {
        font-size: 1.1rem;
        line-height: 2;
        padding: 1rem;
    }
    
    .letter-keyboard {
        gap: 0.25rem;
    }
    
    .letter-key {
        width: 1.8rem;
        height: 1.8rem;
    }
    
    .puzzle-controls button {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    main {
        padding: 1rem;
    }
    
    section {
        /* Remove background and padding on mobile */
        padding: 0; 
        background-color: transparent;
        border: none; /* Remove potential borders */
        box-shadow: none; /* Remove potential shadows */
        margin-left: auto; 
        margin-right: auto; 
        max-width: 100%; /* Allow full width */
        width: 100%; 
        box-sizing: border-box;
        margin-bottom: 1rem; /* Keep some space between sections */
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    h2 {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    nav {
        margin-left: 1rem; /* Add space to the left of nav, pushing it from logo */
    }
    nav ul {
        flex-direction: row;
        flex-wrap: nowrap; 
        justify-content: center; 
        gap: 0.6rem; /* REDUCED from 0.8rem */
        overflow-x: auto; 
        -webkit-overflow-scrolling: touch; 
        padding-bottom: 5px; 
    }
    nav a {
        font-size: 0.9rem; 
        white-space: nowrap; 
    }
    nav li { 
        flex-shrink: 0;
    }

    #dailyPuzzleAdminControls .form-group:nth-child(2) { /* Hint */
        order: 1;
    }

    #dailyPuzzleAdminControls .form-group:nth-child(3) { /* Generate button */
        order: 2;
    }

    .modal {
        width: auto;
        height: auto;
    }
    
    /* Wrapper gap for mobile - Increased column gap */
    .puzzle-lines-wrapper {
        gap: 0.6rem 1rem; /* More row gap, MORE column gap */
    }


    /* Mobile Puzzle Layout Adjustments */
    .puzzle-letter-container {
        width: 2rem; /* Increased width */
        height: 4.2rem;  /* Increased height */
        margin: 0 2px; /* Slightly increased margin */
    }

    .puzzle-solution {
        width: 100%;   /* Take full width of container */
        height: 2rem; /* Adjusted height */
        font-size: 1.2rem; /* Slightly larger font */
        line-height: 2rem; /* Match height */
        margin-bottom: 0.2rem; /* Keep small gap */
    }
    .puzzle-letter {
        height: 2rem; /* Adjusted height */
        line-height: 2rem; /* Match height */
        font-size: 1.2rem; /* Match solution font */
    }
    .puzzle-other { /* Ensure punctuation aligns */
         width: 1rem; /* Make narrower */
         height: 4.2rem; /* Keep height consistent */
         font-size: 1.2rem; 
         line-height: 2rem; 
         margin: 0 1px; /* Reduce horizontal margin */
    }

    .modal-content {
        width: 95%;
    }

    #dailyPuzzleAdminControls,
    .admin-controls { /* Target all admin controls */
        width: 95%;
        margin-left: auto;
        margin-right: auto;
    }

    #dailyPuzzleAdminControls .form-group { /* Adjust form group width within admin controls */
        width: 100%;
    }

    #dailyPuzzleAdminControls label,
    #dailyPuzzleAdminControls input,
    #dailyPuzzleAdminControls textarea,
    #dailyPuzzleAdminControls select,
    #dailyPuzzleAdminControls button,
    #dailyPuzzleAdminControls .puzzle-display {
        width: 100%;
        max-width: 100%; /* Ensure elements don't exceed container width */
        box-sizing: border-box; /* Include padding and border in element's total width and height */
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    /* Ensure puzzle container centers on mobile */
    #interactivePuzzleContainer, #dailyPuzzleContainer {
        width: 100%; /* Take full width */
        display: flex; /* Use flex for centering */
        flex-direction: column; /* Stack items vertically */
        align-items: center; /* Center items horizontally */
        margin-left: auto; /* Explicitly center container */
        margin-right: auto; /* Explicitly center container */
    }
    
    /* Reduce header padding slightly on mobile */
    header {
        padding: 0.8rem 1rem; 
    }

    .interactive-puzzle {
        font-size: 1.1rem; /* Increased base font size */
        line-height: 1.8;
        padding: 0.75rem;
        width: 95%; /* Keep slightly less than full width */
        margin-left: auto;
        margin-right: auto;
        white-space: normal; /* Ensure wrapping */
        overflow-wrap: break-word; /* Ensure long words break */
    }
    
    /* .puzzle-line rule removed as .puzzle-lines-wrapper handles layout */
    
    .puzzle-word {
        margin-bottom: 0.5rem; /* Keep some bottom margin for wrapped words */
    }
    
    .puzzle-letter-container {
        width: 1.5rem;
        height: 3.5rem; /* Keep fixed height */
        margin: 0 2px;
    }
    
    .puzzle-solution {
        width: 100%; /* Ensure it takes full width of its container */
        height: 1.5rem;
        line-height: 1.5rem; 
        border-width: 1px;
        margin-bottom: 0.2rem; /* Explicit margin */
        padding-top: 0; /* Ensure no vertical padding */
        padding-bottom: 0; /* Ensure no vertical padding */
    }

    .puzzle-letter {
        height: 1.8rem; /* Calculated: 3.5 (container) - 1.5 (solution) - 0.2 (margin) */
        line-height: 1.8rem; /* Match height */
        width: 100%; /* Ensure it takes full width of its container */
        text-align: center; /* Center the letter */
        padding-top: 0; /* Ensure no vertical padding */
        padding-bottom: 0; /* Ensure no vertical padding */
    }
    
    .letter-keyboard {
        gap: 0.3rem;
        width: 95%;
        margin-left: auto;
        margin-right: auto;
    }
    
    .letter-key {
        width: 2rem;
        height: 2rem;
        font-size: 1rem;
        border-width: 1px;
    }
    
    /* Adjust puzzle meta for mobile */
    .puzzle-meta {
        flex-direction: column; /* Stack hint and controls */
        align-items: center; /* Center items */
        gap: 0.5rem; /* Consistent gap */
        padding: 0; /* Remove padding */
        padding-right: 0; /* Override desktop padding */
        margin-top: 0.5rem; /* Add some space above meta block */
        margin-bottom: 0.5rem; /* Match space below meta block */
    }

    .hint-line {
        padding-left: 0; /* Remove desktop indent */
        text-align: center; /* Center hint text */
        width: 100%; /* Allow hint line to take full width */
        order: 1; /* Ensure hint is between title/author and controls */
    }

    .hint-line .hint {
         /* No specific hint styles needed here for wrapping/alignment */
    }

    /* Center title/author on mobile */
    .title-line, .author-line { 
        padding-left: 0; /* Remove desktop indent */
        width: 100%; /* Ensure container takes full width */
        text-align: center; /* Center the author line text */
        /* display: flex; */ /* Removed flex centering from parent */
        /* justify-content: center; */ 
    }
    /* .author-line { */ /* Removed specific author centering */
         /* justify-content: center; */ 
    /* } */
    /* Ensure title itself is centered on mobile */
    /* .title-line #solvePuzzleTitle { */ /* Removed rule targeting via parent */
        /* text-align: center; */ /* Override desktop left-align */
    /* } */
    /* Ensure title itself is centered */
    #solvePuzzleTitle {
        display: block; /* Ensure block display */
        width: 100%; /* Ensure full width */
        text-align: center !important; /* Force centering */
        margin: 0; /* Ensure no conflicting margins */
    }
    /* Removed empty .puzzle-controls rule */

    /* Revert mobile stacking for admin-hint-group, keep it row based */
    .admin-hint-group {
        /* flex-direction: row !important; /* Default is row, ensure it stays row */
        /* align-items: flex-end !important; /* Keep original alignment */
        /* gap: 1rem !important; /* Keep original gap */
    }
    .admin-hint-input-container {
        /* width: auto; /* Let content define width */
        /* align-items: flex-start; /* Keep original alignment */
    }
    .admin-hint-input {
        width: 50px !important; /* Keep the very small width for mobile too */
    }
    .admin-hint-equals {
        display: inline !important; /* Ensure "equals" text is visible */
        margin-bottom: 0.7rem; /* Keep vertical alignment with inputs */
    }
    #dailyPuzzleAdminControls .form-group p { /* Center the 'auto-generated' text */
        text-align: center;
    }

} /* Closing brace for @media (max-width: 480px) */

@media (max-width: 360px) {
     /* Wrapper gap for very small mobile */
    .puzzle-lines-wrapper {
        gap: 0.5rem 0.4rem; 
    }

    .letter-keyboard {
        gap: 0.2rem;
    }
    
    .letter-key {
        height: 2rem;
        font-size: 1rem;
    }
    
    .interactive-puzzle {
        font-size: 1rem; /* Keep slightly smaller than 480px */
    }
     /* Further adjustments for very small screens */
    .puzzle-letter-container {
        width: 1.5rem;
        height: 3.5rem;
        margin: 0 2px;
    }
    /* Make puzzle-other consistent with puzzle-letter-container */
    .puzzle-other {
        width: 1.5rem; /* This width is fine for 360px to match letters */
        margin: 0 1px; /* Ensure reduced horizontal margin here too */
        /* height and margin should already match from earlier rules */
    }
    
    .puzzle-solution {
        height: 1.8rem; 
        font-size: 1.1rem; 
        line-height: 1.8rem; 
    }
     .puzzle-letter {
        height: 1.8rem; 
        line-height: 1.8rem; 
        font-size: 1.1rem;
    }
    /* Removed duplicate .puzzle-other rule */
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.2rem;
    }
    
    .puzzle-controls button {
        width: 2.2rem;
        height: 2.2rem;
    }
    
    .btn-icon {
        font-size: 1rem;
    }
}

/* Calendar Styles */
.calendar-grid {
    width: 100%;
    max-width: 350px; /* Adjust as needed for two calendars side-by-side */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    background-color: var(--dark-bg);
    margin-bottom: 1rem; /* Space if they stack vertically */
}

.calendar-grid h4 { /* Month/Year inside calendar */
    text-align: center;
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    text-align: center;
}

.calendar-day-header {
    font-weight: bold;
    font-size: 0.8rem;
    color: var(--medium-gray);
    padding-bottom: 0.5rem;
}

.calendar-date {
    padding: 0.5rem 0;
    font-size: 0.9rem;
    border-radius: 3px;
    min-height: 30px; /* Ensure consistent height */
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-date.other-month {
    color: var(--medium-gray);
    opacity: 0.5;
}

.calendar-date.has-puzzle {
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s ease;
}

.calendar-date.has-puzzle:hover {
    background-color: var(--secondary-color);
}

.calendar-date.today {
    border: 1px solid var(--accent-color);
    font-weight: bold;
}

/* Hide old list/pagination elements *only* on the archive page */
#archiveSection .puzzle-filters,
#archiveSection .puzzles-list,
#archiveSection .pagination {
    display: none;
}

/* Keep original puzzle-filters styles for other pages */
.puzzle-filters {
     margin-bottom: 1.5rem;
}
/* Keep original puzzles-list styles for other pages */
.puzzles-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-top: 1px solid var(--border-color);
}
/* Keep original pagination styles for other pages */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 2rem;
    gap: 1rem;
}

/* How to Play Modal List Indentation */
#howToPlayPopup .modal-content ul {
    padding-left: 20px; /* Adjust value as needed */
    list-style-position: outside; /* Ensures bullets are outside the text block */
}

#howToPlayPopup .modal-content li {
    margin-bottom: 0.5rem; /* Add some space between list items */
}

/* Mobile Calendar View */
@media (max-width: 768px) {
    #calendar-month-1 {
        display: none; /* Hide the first (left) calendar on mobile */
    }
    #calendar-container {
        justify-content: center; /* Ensure the single visible calendar is centered */
    }
}

/* Puzzle Solved Modal Styles */
.puzzle-solved-content {
    text-align: center;
    padding: 25px 30px !important; /* Ensure padding overrides general .modal-content if needed */
    border-radius: 10px; /* Added for rounded corners */
    max-width: 450px; /* Control max width */
}

.solved-icon-container {
    margin-bottom: 15px;
}

.solved-actions {
    display: flex;
    justify-content: center;
    gap: 10px; 
    flex-wrap: wrap; 
    margin-top: 20px; 
}

.solved-actions button {
    padding: 0.7rem 1.2rem !important; /* Ensure padding overrides general button styles */
    border-radius: 20px !important; /* Match other main action buttons */
    width: auto !important; /* Let content define width */
    height: auto !important; /* Let content define height */
    font-size: 0.9rem !important; 
    /* Inherits .primary-btn or .secondary-btn styles */
}

.footer-disclaimer {
    max-width: 42rem;
    margin: 0.5rem auto 0;
    padding: 0 1rem;
    color: var(--medium-gray);
    font-size: 0.8rem;
    line-height: 1.5;
}

@media (max-width: 768px) {
    #dailySection .interactive-puzzle,
    #solveSection .interactive-puzzle {
        width: 100%;
        padding: 8px 0;
        margin: 0 0 12px;
        font-size: 1rem;
        line-height: 1.4;
    }

    #dailySection .puzzle-lines-wrapper,
    #solveSection .puzzle-lines-wrapper {
        gap: 10px 12px;
    }

    #dailySection .puzzle-word,
    #solveSection .puzzle-word {
        max-width: 100%;
        flex-wrap: wrap;
        margin: 0;
    }

    #dailySection .puzzle-letter-container,
    #solveSection .puzzle-letter-container {
        flex: 0 0 auto;
        width: clamp(18px, 5vw, 22px);
        height: 44px;
        margin: 0 1px;
    }

    #dailySection .puzzle-solution,
    #solveSection .puzzle-solution {
        height: 24px;
        line-height: 24px;
        margin: 0 0 2px;
        padding: 0;
        font-size: 16px;
        border-bottom-width: 1px;
    }

    #dailySection .puzzle-letter,
    #solveSection .puzzle-letter {
        height: 18px;
        line-height: 18px;
        font-size: 15px;
    }

    #dailySection .puzzle-other,
    #solveSection .puzzle-other {
        width: 10px;
        height: 44px;
        margin: 0 1px;
    }

    #dailySection .puzzle-other > div:first-child,
    #solveSection .puzzle-other > div:first-child {
        height: 24px;
        margin-bottom: 2px;
    }

    #dailyPuzzleContainer,
    #interactivePuzzleContainer {
        margin-top: 12px;
    }

    #solvePuzzleTitle {
        font-size: 1.35rem;
    }

    #dailySection .archive-link-container,
    #solveSection .archive-link-container {
        margin-top: 16px !important;
    }
}

.puzzle-letter-container {
    touch-action: manipulation;
    cursor: pointer;
}

@media (max-width: 768px), (pointer: coarse) {
    .puzzle-letter-container {
        user-select: none;
    }
}

@media (max-width: 380px) {
    .header-container {
        flex-direction: column;
        gap: 10px;
    }

    header nav {
        width: 100%;
        margin: 0;
    }

    header nav ul {
        justify-content: space-around;
    }
}

/* Shared puzzle keyboard; mobile docks it above the phone's safe area. */
.puzzle-keyboard-page .keyboard-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 4px;
    margin: 0;
}

.puzzle-keyboard-page .letter-key {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    height: 40px;
    margin: 0;
    padding: 0;
    font-size: 1.25rem;
    font-weight: 600;
    border-radius: 5px;
    touch-action: manipulation;
    user-select: none;
}

.puzzle-keyboard-page .letter-key:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

@media (max-width: 768px), (pointer: coarse) {
    body.puzzle-keyboard-page {
        padding-bottom: calc(178px + env(safe-area-inset-bottom, 0px));
    }

    .puzzle-keyboard-page .keyboard-container {
        position: fixed;
        z-index: 900;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 10px max(4px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px));
        background: var(--dark-bg);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    }

    .puzzle-keyboard-page .letter-keyboard {
        width: 100%;
        max-width: 720px;
        gap: 6px;
        margin: 0 auto;
    }

    .puzzle-keyboard-page .letter-key {
        height: 46px;
        font-size: clamp(15px, 4.5vw, 19px);
        transition: background-color 0.15s ease;
    }

    .puzzle-keyboard-page .letter-key:hover {
        transform: none;
    }

    .puzzle-keyboard-page .login-container {
        position: static;
        align-self: center;
        margin: 12px 16px;
    }
}
