/* VerbaTile - Namespaced Styles (vt- prefix) */
/* All styles are prefixed to avoid conflicts with parent site CSS */

/* ========================================
   VARIABLES & RESET
   ======================================== */

:root {
    --vt-color-bg: #f5f1e8;
    --vt-color-surface: #ffffff;
    --vt-color-primary: #8b6f47;
    --vt-color-primary-dark: #6b5437;
    --vt-color-accent: #d4a574;
    --vt-color-green: #6faa3e;
    --vt-color-yellow: #f4b942;
    --vt-color-orange: #e67e22;
    --vt-color-purple: #9b59b6;
    --vt-color-text: #2c2416;
    --vt-color-text-light: #5a4f3c;
    --vt-color-border: #d4c5af;
    
    --vt-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --vt-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --vt-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    
    --vt-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}



/* ========================================
   PAGE HEADER
   ======================================== */

.vt-page-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding-top: 10px;
}

.vt-page-header h1 {
    font-family: 'Palatino', 'Book Antiqua', serif;
    font-size: 3rem;
    font-weight: 700;
    color: var(--vt-color-primary);
    letter-spacing: 0.05em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    margin: 0;
    line-height: 1;
}

.vt-tagline {
    color: var(--vt-color-text-light);
    font-size: 1.1rem;
    margin: 0;
    align-self: center;
}

/* ========================================
   GAME CONTAINER
   ======================================== */
#main {
    background-color: #f8f9fa; /* Light Gray */
    min-height: 0;
    padding: 1rem 1rem 2rem;
    box-sizing: border-box;
}

#vt-game-container {
    background: var(--vt-color-surface);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--vt-shadow-lg);
    border: 2px solid var(--vt-color-border);
    margin-bottom: 30px;
    position: relative;
    overflow: visible;
}

/* Match the overscroll area to your new light gray */
html {
    background-color: #f8f9fa; /* Or whichever gray you picked */
}

body {
    background-color: #f8f9fa;
    margin: 0;
    /* This prevents the "bounce" from showing a different color */
    overscroll-behavior: none; 
}

/* Prevent any stray pseudo-elements on container */
#vt-game-container::before,
#vt-game-container::after {
    display: none !important;
}

/* ========================================
   CONTROLS SECTION
   ======================================== */

.vt-controls-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    gap: 20px;
    flex-wrap: wrap;
}

.vt-stats-and-help {
    display: flex;
    align-items: center;
    gap: 12px;
}

.vt-icon-btn {
/* 1. Reset standard button behavior */
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box; /* Ensures border/padding don't expand the width */
    padding: 0;             /* iPhone buttons often have default side padding */
    
    /* 2. Force the dimensions */
    width: 32px !important;
    height: 32px !important;
    min-width: 32px;        /* Some layouts ignore 'width' but respect 'min-width' */
    flex: 0 0 32px;         /* Shorthand for: don't grow, don't shrink, stay 32px */
    
    /* 3. Keep the circle */
    border-radius: 50%;
    width: 32px;
    height: 32px;
    flex-shrink: 0;        /* Vital: Prevents the button from squishing */
    aspect-ratio: 1 / 1;   /* Forces a 1:1 ratio just in case */
    
    border-radius: 50%;
    border: 2px solid var(--vt-color-primary);
    
    /* Ensure no default padding from the browser interferes */
    padding: 0;
    overflow: hidden; 
    
    color: var(--vt-color-primary);
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--vt-transition);
    box-shadow: var(--vt-shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    display: flex;
    align-items: center;
    justify-content: center;
}
.vt-icon-btn:hover {
    background: var(--vt-color-primary);
    color: white;
    transform: scale(1.1);
}

.vt-settings-icon {
    font-size: 1.1rem;
}

/* Eyeball toggle button */
.vt-eye-icon {
    font-size: 1.2rem;
}

.vt-stats-display {
    display: flex;
    gap: 15px;
    background: var(--vt-color-surface);
    padding: 10px 20px;
    border-radius: 12px;
    box-shadow: var(--vt-shadow-sm);
    border: 1px solid var(--vt-color-border);
}

.vt-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.vt-stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--vt-color-text-light);
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.vt-stat-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--vt-color-primary);
    font-family: 'Verdana', sans-serif;
}

.vt-level-badge-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.vt-difficulty-label {
    font-size: 0.9rem;
    color: var(--vt-color-text);
    font-weight: 600;
    font-family: 'Verdana', sans-serif;
}

.vt-level-badge {
    display: inline-block;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: 'Verdana', sans-serif;
    color: var(--vt-color-primary);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    transition: var(--vt-transition);
}

.vt-level-badge:hover {
    color: var(--vt-color-primary-dark);
    text-decoration-style: solid;
}

.vt-game-type-container {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 15px;
}

.vt-game-type-label {
    font-size: 0.9rem;
    color: var(--vt-color-text);
    font-weight: 600;
    font-family: 'Verdana', sans-serif;
}

.vt-game-type {
    font-size: 0.95rem;
    font-weight: 700;
    font-family: 'Verdana', sans-serif;
    color: var(--vt-color-purple);
}

.vt-player-display {
    font-size: 0.9rem;
    color: var(--vt-color-text);
    font-family: 'Verdana', sans-serif;
    margin-left: 20px;
}

.vt-player-display::before {
    content: 'Player: ';
    font-weight: 600;
}

.vt-player-display-name {
    font-weight: 700;
    color: var(--vt-color-primary);
}

.vt-button-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.vt-custom-select {
    padding: 10px 16px;
    border: 2px solid var(--vt-color-purple);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: 'Verdana', sans-serif;
    background: white;
    cursor: pointer;
    font-weight: 600;
    color: var(--vt-color-purple);
    min-width: 150px;
}

.vt-custom-select:focus {
    outline: none;
    border-color: var(--vt-color-primary);
    box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.1);
}

.vt-custom-select option {
    padding: 8px;
}

.vt-hint-message {
    color: #d32f2f;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
    margin: 15px 0 20px;
    font-family: 'Verdana', sans-serif;
    animation: vt-pulse-text 1.5s ease-in-out infinite;
    width: 100%;
}

@keyframes vt-pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.vt-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--vt-transition);
    box-shadow: var(--vt-shadow-sm);
    font-family: 'Verdana', sans-serif;
    letter-spacing: 0.3px;
}

.vt-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--vt-shadow-md);
}

.vt-btn:active {
    transform: translateY(0);
}

.vt-btn-primary {
    background: linear-gradient(135deg, var(--vt-color-primary) 0%, var(--vt-color-primary-dark) 100%);
    color: white;
}

.vt-btn-solution {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
}

.vt-btn-undo {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    color: white;
}

.vt-btn-undo:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.vt-btn-custom {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.vt-btn-clear {
    background: #e74c3c;
    color: white;
    padding: 8px 16px;
    font-size: 0.85rem;
}

.vt-btn-danger {
    background: #c0392b;
    color: white;
}

.vt-btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.vt-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ========================================
   CUSTOM GAMES SECTION
   ======================================== */

.vt-custom-games-section {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    padding: 15px;
    background: var(--vt-color-surface);
    border-radius: 12px;
    border: 2px solid var(--vt-color-purple);
    flex-wrap: wrap;
}

.vt-custom-label {
    font-weight: 600;
    color: var(--vt-color-text);
    font-size: 0.95rem;
}

.vt-custom-select {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 2px solid var(--vt-color-border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: 'Verdana', sans-serif;
    background: white;
}

.vt-custom-select:focus {
    outline: none;
    border-color: var(--vt-color-purple);
}

/* ========================================
   GAME AREA
   ======================================== */

.vt-game-area {
    display: grid;
    grid-template-columns: auto auto;
    gap: 30px;
    justify-content: start;
    align-items: start;
}

/* Stack grids on smaller screens */
@media (max-width: 768px) {
    .vt-game-area {
        grid-template-columns: 1fr;
        justify-content: center;
    }
}

/* ========================================
   LETTER POOL
   ======================================== */

.vt-letter-pool {
    display: grid;
    grid-template-columns: repeat(5, 60px);
    grid-template-rows: repeat(5, 60px);
    gap: 8px;
    justify-content: start;
    justify-self: start;
    padding: 20px;
    background: linear-gradient(135deg, #fdfbf7 0%, #f9f6f0 100%);
    border-radius: 12px;
    border: 2px dashed var(--vt-color-border);
    width: fit-content;
    max-width: 100%;
}

@media (max-width: 480px) {
    .vt-letter-pool {
        grid-template-columns: repeat(5, 50px);
        grid-template-rows: repeat(5, 50px);
        gap: 6px;
        padding: 15px;
    }
}

.vt-empty-slot {
    width: 60px;
    height: 60px;
}

@media (max-width: 480px) {
    .vt-empty-slot {
        width: 50px;
        height: 50px;
    }
}

/* ========================================
   WORD GRID
   ======================================== */

.vt-word-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    background: linear-gradient(135deg, #fdfbf7 0%, #f9f6f0 100%);
    border-radius: 12px;
    border: 2px dashed var(--vt-color-border);
    width: fit-content;
    max-width: 100%;
}

@media (max-width: 480px) {
    .vt-word-grid {
        padding: 15px;
    }
}

.vt-word-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vt-row-arrow {
    font-size: 1.5rem;
    color: var(--vt-color-accent);
    font-weight: bold;
    margin-right: 8px;
}

.vt-row-slots {
    display: flex;
    gap: 8px;
}

@media (max-width: 480px) {
    .vt-row-slots {
        gap: 6px;
    }
    
    .vt-word-row {
        gap: 6px;
    }
}

/* Grid slot styling */
.vt-grid-slot {
    width: 60px;
    height: 60px;
    border: 2px dashed var(--vt-color-border);
    border-radius: 8px;
    background: linear-gradient(145deg, #fafaf8 0%, #f5f3ef 100%);
    transition: var(--vt-transition);
}

@media (max-width: 480px) {
    .vt-grid-slot {
        width: 50px;
        height: 50px;
    }
}

.vt-grid-slot.vt-drop-target {
    border-color: var(--vt-color-accent);
    background: rgba(212, 165, 116, 0.1);
    border-style: solid;
    transform: scale(1.05);
}

.vt-word-row.vt-valid-word .vt-grid-slot {
    background: linear-gradient(145deg, #fff9c4 0%, #ffeb3b 50%, #fdd835 100%);
    border-color: var(--vt-color-yellow);
    border-style: solid;
}

.vt-word-row.vt-solution-word .vt-grid-slot {
    background: linear-gradient(145deg, #c8e6c9 0%, #66bb6a 50%, #43a047 100%);
    border-color: var(--vt-color-green);
    border-style: solid;
}

/* ========================================
   LETTER TILES
   ======================================== */

.vt-letter-tile {
    width: 60px;
    height: 60px;
    background: linear-gradient(145deg, #ffffff 0%, #f0ebe3 100%);
    border: 2px solid var(--vt-color-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: var(--vt-color-text);
    cursor: move;
    box-shadow: var(--vt-shadow-sm);
    transition: transform 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    font-family: 'Verdana', sans-serif;
    position: relative;
}

@media (max-width: 480px) {
    .vt-letter-tile {
        width: 50px;
        height: 50px;
        font-size: 1.6rem;
    }
}

.vt-letter-tile:hover {
    transform: scale(1.05);
    box-shadow: var(--vt-shadow-md);
}

.vt-letter-tile.vt-dragging {
    opacity: 0.5;
}

.vt-letter-tile.vt-ghost {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    opacity: 0.9;
    box-shadow: var(--vt-shadow-lg);
    transform: scale(1.1);
}

.vt-letter-tile.vt-hint-letter {
    background: linear-gradient(145deg, var(--vt-color-accent) 0%, var(--vt-color-primary) 100%);
    color: white;
    border-color: var(--vt-color-primary-dark);
    box-shadow: 0 0 12px rgba(212, 165, 116, 0.6);
}

.vt-letter-tile.vt-locked {
    cursor: not-allowed;
    background: 
        linear-gradient(135deg, rgba(232,226,213,0.9) 0%, rgba(212,206,193,0.9) 100%);
    border-color: #b8b0a0;
    opacity: 0.85;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.vt-letter-tile.vt-locked::after {
    content: '🔒';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.7rem;
    z-index: 10;
    pointer-events: none;
}

/* Tile color states for valid/solution words */
.vt-letter-tile.vt-green {
    background: 
        linear-gradient(135deg, rgba(123,201,80,0.95) 0%, rgba(95,163,58,0.95) 50%, rgba(77,136,48,0.95) 100%);
    color: white;
    border-color: rgba(77, 136, 48, 0.8);
    box-shadow: 
        0 4px 8px rgba(107, 170, 62, 0.4),
        0 1px 2px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 0 -2px 0 rgba(0, 0, 0, 0.15);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.vt-letter-tile.vt-green::before {
    background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 100%);
}

.vt-letter-tile.vt-yellow {
    background: 
        linear-gradient(135deg, rgba(255,200,87,0.95) 0%, rgba(244,169,66,0.95) 50%, rgba(217,143,47,0.95) 100%);
    color: var(--vt-color-text);
    border-color: rgba(217, 143, 47, 0.8);
    box-shadow: 
        0 4px 8px rgba(244, 185, 66, 0.4),
        0 1px 2px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1);
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
}

.vt-letter-tile.vt-yellow::before {
    background: linear-gradient(180deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 100%);
}

/* ========================================
   VALID WORDS PANEL (Floating)
   ======================================== */

   /* Layout & Scrollbar Container */
/* Remove the old max-height on .vt-valid-words-panel */

/* Apply height control to the box with the words instead */
.vt-panel-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 12px;
    border: 2px solid var(--vt-color-border); /* The border you requested */
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.5);
    
    /* This ensures it stays within view on laptops and tablets */
    max-height: 250px; 
    
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(75px, 1fr)); 
    gap: 8px;
}

/* Specific adjustment for iPhone Portrait */
@media (max-width: 480px) and (orientation: portrait) {
    .vt-panel-content {
        /* Shorter height for small phones so the grid stays visible */
        max-height: 180px; 
    }
}
/* Chrome, Edge, and Safari scrollbar styling */
.vt-panel-content::-webkit-scrollbar {
    width: 8px;
}

.vt-panel-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.vt-panel-content::-webkit-scrollbar-thumb {
    background: var(--vt-color-orange);
    border-radius: 4px;
}

/* Individual Word Styling */
.vt-panel-content div {
    padding: 6px;
    text-align: center;
    transition: var(--vt-transition);
    border-radius: 4px;
    background: rgba(230, 126, 34, 0.05); /* Soft background for grid visibility */
}


@media (max-width: 480px) and (orientation: portrait) {
    .vt-valid-words-panel {
        width: 100%;
        position: relative; /* Ensure it stays in the flow */
    }

    .vt-panel-content {
        max-height: 180px; /* Limits height so it doesn't push off-screen */
        -webkit-overflow-scrolling: touch; /* Smooth scroll for iOS */
    }
}
/* ========================================
   MODALS
   ======================================== */

.vt-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: vt-fade-in 0.3s ease-out;
}

@keyframes vt-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.vt-modal {
    background: var(--vt-color-surface);
    border-radius: 16px;
    box-shadow: var(--vt-shadow-lg);
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 2px solid var(--vt-color-border);
    resize: both;
    min-width: 300px;
    min-height: 200px;
    animation: vt-slide-up 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes vt-slide-up {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.vt-modal-header {
    background: linear-gradient(135deg, var(--vt-color-primary) 0%, var(--vt-color-primary-dark) 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: left;
    cursor: move;
}

.vt-modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.vt-close-btn {
    /* 1. Reset Browser Defaults */
    -webkit-appearance: none;
    appearance: none;
    background: transparent; /* Changed from 'none' to be explicit */
    border: none;
    outline: none;
    padding: 0;
    margin: 0;

    /* 2. Force the Shape (The iPhone 'Oval' and 'Big Box' Killer) */
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    flex: 0 0 32px !important; /* Forces flexbox to respect the 32px width */
    
    /* 3. Aesthetics */
    color: white;
    font-size: 1.5rem; /* Reduced slightly to fit better in a 32px circle */
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--vt-transition);
}

.vt-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}


.vt-modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.vt-modal-body::-webkit-scrollbar {
    width: 10px;
}

.vt-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.vt-modal-body::-webkit-scrollbar-thumb {
    background: var(--vt-color-primary);
    border-radius: 5px;
}

/* ========================================
   HELP CONTENT
   ======================================== */

.vt-help-content {
    line-height: 1.7;
}

.vt-help-content h3 {
    color: var(--vt-color-primary);
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.vt-help-content p {
    margin-bottom: 15px;
}

.vt-help-content ul {
    margin: 10px 0 15px 25px;
}

.vt-help-content li {
    margin: 6px 0;
}

/* ========================================
   SETTINGS CONTENT
   ======================================== */

.vt-settings-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.vt-setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vt-setting-group--inline {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.vt-setting-group--inline label {
    font-weight: 600;
    color: var(--vt-color-text);
    font-size: 0.95rem;
    margin: 0;
    cursor: pointer;
}

.vt-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--vt-color-primary);
    flex-shrink: 0;
}

.vt-setting-group label {
    font-weight: 600;
    color: var(--vt-color-text);
    font-size: 0.95rem;
}

.vt-difficulty-select,
.vt-player-name-input {
    padding: 10px;
    border: 2px solid var(--vt-color-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Verdana', sans-serif;
    transition: var(--vt-transition);
}

.vt-difficulty-select:focus,
.vt-player-name-input:focus {
    outline: none;
    border-color: var(--vt-color-primary);
    box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.1);
}

/* ========================================
   HINT SELECTION WINDOW
   ======================================== */

.vt-hint-window {
    position: fixed;
    top: 150px;
    right: 50px;
    background: var(--vt-color-surface);
    border: 2px solid var(--vt-color-primary);
    border-radius: 12px;
    box-shadow: var(--vt-shadow-lg);
    z-index: 1500;
    min-width: 220px;
}

.vt-hint-header {
    background: linear-gradient(135deg, var(--vt-color-primary) 0%, var(--vt-color-primary-dark) 100%);
    color: white;
    padding: 12px 16px;
    font-weight: 600;
    border-radius: 10px 10px 0 0;
    cursor: move;
    user-select: none;
    font-size: 0.95rem;
    text-align: center;
}

.vt-hint-selectable {
    box-shadow: 0 0 0 2px var(--vt-color-primary) !important;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 2px var(--vt-color-primary);
    }
    50% {
        box-shadow: 0 0 0 4px var(--vt-color-accent);
    }
}

/* ========================================
   LETTER SELECTION GRID
   ======================================== */

.vt-letter-selection-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.vt-selectable-letter {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(145deg, #ffffff 0%, #f0ebe3 100%);
    border: 2px solid var(--vt-color-border);
    transition: var(--vt-transition);
}

.vt-selectable-letter:hover {
    transform: scale(1.05);
    border-color: var(--vt-color-accent);
}

.vt-selectable-letter.vt-selected {
    background: linear-gradient(145deg, var(--vt-color-accent) 0%, var(--vt-color-primary) 100%);
    color: white;
    border-color: var(--vt-color-primary-dark);
}

/* ========================================
   TOUCH ACTION
   ======================================== */

.vt-letter-tile,
.vt-panel-header,
.vt-modal-header {
    touch-action: none;
    -webkit-touch-callout: none;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    .vt-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .vt-page-header h1 {
        font-size: 2.5rem;
    }
    
    .vt-controls-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .vt-stats-and-help {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .vt-button-group {
        flex-direction: column;toggleValidWordsPanel
    }
    
    .vt-letter-tile,
    .vt-grid-slot {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .vt-valid-words-panel {
    display: flex;
    flex-direction: column;
    margin-top: 20px;
    /* Ensure it doesn't vanish on mobile if the content is empty */
    min-height: 100px; 
    }

    .vt-panel-header {
    font-weight: 600;
    font-family: 'Verdana', sans-serif;
    margin-bottom: 8px;
    color: var(--vt-color-text);
    }

    .vt-modal {
        margin: 20px;
        max-width: calc(100% - 40px);
    }

    #vt-game-container {
        padding: 20px;
    }
    
    /* Stack grids vertically on tablet */
    .vt-game-area {
        grid-template-columns: 1fr;
        justify-content: center;
    }
}

/* iPad Portrait - smaller grids to fit side by side */
@media (min-width: 481px) and (max-width: 820px) and (orientation: portrait) {
    .vt-letter-pool {
        grid-template-columns: repeat(5, 50px);
        grid-template-rows: repeat(5, 50px);
        gap: 6px;
        padding: 15px;
    }
    
    .vt-empty-slot {
        width: 50px;
        height: 50px;
    }
    
    .vt-letter-tile {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .vt-word-grid {
        padding: 15px;
    }
    
    .vt-row-slots {
        gap: 6px;
    }
    
    .vt-word-row {
        gap: 6px;
    }
    
    .vt-grid-slot {
        width: 50px;
        height: 50px;
    }
    
    /* Grids side by side on iPad portrait */
    .vt-game-area {
        grid-template-columns: auto auto;
        gap: 20px;
        justify-content: center;
    }
}

/* iPhone Portrait - Words panel at bottom */
@media (max-width: 480px) and (orientation: portrait) {
    .vt-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .vt-page-header h1 {
        font-size: 2rem;
    }
    
    .vt-letter-tile,
    .vt-grid-slot {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }
    
    .vt-stats-display {
        flex-wrap: wrap;
        gap: 10px;
        padding: 8px 12px;
    }
    
    .vt-stat-item {
        min-width: 60px;
    }

    #vt-game-container {
        padding: 15px;
    }
    
    /* Position Words panel at bottom for portrait */
    .vt-valid-words-panel {
        position: static;
        width: 100%;
        max-width: 100%;
        margin-top: 20px;
        max-height: 200px;
    }
    
    .vt-level-badge-container {
        order: 1;
    }
    
    .vt-valid-words-panel {
        order: 2;
    }
    
    #vt-game-container {
        display: flex;
        flex-direction: column;
    }
    
    .vt-controls-section {
        order: -2;
    }
    
    .vt-hint-message {
        order: -1;
    }
    
    .vt-game-area {
        order: 0;
        grid-template-columns: 1fr;
    }
}

/* iPhone Landscape - Side by side grids with Words below */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
    /* Adjust letter pool for landscape to match word grid sizing */
    .vt-letter-pool {
        grid-template-columns: repeat(5, 50px);
        grid-template-rows: repeat(5, 50px);
        gap: 6px;
        padding: 12px;
    }
    
    .vt-empty-slot {
        width: 50px;
        height: 50px;
    }
    
    .vt-letter-tile {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .vt-row-slots {
        gap: 6px;
    }
    
    .vt-word-row {
        gap: 6px;
    }
    
    .vt-grid-slot {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    /* Make grids fit side by side */
    .vt-game-area {
        grid-template-columns: auto auto;
        gap: 15px;
        justify-content: center;
    }
    
    /* Position Words panel below grids in landscape */
    .vt-valid-words-panel {
        display:grid;
        grid-template-columns: auto auto;
        grid-auto-flow: row; /* Explicitly sets the flow to fill rows first */
        position: static;
        width: 100%;
        max-width: 100%;
        margin-top: 5px;
        max-height: 150px;
    }
    
    #vt-game-container {
        padding: 15px;
    }
}
/* replace confirm() and alert() */
:root {
    --modal-bg: #ffffff;
    --overlay-color: rgba(0, 0, 0, 0.5);
    --primary-color: #007bff;
}


.modal-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;   /* ADD THIS LINE */
    pointer-events: auto;
}

/* 1. Remove the .hidden { display: none; } rule if it exists */

.modal-overlay {
    position: fixed;
    inset: 0; /* Shorthand for top, right, bottom, left: 0 */
    width: 100%;
    height: 100dvh;
    
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px); 
    -webkit-backdrop-filter: blur(5px);
    
    /* KEEP THIS ALWAYS ACTIVE */
    display: flex; 
    align-items: center; 
    justify-content: center;
    
    z-index: 999999; 
    
    /* CONTROL VISIBILITY VIA OPACITY */
    transition: opacity 0.3s ease, visibility 0.3s ease;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* 2. This is the ONLY class you toggle via JS */
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-box {
    background: var(--modal-bg);
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 450px;
    max-height: 80dvh; /* Changed to dvh for consistency */
    overflow-y: auto; 
    text-align: center;
    
    /* Animation state when hidden */
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 3. Animate the box when the overlay is active */
.modal-overlay.active .modal-box {
    transform: scale(1);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 1.5rem;
}

.modal-overlay:not(.hidden) .modal-box {
    transform: scale(1); /* Grow to full size */
}

button {
    flex: 1;
    padding: 14px;      /* Large touch target for iPhone */
    border: none;
    border-radius: 8px;
    font-size: 1rem;    /* Prevents iOS zoom-on-click */
    font-weight: 600;
    cursor: pointer;
}
#modal-message{
    white-space: pre-wrap;
}
#modal-title {
    margin-top: 0;
    font-size: 1.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Prevents long titles from breaking the layout on narrow screens */
}
.btn-primary { background: var(--primary-color); color: white; }
.btn-secondary { background: #e9ecef; color: #333; }

/* iPhone Portrait Adjustments */
@media (max-width: 480px) {
    .modal-box {
        padding: 1.5rem;
        margin-bottom: 20px; /* Slight lift for thumb ergonomics */
    }
}
.modal-buttons button:active {
    filter: brightness(0.9);
    transform: translateY(1px);
}
/* Fix for game page header layout */
.site-header__inner {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.brand {
    flex-shrink: 0 !important;
}

.nav-toggle {
    /* Resets the width if a global 'button' style is stretching it */
    width: auto !important; 
    /* Ensures it stays on the right */
    margin-left: auto !important;
    /* Prevents the internal bars from shifting left */
    justify-content: center !important; 
}


/* ===== Header Fix: Only apply mobile corrections on mobile screens ===== */
/* ===== Targeted Header Fix for Portrait/Mobile ===== */
@media (max-width: 860px) {
    /* 1. Ensure the header inner doesn't force items to stretch */
    .site-header__inner {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    /* 2. Neutralize the 'flex: 1' from the game's global button rule */
    .nav-toggle {
        display: inline-flex !important;
        flex: 0 0 auto !important; /* Forces it to only be as wide as its content */
        width: auto !important;    /* Prevents the 'two-thirds width' issue */
        margin-left: auto !important; /* Keeps it pinned to the right */
        padding: 10px 12px !important; /* Maintains the oval shape */
    }

    /* 3. Ensure the brand/logo stays on the left */
    .brand {
        flex: 0 0 auto !important;
        margin-right: auto !important;
    }
}

/* ===== Desktop Cleanup ===== */
@media (min-width: 861px) {
    .nav-toggle {
        display: none !important; /* Hides the duplicate icon on PC/Landscape */
    }
}

/* ========================================
   VERBATILE ADDITIONS v2
   Append to verbatile.css
   ======================================== */

/* ── Panels Row ── */
.vt-panels-row {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.vt-panels-row .vt-valid-words-panel {
    flex: 1;
    min-width: 200px;
}

/* ── Who's Playing Panel ── */
.vt-whos-playing-panel {
    flex: 1;
    min-width: 180px;
    background: var(--vt-color-surface);
    border-radius: 12px;
    border: 2px solid var(--vt-color-border);
    box-shadow: var(--vt-shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.vt-whos-playing-panel .vt-panel-header {
    background: linear-gradient(135deg, var(--vt-color-primary) 0%, var(--vt-color-primary-dark) 100%);
    color: white;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: 'Verdana', sans-serif;
    letter-spacing: 0.3px;
}

.vt-whos-playing-panel .vt-panel-content {
    max-height: 180px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    grid-template-columns: unset;
}

.vt-playing-name {
    font-size: 0.85rem;
    font-family: 'Verdana', sans-serif;
    color: var(--vt-color-text);
    padding: 3px 0;
    border-bottom: 1px solid var(--vt-color-border);
}

.vt-playing-name:last-child {
    border-bottom: none;
}

.vt-playing-loading {
    font-size: 0.8rem;
    color: var(--vt-color-text-light);
    font-style: italic;
    padding: 8px 0;
    text-align: center;
}

.vt-lurker-nudge {
    padding: 6px 12px 10px;
    font-size: 0.78rem;
    color: var(--vt-color-text-light);
    text-align: center;
    border-top: 1px solid var(--vt-color-border);
}

.vt-lurker-nudge a {
    color: var(--vt-color-primary);
    font-weight: 600;
    text-decoration: none;
}

.vt-lurker-nudge a:hover {
    text-decoration: underline;
}

/* ── Settings additions ── */
.vt-settings-divider {
    border: none;
    border-top: 1px solid var(--vt-color-border);
    margin: 16px 0;
}

.vt-account-label {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--vt-color-text);
    margin: 0 0 4px;
    font-family: 'Verdana', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.vt-account-note {
    font-size: 0.85rem;
    color: var(--vt-color-text-light);
    margin: 4px 0 10px;
    line-height: 1.4;
}

.vt-account-name {
    font-size: 0.9rem;
    color: var(--vt-color-text);
    margin: 4px 0;
}

/* ── Auth Modal ── */
.vt-auth-error {
    color: #e74c3c;
    font-size: 0.85rem;
    margin: 8px 0 0;
    padding: 8px 12px;
    background: #fdf2f2;
    border-radius: 6px;
    border-left: 3px solid #e74c3c;
}

.vt-auth-success-msg {
    font-size: 1rem;
    font-weight: 600;
    color: var(--vt-color-green);
    margin: 0 0 8px;
}

.vt-auth-switch {
    font-size: 0.85rem;
    color: var(--vt-color-text-light);
    margin-top: 12px;
    text-align: center;
}

.vt-auth-switch a {
    color: var(--vt-color-primary);
    font-weight: 600;
    text-decoration: none;
}

.vt-auth-switch a:hover {
    text-decoration: underline;
}

/* ── Score Modal ── */
.vt-score-display {
    text-align: center;
    margin: 10px 0 16px;
}

.vt-score-big {
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--vt-color-primary);
    font-family: 'Verdana', sans-serif;
    line-height: 1;
}

.vt-score-label {
    font-size: 0.9rem;
    color: var(--vt-color-text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

.vt-score-breakdown {
    font-size: 0.85rem;
    color: var(--vt-color-text-light);
    background: var(--vt-color-bg);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
    line-height: 1.8;
}

.vt-score-breakdown div {
    display: flex;
    justify-content: space-between;
}

.vt-score-breakdown .vt-score-total {
    font-weight: 700;
    color: var(--vt-color-text);
    border-top: 1px solid var(--vt-color-border);
    margin-top: 4px;
    padding-top: 4px;
}

/* ── Leaderboard Modal ── */
.vt-lb-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.vt-lb-tab {
    padding: 6px 14px;
    border: 2px solid var(--vt-color-border);
    border-radius: 20px;
    background: white;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: 'Verdana', sans-serif;
    color: var(--vt-color-text-light);
    cursor: pointer;
    transition: var(--vt-transition);
    flex: 0 0 auto;
}

.vt-lb-tab:hover {
    border-color: var(--vt-color-primary);
    color: var(--vt-color-primary);
    transform: none;
}

.vt-lb-tab-active {
    background: var(--vt-color-primary);
    border-color: var(--vt-color-primary);
    color: white;
}

.vt-lb-my-rank {
    background: linear-gradient(135deg, #fef9f0 0%, #fdf3e3 100%);
    border: 1px solid var(--vt-color-accent);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.88rem;
    color: var(--vt-color-text);
    margin-bottom: 12px;
}

.vt-lb-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Verdana', sans-serif;
    font-size: 0.85rem;
}

.vt-lb-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid var(--vt-color-border);
    color: var(--vt-color-text-light);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.vt-lb-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--vt-color-border);
    color: var(--vt-color-text);
}

.vt-lb-table tr:last-child td {
    border-bottom: none;
}

.vt-lb-table tr.vt-lb-me td {
    background: linear-gradient(135deg, #fef9f0 0%, #fdf3e3 100%);
    font-weight: 700;
}

.vt-lb-rank {
    font-weight: 700;
    color: var(--vt-color-primary);
    width: 30px;
}

.vt-lb-rank-1 { color: #f4b942; }
.vt-lb-rank-2 { color: #95a5a6; }
.vt-lb-rank-3 { color: var(--vt-color-orange); }

/* ── Streak stat in header ── */
#vt-streak-stat .vt-stat-value {
    color: var(--vt-color-orange);
}

/* ── Mobile adjustments ── */
@media (max-width: 480px) {
    .vt-panels-row {
        flex-direction: column;
    }

    .vt-lb-tabs {
        gap: 4px;
    }

    .vt-lb-tab {
        padding: 5px 10px;
        font-size: 0.78rem;
    }

    .vt-score-big {
        font-size: 2.5rem;
    }

    .vt-lb-table th:nth-child(4),
    .vt-lb-table td:nth-child(4) {
        display: none; /* hide difficulty column on small screens */
    }
}

/* ── Streak Badge ── */
.vt-streak-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 8px;
    border-radius: 16px;
    background: var(--vt-color-bg);
    border: 2px solid var(--vt-color-primary);
    color: var(--vt-color-text);
    font-size: 0.9rem;
    font-weight: 700;
    font-family: 'Verdana', sans-serif;
    box-shadow: var(--vt-shadow-sm);
    flex-shrink: 0;
    white-space: nowrap;
}

/* ══════════════════════════════════════
   LIVE TIMER
   ══════════════════════════════════════ */
.vt-live-timer {
    font-size: 0.85rem;
    font-family: 'Verdana', monospace;
    color: var(--vt-color-text-light);
    background: var(--vt-color-bg);
    border: 1px solid var(--vt-color-border);
    border-radius: 8px;
    padding: 2px 8px;
    margin-left: 8px;
}

/* ══════════════════════════════════════
   WIN ANIMATION
   ══════════════════════════════════════ */
@keyframes vt-bounce {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.18) rotate(-3deg); }
    60%  { transform: scale(0.95) rotate(2deg); }
    100% { transform: scale(1); }
}
.vt-win-bounce {
    animation: vt-bounce 0.55s ease forwards;
}

/* ══════════════════════════════════════
   SHARE BUTTON & COPIED MESSAGE
   ══════════════════════════════════════ */
.vt-btn-share {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: opacity 0.15s;
}
.vt-btn-share:hover { opacity: 0.88; }

.vt-share-copied {
    text-align: center;
    font-size: 0.85rem;
    color: var(--vt-color-green);
    margin-top: 6px;
    font-weight: 600;
}

/* ══════════════════════════════════════
   MY PROFILE MODAL
   ══════════════════════════════════════ */
.vt-profile-stats-row {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.vt-profile-stat {
    flex: 1;
    min-width: 70px;
    background: linear-gradient(135deg, #fdfbf7 0%, #f9f6f0 100%);
    border: 1px solid var(--vt-color-border);
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
}
.vt-profile-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--vt-color-primary);
    font-family: 'Verdana', sans-serif;
}
.vt-profile-stat-label {
    font-size: 0.7rem;
    color: var(--vt-color-text-light);
    margin-top: 2px;
}
.vt-profile-table {
    width: 100%;
    font-size: 0.88rem;
}
.vt-profile-offrecord td {
    opacity: 0.55;
    font-style: italic;
}

@media (max-width: 480px) {
    .vt-profile-stat-value { font-size: 1.1rem; }
    .vt-profile-stat-label { font-size: 0.65rem; }
}
