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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100vh;
    overflow: hidden;
    background: #f8f9fa;
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
	 overscroll-behavior: none;
    touch-action: manipulation;

}
body.game-active {
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    /* Prevent iOS bounce */
    -webkit-overflow-scrolling: touch;
    /* Prevent zoom */
    touch-action: none;
}

/* ============================================================================
   WORD LIST TOGGLE STYLES
   ============================================================================ */

/* Title container with toggle button */
.title-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

/* Toggle button styling */
.wordlist-toggle {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
}

.wordlist-toggle:hover:not(:disabled) {
    background: linear-gradient(135deg, #1976D2 0%, #1565C0 100%);
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.4);
}

.wordlist-toggle:active:not(:disabled) {
    transform: scale(0.95);
}

.wordlist-toggle:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    animation: spin 1s linear infinite;
}

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

/* Adjust h3 styling to work with flex container */
.title-container h3 {
    margin: 0;
    flex: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px 4px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.4;
}

.title-container h3:hover {
    background-color: rgba(33, 150, 243, 0.1);
    color: #1565c0;
}

/* FIXED: Word list visibility states - prevents mobile expansion */
.wordList-hidden {
    display: none !important;
    opacity: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    transition: all 0.3s ease-out;
}

.wordList-hidden li {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    opacity: 0 !important;
}

.wordList-visible {
    display: flex !important;
    opacity: 1 !important;
    overflow-x: hidden !important;
    overflow-y: visible !important; /* Allow vertical scrolling if needed */
    margin: 8px 0 0 0 !important;
    transition: all 0.3s ease-in;
    /* Prevent height expansion beyond container */
    max-height: none !important;
    flex-wrap: wrap !important;
}

.wordList-visible li {
    display: block !important;

    opacity: 1 !important;
    flex-shrink: 0 !important;
}

/* Hover effect for the entire title area */
.title-container h3:hover {
    color: #2ea83a;
}

/* Add a subtle indication that the title is clickable for both actions */
.puzzle-title-clickable {
    position: relative;
}

/* Focus styles for accessibility */
.wordlist-toggle:focus {
    outline: 2px solid #2ea83a;
    outline-offset: 2px;
}

/* Ensure list container has proper spacing */
.list-container {
    margin-bottom: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
    position: relative;
}

.list-container:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #c0c0c0;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Highlight effect for newly navigated grid */
.list-container.highlight-grid {
    background: rgba(33, 150, 243, 0.15) !important;
    border-color: #2196F3 !important;
    box-shadow: 0 0 20px rgba(33, 150, 243, 0.3) !important;
    transform: translateY(-2px) !important;
    animation: highlight-pulse 2s ease-in-out;
}

@keyframes highlight-pulse {
    0% { 
        background: rgba(33, 150, 243, 0.25);
        box-shadow: 0 0 25px rgba(33, 150, 243, 0.4);
    }
    50% { 
        background: rgba(33, 150, 243, 0.15);
        box-shadow: 0 0 15px rgba(33, 150, 243, 0.25);
    }
    100% { 
        background: rgba(33, 150, 243, 0.15);
        box-shadow: 0 0 20px rgba(33, 150, 243, 0.3);
    }
}
.settings-button {
    width: 120px;
    height: 45px;
    background: linear-gradient(135deg, #000000 0%, #333333 100%);
    backdrop-filter: blur(15px);
    border-radius: 12px;
    box-shadow: 
        0 8px 32px rgba(102, 126, 234, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
}

.settings-button:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        0 12px 40px rgba(102, 126, 234, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    background: linear-gradient(135deg, #1a1a1a 0%, #333333 100%);
}

.settings-button:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 
        0 4px 16px rgba(102, 126, 234, 0.3),
        0 1px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
/* ============================================================================
   MAIN LAYOUT STYLES
   ============================================================================ */

/* Fixed overlay controls at the top */
.controls-overlay {
    position: fixed;
    top: env(safe-area-inset-top);
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 10px 20px;
    transition: transform 0.3s ease;
}

.controls-overlay.collapsed {
    transform: translateY(-99%);
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}
.control-group {
    position: absolute;
    right: 20px;
    z-index: 1002;
    background: linear-gradient(135deg, #000000 0%, #333333 100%);
    backdrop-filter: blur(15px);
   
    color: white;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    bottom: 425px; /* 175px + 250px lists-section height */
    font-size: 16px;
}

/* Game layout with bottom lists */
.game-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative; /* Important for absolute positioning of lists */
}

/* Game container - full viewport height */
.game-container {
    flex: 1;
    position: relative;
    background: #f8f9fa;
    overflow: hidden;
    /* Remove mobile height calculations - let it take full height */
    height: 100vh !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
}

.canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
}

#gameCanvas {
    background: white;
    cursor: pointer;
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
	    touch-action: none;

}

/* Scroll controls - positioned in top right */
.scroll-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1002;
    display: grid;
    gap: 8px;
    padding: 8px;
    border: none;
    background-color: transparent;
    cursor: pointer;
}

#scrollUp {
    grid-column: 2;
    grid-row: 1;
    background-image: url('img/up.png');
    background-size: cover;
}

#scrollLeft {
    grid-column: 1;
    grid-row: 2;
    background-image: url('img/left.png');
    background-size: cover;
}

#scrollDown {
    grid-column: 2;
    grid-row: 2;
    background-image: url('img/down.png');
    background-size: cover;
}

#scrollRight {
    grid-column: 3;
    grid-row: 2;
    background-image: url('img/right.png');
    background-size: cover;
}

#zoomIn {
    grid-column: 1;
    grid-row: 1;
    background-image: url('img/zoomin.png');
    background-size: cover;
}

#zoomOut {
    grid-column: 3;
    grid-row: 1;
    background-image: url('img/zoomout.png');
    background-size: cover;
}

#zoomDisplay {
    grid-column: 2;
    grid-row: 2;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#zoomReset {
    grid-column: 1;
    grid-row: 3;
    font-size: 8px;
}


/* REPLACE the existing button positioning CSS with this updated version */

/* ============================================================================
   FIXED BUTTON POSITIONING - ABOVE LISTS SECTION
   ============================================================================ */

/* Default desktop positioning - account for 250px lists-section */
.control-group {
    position: absolute;
    right: 20px;
    z-index: 1002;
    background: linear-gradient(135deg, #000000 0%, #333333 100%);
    backdrop-filter: blur(15px);
    width:120px;
    color: white;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    bottom: 425px; /* 175px + 250px lists-section height */
    font-size: 16px;
    border-radius: 10px;
}

#inviteFriendsBtn { 
    position: absolute;
    bottom: 350px; /* 100px + 250px lists-section height */
    right: 20px;
    z-index: 1002;
    width: 140px;
    height: 60px;
    font-size: 16px;
    font-weight: 700;
    /* Shared styles */
    background: linear-gradient(135deg, #000000 0%, #333333 100%);
    backdrop-filter: blur(15px);
    border-radius: 12px;
    box-shadow: 
        0 8px 32px rgba(102, 126, 234, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
}

#inviteFriendsBtn img { 
    width: 35px;
    height: 35px; 
}

/* Statistics panel - positioned in bottom right */
.stats-panel {
    position: absolute;
    bottom: 270px; /* 20px + 250px lists-section height */
    right: 20px;
    z-index: 1002;
    /* Shared styles */
    background: linear-gradient(135deg, #000000 0%, #333333 100%);
    backdrop-filter: blur(15px);
    border-radius: 12px;
    box-shadow: 
        0 8px 32px rgba(102, 126, 234, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 10px 20px;
    font-size: 18px;
    text-align: center;
}

/* Hover effects for all shared elements */
.control-group:hover,
#inviteFriendsBtn:hover,
.stats-panel:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        0 12px 40px rgba(102, 126, 234, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    background: linear-gradient(135deg, #1a1a1a 0%, #333333 100%);
}

/* Active/pressed state */
.control-group:active,
#inviteFriendsBtn:active,
.stats-panel:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 
        0 4px 16px rgba(102, 126, 234, 0.3),
        0 1px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.stat-item {
    padding: 3px;
    color: white;
}

.stat-item span {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 1px;
    line-height: 1;
    color: white;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.stats-panel p {
    color: rgba(255, 255, 255, 0.8);
    margin-top: 5px;
    font-size: 12px;
    font-weight: 400;
}

/* FIXED: Lists section at bottom - STRICT HEIGHT CONTROL */
.lists-section {
    /* Make it a true overlay */
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1001 !important;
      touch-action: pan-y;
  
    /* Background and styling */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    
    /* Height control */
    max-height: 250px !important;
    min-height: 250px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    
    /* Padding */
    padding: 15px;
    
    /* Smooth transitions */
    transition: all 0.3s ease;
    
    /* Remove flex properties since it's now positioned */
    flex: none !important;
    flex-shrink: none !important;
    
    /* Layout containment to prevent expansion issues */
    contain: layout style !important;
}

.lists-section.collapsed {
    max-height: 40px !important;
    min-height: 40px !important;
    overflow: hidden !important;
}

.controls-toggle, .lists-toggle {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 0 0 15px 15px;
    padding: 5px 20px;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1001;
}

.lists-toggle {
    top: -35px;
    left: 50%; 
    transform: translateX(-50%);
    min-width: 60px;
    border-radius: 15px 15px 0 0;
    z-index: 100000;
}

.controls-toggle:hover, .lists-toggle:hover {
    background: rgba(255, 255, 255, 1);
    color: #333;
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.lists-message {
    text-align: center;
    color: #555;
    font-weight: 600;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    font-size: 13px;
}

.controls-toggle {
    bottom: -30px;
}

.lists-toggle {
    top: -20px;
}

/* ============================================================================
   ENHANCED LISTS SECTION STYLES
   ============================================================================ */

/* Section headers for the three categories */
.section-header {
    margin: 15px 0 10px 0;
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 4px solid;
}

.section-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-header.active-section {
    background: rgba(76, 175, 80, 0.1);
    border-left-color: #4CAF50;
    color: #2e7d32;
}

.section-header.other-section {
    background: rgba(33, 150, 243, 0.1);
    border-left-color: #2196F3;
    color: #1565c0;
}

.section-header.completed-section {
    background: rgba(156, 39, 176, 0.1);
    border-left-color: #9c27b0;
    color: #7b1fa2;
}

/* Grids container styling */
.grids-container {
    margin-bottom: 20px;
}

/* Completion indicators */
.completion-indicator {
    font-size: 12px;
    margin-right: 6px;
    font-weight: bold;
}

.completion-indicator.completed {
    color: #4CAF50;
}

.completion-indicator.in-progress {
    color: #FF9800;
}

/* Count and percentage styling */
.count {
    font-size: 11px;
    color: #666;
    font-weight: normal;
    margin-left: 4px;
}

.percentage {
    font-size: 10px;
    color: #888;
    font-weight: normal;
    margin-left: 4px;
    opacity: 0.8;
}

/* Enhanced word list styling */
.wordList {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    transition: all 0.3s ease;
}

.wordList li {
    background-color: #f5f5f5;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    border: 1px solid #ddd;
    transition: all 0.2s ease;
    cursor: default;
    overflow: hidden;
    white-space: nowrap;
}

.wordList li:hover {
    white-space: normal;
    overflow: visible;
    z-index: 10;
    position: relative;
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transform: scale(1.05);
}

/* Found word styling */
.wordList li.word-found {
    background-color: #E8F5E8 !important;
    border-color: #4CAF50;
    text-decoration: line-through;
    color: #2e7d32;
}

.wordList li.word-found-teammate {
    background-color: #E3F2FD !important;
    border-color: #2196F3;
    color: #1565c0;
}

/* Loading and error states */
.loading-placeholder {
    background-color: #f0f0f0 !important;
    color: #888 !important;
    font-style: italic;
    animation: pulse 1.5s ease-in-out infinite alternate;
}

.error-item {
    background-color: #ffebee !important;
    color: #c62828 !important;
    border-color: #f44336 !important;
    font-style: italic;
}

@keyframes pulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

/* Scrollbar styling for lists section */
.lists-section::-webkit-scrollbar {
    width: 8px;
}

.lists-section::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.lists-section::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.lists-section::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Standard button styles */
.btn {
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    width: 30px;
    height: 30px;
}

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

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

.btn-primary {
    background: #007bff;
}

.btn-primary:hover {
    background: #0056b3;
}

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

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

.color-picker {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.color-picker:hover {
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

.control-group label {
    color: white;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Word list styles */
.word-item {
    padding: 8px;
    margin: 4px 0;
    border-radius: 6px;
    background: rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.word-item.found {
    background: rgba(76, 175, 80, 0.2);
    border-left-color: #4CAF50;
    text-decoration: line-through;
}

/* User info styles */
.user-info-panel {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.user-info-panel input {
    min-width: 150px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
}

/* ============================================================================
   INVITE MODAL STYLES
   ============================================================================ */

.invite-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.invite-modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    position: relative;
}

.invite-modal-header {
    text-align: center;
    margin-bottom: 25px;
}

.invite-modal-header h2 {
    color: #333;
    margin-bottom: 10px;
}

.invite-url-container {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    word-break: break-all;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    position: relative;
}

.invite-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: #333;
}

.copy-success {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #28a745;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.copy-success.show {
    opacity: 1;
}

/* Form styles for team creation */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ============================================================================
   ACHIEVEMENT SYSTEM STYLES
   ============================================================================ */

.achievement-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2001;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 350px;
    transform: translateX(100%);
    transition: transform 0.5s ease;
    border: 2px solid #fff;
}

.achievement-notification.show {
    transform: translateX(0);
}

.achievement-notification .achievement-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.achievement-notification .achievement-content {
    flex: 1;
}

.achievement-notification .achievement-title {
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    opacity: 0.9;
}

.achievement-notification .achievement-name {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 2px;
}

.achievement-notification .achievement-description {
    font-size: 13px;
    opacity: 0.8;
}

.achievements-container {
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px 0;
}

.achievement-group {
    margin-bottom: 25px;
}

.achievement-group-title {
    color: #333;
    font-size: 18px;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #eee;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #eee;
    background: white;
    transition: all 0.3s ease;
    position: relative;
}

.achievement-item.unlocked {
    border-color: #28a745;
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.2);
}

.achievement-item.locked {
    border-color: #ddd;
    background: #f8f9fa;
    opacity: 0.7;
}

.achievement-item .achievement-icon {
    font-size: 24px;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
}

.achievement-item.unlocked .achievement-icon {
    background: rgba(40, 167, 69, 0.1);
}

.achievement-item .achievement-details {
    flex: 1;
}

.achievement-item .achievement-name {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    margin-bottom: 4px;
}

.achievement-item.locked .achievement-name {
    color: #666;
}

.achievement-item .achievement-description {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.achievement-item.locked .achievement-description {
    color: #999;
}

.achievement-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #28a745;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ============================================================================
   GAME MESSAGE STYLES
   ============================================================================ */

.game-message-base {
    position: fixed;
    top: 120px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: bold;
    z-index: 1003;
    max-width: 300px;
    transition: all 0.3s ease;
}

.game-message-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.game-message-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.game-message-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.game-message-info {
    background-color: #f8f9fa;
    color: #333;
    border: 1px solid #dee2e6;
}

/* ============================================================================
   USER DISPLAY STYLES
   ============================================================================ */

.team-member {
    background-color: #e8f5e8 !important;
}

.individual-player {
    background-color: #f8f9fa !important;
}

.word-found {
    text-decoration: line-through !important;
    background-color: #E2FFDE !important;
}

.word-found-teammate {
    background-color: #E6F3FF !important;
}

.puzzle-title-clickable {
    cursor: pointer !important;
}

/* ============================================================================
   CANVAS STYLES
   ============================================================================ */

.canvas-fullsize {
    width: 100% !important;
    height: 100% !important;
}

/* ============================================================================
   STATS ANIMATION STYLES
   ============================================================================ */

.stats-diff {
    margin-left: 8px;
    opacity: 1;
    transition: opacity 2.0s ease;
}

.stats-diff-positive {
    color: white;
}

.stats-diff-negative {
    color: red;
}

.stats-updating {
    transition: opacity 2.0s ease;
    opacity: 0;
}

/* ============================================================================
   DARK MODE SUPPORT
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    .list-container {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .wordlist-toggle {
        background: #4CAF50;
    }
    
    .wordlist-toggle:hover {
        background: #45a049;
    }
}

/* ============================================================================
   CONSOLIDATED RESPONSIVE STYLES
   ============================================================================ */

/* ============================================================================
   TABLET STYLES (768px and below)
   ============================================================================ */

@media (max-width: 768px) {
    /* Layout adjustments */
    .controls {
        justify-content: center;
        gap: 8px;
    }
    
    .user-info-panel {
        flex-direction: column;
        width: 100%;
    }
    
    .user-info-panel input {
        min-width: auto;
        width: 100%;
    }

    .lists-section {
        height:200px;
        padding: 8px !important;
    }
    
    .lists-section.collapsed {
        max-height: 35px !important;
        min-height: 35px !important;
    }
    
    /* FIXED: Smaller word list height on mobile */
    .wordList-visible {
        flex-wrap: wrap !important; /* Allow wrapping for mobile */
    }
    
    /* FIXED: Game container maintains full height */
 .game-container {
        height: 100vh !important;
        min-height: 100vh !important;
        max-height: 100vh !important;
    }
    
    /* FIXED: Ensure canvas maintains proper size */
    .canvas-container {
        height: 100% !important;
        width: 100% !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
    }
    
    #gameCanvas {
        width: 100% !important;
        height: 100% !important;
    }

    /* Scroll controls positioning */
    .scroll-controls {
        position: absolute;
        right: 10px;
        top: 10px;
        padding: 5px;
        /* FIXED: Ensure buttons stay within game container */
        max-height: calc(100vh - 200px);
    }

    .scroll-controls .btn, .zoom {
        width: 25px;
        height: 25px;
    }

    /* UI elements positioning and sizing */
.control-group {
        right: 15px;
		width: 100px;
        bottom: 360px; 
        font-size: 14px;
        gap: 8px;
        backdrop-filter: blur(12px);
    }
    
#inviteFriendsBtn {
        right: 15px;
        bottom: 300px; /* 80px + 200px lists-section height */
        width: 100px;
        height: 50px;
        font-size: 14px;
        gap: 6px;
        backdrop-filter: blur(12px);
    }
    
    #inviteFriendsBtn img { 
        width: 30px;
        height: 30px; 
    }
  .lists-section {
        max-height: 200px !important;
        min-height: 200px !important;
        padding: 8px !important;
        /* Ensure it stays at bottom on mobile */
        bottom: 0 !important;
        /* Add safe area padding for mobile devices */
        padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
    }
    
    .lists-section.collapsed {
        max-height: 35px !important;
        min-height: 35px !important;
    }  
 .stats-panel {
        right: 15px;
        bottom: 215px; /* 15px + 200px lists-section height */
        padding: 8px 12px;
        font-size: 14px;
        width: 100px;
        backdrop-filter: blur(12px);
    }
    
    .control-group .color-picker {
        width: 28px;
        height: 28px;
    }

    .stats-panel .stats-grid {
        gap: 6px;
    }

    .stat-item .stat-value, .stat-item span {
        font-size: 16px;
    }

    .stat-item .stat-label {
        font-size: 9px;
    }

    /* Controls overlay */
    .controls-overlay {
        padding: 8px 15px;
    }

    .btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .color-picker {
        width: 35px;
        height: 35px;
    }

    /* Mobile-specific list styling */
    .list-container {
        margin-bottom: 6px;
        padding: 4px;
    }

    .list-container h3 {
        font-size: 12px;
        margin-bottom: 3px;
        padding: 2px 4px;
    }

    /* Mobile word list styling */
    #lists ul {
        gap: 4px !important;
    }

    #lists li {
        padding: 2px 4px !important;
        font-size: 11px !important;
        border-radius: 3px !important;
    }

    /* Mobile list headers and footers */
    #lists > div:first-child {
        margin-bottom: 8px !important;
        font-size: 11px !important;
    }

    #lists > div:last-child {
        margin-top: 6px !important;
        font-size: 10px !important;
    }

    /* Enhanced lists mobile styles */
    .section-header {
        margin: 10px 0 8px 0;
        padding: 6px 10px;
    }
    
    .section-header h4 {
        font-size: 12px;
    }
    
    .title-container h3 {
        font-size: 12px;
        padding: 3px 6px;
    }
    
    .wordlist-toggle {
        width: 28px;
        height: 28px;
        font-size: 18px;
    }
    
    .title-container {
        gap: 6px;
    }
    
    .wordList li {
        font-size: 11px;
        padding: 3px 6px;
    }
    
    .count, .percentage {
        font-size: 10px;
    }

    /* Game messages mobile */
    .game-message-base {
        top: 80px;
        right: 10px;
        max-width: 250px;
        font-size: 14px;
        padding: 10px 12px;
    }

    /* Achievement notifications mobile */
    .achievement-notification {
        right: 10px;
        top: 10px;
        max-width: 280px;
        padding: 12px 15px;
    }

    .achievement-notification .achievement-icon {
        font-size: 24px;
    }

    .achievement-notification .achievement-name {
        font-size: 14px;
    }

    .achievement-notification .achievement-description {
        font-size: 12px;
    }

    .achievements-grid {
        grid-template-columns: 1fr;
    }

    .achievement-item {
        padding: 12px;
    }

    .achievement-item .achievement-icon {
        font-size: 20px;
        width: 35px;
        height: 35px;
    }

    .achievement-item .achievement-name {
        font-size: 14px;
    }

    .achievement-item .achievement-description {
        font-size: 12px;
    }
}

/* ============================================================================
   MOBILE PHONE STYLES (480px and below)
   ============================================================================ */

@media (max-width: 480px) {
.lists-section {
        max-height: 180px !important;
        min-height: 180px !important;
        padding: 6px !important;
        padding-bottom: calc(6px + env(safe-area-inset-bottom)) !important;
    }
	.section-header {
       margin: 3px 0 4px 0;
        padding: 3px 8px;	}
	#lists { margin:0;
	}
.lists-section.collapsed {
        max-height: 30px !important;
        min-height: 30px !important;
    }
    
   
    .game-container {
        min-height: calc(100vh - 240px) !important;
        max-height: calc(100vh - 240px) !important;
    }
	.lists-section { max-height:240px; }
    .scroll-controls .btn, .zoom {
        width: 25px;
        height: 25px;
    }

    /* UI elements mobile sizing */
 .control-group {
        position: absolute;
        right: 5px;
        bottom: 115px; /* Close to bottom, above invite button */
        z-index: 1002;
        width: 65px; /* Narrower than 75px */
        height: 35px;
        padding: 2px 4px;
        font-size: 10px !important;
        gap: 4px;
        border-radius: 8px;
        backdrop-filter: blur(10px);
        /* Keep existing gradient and styling */
        background: linear-gradient(135deg, #000000 0%, #333333 100%);
        color: white;
        font-weight: 600;
        text-align: center;
        cursor: pointer;
        user-select: none;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
        box-shadow: 
            0 8px 32px rgba(102, 126, 234, 0.3),
            0 2px 8px rgba(0, 0, 0, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
    }
	.settings-button { font-size:10px;height:35px; } 
    
  #inviteFriendsBtn {
        position: absolute;
        right: 5px;
        bottom: 75px; /* Staggered between settings and stats */
        z-index: 1002;
        width: 65px; /* Narrower than 75px */
        height: 32px;
        font-size: 10px;
        font-weight: 700;
        gap: 2px;
        padding: 0 4px;
        border-radius: 8px;
        backdrop-filter: blur(10px);
        /* Keep existing gradient and styling */
        background: linear-gradient(135deg, #000000 0%, #333333 100%);
        box-shadow: 
            0 8px 32px rgba(102, 126, 234, 0.3),
            0 2px 8px rgba(0, 0, 0, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.2);
        color: white;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
        cursor: pointer;
        user-select: none;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    
    /* Make invite button icon smaller */
    #inviteFriendsBtn img { 
        width: 18px;
        height: 18px; 
        margin: 0;
    }
    
    /* Stats panel - bottom of stack */
    .stats-panel {
        position: absolute;
        right: 5px;
        bottom: 40px; /* Very close to bottom of canvas */
        z-index: 1002;
        width: 65px; /* Narrower than 75px */
        height: 30px;
        padding: 2px 4px;
        font-size: 10px;
        border-radius: 8px;
        backdrop-filter: blur(10px);
        /* Keep existing gradient and styling */
        background: linear-gradient(135deg, #000000 0%, #333333 100%);
        box-shadow: 
            0 8px 32px rgba(102, 126, 234, 0.3),
            0 2px 8px rgba(0, 0, 0, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.2);
        color: white;
        font-weight: 600;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
        cursor: pointer;
        user-select: none;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
    }
    
    /* Adjust stats text sizing */
    .stat-item {
        padding: 0;
        margin: 0;
        line-height: 1;
    }
    
    .stat-item span {
        font-size: 10px;
        font-weight: bold;
        line-height: 1;
        margin: 0;
    }
    
    .stats-panel p {
        font-size: 7px;
        margin: 1px 0 0 0;
        line-height: 1;
        opacity: 0.8;
    }

    .stats-panel .stats-grid {
        gap: 4px;
    }

    .stat-item .stat-value {
        font-size: 14px;
    }

    .stat-item .stat-label {
        font-size: 8px;
    }
   /* Ensure hover effects work properly */
    .control-group:hover,
    #inviteFriendsBtn:hover,
    .stats-panel:hover {
        transform: translateY(-2px) scale(1.05);
        box-shadow: 
            0 12px 40px rgba(102, 126, 234, 0.4),
            0 4px 12px rgba(0, 0, 0, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
        background: linear-gradient(135deg, #1a1a1a 0%, #333333 100%);
    }
    
    .control-group:active,
    #inviteFriendsBtn:active,
    .stats-panel:active {
        transform: translateY(0) scale(0.98);
        box-shadow: 
            0 4px 16px rgba(102, 126, 234, 0.3),
            0 1px 4px rgba(0, 0, 0, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
    /* Extra small mobile - even more compact lists */
    .list-container {
        margin-bottom: 4px;
        padding: 3px;
    }

    .list-container h3 {
        font-size: 11px;
        margin-bottom: 2px;
        padding: 2px 3px;
    }

    #lists li {
        padding: 2px 3px !important;
        font-size: 10px !important;
    }

    #lists > div:first-child {
        margin-bottom: 6px !important;
        font-size: 10px !important;
    }

    #lists > div:last-child {
        margin-top: 4px !important;
        font-size: 9px !important;
    }

   
    .section-header h4 {
        font-size: 11px;
    }
    
    .title-container {
        gap: 8px;
    }
    
    .title-container h3 {
        font-size: 11px;
        padding: 2px 4px;
    }
    
    .wordlist-toggle {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }
    
    .wordList {
        gap: 4px;
        margin: 6px 0 0 0;
    }
    
    .wordList li {
        font-size: 10px;
        padding: 2px 5px;
    }
    
    .count, .percentage {
        font-size: 9px;
    }
    
    .completion-indicator {
        font-size: 10px;
        margin-right: 4px;
    }

    /* Game messages extra small mobile */
    .game-message-base {
        top: 60px;
        right: 5px;
        left: 5px;
        max-width: none;
        font-size: 13px;
        padding: 8px 10px;
    }
}

/* ============================================================================
   WIDE SCREEN LAYOUT - Left Sidebar for Word Lists
   ============================================================================ */

@media (min-aspect-ratio: 9/7) {
    /* Force horizontal layout */
    .game-layout {
        flex-direction: row !important;
        display: flex !important;
    }

    /* Scroll controls sizing for wide screens */
    .scroll-controls .btn, 
    .zoom {
        width: 30px;
        height: 30px;
    }
    
    /* Word list item styling for vertical layout */
    ul.wordList li { 
        clear: both; 
    }
    
    /* Main lists section - positioned on left side */
    .lists-section {
        order: -1 !important;
        width: 250px !important;
        max-width: 20vw !important;
        max-height: 100vh !important;
        min-height: 100vh !important;
        border-top: none !important;
        border-right: 1px solid #dee2e6 !important;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1) !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        padding: 8px !important;
        flex-shrink: 0 !important;
        position: relative !important;
    }
    
    /* Collapsed state allows natural height */
    .lists-section.collapsed {
        width: 40px !important;
        max-height: 60px !important;
        min-height: auto !important;
        overflow: hidden !important;
    }
    
    /* Game container fills remaining space */
 .game-container {
        flex: 1;
        height: 100vh !important;
        min-height: 100vh !important;
        max-height: 100vh !important;
    }
    
    /* Reposition toggle button for left sidebar */
    .lists-toggle {
        top: 50% !important;
        right: -20px !important;
        left: auto !important;
        transform: translateY(-50%) !important;
        border-radius: 0 15px 15px 0 !important;
        writing-mode: vertical-lr !important;
        text-orientation: mixed !important;
        padding: 10px 5px !important;
    }
    
    /* Word lists adjusted for vertical layout */
    .wordList {
        flex-direction: column !important;
        gap: 0 !important;
        max-height: none !important;
        height: auto !important;
        display: block !important;
        flex-wrap: nowrap !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .wordList li {
        /* CSS truncation for sidebar layout */
        max-width: 200px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        
        /* Prepare for expansion */
        position: relative;
        z-index: 1;
        transition: all 0.2s ease;
    }

    /* On hover, show full word */
    .wordList li:hover {
        /* Reset truncation */
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: initial !important;
        max-width: none !important;
        min-width: 200px;
        
        /* Visual feedback */
        background-color: #fff !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        transform: scale(1.02);
        z-index: 10;
        
        /* Word wrapping for very long words */
        word-wrap: break-word;
        overflow-wrap: break-word;
        
        /* Smooth expansion */
        transition: all 0.3s ease;
    }
    
    /* Override hidden state specifically for left sidebar */
    .wordList-hidden {
        display: none !important;
        height: 0 !important;
        min-height: 0 !important;
        max-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        gap: 0 !important;
        opacity: 0 !important;
        overflow: hidden !important;
    }


    /* Maintain existing found word styling on hover */
    .wordList li.word-found:hover {
        background-color: #f0fff0 !important;
        border-color: #4CAF50 !important;
    }

    .wordList li.word-found-teammate:hover {
        background-color: #f0f8ff !important;
        border-color: #2196F3 !important;
    }  
    .wordList-visible {
        display: block !important;

        opacity: 1 !important;
        overflow: visible !important;
    }
    
    /* List container spacing */
    .list-container {
        margin-bottom: 8px !important;
    }
    
    .list-container h3 {
        font-size: 12px !important;
        margin-bottom: 4px !important;
    }
    
    /* Reposition scroll controls */
    .scroll-controls {
        right: 10px !important;
        top: 10px !important;
    }
    
    /* Adjust right-side UI elements positioning */
    .control-group,
    #inviteFriendsBtn,
    .stats-panel {
        right: 15px;
    }
    .lists-section {
        position: relative !important; /* Not fixed on wide screens */
        order: -1 !important;
        width: 250px !important;
        max-width: 20vw !important;
        max-height: 100vh !important;
        min-height: 100vh !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        border-top: none !important;
        border-right: 1px solid #dee2e6 !important;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1) !important;
        flex-shrink: 0 !important;
        z-index: auto !important;
    }
    
    .lists-section.collapsed {
        width: 40px !important;
        max-height: 60px !important;
        min-height: auto !important;
    }
    .control-group {
        bottom: 160px;
    }
    
    #inviteFriendsBtn {
        bottom: 92px;
    }
    
    .stats-panel {
        bottom: 15px;
    }
}

/* ============================================================================
   MOBILE LANDSCAPE SUPPORT
   ============================================================================ */

@media screen and (max-device-width: 768px) and (orientation: landscape) {
    .game-layout {
        flex-direction: row !important;
    }
    
 .lists-section {
        position: relative !important;
        order: -1 !important;
        width: 250px !important;
        max-height: 100vh !important;
        min-height: 100vh !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
    }
    
    .lists-section.collapsed {
        width: 40px !important;
        max-height: 60px !important;
        min-height: auto !important;
    }
    
.game-container {
        flex: 1 !important;
        height: 100vh !important;
        min-height: 100vh !important;
        max-height: 100vh !important;
    }
	    .wordList li {
        max-width: 180px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        position: relative;
        z-index: 1;
        transition: all 0.2s ease;
    }

    .wordList li:hover {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: initial !important;
        max-width: none !important;
        min-width: 180px;
        background-color: #fff !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        transform: scale(1.02);
        z-index: 10;
        word-wrap: break-word;
        overflow-wrap: break-word;
        transition: all 0.3s ease;
    }

    .wordList li.word-found:hover {
        background-color: #f0fff0 !important;
        border-color: #4CAF50 !important;
    }

    .wordList li.word-found-teammate:hover {
        background-color: #f0f8ff !important;
        border-color: #2196F3 !important;
    }
}

@media (max-width: 768px) and (orientation: landscape) and (hover: none) {
    .game-layout {
        flex-direction: row !important;
    }
    
    .lists-section {
        order: -1 !important;
        width: 250px !important;
        max-height: 100vh !important;
        min-height: 100vh !important;
    }
    
    .lists-section.collapsed {
        width: 40px !important;
        max-height: 60px !important;
        min-height: auto !important;
    }
}

/* ============================================================================
   EXTRA SMALL MOBILE OPTIMIZATION
   ============================================================================ */

@media (max-width: 320px) {
    .control-group {
        padding: 6px 10px;
        font-size: 11px;
        bottom: 160px;
    }
    
    #inviteFriendsBtn {
        width: 90px;
        height: 40px;
        font-size: 11px;
        bottom: 90px;
    }
    
    .stats-panel {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .control-group .color-picker {
        width: 20px;
        height: 20px;
    }
}
#lists { position:relative;max-height:100%; }



/* Add this CSS to your main stylesheet or create a new notifications.css file */

/* Notifications Container */
.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
    pointer-events: none;
}

/* Individual Notification */
.teammate-notification {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    margin-bottom: 12px;
    padding: 0;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    pointer-events: auto;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 100%;
    word-wrap: break-word;
}

.teammate-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.teammate-notification.hide {
    opacity: 0;
    transform: translateX(100%);
}

/* Notification Content */
.notification-content {
    display: flex;
    align-items: flex-start;
    padding: 16px;
    gap: 12px;
    position: relative;
}

/* Notification Icon */
.notification-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Notification Text */
.notification-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 500;
}

.notification-text strong {
    font-weight: 700;
    color: #fff;
}

/* Puzzle Links in Notifications */
.notification-text .puzzle-link {
    color: #a8d8ff;
    text-decoration: none;
    border-bottom: 1px solid rgba(168, 216, 255, 0.3);
    transition: all 0.2s ease;
    cursor: pointer;
}

.notification-text .puzzle-link:hover {
    color: #ffffff;
    border-bottom-color: #ffffff;
    text-shadow: 0 0 8px rgba(168, 216, 255, 0.6);
}

.notification-text .puzzle-link:active {
    transform: translateY(1px);
}

/* Close Button */
.notification-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.notification-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    transform: scale(1.1);
}

.notification-close:active {
    transform: scale(0.95);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .notifications-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .teammate-notification {
        margin-bottom: 8px;
    }
    
    .notification-content {
        padding: 12px;
        gap: 8px;
    }
    
    .notification-icon {
        font-size: 18px;
    }
    
    .notification-text {
        font-size: 13px;
    }
}

/* Animation for stacking notifications */
.teammate-notification:nth-child(1) {
    animation-delay: 0ms;
}

.teammate-notification:nth-child(2) {
    animation-delay: 100ms;
}

.teammate-notification:nth-child(3) {
    animation-delay: 200ms;
}

.teammate-notification:nth-child(4) {
    animation-delay: 300ms;
}

.teammate-notification:nth-child(5) {
    animation-delay: 400ms;
}

/* Hover effect for entire notification */
.teammate-notification:hover {
    transform: translateX(-5px) scale(1.02);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* Success variant for teammate notifications */
.teammate-notification.success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

/* Info variant for teammate notifications */
.teammate-notification.info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Special styling for multiple words in one notification */
.notification-text .word-count {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 4px;
}

/* Loading state for notifications */
.teammate-notification.loading .notification-content::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Dark mode compatibility */
@media (prefers-color-scheme: dark) {
    .teammate-notification {
        border-color: rgba(255, 255, 255, 0.2);
    }
}

/* High contrast mode compatibility */
@media (prefers-contrast: high) {
    .teammate-notification {
        background: #1a1a1a;
        color: #ffffff;
        border: 2px solid #ffffff;
    }
    
    .notification-text .puzzle-link {
        color: #00ffff;
        border-bottom-color: #00ffff;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .teammate-notification {
        transition: opacity 0.3s ease;
        transform: none;
    }
    
    .teammate-notification.show {
        transform: none;
    }
    
    .teammate-notification.hide {
        transform: none;
    }
    
    .teammate-notification:hover {
        transform: none;
    }
}/* REPLACE the existing row message popup CSS with this simplified version */

/* Row Message Popup - Simplified Design */
.row-message-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    min-width: 320px;
    max-width: 500px;
    animation: popupAppear 0.2s ease-out;
}

@keyframes popupAppear {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.row-message-content {
    padding: 20px;
}

.row-message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.row-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.close-row-popup {
    font-size: 20px;
    color: #aaa;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-row-popup:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

.row-instruction {
    font-size: 13px;
    color: #666;
    text-align: center;
    margin-bottom: 15px;
    font-style: italic;
}

.row-message-text {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    padding: 15px 20px;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 8px;
    border-left: 4px solid #3498db;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    min-height: 20px;
    word-break: break-word;
    text-align: center;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .row-message-popup {
        min-width: 280px;
        max-width: 90vw;
        margin: 0 10px;
    }
    
    .row-message-content {
        padding: 15px;
    }
    
    .row-message-text {
        font-size: 16px;
        padding: 12px 16px;
    }
    
    .row-title {
        font-size: 14px;
    }
    
    .row-instruction {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .row-message-popup {
        min-width: 260px;
        max-width: 95vw;
    }
    
    .row-message-content {
        padding: 12px;
    }
    
    .row-message-header {
        margin-bottom: 12px;
        padding-bottom: 8px;
    }
    
    .row-message-text {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .row-instruction {
        margin-bottom: 12px;
    }
}

.section-header.special-section {
    background: rgba(255, 193, 7, 0.1);
    border-left-color: #FFC107;
    color: #F57F17;
}
/* ============================================================================
   LOADING SCREEN STYLES
   ============================================================================ */

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%),
                url('img/loading-background.jpg');
    background-size: cover;
    background-position: center;
    background-blend-mode: overlay;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: white;
}

.loading-content {
    text-align: center;
    padding: 40px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 30px;
}

.loading-screen h2 {
    font-size: 24px;
    margin-bottom: 10px;
    font-weight: 600;
}

.loading-screen p {
    font-size: 16px;
    opacity: 0.9;
}

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

/* Hide loading screen when game is ready */
.loading-screen.hidden {
    display: none;
}

/* ============================================================================
   ROW MARKERS - HIDDEN FOR NOW (INCOMPLETE FEATURE)
   ============================================================================ */

/* Hide row markers until the feature is complete */
.row-message-popup,
.row-markers {
    display: none !important;
}

/* ============================================================================
   CONSOLIDATED RESPONSIVE STYLES
   ============================================================================ */
   /* Add to style.css or in <style> block */
.modal {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 15px;
    right: 20px;
}

.close-modal:hover {
    color: #000;
}

.upgrade-header {
    text-align: center;
    margin-bottom: 20px;
}

.upgrade-header h2 {
    color: #333;
    margin-bottom: 10px;
}

.upgrade-benefits ul {
    margin: 20px 0;
    padding-left: 20px;
}

.upgrade-benefits li {
    margin: 8px 0;
    color: #555;
}

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

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

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}

.form-group input:focus {
    border-color: #667eea;
    outline: none;
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 10px;
    transition: background-color 0.3s ease;
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

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

.btn:hover {
    opacity: 0.9;
}
/* Save Progress Button - positioned above Settings button */
#saveProgressBtn {
    position: absolute;
    right: 20px;
    bottom: 480px; /* Above the settings button (425px) */
    z-index: 1002;
    width: 140px;
    height: 50px;
    font-size: 14px;
    font-weight: 700;
    
    /* Shared button styling */
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    backdrop-filter: blur(15px);
    border-radius: 12px;
    box-shadow: 
        0 8px 32px rgba(40, 167, 69, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    
    /* Subtle pulsing animation */
    animation: save-progress-pulse 3s ease-in-out infinite;
}

@keyframes save-progress-pulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 
            0 8px 32px rgba(40, 167, 69, 0.3),
            0 2px 8px rgba(0, 0, 0, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }
    50% { 
        transform: scale(1.02);
        box-shadow: 
            0 12px 40px rgba(40, 167, 69, 0.4),
            0 4px 12px rgba(0, 0, 0, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
}

#saveProgressBtn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        0 12px 40px rgba(40, 167, 69, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    background: linear-gradient(135deg, #218838 0%, #1ea085 100%);
    animation: none; /* Stop pulsing on hover */
}

#saveProgressBtn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 
        0 4px 16px rgba(40, 167, 69, 0.3),
        0 1px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    #saveProgressBtn {
        right: 15px;
        bottom: 410px; /* Adjust for mobile button positions */
        width: 100px;
        height: 45px;
        font-size: 12px;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    #saveProgressBtn {
        right: 5px;
        bottom: 155px; /* Stack above other mobile buttons */
        width: 65px;
        height: 30px;
        font-size: 10px;
        gap: 2px;
        padding: 0 4px;
    }
}
}