/* WordScape Scrollable Layout - Proper wheel container sizing */

/* Scrollable fixed width container */
.wordscape-fixed-game {
    width: 1080px;
    max-width: 95vw;
    margin: 0 auto;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    font-family: Arial, sans-serif;
    min-height: calc(100vh - 20px);
    /* RESTORED: Allow scrolling again */
    overflow-y: auto;
    overflow-x: hidden;
}

/* Compact Grid Section */
.game-grid {
    margin-bottom: 1px;
    text-align: center;
}

.generation-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 15px;
}

.grid-container {
    display: grid;
    gap: 1px;  /* CONFIRMED: Exact 1px gap between grid cells */
    justify-content: center;
    margin: 0 auto 10px auto;
    background: #dee2e6;
    border: 2px solid #007bff;
    border-radius: 6px;
    padding: 2px;  /* REDUCED: From 6px to 2px for minimal width padding */
    /* Fix grid overflow issues and support wider grids on Android */
    max-width: fit-content;
    overflow: hidden;
    /* UPDATED: Better responsiveness for wider grids on mobile/Android */
    width: fit-content;
    max-width: min(98vw, fit-content); /* Use more screen width on mobile */
}

.grid-cell {
    width: 28.8px;
    height: 28.8px;
    background: #008B8B;  /* FIXED: Default background matches found word in grid color */
    border: none;  /* OPTIMIZED: Remove border to minimize visual gaps */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.grid-cell.revealed {
    background: #008B8B;  /* Dark Cyan - matches word-status-in-grid */
    color: white;
}

.grid-cell.hidden {
    background: #008B8B;  /* FIXED: Same as revealed cells - Dark Cyan matches found words in grid */
    color: transparent;
}

.grid-cell.clicked-highlight {
    background: #ffc107 !important;
    color: #000 !important;
    transform: scale(1.1);
}

.grid-cell.hint-reveal {
    background: #28a745 !important;
    color: white !important;
    animation: pulse 0.5s ease-in-out;
}

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

/* Compact Current Word Bar */
.current-word-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    margin-bottom: 1px;
    padding: 1px;
}

.settings-button, .newgame-button {
    width: 48px;
    height: 32px;
    border: 2px solid #007bff;
    border-radius: 6px;
    color: #007bff;
    background: white;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

/* Icon fallback system - show icons by default, fallback to text if needed */
.settings-button .icon-fallback, .newgame-button .icon-fallback, .center-shuffle-button .icon-fallback {
    font-size: 16px;
    line-height: 1;
    display: inline;
    /* ENHANCED: Better font stack for Unicode symbols */
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', 'Symbola', 'DejaVu Sans', 'Arial Unicode MS', Arial, sans-serif;
    font-variant-emoji: unicode;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.settings-button .text-fallback, .newgame-button .text-fallback, .center-shuffle-button .text-fallback {
    display: none;
    font-size: 10px;
    font-weight: bold;
}

/* Show text fallback if browser has poor Unicode support */
.no-emoji-support .settings-button .icon-fallback, 
.no-emoji-support .newgame-button .icon-fallback, 
.no-emoji-support .center-shuffle-button .icon-fallback {
    display: none !important;
}

.no-emoji-support .settings-button .text-fallback, 
.no-emoji-support .newgame-button .text-fallback, 
.no-emoji-support .center-shuffle-button .text-fallback {
    display: inline !important;
}

/* Alternative fallback detection for older browsers */
@supports not (font-feature-settings: "liga") {
    .settings-button .icon-fallback, .newgame-button .icon-fallback, .center-shuffle-button .icon-fallback {
        display: none !important;
    }
    .settings-button .text-fallback, .newgame-button .text-fallback, .center-shuffle-button .text-fallback {
        display: inline !important;
    }
}

/* Media query fallback for Windows systems that may have font issues */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .settings-button .icon-fallback, .newgame-button .icon-fallback, .center-shuffle-button .icon-fallback {
        display: none !important;
    }
    .settings-button .text-fallback, .newgame-button .text-fallback, .center-shuffle-button .text-fallback {
        display: inline !important;
    }
}

/* DEBUGGING: Force text fallback temporarily to test if the system works */
.debug-text-fallback .settings-button .icon-fallback, 
.debug-text-fallback .newgame-button .icon-fallback, 
.debug-text-fallback .center-shuffle-button .icon-fallback {
    display: none !important;
}

.debug-text-fallback .settings-button .text-fallback, 
.debug-text-fallback .newgame-button .text-fallback, 
.debug-text-fallback .center-shuffle-button .text-fallback {
    display: inline !important;
}

/* NEW: Additional detection method - check if specific Unicode characters are supported */
@supports not ((font-family: "Apple Color Emoji") or (font-family: "Segoe UI Emoji")) {
    .settings-button .icon-fallback, .newgame-button .icon-fallback, .center-shuffle-button .icon-fallback {
        display: none !important;
    }
    .settings-button .text-fallback, .newgame-button .text-fallback, .center-shuffle-button .text-fallback {
        display: inline !important;
    }
}

.settings-button:hover:not(:disabled) {
    background: #007bff;
    color: white;
    transform: translateY(-1px);
}

.newgame-button:hover:not(:disabled) {
    background: #007bff;
    color: white;
    transform: translateY(-1px);
}

.settings-button:disabled, .newgame-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    border-color: #6c757d;
    color: #6c757d;
}

.current-word-display {
    flex: 1;
    max-width: 250px;
    padding: 6px 12px;
    border: 1px solid #007bff;
    border-radius: 6px;
    background: white;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.current-word-display:empty::before {
    content: "Tap letters to spell words";
    color: #6c757d;
    font-style: italic;
    font-weight: normal;
    font-size: 14px;
}

.current-word-display:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Word status colors */
.current-word-display.word-status-in-grid {
    background: #008B8B;
    color: white;
    border-color: #006666;
}

.current-word-display.word-status-in-large-dict {
    background: #20B2AA;
    color: white;
    border-color: #1a9999;
}

.current-word-display.word-status-in-small-dict {
    background: #87CEEB;
    color: #333;
    border-color: #6bb6ff;
}

.current-word-display.word-status-not-found {
    background: #f8d7da;
    color: #721c24;
    border-color: #f1b0b7;
}

.current-word-display.word-status-already-found {
    background: white;  /* FIXED: White background when word already found in grid */
    color: #495057;     /* Dark gray text for good contrast */
    border-color: #6c757d;  /* Gray border */
}

.current-word-display.word-status-too-short {
    background: #f8d7da;
    color: #721c24;
    border-color: #f1b0b7;
}

/* FIXED: Game Wheel Section - Proper sizing to contain letters */
.game-wheel {
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
}

.wheel-container {
    position: relative;
    /* FIXED: Proper container size - wheel diameter + 2 * letter radius */
    /* Wheel circle: r=250, Letter circles: r=54 */
    /* Total needed: (250 + 54) * 2 = 608px */
    /* Reduced by 10% as requested: 608 * 0.9 = 547.2px ? 547px */
    width: 547px;
    height: 547px;
    max-width: 90vw;
    max-height: 90vw;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Ensure letters don't bleed out */
    overflow: visible;
}

/* Compact Corner stats */
.corner {
    position: absolute;
    background: rgba(248,249,250,0.95);
    border: 1px solid #007bff;
    border-radius: 6px;
    padding: 6px 10px;
    min-width: 70px;
    text-align: center;
    font-size: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    z-index: 10;
}

.corner-topleft { top: -5px; left: -5px; }
.corner-topright { top: -5px; right: -5px; }
.corner-bottomleft { bottom: -5px; left: -5px; }
.corner-bottomright { bottom: -5px; right: -5px; }

.corner-label {
    font-size: 10px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    font-weight: bold;
}

.corner-value {
    font-size: 18px;
    font-weight: bold;
    color: #007bff;
    line-height: 1;
}

/* FIXED: Letter wheel - Properly sized to fit in container */
.letter-wheel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.letter-wheel svg {
    /* FIXED: SVG size matches the calculated container size */
    /* Reduced by 10% from original 600px: 600 * 0.9 = 540px */
    width: 540px;
    height: 540px;
    max-width: 85vw;
    max-height: 85vw;
    touch-action: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
}

.center-shuffle-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border: 2px solid #007bff;
    border-radius: 24px;
    background: white;
    color: #007bff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
}

.center-shuffle-button:hover:not(:disabled) {
    background: #007bff;
    color: white;
    transform: translate(-50%, -50%) scale(1.1);
}

.center-shuffle-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    border-color: #6c757d;
    color: #6c757d;
}

/* Compact Message display */
.game-message {
    text-align: center;
    margin: 5px 0;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-message:not(:empty) {
    padding: 6px 12px;
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #bbdefb;
    border-radius: 6px;
    animation: fadeIn 0.3s ease-in;
    font-size: 14px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Scrollable Found Words Section */
.found-words-section {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px; /* Add margin for scroll space */
}

.found-words-section h4 {
    margin: 0 0 8px 0;
    color: #495057;
    font-size: 16px;
    text-align: center;
}

.words-list {
    display: grid;
    /* ? FIXED: Proper multi-column layout that works on all devices */
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    /* UPDATED: Increased minimum width from 80px to 100px for wider items */
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
    /* FIXED: Control item height to prevent stretching when only one row */
    grid-auto-rows: min-content;  /* Items only take the space they need */
    align-items: start;           /* Align items to the start instead of stretching */
    justify-items: center;        /* Center items in their grid areas */
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 10px;
    background: #f8f9fa;
    /* Allow natural height */
    min-height: 100px;
}

.found-word {
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    /* ? FIXED: Variable width to accommodate longer words while maintaining multi-column */
    /* UPDATED: Increased max-width from 150px to 180px to utilize wider grid cells */
    width: auto;
    min-width: 50px;
    max-width: 150px; /* Reasonable max to prevent extremely long words from breaking layout */
    max-width: 180px; /* Increased from 150px to better utilize the wider grid columns */
    /* FIXED: Prevent vertical stretching */
    height: auto;
    align-self: start;  /* Don't stretch vertically */
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden;
    text-overflow: ellipsis; /* Fallback for extremely long words */
}

.found-word:hover {
    transform: translateY(-1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* ? NEW: Animation for newly added words */
.found-word.newly-added {
    animation: wordHighlight 3s ease-out;
    border: 2px solid #ffc107 !important;
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.6) !important;
}

@keyframes wordHighlight {
    0% {
        background: #fff3cd !important;
        transform: scale(1.2);
        box-shadow: 0 0 20px rgba(255, 193, 7, 0.8) !important;
    }
    25% {
        transform: scale(1.1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        border: 1px solid transparent;
        box-shadow: none;
    }
}

/* ? FIXED: Found word colors - make sure they have proper specificity */
.found-word.word-in-grid {
    background: #008B8B !important;
    color: white !important;
    border: 1px solid #006666 !important;
}

.found-word.word-in-large-dict {
    background: #20B2AA !important;
    color: white !important;
    border: 1px solid #1a9999 !important;
}

.found-word.word-in-small-dict {
    background: #87CEEB !important;
    color: #333 !important;
    border: 1px solid #6bb6ff !important;
}

.found-word.word-not-found {
    background: #f8d7da !important;
    color: #721c24 !important;
    border: 1px solid #f1b0b7 !important;
}

/* Settings overlay */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.settings-panel {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    max-width: 350px;
    width: 90%;
}

.settings-panel h3 {
    margin: 0 0 15px 0;
    color: #495057;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: bold;
    color: #495057;
}

.form-control {
    width: 100px;
    padding: 6px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.debug-controls {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #dee2e6;
}

.checkbox-group {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 6px;
}

.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    margin-right: 8px;
    transition: all 0.2s ease;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.alert {
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 6px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    position: relative;
    z-index: 1000;
}

/* ? NEW: Enhanced congratulations overlay for better visibility */
.congratulations-overlay {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: overlayFadeIn 0.5s ease-out;
}

.congratulations-panel {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: congratsPanelSlideIn 0.6s ease-out;
    border: 3px solid #28a745;
}

.congratulations-panel h3 {
    color: #28a745;
    font-size: 28px;
    margin: 0 0 20px 0;
    animation: congratsTextGlow 2s ease-in-out infinite;
}

.congratulations-panel .final-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.congratulations-panel .final-stat-item {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.congratulations-panel .final-stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #007bff;
}

.congratulations-panel .final-stat-label {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
    margin-top: 5px;
}

.congratulations-panel .play-again-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
}

.congratulations-panel .play-again-btn:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

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

@keyframes congratsPanelSlideIn {
    from { 
        opacity: 0; 
        transform: translateY(-50px) scale(0.8); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

@keyframes congratsTextGlow {
    0%, 100% { text-shadow: 0 0 5px rgba(40, 167, 69, 0.5); }
    50% { text-shadow: 0 0 20px rgba(40, 167, 69, 0.8), 0 0 30px rgba(40, 167, 69, 0.3); }
}

/* ? ENHANCED: Grid cell flash animation for completed puzzle and word reveals */
.grid-cell.celebration-flash {
    animation: cellFlash 0.8s ease-in-out;
}

/* ? NEW: Animation for when individual words are revealed in grid */
.grid-cell.word-reveal-flash {
    animation: wordRevealFlash 1.2s ease-out;
}

@keyframes cellFlash {
    0%, 100% { 
        background: #008B8B;
        transform: scale(1);
    }
    25% { 
        background: #ffc107;
        transform: scale(1.1);
        box-shadow: 0 0 10px rgba(255, 193, 7, 0.6);
    }
    75% { 
        background: #28a745;
        transform: scale(1.05);
        box-shadow: 0 0 8px rgba(40, 167, 69, 0.5);
    }
}

@keyframes wordRevealFlash {
    0% { 
        background: #008B8B;
        transform: scale(1);
    }
    20% { 
        background: #28a745;
        transform: scale(1.2);
        box-shadow: 0 0 15px rgba(40, 167, 69, 0.8);
        border: 2px solid #28a745;
    }
    40% { 
        background: #17a2b8;
        transform: scale(1.1);
        box-shadow: 0 0 12px rgba(23, 162, 184, 0.6);
    }
    60% { 
        background: #ffc107;
        transform: scale(1.05);
        box-shadow: 0 0 8px rgba(255, 193, 7, 0.5);
    }
    100% { 
        background: #008B8B;
        transform: scale(1);
        box-shadow: none;
        border: none;
    }
}

/* Debug mode borders */
.debug-regions .game-grid {
    border: 2px solid red !important;
}

.debug-regions .current-word-bar {
    border: 2px solid blue !important;
}

.debug-regions .game-wheel {
    border: 2px solid green !important;
}

.debug-regions .found-words-section {
    border: 2px solid orange !important;
}

/* Responsive adjustments */
@media (max-width: 1120px) {
    .wordscape-fixed-game {
        width: 95vw;
    }
}

/* UPDATED: Better support for Android devices and wider grids */
@media (max-width: 768px) {
    .wordscape-fixed-game {
        padding: 8px;
    }
    
    /* Android-specific grid optimizations */
    .grid-container {
        max-width: min(98vw, fit-content); /* Use even more width on mobile/Android */
        padding: 1px; /* Reduce padding further for more grid space */
        /* ADDED: Ensure proper centering on Android to prevent right-shift */
        margin-left: auto !important;
        margin-right: auto !important;
        display: grid;
        justify-content: center;
        position: relative;
    }
    
    /* ADDED: Android-specific game grid centering */
    .game-grid {
        /* UPDATED: Use flexbox approach like current-word-bar for flush positioning */
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        /* Remove transform positioning */
        position: static !important;
        left: auto !important;
        transform: none !important;
    }
    
    .wheel-container {
        /* FIXED: Mobile container sized proportionally */
        /* Original mobile was 450px, reduce by 10%: 450 * 0.9 = 405px */
        width: 405px;
        height: 405px;
    }
    
    .letter-wheel svg {
        /* FIXED: Mobile SVG sized?? */
        /* Original mobile was 400px, reduce by 10%: 400 * 0.9 = 360px */
        width: 360px;
        height: 360px;
    }
    
    .current-word-bar {
        gap: 6px;
        padding: 4px;
    }
    
    .settings-button, .newgame-button {
        width: 32px;
        height: 24px;
        font-size: 10px;
    }
    
    .current-word-display {
        max-width: none;
        width: 100%;
        font-size: 14px;
        padding: 4px 8px;
        min-height: 24px;
    }
    
    .words-list {
        /* ? UPDATED: Variable width for mobile too */
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        /* UPDATED: Increased minimum width from 60px to 80px for wider mobile items */
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 4px;
        padding: 8px;
        justify-items: center;
    }
}

@media (max-width: 480px) {
    /* Further Android grid optimizations for smaller screens */
    .grid-container {
        max-width: min(99vw, fit-content); /* Maximum width usage on small screens */
        padding: 1px;
        margin: 0 auto 5px auto; /* Reduce bottom margin */
        /* UPDATED: Remove transform positioning - let flexbox parent handle centering */
        position: static !important;
        left: auto !important;
        transform: none !important;
    }
    
    /* UPDATED: Make game grid use flexbox like current-word-bar */
    .game-grid {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin: 0 !important;
        /* Remove transform positioning */
        position: static !important;
        left: auto !important;
        transform: none !important;
    }
    
    .wheel-container {
        /* FIXED: Small screen container sized proportionally */
        /* Original small was 300px, reduce by 10%: 300 * 0.9 = 270px */
        width: 270px;
        height: 270px;
    }
    
    .letter-wheel svg {
        /* FIXED: Small screen SVG sized?? */
        /* Original small was 270px, reduce by 10%: 270 * 0.9 = 243px */
        width: 243px;
        height: 243px;
    }
    
    .corner {
        min-width: 50px;
        padding: 5px 8px;
        font-size: 10px;
    }
    
    .corner-value {
        font-size: 16px;
    }
    
    .corner-label {
        font-size: 8px;
    }
    
    .current-word-bar {
        gap: 4px;
        padding: 2px;
    }
    
    .settings-button, .newgame-button {
        width: 28px;
        height: 20px;
        font-size: 9px;
    }
    
    .current-word-display {
        font-size: 12px;
        padding: 3px 6px;
        min-height: 20px;
    }
    
    .words-list {
        /* ? UPDATED: Variable width for mobile too */
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        /* UPDATED: Increased minimum width from 60px to 80px for wider mobile items */
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 4px;
        padding: 8px;
        justify-items: center;
    }
}

/* ADDED: Android-specific grid positioning fix */
@media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 1) {
    /* Target Android Chrome specifically */
    .game-grid {
        position: relative;
        left: 0;
        right: 0;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    .grid-container {
        position: relative;
        left: 0;
        right: 0;
        margin-left: auto !important;
        margin-right: auto !important;
        transform: none !important;
    }
}

/* ADDED: Android edge-to-edge grid positioning - FLEXBOX APPROACH like current-word-bar */
@media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 1) {
    /* Target Android Chrome specifically for edge-to-edge layout */
    .game-grid {
        /* UPDATED: Use flexbox like current-word-bar instead of transform positioning */
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        /* Remove transform positioning */
        position: static !important;
        left: auto !important;
        transform: none !important;
    }
    
    .grid-container {
        /* UPDATED: Behave like current-word-display - let flexbox parent handle centering */
        margin: 0 !important;
        padding: 1px !important;
        max-width: none !important;
        width: fit-content !important;
        /* Remove transform positioning */
        position: static !important;
        left: auto !important;
        transform: none !important;
    }
    
    /* Remove all container padding that causes left whitespace */
    .wordscape-fixed-game,
    .game-content,
    article.content,
    .content,
    .px-4 {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .wordscape-fixed-game {
        width: 100vw !important;
        max-width: 100vw !important;
    }
}

/* ADDED: Android viewport fix for grid centering - FLEXBOX APPROACH */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari and Android WebKit - make grid flush like current-word-bar */
    .grid-container {
        /* UPDATED: Let flexbox parent handle centering like current-word-display */
        margin: 0 !important;
        justify-self: center !important;
        padding: 1px !important;
        max-width: none !important;
        width: fit-content !important;
        /* Remove transform positioning */
        position: static !important;
        left: auto !important;
        transform: none !important;
    }
    
    .game-grid {
        /* UPDATED: Use flexbox like current-word-bar */
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        /* Remove transform positioning */
        position: static !important;
        left: auto !important;
        transform: none !important;
    }
    
    /* Remove padding from all parent containers */
    .wordscape-fixed-game,
    .game-content,
    article.content {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
    }
}

/* DRAGGABLE WHEEL - NEW STYLES */
.draggable-wheel-container {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    overflow: hidden;
    /* FIXED: Proper container size - wheel diameter + 2 * letter radius */
    /* Wheel circle: r=250, Letter circles: r=54 */
    /* Total needed: (250 + 54) * 2 = 608px */
    /* Reduced by 10% as requested: 608 * 0.9 = 547.2px ? 547px */
    width: 547px;
    height: 547px;
    max-width: 90vw;
    max-height: 90vw;
    margin: 0 auto;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

/* NEW: Draggable wheel corner stats - same as regular corners but with !important to override */
.draggable-wheel-container .corner {
    padding: 3px 5px !important;
    min-width: 45px !important;
    font-size: 10px !important;
}

.draggable-wheel-container .corner-value {
    font-size: 14px !important;
}

.draggable-wheel-container .corner-label {
    font-size: 7px !important;
}

/* Word wheel and letters - full control over size and positions */
.draggable-wheel-container .letter-wheel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    touch-action: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
}

.draggable-wheel-container .letter-wheel svg {
    width: 98%;
    height: 98%;
    max-width: none;
    max-height: none;
    position: absolute;
    top: 1%;
    left: 1%;
    pointer-events: none;
}

/* Center shuffle button - Full control over position and size */
.draggable-wheel-container .center-shuffle-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 20px;
    background: #007bff;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
}

.draggable-wheel-container .center-shuffle-button:hover:not(:disabled) {
    background: #0056b3;
    transform: translate(-50%, -50%) scale(1.1);
}

.draggable-wheel-container .center-shuffle-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Override global found word styles for draggable wheel context */
.draggable-wheel-container .found-word {
    padding: 4px 6px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    /* FIXED: Prevent vertical stretching */
    height: auto;
    align-self: start;  /* Don't stretch vertically */
}

/* FOUND WORD COLORS - Same as regular styles, but !important to override */
.draggable-wheel-container .found-word.word-in-grid {
    background: #008B8B !important;
    color: white !important;
    border: 1px solid #006666 !important;
}

.draggable-wheel-container .found-word.word-in-large-dict {
    background: #20B2AA !important;
    color: white !important;
    border: 1px solid #1a9999 !important;
}

.draggable-wheel-container .found-word.word-in-small-dict {
    background: #87CEEB !important;
    color: #333 !important;
    border: 1px solid #6bb6ff !important;
}

.draggable-wheel-container .found-word.word-not-found {
    background: #f8d7da !important;
    color: #721c24 !important;
    border: 1px solid #f1b0b7 !important;
}

/* Ensure corner controls are positioned at very edges */
.corner-topleft,
.draggable-wheel-container .corner-topleft {
    top: -5px !important;
    left: -5px !important;
}

.corner-topright,
.draggable-wheel-container .corner-topright {
    top: -5px !important;
    right: -5px !important;
}

.corner-bottomleft,
.draggable-wheel-container .corner-bottomleft {
    bottom: -5px !important;
    left: -5px !important;
}

.corner-bottomright,
.draggable-wheel-container .corner-bottomright {
    bottom: -5px !important;
    right: -5px !important;
}

