/* Custom Reset */
* { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* Safe Area Support for Mobile Browsers */
:root {
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Mobile viewport height handling */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific - use dynamic viewport height */
    body {
        height: 100dvh;
        height: -webkit-fill-available;
    }
}

/* Default (desktop) - minimal padding */
.pb-safe {
    padding-bottom: 2rem; /* 32px - original desktop value */
}

.mb-safe {
    margin-bottom: 0;
}

/* Mobile only - aggressive padding for browser UI */
@media (max-width: 768px) {
    .pb-safe {
        padding-bottom: max(70px, calc(var(--safe-area-bottom) + 50px));
    }
    
    .mb-safe {
        margin-bottom: max(24px, calc(var(--safe-area-bottom) + 16px));
    }
}

/* Ensure the main container can hold the absolute loader */
main {
    position: relative;
    min-height: 0; /* Important for flex children */
}

/* Sentence container improvements for mobile */
#sentence-container {
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

#sentence-container p {
    line-height: 1.8;
    margin: 0;
}

/* Responsive font sizing for mobile only */
@media (max-width: 768px) {
    #sentence-container {
        font-size: 1.125rem; /* 18px */
        line-height: 1.5;
    }
    
    #sentence-container p {
        line-height: 1.5;
    }
}

/* Feedback Toast Animation */
.feedback.show {
    opacity: 1 !important;
    transform: translate(-50%, 0) !important;
}

/* Success Card Animation */
.modal-active #success-backdrop { opacity: 1; }
.modal-active #success-card {
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* --- Sentence Board Slots --- */
.word-slot {
    display: inline-flex;
    align-items: baseline;
    margin: 0 4px;
    position: relative;
    white-space: nowrap;
}

.word-slot .blanks {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    letter-spacing: 2px;
    color: #cbd5e1; /* Slate 300 */
    border-bottom: 2px solid #e2e8f0;
    min-width: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

/* Mobile responsive blanks */
@media (max-width: 768px) {
    .word-slot .blanks {
        letter-spacing: 1px;
        font-size: 0.95em;
    }
    
    .word-slot {
        margin: 0 2px;
    }
}

.word-slot.solved .blanks {
    color: #121212;
    border-bottom-color: transparent;
    letter-spacing: normal;
}

/* The small number hint */
.word-slot .len-tag {
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.6rem;
    color: #94a3b8;
    font-weight: 600;
    vertical-align: super;
    margin-left: 2px;
}

@media (max-width: 768px) {
    .word-slot .len-tag {
        font-size: 0.55rem;
    }
}

.word-slot.solved .len-tag { display: none; }

/* Bonus Tags */
.bonus-tag {
    background: #f3f4f6;
    padding: 6px 12px;
    border-radius: 99px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #374151;
}

/* --- Success Modal State --- */

/* When modal-active is present, make the backdrop visible */
.modal-active #success-backdrop {
    opacity: 1;
    pointer-events: auto;
}

/* When modal-active is present, make the card visible and reset its position */
.modal-active #success-card {
    opacity: 1;
    transform: translateY(0);
}

/* Hint Badge */
#hint-badge {
    font-size: 0.7rem;
    transition: all 0.3s ease;
}

#hint-btn:hover #hint-badge {
    transform: scale(1.1);
}

/* Stats Icons - Better coin icon */
.flex.items-center.gap-1 svg {
    flex-shrink: 0;
}

/* Coin SVG styling */
.flex.items-center.gap-1 svg circle {
    stroke: currentColor;
}

.flex.items-center.gap-1 svg text {
    fill: currentColor;
}

/* User Menu Animation */
#user-menu-modal {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Stats Icons */
.flex.items-center.gap-1 svg {
    flex-shrink: 0;
}

/* --- Expanded Success Modal --- */
/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Staggered Animation for Vocab Cards */
.vocab-card {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.5s ease forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Add to your style.css --- */

/* Interactive Solved Words */
.word-slot.solved {
    cursor: pointer;
    /* Optional: subtle border to hint clickability */
    border-bottom: 2px solid transparent; 
}

.word-slot.solved:hover .blanks {
    color: #4f85e5; /* NYT Blue highlight on hover */
}

/* Dictionary Modal Animation State */
.modal-active #dict-backdrop { opacity: 1; }
.modal-active #dict-card {
    opacity: 1;
    transform: translateY(0);
}

/* Dictionary Styling */
.dict-entry { margin-bottom: 1.5rem; }
.dict-pos {
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af; /* Gray 400 */
    margin-bottom: 0.5rem;
    display: inline-block;
    border-bottom: 2px solid #f3f4f6;
    padding-bottom: 2px;
}
.dict-def {
    margin-bottom: 0.75rem;
    line-height: 1.5;
    color: #374151;
}
.dict-example {
    color: #6b7280;
    font-style: italic;
    font-size: 0.95em;
    margin-top: 0.25rem;
    padding-left: 0.75rem;
    border-left: 2px solid #e5e7eb;
}

/* --- Interactive Sentence Words --- */

/* Normal words in the sentence (not blanks) */
.static-word {
    cursor: pointer;
    transition: color 0.2s ease;
}

/* Optional: Very subtle feedback on hover just to confirm hit-area */
.static-word:hover {
    color: #4b5563; /* slightly lighter gray (Tailwind gray-600) */
}

/* --- Add to style.css --- */

/* Loading Overlay */
#loading-overlay {
    position: absolute; /* Changed from fixed */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    z-index: 40; /* Lower than modals but above content */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
    pointer-events: none; /* KEY FIX: Disable pointer events by default */
}


#loading-overlay:not(.hidden) {
    pointer-events: auto; /* Only enable when visible */
}


/* Elegant Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #121212; /* NYT Black */
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Transition for the game area */
#game-interactive-area {
    transition: opacity 0.3s ease;
}