/* Import Google Font - Consider changing if needed for label look */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap'); /* Or Helvetica/Arial */

:root {
    /* Nutrition Label Theme Palette */
    --primary-color: #3498db;    /* Accent Blue (Keep for potential future use/info messages) */
    --secondary-color: #2ecc71;  /* Success Green (Keep for correct answers) */
    --error-color: #e74c3c;      /* Error Red (Keep for far-off hints/errors) */
    --warning-color: #f39c12;    /* Warning Orange (Keep for close hints) */
    --correct-color: var(--secondary-color);

    --bg-color: #f8f8f8;         /* Off-white background */
    --text-color: #000000;       /* Black text */
    --border-color: #000000;     /* Black borders */
    --text-secondary-color: #555; /* Dark gray for less prominent text */
    --text-on-primary: #ffffff;
    --text-on-secondary: #ffffff;
    --text-on-error: #ffffff;
    --text-on-warning: #ffffff;
    --text-on-correct: #ffffff; /* Text on green background */
    --text-on-dark-button: #ffffff; /* Text for solid dark buttons */
    --button-bg: #000000;       /* Default button background */
    --button-text: #ffffff;      /* Default button text */
    --input-bg: #ffffff;         /* White input background */
    --input-border: #ccc;        /* Lighter border for inputs */

    --border-radius-sm: 4px;
    --border-radius-md: 6px;
    --border-radius-lg: 8px;

    /* Spacing units */
    --space-xxs: 0.25rem;
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
    --space-xxl: 3.75rem;

    /* Font sizes */
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-md: 1.125rem;
    --font-size-lg: 1.5rem;
    --font-size-xl: 2.25rem;
    --font-size-xxl: 3rem;

    /* Nutrition Label Specific */
    --label-border-thick: 2px;
    --label-border-thin: 1px;
    --label-padding: 0.75rem;
}

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

html {
    font-size: 100%;
    /* overscroll-behavior-y: contain; Removed as html will not scroll */
    height: 100%;
    overflow: hidden; /* Make body the explicit scroller, hide html overflow */
}

body {
    font-family: 'Poppins', sans-serif;
    line-height: 1.6;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    /* min-height: 100vh; Replaced with height: 100% */
    height: 100%; /* Take full height of html element */
    padding: 0;
    overscroll-behavior-y: contain; /* Apply to body as it's the scroller */
    overflow-y: auto; /* Allow body to scroll vertically */
    overflow-x: hidden; /* Prevent horizontal scroll on body */
}

.container {
    width: 100%;
    max-width: 600px; /* Default max-width for mobile */
    min-width: 350px; /* Added minimum width */
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    transition: max-width 0.3s ease; /* Smooth transition */
    flex-grow: 1; /* Allow container to grow and push footer down */
}

/* --- New Header Styling --- */
.site-header {
    background-color: var(--input-bg); /* Or keep original ribbon bg if preferred */
    border-bottom: var(--label-border-thin) solid var(--border-color);
    padding: var(--space-xs) var(--space-md); /* Roughly p-4 */
    margin-bottom: var(--space-md);
    min-width: 350px; /* Added minimum width */
    position: sticky; /* Make header sticky */
    top: 0; /* Stick to the top */
    z-index: 1000; /* Ensure it's above other content but below side panel */
    transform: translateZ(0); /* Promote to own compositor layer to fix mobile scroll glitches */
}

.header-content-wrapper {
    max-width: 2400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md); /* Roughly gap-4 */
}

.header-title-group {
    display: flex;
    align-items: baseline; /* Align title and subtitle baseline */
    gap: var(--space-xs); /* Roughly gap-2 */
}

.header-main-title {
    font-size: var(--font-size-xl); /* Roughly text-2xl */
    font-weight: 700; /* Bold */
    color: var(--text-color);
    white-space: nowrap;
    user-select: none;
}

.header-subtitle {
    font-size: var(--font-size-sm); /* text-sm */
    color: var(--text-secondary-color); /* Roughly text-gray-600 */
    display: none; /* hidden by default */
}

/* Container for CTA and Hamburger */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm); /* Space between CTA and hamburger */
}

.header-cta-button {
    background-color: #facc15; /* Roughly bg-yellow-400 */
    color: #1f2937; /* Dark text for yellow background */
    padding: calc(var(--space-xs)*0.8) var(--space-sm); /* Roughly px-4 py-2 */
    margin-left: var(--space-sm); /* Add base margin for spacing */
    border-radius: var(--border-radius-md); /* rounded */
    font-size: var(--font-size-sm); /* text-sm */
    font-weight: 600; /* font-semibold */
    text-decoration: none;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); /* shadow */
    white-space: nowrap;
    /* Transition properties for smooth fade/shrink */
    opacity: 1;
    max-width: 200px; /* Estimate - adjust if needed */
    overflow: hidden; /* Clip content during shrink */
    /* Adjusted transition: removed visibility, added max-width, padding, margin */
    transition: background-color 0.1s ease,
                opacity 0.2s ease,
                max-width 0.3s ease-out, /* Slightly longer ease-out for shrink */
                padding 0.3s ease-out,
                margin 0.3s ease-out;
}

.header-cta-button:hover {
    background-color: #fde047; /* Roughly hover:bg-yellow-300 */
}

/* --- Hamburger Menu Styles (Re-added & Adjusted) --- */
.hamburger-menu {
    background: none;
    border: none; /* Removed border */
    padding: var(--space-xs); /* Keep padding for click area */
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 36px;
    height: 30px;
    /* border-radius: var(--border-radius-sm); Optional: Add if you want rounded corners */
}

.hamburger-menu span {
    display: block;
    width: 100%;
    height: 2px; /* Line thickness */
    background-color: var(--text-secondary-color); /* Use secondary text color */
    border-radius: 1px;
    transition: background-color 0.2s ease; /* Add transition for hover */
}

.hamburger-menu:hover span {
    background-color: var(--text-color); /* Darken lines on hover */
}
/* --- End Hamburger Menu Styles --- */

/* --- Header Responsive Adjustments --- */
@media (max-width: 600px) { /* Below sm breakpoint */
    .site-header {
        padding: var(--space-xs) var(--space-sm); /* Reduced padding */
    }
    .header-content-wrapper {
        gap: var(--space-sm); /* Reduced gap */
        position: relative; /* Needed for absolute positioning of title */
        justify-content: flex-end; /* Push hamburger to the right */
    }
    .header-title-group {
        position: absolute; /* Detach from flow */
        left: 50%;          /* Center horizontally */
        transform: translateX(-50%);
        /* Ensure it doesn't overlap hamburger if title is very long */
        max-width: calc(100% - 80px); /* Adjust 80px based on hamburger width/padding */
        justify-content: center; /* Center title within its own group if needed */
    }
    /* General subtitle hiding on mobile */
    .header-subtitle {
        display: none;
    }
    .header-cta-button {
        /* Fade and shrink */
        opacity: 0;
        max-width: 0;
        padding-left: 0;
        padding-right: 0;
        margin-left: 0; /* Collapse margin */
        margin-right: 0;
        /* No transition needed here, base style handles it */
    }
}

/* Responsive subtitle visibility */
@media (min-width: 601px) { /* Roughly sm: breakpoint */
    /* Show general subtitle on larger screens */
    .header-subtitle {
        display: inline; /* sm:inline */
    }
}

/* --- Side Panel --- */
.side-panel {
    position: fixed;
    top: 0;
    right: -290px; /* Start off-screen (adjust width as needed) */
    width: 290px; /* Panel width */
    height: 100%;
    background-color: var(--input-bg);
    border-left: 1px solid var(--border-color);
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    padding: var(--space-xxl) var(--space-sm) var(--space-lg) var(--space-sm); /* Increased top padding */
    z-index: 1002; /* Above overlay */
    overflow-y: auto; /* Scroll if content overflows */
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    gap: var(--space-xxs); /* Space between panel items */
}

/* Helper class to disable transitions temporarily */
.side-panel.no-transition,
.page-overlay.no-transition { /* Apply to both panel and overlay */
    transition: none !important;
}

.side-panel.open {
    transform: translateX(-100%); /* Slide in */
}

/* Side Panel Close Button */
.close-panel-btn {
    position: absolute;
    top: var(--space-xs); /* Reduced from --space-sm */
    right: var(--space-sm);
    background: none;
    border: none;
    font-size: 1.8rem; /* Larger 'x' */
    line-height: 1;
    color: var(--text-secondary-color);
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    transition: color 0.2s ease;
}

.close-panel-btn:hover {
    color: var(--text-color);
}

/* Side Panel Item Styles */
.panel-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-size-sm);
    border-radius: var(--border-radius-md); /* Re-add base radius */
    min-height: 2.7rem; /* ADDED consistent minimum height */
}

.panel-item:hover {
    background-color: #eee;
}

.panel-divider {
    height: var(--label-border-thin);
    background-color: var(--input-border);
}

.panel-item .item-label {
    font-weight: 600;
    color: var(--text-secondary-color);
    padding: var(--space-xs) var(--space-sm); /* ADDED padding here for non-link labels */
}

.panel-item .item-control {
    display: flex;
    gap: var(--space-xs);
    margin: var(--space-xs) var(--space-sm);
}

/* Style unit buttons within the panel item */
.side-panel .unit-toggle .unit-button {
    width: auto;
    padding: calc(var(--space-xs) * 0.5) var(--space-xs);
    font-size: calc(var(--font-size-sm) * 0.9);
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    border-radius: var(--border-radius-sm);
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    cursor: pointer;
}

.side-panel .unit-toggle .unit-button:hover:not(.disabled) {
    color: var(--text-color);
    background-color: #eee;
    border-color: var(--text-secondary-color);
}

.side-panel .unit-toggle .unit-button.active {
    background-color: var(--button-bg);
    color: var(--button-text);
    border-color: var(--button-bg);
    font-weight: 600;
    text-decoration: none;
}

.side-panel .unit-toggle .unit-button.disabled {
    cursor: not-allowed;
    opacity: 0.6;
    color: var(--text-secondary-color);
    background-color: #f0f0f0;
    border-color: var(--input-border);
    text-decoration: none;
    transition: none;
}

.side-panel .unit-toggle .unit-button.disabled:hover {
    color: var(--text-secondary-color);
    background-color: #f0f0f0;
    border-color: var(--input-border);
    cursor: not-allowed;
}

/* Specific style for the link buttons in the panel */
.panel-item a.item-label.link-button {
    display: block; /* Make link fill width */
    width: 100%;    /* Make link fill width */
    padding: var(--space-xs) var(--space-sm); /* Apply padding to the link */
    text-decoration: none; /* Ensure no underline */
    color: var(--text-secondary-color); /* Match other labels */
    border-radius: var(--border-radius-md); /* Inherit parent radius for hover */
}

.panel-item a.item-label.link-button:hover {
    background-color: #eee; /* Apply hover background to link */
    text-decoration: none; /* Ensure no underline on hover */
}

/* --- Toggle Switch Styles --- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px; /* Adjust width */
  height: 20px; /* Adjust height */
}

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

.toggle-label {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 20px; /* Height / 2 */
  transition: .4s;
}

.toggle-label:before {
  position: absolute;
  content: "";
  height: 14px; /* Smaller than label height */
  width: 14px; /* Smaller than label height */
  left: 3px; /* Adjust positioning */
  bottom: 3px; /* Adjust positioning */
  background-color: white;
  border-radius: 50%;
  transition: .4s;
}

.toggle-input:checked + .toggle-label {
  background-color: var(--text-color);
}

.toggle-input:checked + .toggle-label:before {
  transform: translateX(20px); /* Width - Height */
}
/* End Toggle Switch Styles */

/* Page Overlay */
.page-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3); /* Reduced opacity from 0.5 */
    opacity: 0;
    visibility: hidden;
    z-index: 1001; /* Below panel, above content */
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

/* --- Body Transition when Panel Open --- */
body.panel-open {
    overflow: hidden; /* Prevent scrolling background */
}

/* Show Overlay when panel is open */
body.panel-open .page-overlay {
    opacity: 1;
    visibility: visible;
}

/* --- Game Content Wrapper (Mobile First) --- */
.game-content-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center; /* Keep centering the sections themselves */
    gap: var(--space-md);
}

/* --- Food Display Section --- */
.food-display-section {
    width: 100%;
    display: flex; /* Use flex to center the card inside */
    justify-content: center;
}

.food-display-card {
    background-color: var(--input-bg);
    border: var(--label-border-thin) solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: var(--space-xs);
    width: 100%; /* Take full width of its column/section */
    max-width: 450px; /* Keep max-width for card */
    margin: 0; /* Remove auto margin, rely on parent flex/grid */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}

.food-display-card:hover {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

.food-image-container {
    max-width: 300px;
    width: 100%;
    margin-bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.food-image {
    display: block;
    max-width: 100%;
    max-height: 250px;
    height: auto;
    border-radius: var(--border-radius-md);
    object-fit: contain;
    border: var(--label-border-thin) solid var(--border-color);
    background-color: #fff;
}

.food-display-card h2 {
    color: var(--text-color);
    font-weight: 600;
    font-size: var(--font-size-lg);
    margin-bottom: 0;
    text-align: center;
}

/* --- Guess Indicators --- */
.guess-indicators {
    display: flex;
    justify-content: left;
    gap: var(--space-xxs); /* Smaller gap */
    width: auto; /* Don't take full width */
    margin-bottom: 0; /* Reset margin */
    margin-right: var(--space-sm);
}

.dot {
    width: 8px; /* Smaller dots */
    height: 8px;
    border-radius: 50%;
}

.dot.used {
    background-color: var(--text-secondary-color);
}

.dot.remaining {
    background-color: transparent;
    border: var(--label-border-thin) solid var(--text-secondary-color);
    align-items: center;
    gap: var(--space-xs);
    flex-shrink: 0;
}

/* --- Nutrition Label Section --- */
.nutrition-label-section {
    width: 100%;
    display: flex; /* Use flex for centering */
    flex-direction: column; /* Stack wrapper and button vertically */
    align-items: center; /* Center items horizontally */
    gap: var(--space-md); /* Add space between wrapper and button */
}

.nutrition-label-form {
    width: 100%; /* Take available width */
    max-width: 350px; /* But don't exceed this */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    /* Removed fixed width: 350px; */
    /* Removed flex-shrink: 0; - Allow shrinking */
}

.nutrition-label {
    background-color: var(--input-bg);
    border: var(--label-border-thin) solid var(--border-color);
    padding: var(--label-padding);
    width: 100%; /* Label takes full width of form */
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text-color);
    line-height: 1.4;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease;
}

.nutrition-label:hover {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

.nutrition-label h3 { /* "Nutrition Facts" */
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin: 0;
    padding-bottom: calc(var(--space-xs) * 0.5);
    border-bottom: 8px solid var(--border-color); /* Thick bottom border */
    text-align: left;
    white-space: nowrap; /* Prevent wrapping */
}

.serving-size-info {
    font-size: var(--font-size-sm);
    margin-top: var(--space-xs);
    margin-bottom: var(--space-xs);
    text-align: left;
    border-bottom: var(--label-border-thin) solid var(--border-color); /* Thin line below serving */
    padding-bottom: var(--space-xs);
    white-space: nowrap; /* Prevent wrapping */
    overflow: hidden; /* Hide overflow if nowrap isn't enough */
    text-overflow: ellipsis; /* Add ellipsis for hidden text */
}

/* --- Calories Section --- */
.calories-section {
    border-bottom: 4px solid var(--border-color);
    padding: var(--space-xs) 0;
    margin-bottom: var(--space-xs);
}

.calories-section label { /* "Amount per serving" */
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 700;
    text-align: left;
    margin-bottom: 2px;
    white-space: nowrap; /* Prevent wrapping */
}

.calories-input-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: var(--font-size-lg);
    font-weight: 700;
}

/* Prevent the 'Calories' or 'Energy (kJ)' text from wrapping */
.calories-input-line span {
    white-space: nowrap;
}

/* Input field within the label */
.calories-input-line input[type="number"] {
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
    border: none;
    border-bottom: var(--label-border-thin) solid var(--border-color);
    background-color: transparent;
    color: var(--text-color);
    font-family: inherit;
    font-weight: 700;
    font-size: var(--font-size-lg);
    padding: 0;
    margin: 0;
    text-align: right;
    width: 80px;
    border-radius: 0;
    box-shadow: none;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.calories-input-line input[type="number"]::-webkit-outer-spin-button,
.calories-input-line input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.calories-input-line input[type="number"]:focus {
    outline: none; /* Remove focus outline */
}
.calories-input-line input[type="number"]::placeholder {
    color: var(--text-secondary-color);
    opacity: 0.7;
    font-weight: 400; /* Lighter placeholder */
}

/* --- Input Feedback Styles --- */
.calories-input-line input[type="number"].input-error {
    color: var(--error-color);
    border-bottom-color: var(--error-color);
}

.calories-input-line input[type="number"].input-correct {
    color: var(--correct-color);
    border-bottom-color: var(--correct-color);
}

/* --- Disabled Input Styles --- */
.calories-input-line input[type="number"]:disabled {
    background-color: transparent; /* Keep background transparent */
    opacity: 0.8; /* Slightly fade */
    /* Color and border-color will be set by .input-correct or default */
}
/* Ensure correct color persists when disabled and correct */
.calories-input-line input[type="number"].input-correct:disabled {
     color: var(--correct-color);
     border-bottom-color: var(--correct-color);
     opacity: 1; /* Don't fade if correct */
}

/* --- Macros Section --- */
.macros-section {
    border-bottom: var(--label-border-thick) solid var(--border-color); /* Thick line at end */
    padding-bottom: var(--space-xs);
}

.macro-line { /* Style for regular display (like on index.html) */
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-base);
    border-bottom: var(--label-border-thin) solid #ddd; /* Light lines between macros */
    padding: 2px 0;
    margin-left: var(--space-sm); /* Indent macros */
}
.macro-line:last-child {
    border-bottom: none; /* No line after last macro */
}

.macro-name {
    font-weight: 700; /* Bold macro names */
    white-space: nowrap;
}

.macro-value { /* Style for the display value (e.g., 10g) */
    font-weight: 400; /* Normal weight for value */
}

/* --- Styles for Macros Game Input Label --- */
.macros-input-section .macros-section {
    padding-bottom: 0; /* Remove bottom padding if only used for inputs */
}

/* Wrapper for form and indicators */
.label-form-wrapper {
    position: relative;
    width: 100%; /* Fill parent section */
    /* Max width = label max-width + feedback width + gap */
    max-width: calc(350px + 70px + var(--space-sm)); /* Adjust 70px if feedback width changes */
    display: flex; /* Arrange form and feedback side-by-side */
    justify-content: center; /* Center content horizontally */
    align-items: flex-start; /* Align tops */
    gap: var(--space-xxs); /* Space between label and feedback */
}

.macro-input-line { /* Style for label line with input (macros.html) */
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: var(--font-size-base);
    border-bottom: var(--label-border-thin) solid #ddd; /* Light lines between macros */
    padding: 4px 0; /* Adjust padding */
    margin-left: var(--space-sm); /* Indent macros */
}
.macro-input-line:last-child {
     border-bottom: none; /* No border after last input line */
}

/* Container for the input and its unit */
.macro-value-input {
    display: inline-flex; /* Align input and unit */
    align-items: baseline;
}

/* Styling for the macro input fields */
.macro-input-line input[type="number"] {
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
    border: none;
    border-bottom: var(--label-border-thin) solid var(--border-color); /* Underline like calorie input */
    background-color: transparent;
    color: var(--text-color);
    font-family: inherit; /* Use label font */
    font-weight: 400; /* Normal weight for input */
    font-size: var(--font-size-base);
    padding: 0 2px; /* Minimal padding */
    margin: 0;
    text-align: right;
    width: 60px; /* Adjust width as needed */
    border-radius: 0;
    box-shadow: none;
    margin-right: 2px; /* Space before unit */
}
.macro-input-line input[type="number"]::-webkit-outer-spin-button,
.macro-input-line input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.macro-input-line input[type="number"]:focus {
    outline: none;
}
.macro-input-line input[type="number"]::placeholder {
    color: var(--text-secondary-color);
    opacity: 0.7;
    font-weight: 400; /* Lighter placeholder */
}

.input-unit {
    font-size: var(--font-size-base);
    font-weight: 400;
    color: var(--text-color);
    margin-left: 1px; /* Small space after input */
}

/* Disabled state for macro inputs */
.macro-input-line input[type="number"]:disabled {
    background-color: transparent;
    opacity: 0.7;
    border-bottom-color: #ccc; /* Lighter border when disabled */
    color: var(--text-secondary-color);
}

/* Hidden Macros State (for index.html toggle) */
#macros-container.macros-hidden .macro-value {
    font-size: 0; /* Hide original text */
}

/* General Button Styling */
button {
    cursor: pointer;
    border: none;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.1s ease;
}
button:active { transform: scale(0.98); }

.button-submit {
    background-color: var(--button-bg); /* Black button */
    color: var(--button-text); /* White text */
    width: 100%;
    max-width: 200px; /* Reduced max-width */
    padding: var(--space-xs) var(--space-md); /* Reduced padding */
    font-size: var(--font-size-sm); /* Reduced font size */
    transition: transform 0.2s ease;
}

.button-submit:hover { 
    background-color: #333; /* Dark gray hover */
    transform: translateY(-1px);
}

/* --- Results Display --- */
.results {
    /* Positioning */
    position: fixed; /* Float over content */
    bottom: var(--space-sm); /* Changed from 2% to a fixed unit */
    left: 50%; /* Center horizontally */
    transform: translateX(-50%);
    z-index: 1000; /* Ensure it's on top */
    width: 90%; /* Responsive width */
    max-width: 500px; /* Limit max width */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); /* Floating shadow */

    /* Original styles */
    padding: var(--space-md);
    border-radius: var(--border-radius-lg);
    font-weight: 600;
    border: 1px solid transparent; /* Base border */
    text-align: center;
    line-height: 1.5;
}

.results.correct {
    /* Revert to solid colors */
    background-color: var(--correct-color);
    color: var(--text-on-correct);
    border-color: var(--correct-color);
    font-weight: 600;
}

.results.game-over {
    /* Revert to solid colors */
    background-color: var(--text-secondary-color); /* Using a dark gray */
    color: var(--bg-color); /* Light text on dark gray */
    border-color: var(--text-secondary-color);
    font-weight: 500;
}

/* --- History Section --- */
.history-section {
    width: 100%;
    padding-top: var(--space-md);
    border-top: var(--label-border-thin) solid var(--border-color); /* Use label border */
}

.history {
    width: 100%;
    padding-top: 0;
    border-top: none;
}

.history h3 {
    color: var(--text-color);
    font-weight: 600;
    font-size: var(--font-size-md);
    margin-bottom: var(--space-sm);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.history ul {
    list-style: none;
    max-height: none; /* Remove height limit or adjust */
    overflow-y: visible; /* Remove scroll */
    scrollbar-width: none; /* Hide scrollbar */
    padding-right: 0;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center history items */
    gap: calc(var(--space-xs) * 0.5); /* Smaller gap */
}
.history ul::-webkit-scrollbar { display: none; } /* Hide scrollbar */

.history li {
    background-color: var(--input-bg); /* White background */
    border: var(--label-border-thin) solid var(--input-border); /* Light gray border, same as input */
    color: var(--text-color); /* Black text by default inside the box */
    margin-bottom: var(--space-xs); /* Space between items */
    padding: var(--space-xs) var(--space-sm); /* Padding inside */
    border-radius: var(--border-radius-md); /* Rounded corners */
    font-size: var(--font-size-sm);
    text-align: center; /* Center text */
    width: 80%; /* Make boxes take up most of the history section width */
    max-width: 300px; /* But limit max width */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); /* Subtle shadow */
    transition: transform 0.2s ease;
}

.history li:hover {
    transform: translateY(-1px);
}

/* Feedback colors override the default black text color */
.history li:contains("✅") { color: var(--correct-color); font-weight: 600; }
.history li:contains("↓"):not(:contains("↓↓")),
.history li:contains("↑"):not(:contains("↑↑")) { color: var(--warning-color); } /* Close */
.history li:contains("↓↓"), .history li:contains("↑↑") { color: var(--error-color); } /* Far */

.no-guesses {
    color: var(--text-secondary-color);
    font-style: italic;
    text-align: center;
    padding: var(--space-sm) 0;
    font-size: var(--font-size-sm);
}

/* --- Report Problem Section (Simplified) --- */
.report-section {
    width: 100%;
    max-width: 100%;
    padding-top: var(--space-lg);
    border-top: var(--label-border-thin) solid var(--border-color); /* Use label border */
    margin-bottom: var(--space-md);
}

.report-section details {
    text-align: center;
}

.report-section summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary-color);
    transition: color 0.2s ease;
    padding-bottom: var(--space-sm);
    text-transform: uppercase;
    font-size: var(--font-size-sm);
}
.report-section summary:hover {
    color: var(--text-color);
}

.report-description {
    color: var(--text-secondary-color);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-md);
}

.report-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.report-form .form-group { width: 100%; }

.report-form textarea {
    width: 100%;
    padding: var(--space-sm);
    border: var(--label-border-thin) solid var(--input-border); /* Lighter border */
    background-color: var(--input-bg); /* White background */
    color: var(--text-color);
    border-radius: var(--border-radius-md);
    font-family: inherit;
    font-size: var(--font-size-base);
    resize: vertical;
    min-height: 80px;
}
.report-form textarea::placeholder {
    color: var(--text-secondary-color);
    opacity: 0.7;
}

.report-form textarea:focus {
    border-color: var(--border-color); /* Black border on focus */
    box-shadow: none;
    outline: none;
    background-color: var(--input-bg);
}

.button-report {
    background-color: var(--text-secondary-color); /* Gray button */
    color: var(--bg-color); /* Off-white text */
    padding: var(--space-xs) var(--space-md);
    font-size: var(--font-size-sm);
}
.button-report:hover { background-color: var(--text-color); } /* Black hover */

/* --- Error Messages --- */
.error { /* General error message styling */
    color: var(--error-color); /* Use error color */
    background-color: rgba(231, 76, 60, 0.1);
    border: 1px solid var(--error-color);
    padding: var(--space-sm);
    border-radius: var(--border-radius-md);
    margin-bottom: var(--space-md);
    font-size: var(--font-size-sm);
    width: 100%;
    text-align: center;
}

.report-form .form-errors {
    color: var(--error-color);
    font-size: var(--font-size-sm);
    margin-top: var(--space-xs);
    text-align: left;
}

/* --- Django Messages --- */
.messages { /* Style the UL container */
    /* Positioning */
    position: fixed; /* Float over content */
    top: var(--space-md); /* Position below header or potential .results */
    left: 50%;
    transform: translateX(-50%);
    z-index: 999; /* Below .results if both appear */
    width: 90%; /* Responsive width */
    max-width: 500px; /* Limit max width */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); /* Floating shadow */

    /* Container styles */
    list-style: none;
    /* width: 100%; REMOVED */
    /* max-width: 100%; REMOVED */
    margin-bottom: 0; /* Remove bottom margin as it's fixed */
    padding: 0;
    border-radius: var(--border-radius-md); /* Apply rounding to the container */
    overflow: hidden; /* Clip children to rounded corners */
}

.messages li {
    padding: var(--space-sm) calc(var(--space-lg) + var(--space-sm)) var(--space-sm) var(--space-sm); /* Add padding-right for button */
    position: relative; /* Needed for absolute positioning of close button */
    /* border-radius: var(--border-radius-md); REMOVED - Applied to UL */
    font-size: var(--font-size-sm);
    /* border-width: 1px; REMOVED - Borders might look odd stacked */
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1); /* Separator line */
}
.messages li:last-child {
    border-bottom: none; /* No line after last message */
}

/* Adjusted Message Type Backgrounds */
.messages li.success {
    /* Revert to solid colors */
    background-color: var(--secondary-color);
    color: var(--text-on-secondary);
    font-weight: 600;
}
.messages li.error {
    /* Revert to solid colors */
    background-color: var(--error-color);
    color: var(--text-on-error);
}
.messages li.warning {
    /* Revert to solid colors */
    background-color: var(--warning-color);
    color: var(--text-on-warning);
}
.messages li.info {
    /* Revert to solid colors */
    background-color: var(--primary-color);
    color: var(--text-on-primary);
}

/* --- Close Button Style --- */
.close-message {
    position: absolute;
    top: 5px; /* Adjust as needed */
    right: 10px; /* Adjust as needed */
    background: none;
    border: none;
    font-size: 1.5rem; /* Make the 'x' larger */
    line-height: 1;
    color: inherit; /* Inherit color from parent message */
    opacity: 0.7;
    cursor: pointer;
    padding: 0.2rem 0.5rem; /* Easier click target */
    transition: opacity 0.2s ease;
}

.close-message:hover {
    opacity: 1;
}

/* --- About Page Styling --- */

/* --- About Text Card --- */
.about-text-card {
    background-color: var(--input-bg);
    border: var(--label-border-thin) solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: var(--space-md);
    width: 100%;
    max-width: 700px;
    margin: 0 auto; /* Center the card */
    margin-top: var(--space-xxs); /* Space from header */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    text-align: left; /* Align text left within the card */
}

/* Styling for headings within the about card */
.about-text-card h2 {
    color: var(--text-color);
    font-weight: 600;
    font-size: var(--font-size-lg); /* Use slightly smaller than header */
    margin-bottom: var(--space-sm);
    /* Removed text-align: center; use inline style if needed per heading */
}

/* Styling for paragraphs within the about card */
.about-text-card p {
    font-size: var(--font-size-sm);
    color: var(--text-secondary-color);
    line-height: 1.6;
    margin-bottom: var(--space-sm); /* Add slightly more space below paragraphs */
}

/* Styling for strong tag within paragraphs */
.about-text-card strong {
    font-weight: 600;
    color: var(--text-color);
}

/* Added styling for lists within the about card */
.about-text-card ul {
    list-style-type: disc; /* Or square, circle, etc. */
    padding-left: var(--space-md); /* Indent the list */
    margin-bottom: var(--space-sm); /* Space below the list */
}

.about-text-card li {
    font-size: var(--font-size-sm); /* Make list items slightly smaller */
    color: var(--text-secondary-color); /* Use secondary text color */
    margin-bottom: var(--space-xs); /* Space between list items */
    line-height: 1.6; /* Match paragraph line height */
}

/* Ensure strong tag inside li inherits size but keeps color */
.about-text-card li strong {
    font-weight: 600;
    color: var(--text-color);
}

/* Adjust back link position relative to card */
.about-container .back-link {
    display: block; /* Make it a block element */
    margin-top: var(--space-md); /* Add space above */
}

.back-link-container {
    text-align: center;
}

.back-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.back-link:hover {
    text-decoration: underline;
}

.about-container {
    padding-top: var(--space-xxl); /* Adjust value as needed */
}

/* Hidden Macros State (for index.html toggle) */
#macros-container.macros-hidden .macro-value {
    /* Hide original text transparently instead of font-size */
    color: transparent;
    /* Ensure it still takes up space for alignment if needed */
    /* display: inline-block; */ /* Optional */
}

#macros-container.macros-hidden .macro-value::before {
    content: "-- g";
    color: var(--text-secondary-color); /* Make the placeholder visible */
    /* Ensure correct font-size if parent was changed */
    font-size: var(--font-size-base);
    font-weight: 400; /* Match original value style */
}

/* Spinner animation */
@keyframes spinner-border {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 2rem; /* Adjust size as needed */
  height: 2rem; /* Adjust size as needed */
  vertical-align: text-bottom;
  border: .25em solid currentColor; /* Use current text color */
  border-right-color: transparent; /* Make one side transparent */
  border-radius: 50%;
  animation: spinner-border .75s linear infinite;
  opacity: 0.7; /* Slightly faded */
  margin-bottom: var(--space-xs); /* Add space below spinner */
}

/* Optional: Center spinner if used within a block container */
#loading-indicator { /* Apply to the specific ID used in message_display.html */
  text-align: center;
}

/* --- Reroll Button Alignment --- */
#reroll-panel-item,
#restore-daily-panel-item {
    padding: 0; /* Remove default padding if it interferes */
}

#reroll-panel-item .reroll-form,
#restore-daily-panel-item .restore-daily-form {
    margin: 0; /* Reset form margin */
    display: flex; /* Align button within form */
    align-items: center;
}

#reroll-panel-item .button-reroll,
#restore-daily-panel-item .button-restore-daily {
    /* Adjust padding if needed to match other controls visually */
    padding: var(--space-xs) var(--space-sm);
    background-color: transparent;
    font-size: var(--font-size-sm);
    color: var(--text-secondary-color);
}

.footer-link-container {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: var(--space-sm);
    padding: var(--space-sm) 0; /* Add padding */
    background-color: var(--bg-color); /* Ensure it has a background */
    flex-shrink: 0; /* Prevent footer from shrinking */
    border-top: var(--label-border-thin) solid var(--input-border); /* Add top border */
    margin-top: var(--space-sm); /* Add some space above the footer */
}
.footer-link-container a {
    display: inline-block; /* Arrange links side-by-side */
    margin: 0 var(--space-sm); /* Spacing between links */
    font-size: var(--font-size-sm); /* Use standard small font size */
    color: var(--text-secondary-color); /* Use secondary text color */
    text-decoration: none; /* Remove underline */
    transition: color 0.2s ease;
}
.footer-link-container a:hover {
    color: var(--text-color); /* Darken on hover */
    text-decoration: underline; /* Add underline on hover */
}

/* Reroll Button Main Styling - Attractive button that appears after game completion */
.reroll-button-container {
    text-align: center;
}

.button-reroll-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.8rem 1.5rem;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
}

.button-reroll-main:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.button-reroll-main:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.button-reroll-main::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.button-reroll-main:hover::before {
    transform: translateX(100%);
}

.reroll-icon {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    display: inline-block;
    animation: spin 2s infinite linear paused;
}

.button-reroll-main:hover .reroll-icon {
    animation-play-state: running;
}

@keyframes spin {
    from {
        transform: rotate(360deg);
    }
    to {
        transform: rotate(0deg);
    }
}

.reroll-text {
    font-size: 1.1rem;
    font-weight: 600;
    display: block;
}

.reroll-count {
    font-size: 0.75rem;
    opacity: 0.9;
    margin-top: 0.3rem;
    display: block;
}

/* Unlimited token styling for the reroll button */
.button-reroll-main[data-token-type="unlimited"] {
    background: linear-gradient(135deg, #FF9900, #FF5EDF);
}

.button-reroll-main[data-token-type="unlimited"] .reroll-count {
    font-size: 0.85rem;
    font-weight: 600;
    color: #FFFF00;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Media query for large screens */
@media (min-width: 1100px) {
    .container {
        max-width: 1000px;
    }

    .game-content-wrapper {
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: start;
        gap: var(--space-md);
        width: 100%;
    }

    /* Adjust section alignment within columns if needed */
    .food-display-section,
    .nutrition-label-section {
        align-items: center;
    }

    .game-content-wrapper {
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: start;
        gap: var(--space-md);
        width: 100%;
    }

    /* Move reroll button under food display card */
    .food-display-section {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .reroll-button-container {
        margin-top: var(--space-sm);
    }

    /* Hide reroll button in nutrition label section on large screens */
    .nutrition-label-section .reroll-button-container {
        display: none;
    }

}

/* Show reroll button in nutrition label section on small screens */
@media (max-width: 1099px) {
    .food-display-section .reroll-button-container {
        display: none;
    }
    .button-reroll-main {
        font-size: 1rem;
        padding: 0.7rem 1.2rem;
    }
    
    .reroll-icon {
        font-size: 1.2rem;
    }
    
    .reroll-text {
        font-size: 1rem;
    }
    
    .reroll-count {
        font-size: 0.7rem;
    }
}

/* Reroll Message Area Styling */
#reroll-message-area {
    display: none; /* Hidden by default, shown by JS */
    padding: var(--space-sm, 12px) var(--space-md, 16px);
    margin: var(--space-md, 16px) auto;
    border-radius: var(--border-radius-md, 8px);
    text-align: center;
    font-size: var(--font-size-md, 1rem);
    font-weight: 500;
    max-width: 500px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid transparent;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    transform: translateY(-10px);
    position: fixed; /* Or absolute, depending on desired placement */
    top: 20px; /* Adjust as needed */
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    z-index: 1050; /* Ensure it's above other content */
    width: auto; /* Auto width based on content, up to max-width */
    min-width: 280px; /* Minimum width */
}

/* Styles for when the message area is shown */
#reroll-message-area.error-message,
#reroll-message-area.success-message,
#reroll-message-area.info-message {
    display: block; /* Ensure it is display block when a message type class is applied */
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Specific message type styling using CSS variables from your project (defaults provided if vars not found) */
#reroll-message-area.success-message {
    background-color: var(--correct-color, #d4edda); /* Light green */
    color: var(--text-on-correct, #155724); /* Dark green */
    border-color: var(--correct-color-darker, #c3e6cb); /* Slightly darker green border */
}

#reroll-message-area.error-message {
    background-color: var(--error-color, #f8d7da); /* Light red */
    color: var(--text-on-error, #721c24); /* Dark red */
    border-color: var(--error-color-darker, #f5c6cb); /* Slightly darker red border */
}

#reroll-message-area.info-message {
    background-color: var(--info-color, #d1ecf1); /* Light blue */
    color: var(--text-on-info, #0c5460); /* Dark blue */
    border-color: var(--info-color-darker, #bee5eb); /* Slightly darker blue border */
}

/* Optional: Add keyframes for a more prominent appearance animation if desired */
@keyframes fadeInRise {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

#reroll-message-area.error-message,
#reroll-message-area.success-message,
#reroll-message-area.info-message {
    animation: fadeInRise 0.4s ease-out forwards;
}
