/* ==========================================================================
   Disable zoom and touch behaviors
   ========================================================================== */

* {
    touch-action: manipulation; /* Prevents double-tap zoom */
    -webkit-tap-highlight-color: transparent; /* Removes tap highlight on iOS */
}

/* Extra protection for interactive elements */
button,
input,
.letter-box,
.virtual-keyboard button,
.action-icon-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

body {
    -webkit-text-size-adjust: 100%; /* Prevents zoom on orientation change */
    -ms-text-size-adjust: 100%;
}

/* ==========================================================================
   Custom Fonts
   ========================================================================== */

@font-face {
    font-family: 'Jost';
    src: url('/fonts/Jost-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Garamond';
    src: url('/fonts/CormorantGaramond-Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Deutsch-gothic';
    src: url('/fonts/Deutsch.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ==========================================================================
   CSS Variables
   ========================================================================== */

:root {
    --color-bg: #4be3bb;
    --color-secondary: #d2b3d2;
    --color-failure-bg: #d35251;
    --color-surface: #fff;
    --color-ink: #000000;
    --color-hint: #5e3766;
    --color-success: #059669;
    --color-border: #000000;
    --color-shadow: rgba(44, 44, 44, 0.08);
    --color-yellow: #ffff00;
    --color-yellow-pale: #fffacd;
    --color-yellow-dark: #e6cc00;
    --color-yellow-medium: #ffeb3b;
    --color-yellow-light: #fff9c4;
    --color-paper: #f9f9f7;

    /* Modal / notification unified text color */
    --color-modal-text: #ffffff; /* solid color usage */
    /* Space-separated channels for alpha variants (use with rgba(var(--color-modal-text-channels) / <alpha>)) */
    --color-modal-text-channels: 255 255 255; /* corresponds to #ffffff */

    /* RGB versions for opacity usage */
    --color-bg-rgb: 75, 227, 187;      /* #4be3bb */
    --color-ink-rgb: 0, 0, 0;          /* #000000 */
    --color-hint-rgb: 94, 55, 102;     /* #5e3766 */

    --font-logo: 'Deutsch-gothic', system-ui, -apple-system, sans-serif;
    --font-sans: 'Jost', system-ui, -apple-system, sans-serif;
    --font-serif: 'Spectral', 'Garamond', Georgia, serif;

    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;

    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;

    --shadow-sm: 0 1px 3px var(--color-shadow);
    --shadow-md: 0 4px 6px var(--color-shadow);
    --shadow-lg: 0 10px 15px var(--color-shadow);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

* {
    box-sizing: border-box;
}

body {
    background: var(--color-bg);
    color: var(--color-ink);
    font-family: var(--font-sans);
    line-height: 1.6;
    margin: 0;
    min-height: 100vh;
}

/* Ensure containers never exceed viewport */
.max-w-6xl {
    max-width: 100% !important;
}

/* Mobile-specific adjustments */
@media (max-width: 1100px) {
    .max-w-6xl {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    /* Ensure letter boxes don't overflow */
    .w-12 {
        width: 2.5rem !important;
    }

    /* Constrain any wide elements */
    * {
        max-width: 100%;
    }
}

/* ==========================================================================
   Header & Logo
   ========================================================================== */


/* Fixed-size logo */
.logo-top-left {
    font-family: var(--font-logo);
    color: var(--color-yellow);
    font-weight: normal;
    font-size: clamp(4rem, 8vw, 8rem);
    line-height: 0.8;
    margin: 0;
    letter-spacing: 0.4em;
    text-shadow: 2px 2px 2px rgba(128, 128, 128, 0.25);
    align-self: start;
    justify-self: start;
}


/* Main wrapper for full-width sticky header structure */
.game-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Full-width sticky header wrapper */
.grid-logo-wrapper {
    position: sticky;
    top: 0;
    z-index: 500; /* Above keyboard (40), below emojis (600) */
    width: 100%;
    background-color: var(--color-bg); /* Match body background */
    /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); Subtle shadow for depth */
    transition: background-color 0.3s ease; /* Smooth transition to failure state */
}

/* Failure state for sticky header wrapper */
.grid-logo-wrapper.failure-state {
    background-color: var(--color-failure-bg);
}

/* Logo content centered within wrapper */
.grid-logo {
    max-width: 640px;
    margin: 0 auto;
    padding: clamp(1rem, 2vw, 2rem) clamp(1rem, 3vw, 2rem) clamp(0.5rem, 1vw, 1rem);
    display: flex;
    justify-content: space-between;
    align-items: start;
}

/* Simplified container replacing previous grid-based layout */
.game-grid {
    --grid-unit: clamp(0.5rem, 2vw, 1rem);
    --component-scale: clamp(0.9, 2vw, 1.1);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    /* Remove top padding since header is now separate */
    padding: 0 clamp(1rem, 3vw, 2rem) clamp(6rem, 8vh, 7rem) clamp(1rem, 3vw, 2rem);
    gap: clamp(1rem, 2.5vw, 2rem);
}

/* Remove unused legacy classes */
.grid-tray, .desktop-menu-toggle, .mobile-menu-toggle, .full-height-tray { display: none !important; }
.grid-round-tracker, .grid-clue, .grid-input, .grid-status { width: 100%; }


/* Legacy sidebar support - keeping for compatibility */
.sidebar {
    background: var(--color-surface);
    border-radius: 0; /* Squared */
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: var(--space-lg);
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: var(--color-border);
    border-radius: 4px 0 0 4px;
}

/* ==========================================================================
   Game Components
   ========================================================================== */


.pass-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    transition: all 0.2s ease;
}

.pass-number {
    font-size: 0.75rem;
    font-weight: bold;
    position: absolute;
    top: 0.25rem;
    left: 0.25rem;
    color: var(--color-hint);
    pointer-events: none;
    z-index: 2;
}

/* ==========================================================================
   Clue Display
   ========================================================================== */

.clue-container {
    margin: var(--space-xl) 0;
    text-align: left;
}

.clue-display {
    align-self: start;
    text-align: left;
    width: 100%;
}

.clue-text {
    font-family: 'Garamond', 'EB Garamond', Georgia, serif;
    /* Combine width + height responsiveness: grows a bit on taller screens */
    font-size: clamp(2rem, 3vh + 2vw, 4rem);
    font-weight: 100;
    line-height: 1.5;
    color: var(--color-ink);
    letter-spacing: -0.03em;
    margin: 0;
    text-align: left;
    font-variant-numeric: lining-nums; /* Capital/lining numbers */
    max-width: 100%;
    text-shadow: 1px 1px 2px rgba(128, 128, 128, 0.25);
}

.letter-count {
    color: var(--color-ink);
    margin-left: var(--space-xs);
    opacity: 0.9;
    font-size: 0.9em;
    font-family: 'Garamond', 'EB Garamond', Georgia, serif; /* Garamond as requested */
    font-variant-numeric: lining-nums; /* Capital/lining numbers */
    text-shadow: 1px 1px 2px rgba(128, 128, 128, 0.25);
}


/* ==========================================================================
   Input Components - Grid-based Layout
   ========================================================================== */

.input-section {
    align-self: start;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.input-with-buttons,
.letter-boxes-with-buttons {
    display: grid;
    gap: calc(var(--grid-unit) * 2);
    align-items: start;
}

.input-with-buttons {
    grid-template-columns: auto auto;
    grid-template-areas:
        "input buttons";
}

.letter-boxes-with-buttons {
    grid-template-columns: auto auto;
    grid-template-areas:
        "boxes buttons";
}

/* Responsive stacking on mobile */
@media (max-width: 1100px) {
    .input-with-buttons,
    .letter-boxes-with-buttons {
        grid-template-columns: 1fr;
        grid-template-areas:
            "input"
            "buttons";
    }

    .letter-boxes-with-buttons {
        grid-template-areas:
            "boxes"
            "buttons";
    }
}

.input-with-buttons > input { grid-area: input; }
/* (Removed .button-group usage; layout now relies solely on keyboard actions) */

.input-container {
    margin: var(--space-xl) 0;
    display: flex;
    justify-content: flex-start;
}

.text-input-container {
    display: flex;
    justify-content: flex-start;
}

.text-input {
    width: calc(24rem * var(--component-scale));
    height: calc(3rem * var(--component-scale));
    border: 2px solid var(--color-border);
    background: var(--color-surface);
    font-size: calc(1.25rem * var(--component-scale));
    font-family: var(--font-sans);
    font-weight: 500;
    text-align: center;
    text-transform: uppercase;
    color: var(--color-ink);
    border-radius: 0;
    outline: none;
    transition: border-color 0.2s ease;
    text-shadow: 2px 2px 2px rgba(128, 128, 128, 0.25);
}

.text-input:focus {
    border-color: var(--color-border);
}

.text-input::placeholder {
    font-family: var(--font-hint);
    color: var(--color-hint);
    opacity: 0.6;
    text-transform: none;
    font-weight: normal;
}

.letter-boxes-container {
    display: flex;
    justify-content: flex-start;
}

.letter-boxes {
    display: inline-flex;
    gap: 0;
}

.letter-box {
    width: calc(3rem * var(--component-scale));
    height: calc(3rem * var(--component-scale));
    border: 2px solid var(--color-border);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(1.25rem * var(--component-scale));
    font-family: var(--font-sans);
    font-weight: 500;
    text-transform: uppercase;
    color: var(--color-ink);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    text-shadow: 2px 2px 2px rgba(128, 128, 128, 0.25);
}

/* ==========================================================================
   Letter Box Styling - SIMPLE APPROACH
   ========================================================================== */

/* All letter boxes have complete borders and touch edge-to-edge */
.letter-box {
    border: 2px solid var(--color-border);
    margin-left: -2px; /* Overlap borders so they touch */
}

.letter-box:first-child {
    margin-left: 0; /* First box doesn't overlap */
}



.position-indicator {
    position: absolute;
    top: 0.125rem;
    left: 0.25rem;
    font-size: 0.625rem;
    color: var(--color-hint);
    pointer-events: none;
}

/* ==========================================================================
   Button Components
   ========================================================================== */
/* 
.button-container {
    margin: var(--space-xl) 0;
    display: flex;
    justify-content: flex-start;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.btn-primary {
    background: var(--color-yellow);
    color: var(--color-ink);
    border: none;
    border-radius: 0;
    padding: 0.75rem 2rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    text-transform: lowercase;
    width: clamp(5rem, 15vw, 6rem);
    height: clamp(2.5rem, 8vw, 3rem);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-yellow-medium);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--color-yellow-pale);
    color: var(--color-ink);
    border: none;
    border-radius: 0;
    padding: 0.75rem 2rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: lowercase;
    width: clamp(5rem, 15vw, 6rem);
    height: clamp(2.5rem, 8vw, 3rem);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-yellow-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
} */

/* ==========================================================================
   Game Container
   ========================================================================== */
.game-container {
    font-size: clamp(0.875rem, 2.5vw, 1.125rem);
    container-type: inline-size;
}

.game-container > * {
    width: 100%;
    max-width: 100%;
}

/* Consistent width for all major elements */
.game-container .clue-display,
.game-container .input-section,
.game-container .round-tracker-section,
.game-container .letter-boxes-section {
    margin-left: 0%;
    margin-right: 0%;
    width: 100%;
    margin-bottom: 0.1 ch;
}

.game-container .clue-display {
    text-align: left;
}

.game-container .input-section,
.game-container .round-tracker-section,
.game-container .letter-boxes-section {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.game-container * {
    box-sizing: border-box;
}

/* Responsive layout within container */
@container (max-width: 600px) {
    .game-container .clue-display,
    .game-container .input-section,
    .game-container .round-tracker-section,
    .game-container .letter-boxes-section {
        margin-left: 15%;
        margin-right: 15%;
        width: 70%;
    }

    .game-container .inline-to-stack {
        flex-direction: column !important;
        gap: 1rem !important;
        align-items: flex-start !important;
    }
}

@container (max-width: 400px) {
    .game-container .buttons-inline {
        flex-direction: column !important;
        width: 100% !important;
    }

    .game-container .btn-primary,
    .game-container .btn-secondary {
        width: 100% !important;
    }
}

/* ==========================================================================
   Round Tracker - Grid Layout
   ========================================================================== */
.round-tracker-container {
    display: grid;
    grid-template-columns: 1fr auto; /* Left: tracker boxes grow, Right: icon cluster */
    gap: calc(var(--grid-unit) * 1);
    align-items: center;
    width: 100%;
}

/* Increase space below round tracker before the clue section */
/* .grid-round-tracker { margin-bottom: 0.1 ch; } */

/* Ensure clue doesn't collapse upward if margins combine */
.grid-clue { margin-top: 0 !important; }

/* Ensure the tracker boxes wrap gracefully and icons stay visible */
.round-tracker-container > div:first-child {
    min-width: 0;
}

.round-tracker-container .relative.flex.items-center.gap-2 {
    justify-self: end;
}

.round-tracker-current {
    background: var(--color-yellow) !important;
}
.round-tracker-future {
    background: var(--color-yellow-pale) !important;
}
.round-tracker-past {
    background: var(--color-yellow-light) !important;
}
.round-tracker-correct {
    background: var(--color-yellow-medium) !important;
}

/* Ensure consistent font family and weight for round tracker numbers across main and modal */
/* More specific selector to avoid affecting date text */
.grid-round-tracker .round-tracker-container span,
.result-modal-header .round-tracker-container span {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    font-weight: 700 !important;
}

/* Fixed Round Tracker */
.round-tracker-fixed {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Date Navigation (Above Round Tracker)
   ========================================================================== */

.date-nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.8rem;
    padding: 0.5rem 0;
}

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

.date-arrow-btn {
    background: transparent;
    border: none;
    color: var(--color-hint);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.date-arrow-btn:hover:not(:disabled) {
    opacity: 1;
    transform: scale(1.1);
}

.date-arrow-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

.date-text-main {
    font-family: var(--font-sans) !important; /* Jost font - force override */
    font-size: 1.1rem;
    font-weight: 400 !important; /* Match Jost-Regular.ttf weight */
    color: var(--color-hint);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
    transition: background-color 0.2s ease;
    user-select: none;
}

/* Also apply to child spans */
.date-text-main span {
    font-family: inherit;
    font-weight: inherit;
}

.date-text-main.clickable {
    cursor: pointer;
}

.date-text-main.clickable:hover {
    background-color: rgba(0, 0, 0, 0.05);
}


.calendar-icon-btn {
    background: transparent;
    border: none;
    color: var(--color-hint);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.calendar-icon-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Mobile adjustments */
@media (max-width: 640px) {
    .date-nav-row {
        padding: 0.375rem 0;
    }

    .date-text-main {
        font-size: 0.9rem;
    }

    .date-display-center {
        gap: 0.375rem;
    }
}

/* Smooth transitions for date navigation */
.game-grid {
    will-change: opacity, transform;
    transform-origin: center center;
}

/* ==========================================================================
   Calendar Date Picker Modal
   ========================================================================== */

.calendar-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1300; /* Above menu (1200), below result modal (1500) */
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
}

.calendar-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.calendar-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.calendar-month-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.calendar-nav-btn {
    background: transparent;
    border: none;
    color: var(--color-hint);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.calendar-nav-btn:hover:not(:disabled) {
    opacity: 1;
}

.calendar-nav-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

.calendar-month-year {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-ink);
    min-width: 140px;
    text-align: center;
}

.calendar-close-btn {
    background: transparent;
    border: none;
    color: var(--color-hint);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.calendar-close-btn:hover {
    opacity: 1;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.375rem;
}

.calendar-day-label {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-ink);
    text-align: center;
    padding: 0.5rem 0;
}

.calendar-day-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.125rem;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 0.875rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-ink);
    position: relative;
}

.calendar-day-cell:hover:not(.disabled):not(.today) {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
}

.calendar-day-cell.today {
    background: var(--color-yellow);
    font-weight: 600;
    border-color: var(--color-yellow-dark);
}

.calendar-day-cell.completed {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

.calendar-day-cell.completed:hover:not(.disabled) {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.4);
}

.calendar-day-cell.failed {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.calendar-day-cell.failed:hover:not(.disabled) {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
}

/* Selected day overrides - must come after status classes */
.calendar-day-cell.selected.completed,
.calendar-day-cell.selected.failed,
.calendar-day-cell.selected {
    border: 2px solid rgba(0, 0, 0, 0.6) !important;
    font-weight: 700;
}

.calendar-day-cell .status-icon {
    font-size: 0.7rem;
    line-height: 1;
}

.calendar-day-cell.completed .status-icon {
    color: rgb(34, 197, 94);
}

.calendar-day-cell.failed .status-icon {
    color: rgb(239, 68, 68);
}

.calendar-day-cell.disabled {
    color: rgba(0, 0, 0, 0.2);
    cursor: not-allowed;
}

.calendar-day-cell.other-month {
    color: rgba(0, 0, 0, 0.3);
}

/* Mobile adjustments */
@media (max-width: 640px) {
    .calendar-modal-content {
        width: 95%;
        padding: 1.25rem;
    }

    .calendar-day-cell {
        font-size: 0.8rem;
    }

    .calendar-month-year {
        font-size: 0.9rem;
        min-width: 120px;
    }
}

/* ==========================================================================
   Previous Guesses
   ========================================================================== */

.previous-guesses {
    margin: var(--space-xs) 0;
    text-align: left;
    display: flex;
    justify-content: flex-start;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* .guess-item {
    font-size: clamp(1rem, 3vh, 2rem);
    color: var(--color-hint);
    opacity: 0.8;
} */

/* ==========================================================================
   Result Message
   ========================================================================== */

.result-message {
    margin: var(--space-lg) 0;
    text-align: left;
    color: var(--color-ink);
    font-weight: 300;
    white-space: pre-line;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.loading-screen {
    position: fixed;
    inset: 0;
    background: rgba(245, 245, 240, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(2px);
}

/* ==========================================================================
   Development Info
   ========================================================================== */

.dev-info {
    max-width: 7xl;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-sm);
    border-top: 1px solid rgba(139, 115, 85, 0.2);
    margin-top: var(--space-xl);
}

.dev-reset-btn {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    border: 1px solid var(--color-hint);
    color: var(--color-hint);
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: var(--space-sm);
}

.dev-reset-btn:hover {
    border-color: var(--color-border);
    color: var(--color-border);
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.bg-riddle-paper {
    background-color: var(--color-paper);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Color Classes - Single Source of Truth */
.bg-riddle-beige { background-color: var(--color-bg); }
.bg-riddle-secondary { background-color: var(--color-secondary); }
.bg-riddle-yellow { background-color: var(--color-yellow); }
.text-riddle-ink { color: var(--color-ink); }
.text-riddle-hint { color: var(--color-hint); }
.border-riddle-ink { border-color: var(--color-ink); }
.border-riddle-hint { border-color: var(--color-hint); }
.border-riddle-secondary { border-color: var(--color-secondary); }
.border-l-riddle-ink { border-left-color: var(--color-ink); }
.border-r-riddle-ink { border-right-color: var(--color-ink); }
.bg-riddle-ink { background-color: var(--color-ink); }

/* Revealed Letter Box - Maximum specificity to override Tailwind */
html div.revealed-letter-box,
html .revealed-letter-box,
.revealed-letter-box.revealed-letter-box.revealed-letter-box {
    background: #d1fae5 !important; /* light green */
    background-color: #d1fae5 !important;
    border-color: #10b981 !important; /* green border */
    color: #000000 !important;
    font-weight: bold !important;
}


/* Opacity variants */
.text-riddle-hint\/60 { color: rgba(var(--color-hint-rgb), 0.6); }
.text-riddle-hint\/40 { color: rgba(var(--color-hint-rgb), 0.4); }
.border-riddle-hint\/20 { border-color: rgba(var(--color-hint-rgb), 0.2); }
.border-riddle-hint\/10 { border-color: rgba(var(--color-hint-rgb), 0.1); }
.bg-riddle-beige\/50 { background-color: rgba(var(--color-bg-rgb), 0.5); }
.bg-riddle-hint\/10 { background-color: rgba(var(--color-hint-rgb), 0.1); }
.bg-riddle-hint\/20 { background-color: rgba(var(--color-hint-rgb), 0.2); }
.bg-riddle-ink\/80 { background-color: rgba(var(--color-ink-rgb), 0.8); }
.bg-riddle-secondary\/80 { background-color: rgba(255, 229, 255, 0.8); } /* #ffe5ff with 80% opacity */

/* Hover variants */
.hover\:text-riddle-ink:hover { color: var(--color-ink); }
.hover\:text-riddle-secondary:hover { color: var(--color-secondary); }
.hover\:border-riddle-secondary:hover { border-color: var(--color-secondary); }
.hover\:bg-riddle-ink\/80:hover { background-color: rgba(var(--color-ink-rgb), 0.8); }
.hover\:bg-riddle-hint\/20:hover { background-color: rgba(var(--color-hint-rgb), 0.2); }

/* ==========================================================================
   Grid Tray Integration - No Manual Layout Adjustments Needed
   ========================================================================== */

/* Grid automatically handles tray space allocation */

/* ==========================================================================
   Definition Highlighting
   ========================================================================== */

mark {
    background: var(--color-yellow); /* Main yellow for definition highlighting */
    color: inherit; /* Keep original text color - don't fade */
    padding: 0.125rem 0.25rem;
    border-radius: 0; /* Squared */
    font-weight: inherit; /* Keep original weight - not bold */
}

/* Indicator underlining (Round 4+) */
.indicator-underline {
    text-decoration: underline;
    text-decoration-color: var(--color-yellow);
    text-decoration-thickness: 3px;
    text-underline-offset: 5px;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 1100px) {
    :root {
        --space-xl: 2rem;
        --space-lg: 1.5rem;
    }

    .letter-box {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.125rem;
    }

    .text-input {
        width: 20rem;
        height: 2.5rem;
        font-size: 1.125rem;
    }

    .button-container {
        gap: var(--space-xs);
    }

    .btn-primary,
    .btn-secondary {
        padding: 0.625rem 1.5rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 480px) {
    .letter-box {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1rem;
    }

    .text-input {
        width: 18rem;
        height: 2.25rem;
        font-size: 1rem;
    }

    .position-indicator {
        font-size: 0.5rem;
    }
}

/* FINAL OVERRIDE - Revealed Letter Box - Must be at end of file for specificity */
div[data-debug-revealed="true"],
div.revealed-letter-box {
    background: #d1fae5 !important; /* light green */
    background-color: #d1fae5 !important;
    border-color: #10b981 !important; /* green border */
    color: #000000 !important;
    font-weight: bold !important;
}


/* Responsive letter box sizing */
.letter-box-responsive {
    width: clamp(2.3rem, 8vw, 3rem);
    height: clamp(2.3rem, 8vw, 3rem);
    min-width: 2.3rem; /* Do not shrink below this; enables horizontal scroll instead */
    min-height: 2.3rem;
    flex: 0 0 auto; /* Prevent flexbox from shrinking boxes to fit; allow overflow */
}

/* Simple horizontal scroll container for letter boxes (always show scrollbar space) */
.letter-boxes-scroll {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    gap: 0; /* borders touch already */
    scrollbar-gutter: stable; /* Reserve space so layout doesn't shift */
    padding-bottom: 0.4rem; /* Room for scrollbar so boxes not flush */
}
/* Restore native scrollbar styling */
.letter-boxes-scroll::-webkit-scrollbar { height: 8px; }
.letter-boxes-scroll::-webkit-scrollbar-track { background: rgba(0,0,0,0.08); }
.letter-boxes-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.35); border-radius: 4px; }
.letter-boxes-scroll::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.5); }
/* Firefox */
.letter-boxes-scroll { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.45) rgba(0,0,0,0.1); }

/* ==========================================================================
   Countdown Timer
   ========================================================================== */

/* Countdown timer in modal (above round tracker) */
.countdown-timer-modal {
    margin-bottom: 1.25rem;
    text-align: center;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: clamp(0.95rem, 2.25vh, 1.15rem);
    font-weight: bold;
    text-transform: uppercase;
    /* Lighter version of modal text color - subtle but readable */
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.1em;
}

/* ==========================================================================
   Celebration Animations - Chaos Emoji Catherine Wheel
   ========================================================================== */

/* CELEBRATION OVERLAY - No background, just container */
.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Lowered from 999 so top-level menus/tooltips can layer above celebrations */
    z-index: 30;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

.celebration-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Base celebration emoji styles */
.celebration-emoji {
    position: fixed;
    font-size: 2rem;
    pointer-events: none;
    /* Above logo row (500), below menu (1200) */
    z-index: 600;
}

/* Elevate top menu button & dropdown definitively above celebration and all emojis */
.top-menu-btn { position: relative; z-index: 1200; }
.main-menu-dropdown {
    position: relative;
    z-index: 1200 !important;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.menu-item {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    color: #333;
    font-weight: 400;
}

.menu-item:hover {
    background: rgba(0, 0, 0, 0.03) !important;
    color: #000;
}

.menu-arrow {
    display: inline-block;
    width: 12px;
    color: #999;
    margin-right: 4px;
}

.menu-item:hover .menu-arrow {
    color: #333;
}

/* How To Play (help) must sit above everything except toast notifications */
.how-to-play-trigger { position: relative; z-index: 2000; }
.how-to-play-overlay { z-index: 2000 !important; }

/* ==========================================================================
   Previous Guesses Styling
   Centralized styles replacing scattered Tailwind utility classes
   ========================================================================== */
.previous-guesses-above { margin-bottom: 1ch; }
.previous-guesses-list {
    font-size: clamp(0.9rem, 2vh, 1.5rem);
    color: var(--riddle-ink, #222);
    font-weight: 500; /* font-medium */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem; /* replaces space-x-2 with gap for wrapping */
}
.previous-guess { display: inline-flex; align-items: center; }
.previous-guess .guess-text { font-weight: 500; }
.previous-guess--correct .guess-text { color: var(--riddle-ink, #222); text-decoration: none; }
.previous-guess--wrong .guess-text,
.previous-guess--hint .guess-text,
.previous-guess--giveup .guess-text {
    text-decoration: line-through;
    font-style: italic;
    color: rgba(92, 17, 17, 0.55);
}
.previous-guess--wrong .guess-text { font-style: normal;}
.guess-icon { margin-left: 0.25rem; font-size: 0.75rem; line-height: 1; }
.guess-icon.correct { color: #065f46; /* green-800 */ }
.guess-icon.wrong { color: #7f1d1d; /* red-800 */ margin-left: 0.35rem; }


/* ==========================================================================
   Round Tips Display - Elegant Serif Style (Option 2)
   ========================================================================== */

.round-tip {
    position: relative;
    font-family: var(--font-serif);
    color: var(--color-ink);
    font-size: clamp(1rem, 2.2vh, 1.3rem);
    text-align: left;
    margin-top: 1rem;
    font-style: italic;
    font-weight: 300;
    line-height: 1.05;
    max-width: 70%;
    width: 100%;

    /* Info box styling */
    background: rgba(255, 229, 255, 0.5);
    border: 1px solid rgba(255, 229, 255, 0.2);
    border-left: 3px solid var(--color-secondary);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);

    /* Subtle animation */
    opacity: 0;
    transform: translateY(10px);
    animation: roundTipFadeIn 0.4s ease-out 0.2s forwards;
}

/* Make round tip clickable when expandable (round 4+) */
.round-tip.clickable {
    cursor: pointer;
}

.round-tip.clickable:hover {
    opacity: 0.85;
}

/* Expand arrow inline at end of round tip text */
.round-tip-expand-arrow {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    font-style: normal;
    color: var(--color-ink);
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0.6;
    vertical-align: middle;
}

.round-tip-expand-arrow:hover {
    opacity: 1;
}

.round-tip-expand-arrow.expanded {
    transform: rotate(180deg);
}

/* Expanded clue type descriptions within round tip box */
.clue-type-expanded-content {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(210, 179, 210, 0.3);
}

.clue-type-list {
    margin: 0;
    padding-left: 1.2rem;
    list-style: square;
    font-style: normal;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    line-height: 1.6;
}

.clue-type-item {
    margin-bottom: 0.5rem;
    font-weight: normal;
    color: var(--color-ink);
}

.clue-type-item:last-child {
    margin-bottom: 0;
}

.clue-type-item strong {
    text-transform: capitalize;
    font-weight: bold;
    color: var(--color-ink);
}

/* On wide screens, make round tip span both input and button columns */
@media (min-width: 1100px) {
    .letter-boxes-with-buttons .round-tip {
        grid-column: 1 / -1; /* Span all columns */
        max-width: 100%;
    }
}

@keyframes roundTipFadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}
/* Optimized celebration container */
#celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;

    /* Create a stacking context without preserve-3d */
    transform: translateZ(0);

    /* Isolate layout only - not paint (avoid compositing issues) */
    contain: layout;
}

/* Optimized particle styles */
.celebration-emoji.catherine-wheel {
    position: fixed;
    font-size: calc(3rem * var(--size-multiplier, 1));
    pointer-events: none;
    z-index: 600;
    
    /* Only use will-change, not both will-change and transform */
    will-change: transform;
    
    /* Lighter containment to avoid compositing conflicts */
    contain: layout;
    
    /* Prevent text selection and improve rendering */
    user-select: none;
    -webkit-user-select: none;
    
    /* Optimize text rendering for animation */
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: subpixel-antialiased;
    
    /* GPU acceleration hint without conflicting transform */
    backface-visibility: hidden;
    
    /* Reduce paint complexity */
    isolation: isolate;
}

/* Frozen state optimization */
.celebration-emoji.frozen {
    /* Remove from GPU animation pipeline */
    will-change: auto;
    animation: none !important;
    transition: none !important;
}

/* Commiseration emoji - simple falling animation */
.commiseration-emoji {
    position: fixed;
    font-size: 80px;
    pointer-events: none;
    z-index: 600; /* Above logo row (500), below menu (1200) */
    user-select: none;
}

/* ==========================================================================
   Result Overview Modal - V3 Final Design
   ========================================================================== */

/* Notification bar at bottom - MOBILE ONLY */
.result-notification-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-bg);
    color: var(--color-modal-text);
    padding: 1rem;
    text-align: center;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    z-index: 1000; /* Above emojis (600) and logo (500), below menu (1200) */
    box-shadow: 0 -10px 15px rgba(0, 0, 0, 0.15);
    transition: background 0.2s;    
}

.result-notification-bar:hover {
    background: #6a666a;
}

/* Failure state styling for notification bar */
.result-notification-bar.failure-state {
    background: #d35251;
    color: white;
}

.result-notification-bar.failure-state:hover {
    background: #c24241;
}

/* Unified layout: keep notification bar eligible at all widths (visibility controlled by Alpine) */

/* MOBILE: Modal wrapper - slides up from bottom */
.result-modal-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1600; /* Above backdrop (1500), below how-to modal (2000) */
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
    padding-top: 5rem; /* Responsive gap so logo/title remain visible on all screens */
}

.result-modal-wrapper .result-modal-card {
    pointer-events: auto;
}

/* MOBILE: Modal card content - takes nearly full screen, only title visible */
.result-modal-card {
    position: relative;
    width: 100%;
    max-height: calc(100vh - 5rem); /* Match wrapper padding to prevent overflow */
    background: var(--color-bg);
    padding: 3rem 1.5rem 2rem 1.5rem;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    border-radius: 10px 10px 0 0;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
    color: var(--color-modal-text);
}

/* MOBILE: Slide up animation */
.result-modal-wrapper.modal-open .result-modal-card {
    transform: translateY(0);
}

/* Failure state styling for modal card */
.result-modal-card.failure-state {
    background: #d35251;
    color: white;
}

/* Removed desktop-centered variant – single mobile sheet pattern for all widths */

/* Minimize button - mobile only */
/* Bottom sheet drag handle (unified across widths) - ENLARGED for easier tap */
.modal-minimize-btn {
        position: absolute;
        top: 0.5rem;
        left: 50%;
        transform: translateX(-50%);
        /* Larger tap target area */
        width: 5rem;
        height: 1.5rem;
        cursor: pointer;
        transition: background 0.2s, opacity 0.2s;
        /* Visual indicator inside the tap area */
        display: flex;
        align-items: center;
        justify-content: center;
}
/* The actual visible bar inside the tap area */
.modal-minimize-btn::before {
        content: '';
        width: 3.25rem;
        height: 0.35rem;
        background: rgba(255, 255, 255, 0.6);
        border-radius: 4px;
        transition: background 0.2s;
}
.modal-minimize-btn:hover::before { background: rgba(255,255,255,0.8); }
@media (hover:none) {
    .modal-minimize-btn:hover::before { background: rgba(255,255,255,0.6); }
}

/* Desktop results button - matches notification bar style, positioned under input */
/* Removed desktop-only results button */




/* Header: Round Tracker + Title */
.result-modal-header {
    text-align: center;
    margin-bottom: 2rem;
    margin-top: 1rem;
}

.result-modal-emoji {
    font-size: 3.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

.result-modal-title {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--color-modal-text);
    margin: 0;
    line-height: 1.3;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    margin-top: 0.75rem;
}

.clue-constructor-inline {
    /* font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; */
    font-family: 'Iowan Old Style', 'Palatino Linotype', 'URW Palladio L', P052, serif;
    font-size: clamp(1.5rem, 2vh + 1.5vw, 3rem); /* Match clue text size */
    font-weight: 400;
    color: rgba(255, 255, 255, 0.4); /* Match countdown timer color */
    text-shadow: none;
}

/* Explanation section */
.result-modal-explanation-section {
    margin-bottom: 1.5rem;
    cursor: pointer;
}

.result-modal-explanation-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 0.8rem;
    color: var(--color-modal-text);
    cursor: pointer;
    font-weight: 500;
    padding: 0.75rem 1rem;
    width: 100%;
    text-align: left;
    border-radius: 6px;
    transition: background 0.2s;
}

.result-modal-explanation-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.result-modal-explanation-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    margin-top: 0.5rem;
}

.result-modal-explanation-content.open {
    max-height: 300px;
}

.result-modal-explanation-text {
    font-size: 0.9rem;
    color: var(--color-modal-text);
    line-height: 1.6;
    margin: 0;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* Today's Performance Stars Section */
.today-stats-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.today-stats-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-modal-text);
    margin-bottom: 0.75rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.today-stats-stars {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.stars-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.stars-label {
    font-size: 0.9rem;
    color: var(--color-modal-text);
    font-weight: 500;
    min-width: 70px;
    text-align: right;
}

.stars-display {
    font-size: 1.5rem;
    line-height: 1;
    letter-spacing: 0.1em;
}

.star-filled {
    color: #FFD700; /* Gold */
}

.star-filled-avg {
    color: rgba(255, 215, 0, 0.6); /* Lighter gold for average */
}

.star-empty {
    color: rgba(255, 255, 255, 0.3);
}

.today-stats-percentile {
    text-align: center;
    font-size: 0.9rem;
    color: var(--color-modal-text);
    font-weight: 500;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* Stats overview - 3 in a row */
.result-modal-stats-overview {
    margin-bottom: 1.5rem;
}

.result-modal-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.result-modal-stat-item {
    text-align: center;
}

.result-modal-stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--color-modal-text);
    line-height: 1;
    margin-bottom: 0.25rem;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.result-modal-stat-label {
    font-size: 0.7rem;
    color: rgba(var(--color-modal-text-channels) / 0.8);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* Guess distribution section */
.result-modal-distribution-label {
    font-size: 0.7rem;
    color: rgba(var(--color-modal-text-channels) / 0.8);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.result-modal-distribution-grid {
    display: grid;
    gap: 0.35rem;
}

.result-modal-distribution-row {
    display: grid;
    grid-template-columns: 1.25rem 1fr;
    gap: 0.4rem;
    align-items: center;
}

.result-modal-distribution-label-num {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-modal-text);
    text-align: right;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.result-modal-distribution-bar {
    background: rgba(255, 255, 255, 0.3);
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.4rem;
    min-width: 2rem;
    transition: all 0.3s ease;
    border-radius: 4px;
}

.result-modal-distribution-bar.today,
.result-modal-distribution-bar.failed-today {
    background: rgba(255, 255, 0, 0.9);
}

.result-modal-distribution-bar.empty {
    background: rgba(255, 255, 255, 0.1);
}

.result-modal-distribution-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-modal-text);
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.result-modal-distribution-bar.empty .result-modal-distribution-count {
    color: rgba(var(--color-modal-text-channels) / 0.5);
}

.result-modal-distribution-bar.today .result-modal-distribution-count,
.result-modal-distribution-bar.failed-today .result-modal-distribution-count {
    color: #000000;
}

/* Auth section for non-logged-in users */
.result-modal-auth-section {
    margin-top: 1.5rem;
    text-align: center;
    padding-top: 0;
}

.result-modal-auth-message {
    font-size: 0.85rem;
    /* Slightly dimmer than main modal text for secondary prompt */
    color: rgba(var(--color-modal-text-channels) / 0.85);
    margin-bottom: 1rem;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.result-modal-auth-btn {
    width: 100%;
    padding: 0.75rem 2rem;
    font-family: 'Jost', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-transform: lowercase;
    letter-spacing: 0.02em;
    background: var(--color-yellow);
    color: #1a1a1a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.result-modal-auth-btn:hover {
    background: var(--color-yellow-medium);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ==========================================================================
   Support Button & Modal
   ========================================================================== */

.support-btn {
    position: absolute;
    top: 4%;
    left: 4%;
    /* allow text below icon */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    width: auto;
    height: auto;
    cursor: pointer;
    background: none; /* no circle behind; remove if you want one */
    border: none;
    padding: 0;
    color: var(--color-yellow); /* drives SVG via currentColor */
    z-index: 10;
    text-decoration: none;
    font-size: 12px;
}

.support-icon {
    /* size responds to width 12vw but clamp at 48px */
    width: clamp(48px, 8vw, 64px);
    height: auto;
    display: block;
    color: var(--color-yellow); /* ensure yellow */
}

/* Optional hover */
.support-btn:hover { transform: translateY(-2px) scale(1.08); }


/* Support Modal Overlay */
.support-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000; /* Same level as how-to modal */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.support-modal-overlay.show {
    opacity: 1;
}

.support-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
}

.support-modal-content {
    position: relative;
    background: var(--color-bg);
    border-radius: 16px;
    padding: 32px 24px 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    text-align: center;
    transition: background-color 0.3s ease; /* Smooth transition to failure state */
    /* font-family: var(--font-sans); */
}

/* Failure state for support modal */
.support-modal-content.failure-state {
    background: var(--color-failure-bg);
}

.support-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 28px;
    color: white;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.support-modal-close:hover {
    opacity: 1;
}

.support-modal-content h3 {
    margin: 0 0 6px 0;
    font-size: 24px;
    font-weight: 1000;
    color: var(--color-yellow);
}

.support-modal-subtitle {
    color: rgba(0, 0, 0, 0.85);
    /* color: #000; */
    margin: 0 0 28px 0;
    font-size: 18px;
    font-weight: 300;
    padding-top: 10px;
    /* clean font */
    font-family: 'Spectral', 'Garamond', Georgia, serif;
}

/* Grid layout for amount buttons */
.support-modal-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.support-amount-btn {
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    /* background: var(--colo÷r-); */
    border-radius: 10px;
    font-size: 20px;
    font-weight: 400;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    /* font-family: 'Spectral', 'Garamond', Georgia, serif; */
    backdrop-filter: blur(10px);
}

.support-amount-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.support-amount-btn.active {
    background: var(--color-yellow);
    border-color: var(--color-yellow-dark);
    color: var(--color-ink);
    box-shadow: 0 4px 12px rgba(255, 255, 0, 0.3);
}

/* Custom button - spans full width on bottom row */
.support-custom-btn {
    grid-column: 1 / -1;
}

.support-custom-currency {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    font-weight: 400;
    color: white;
    pointer-events: none;
    /* font-family: 'Spectral', 'Garamond', Georgia, serif; */
}

.support-custom-input {
    width: 100%;
    padding: 18px 18px 18px 40px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    /* background: rgba(255, 255, 255, 0.15); */
    border-radius: 10px;
    font-size: 20px;
    font-weight: 400;
    color: white;
    text-align: left;
    backdrop-filter: blur(10px);
}

.support-custom-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.support-custom-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
    font-weight: 300;
}

/* Confirm button */
.support-confirm-btn {
    width: 100%;
    padding: 18px;
    background: var(--color-ink);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 12px;
}

.support-confirm-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.support-modal-footer {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
    text-align: center;
    font-weight: 300;
}

/* Thank You Toast - Option 2 Style */
.support-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-bg);
    padding: 12px 20px;
    border-left: 4px solid var(--color-yellow);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    z-index: 3000; /* Above all modals */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 400px;
}

.support-toast.show {
    transform: translateX(-50%) translateY(0);
}

.support-toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.support-toast-icon {
    font-size: 24px;
}

.support-toast-text {
    font-size: 15px;
    color: white;
    font-weight: 400;
    font-family: 'Spectral', 'Garamond', Georgia, serif;
}

/* Mobile optimization */
@media (max-width: 640px) {
    .support-modal-content {
        width: 95%;
        max-width: 360px;
        padding: 20px;
    }

    .support-modal-grid {
        gap: 8px;
    }

    .support-amount-btn {
        padding: 14px;
        font-size: 16px;
    }
}

/* === SUPPORT & FEEDBACK MODAL STYLES === */

/* Support & Feedback Grid (2 buttons side by side) */
.support-feedback-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.support-feedback-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Jost', sans-serif;
    /* make room around below */
    padding-bottom: 16px;
}

.support-feedback-btn:hover {
    transform: translateY(-2px) scale(1.05);
}

.support-feedback-btn .sf-icon {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.support-feedback-btn .sf-icon img {
    width: 100%;
    height: 100%;
    transition: filter 0.2s ease;
}

.support-feedback-btn:hover .sf-icon img {
    filter: invert(88%) sepia(93%) saturate(4893%) hue-rotate(359deg) brightness(104%) contrast(107%);
}

.support-feedback-btn .sf-desc {
    font-size: 24px;
    color: rgba(0, 0, 0, 0.8);
    font-weight: 500;
    transition: color 0.2s ease;
}

.support-feedback-btn:hover .sf-desc {
    color: var(--color-yellow);
}

/* Feedback Form Modal */
.feedback-modal .support-modal-content {
    max-width: 500px;
}

.feedback-form-content {
    width: 100%;
}

.feedback-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 17px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.9);
    letter-spacing: 0.3px;
    text-align: left;
}

.form-group input,
.form-group textarea {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 15px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--color-text);
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--color-yellow);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

.feedback-submit-btn {
    margin-top: 8px;
    padding: 14px 24px;
    background: var(--color-yellow);
    color: #000;
    font-family: 'Jost', sans-serif;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.feedback-submit-btn:hover {
    background: #ffff33;
    transform: translateY(-1px);
}

.feedback-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.form-status {
    font-family: 'Jost', sans-serif;
    font-size: 14px;
    padding: 10px 14px;
    border-radius: 6px;
    text-align: center;
    display: none;
}

.form-status.success {
    display: block;
    background: rgba(75, 227, 187, 0.2);
    color: var(--color-bg);
    border: 1px solid var(--color-bg);
}

.form-status.error {
    display: block;
    background: rgba(255, 100, 100, 0.2);
    color: #ff6464;
    border: 1px solid #ff6464;
}

/* Mobile responsive for feedback */
@media (max-width: 640px) {
    .support-feedback-grid {
        gap: 12px;
    }

    .support-feedback-btn {
        padding: 8px 12px;
        gap: 4px;
    }

    .support-feedback-btn .sf-icon {
        width: 80px;
        height: 80px;
    }

    .support-feedback-btn .sf-desc {
        font-size: 20px;
    }

    .feedback-form {
        gap: 14px;
    }

    .form-group input,
    .form-group textarea {
        font-size: 14px;
        padding: 10px 12px;
    }
}

/* Mobile responsive */
@media (max-width: 600px) {
    .result-modal-card {
        padding: 1.5rem 1.25rem;
        width: 100%;
        border-radius: 16px 16px 0 0;
    }

    .result-modal-stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }

    .result-modal-stat-value {
        font-size: 1.75rem;
    }

    .result-modal-title {
        font-size: 1.25rem;
    }

    .result-modal-header {
        margin-bottom: 1.25rem;
    }

    .result-modal-explanation-section {
        margin-bottom: 1.25rem;
    }

    .result-modal-stats-overview {
        margin-bottom: 1.25rem;
    }
}

/* ========================================================================== */
/*  Force-Mobile Overrides (Single Layout Across All Viewports)               */
/*  These rules neutralize desktop-specific variants to ensure we maintain   */
/*  one canonical mobile-first UI.                                           */
/* ========================================================================== */
html.force-mobile .desktop-menu-toggle,
html.force-mobile .grid-tray {
    display: none !important;
}

/* Keep original notification bar visibility rules; do not force display at large widths */

/* Prevent desktop modal centering; keep slide-up sheet style */
html.force-mobile .result-modal-wrapper {
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    width: 100% !important;
    padding: 0 !important; /* reset all */
    padding-top: 6rem !important; /* maintain visual breathing room for logo/title */
    align-items: flex-end !important;
    justify-content: center !important;
}
/* IMPORTANT: Preserve slide-up behavior (translateY(100%) -> 0) instead of forcing always open */
/* Unified modal (force-mobile): center card width while keeping bottom sheet behavior */
html.force-mobile .result-modal-card {
    max-width: 640px !important;
    margin: 0 auto;
}

/* Top-right menu button adaptive sizing */
.top-menu-btn {
    width: clamp(2.25rem, 1.8rem + 0.8vw, 2.9rem);
    height: clamp(2.25rem, 1.8rem + 0.8vw, 2.9rem);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
}
.top-menu-btn svg { width: 60%; height: 60%; }
@media (min-width: 480px) { .top-menu-btn svg { width: 65%; height: 65%; } }
@media (min-width: 640px) { .top-menu-btn svg { width: 70%; height: 70%; } }

/* Collapse complex desktop grid into a centered fluid column */
html.force-mobile .game-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 640px !important; /* fluid upper bound */
    margin: 0 auto !important;
    /* Top padding modest; bottom generous for keyboard; include vh for tall screens */
    padding: clamp(1rem, 1rem + 1vh, 2.5rem) clamp(1rem, 3vw, 2rem) clamp(6rem, 10vh, 9rem) clamp(1rem, 3vw, 2rem) !important;
    /* Gap scales with height more than width to avoid bunching on tall devices */
    gap: clamp(1rem, 0.75rem + 1.6vh, 4rem) !important;
}

/* Remove reliance on grid-area placement */
html.force-mobile .grid-logo,
html.force-mobile .grid-round-tracker,
html.force-mobile .grid-clue,
html.force-mobile .grid-input,
html.force-mobile .grid-status { width: 100% !important; }

/* Sidebar open state should not adjust layout */
html.force-mobile .game-grid.sidebar-open { padding-right: clamp(1rem, 3vw, 2rem) !important; }

/* Hide leftover spacing assumptions */
html.force-mobile .full-height-tray { display: none !important; }

/* Ensure keyboard is always allowed on large screens (we may refine later) */
/* Allow Alpine x-show to control display; just constrain width */
html.force-mobile #virtual-keyboard { max-width: 640px; margin: 0 auto; }

/* Keep round tip full width beneath inputs */
html.force-mobile .round-tip { max-width: 100% !important; }

/* Guarantee clue text line length remains readable at max width */
html.force-mobile .clue-text { line-height: 1.4; }

/* Height-aware vertical rhythm adjustments */
html.force-mobile body {
    /* Define dynamic custom properties that respond to viewport height */
    --vh-unit: 1vh;
    --vspace-xs: clamp(0.25rem, 0.4vh, 0.6rem);
    --vspace-sm: clamp(0.5rem, 0.8vh, 1rem);
    --vspace-md: clamp(0.75rem, 1.4vh, 1.75rem);
    --vspace-lg: clamp(1rem, 2.2vh, 2.5rem);
    --vspace-xl: clamp(1.5rem, 3vh, 3.25rem);
}

/* Apply extra breathing room on tall screens so content doesn't bunch at the top */
@media (min-height: 780px) {
  html.force-mobile .game-grid {
            /* Further ease spacing on taller screens */
            gap: clamp(1.5rem, 1rem + 2vh, 4.5rem) !important;
            padding-top: clamp(1.25rem, 2vh, 3.75rem) !important;
  }
  html.force-mobile .clue-text {
      line-height: clamp(1.3, 1.1 + 0.5vh, 1.55);
  }
}

/* Utility spacer that can be inserted if we want dynamic vertical space */
/* Spacer utility no longer required (using section margins & dynamic gap). Keep as zero to avoid layout impact if remnants exist. */
.vh-spacer { height: 0 !important; }

/* Section-level vertical margins that scale with height */
html.force-mobile .grid-clue { margin-bottom: clamp(1rem, 0.5rem + 2vh, 1rem) !important; }
html.force-mobile .grid-input { margin-bottom: clamp(1rem, 0.5rem + 1.6vh, 3.5rem) !important; }
html.force-mobile .grid-status { margin-bottom: clamp(1rem, 0.5rem + 1.4vh, 3rem) !important; }

/* Avoid layout shift from button groups expecting side-by-side columns */
html.force-mobile .input-with-buttons,
html.force-mobile .letter-boxes-with-buttons {
    grid-template-columns: 1fr !important;
    grid-template-areas: 'input' 'boxes' 'buttons' !important;
}
html.force-mobile .input-with-buttons > input,
html.force-mobile .letter-boxes-with-buttons > .flex { width: 100%; }

/* Safety: ensure celebration overlay still spans full viewport */
html.force-mobile #celebration { position: fixed !important; }

/* ========================================================================== */
/*  Action Icon Buttons (ensure consistent tap target & size on all widths)  */
/* ========================================================================== */
.action-icon-btn {
        width: 2.75rem; /* ~44px tap target */
        height: 2.75rem;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0; /* rely on explicit sizing */
        line-height: 1;
}
.action-icon-btn svg, .action-icon-btn span.icon-text {
        width: 1.35rem; /* ~22px */
        height: 1.35rem;
        flex: none;
}
/* Prevent unwanted shrinking inside flex rows */
.action-icon-btn { flex: 0 0 auto; }

/* Question mark and text glyph icons scale similarly */
.action-icon-btn.icon-text { font-size: 1.15rem; }

@media (max-width: 480px) {
    .action-icon-btn { width: 2.6rem; height: 2.6rem; }
    .action-icon-btn svg, .action-icon-btn span.icon-text { width: 1.3rem; height: 1.3rem; }
}
