/* Word Search Game - Modern Responsive Stylesheet */
/* Version 2.0 - 2026 Redesign */

/* ============================================
   CSS Custom Properties (Theme Variables)
   ============================================ */
:root {
    /* Colors */
    --primary: #0267ae;
    --primary-dark: #004b7f;
    --primary-light: #4790c3;
    --secondary: #f7931e;
    --secondary-dark: #d67d0c;
    --success: #28a745;
    --success-light: #5dd879;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;

    /* Neutrals */
    --white: #ffffff;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    --black: #000000;

    /* Game-specific colors */
    --found-word-bg: rgba(40, 167, 69, 0.3);
    --selection-color: rgba(255, 193, 7, 0.6);
    --hint-color: rgba(220, 53, 69, 0.5);
    --cell-hover: rgba(2, 103, 174, 0.1);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.15);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Font sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
}

/* ============================================
   Base Styles - Scoped to game container only
   ============================================ */
.game-container *,
.game-container *::before,
.game-container *::after {
    box-sizing: border-box;
}

.game-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.5;
    color: var(--gray-800);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Game Layout - Desktop First
   ============================================ */
.game-wrapper {
    width: 100%;
    margin: 0;
    padding: 0;
}

.game-category {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--gray-600);
    background: var(--gray-100);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
}

.game-main {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 0;
    background: var(--white);
}

.game-board-section {
    padding: var(--space-sm);
}

.game-sidebar {
    background: var(--gray-100);
    border-left: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
}

/* ============================================
   Timer & Progress Bar
   ============================================ */
.game-stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
    padding: var(--space-sm);
    background: var(--gray-100);
}

.timer-display {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-2xl);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--gray-800);
}

.timer-display.warning {
    color: var(--warning);
    animation: pulse 1s ease-in-out infinite;
}

.timer-display.danger {
    color: var(--danger);
    animation: pulse 0.5s ease-in-out infinite;
}

.timer-icon {
    width: 24px;
    height: 24px;
}

.words-progress {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.progress-text {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--gray-700);
}

.progress-bar-container {
    width: 120px;
    height: 8px;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--success-light));
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

/* ============================================
   Game Board / Grid
   ============================================ */
.board-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    aspect-ratio: 1;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.board-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--white);
    border: 2px solid var(--primary);
    overflow: visible;
}

.game-grid {
    display: grid;
    width: 100%;
    height: 100%;
    gap: 0;
}

.grid-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: clamp(14px, 4vw, 28px);
    color: var(--gray-800);
    background: var(--white);
    border: 1px solid var(--gray-200);
    transition: background-color var(--transition-fast), transform var(--transition-fast);
    cursor: pointer;
    text-transform: uppercase;
}

.grid-cell:hover {
    background: var(--cell-hover);
}

.grid-cell.selected {
    background: var(--selection-color);
    transform: scale(1.05);
    z-index: 1;
}

.grid-cell.found {
    background: var(--found-word-bg);
}

.grid-cell.hint {
    background: var(--hint-color);
    animation: hint-pulse 1s ease-in-out 3;
}

/* Canvas layers for drawing */
.canvas-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#selection-canvas {
    z-index: 10;
    pointer-events: auto;
}

#found-canvas {
    z-index: 5;
}

/* ============================================
   Word List (Desktop Sidebar)
   ============================================ */
.word-list-header {
    padding: var(--space-md);
    background: var(--primary);
    color: var(--white);
}

.word-list-header h2 {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 600;
}

.word-list-count {
    font-size: var(--text-sm);
    opacity: 0.9;
}

.word-list-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.word-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-xs);
    list-style: none;
    margin: 0;
    padding: 0;
}

.word-item {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--gray-700);
    background: var(--white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    transition: all var(--transition-fast);
}

.word-item.found {
    background: var(--success);
    color: var(--white);
    border-color: var(--success);
    text-decoration: line-through;
    opacity: 0.7;
}

.word-item.found::before {
    content: "\2713 ";
}

.word-item.animating {
    animation: word-found 0.6s ease-out;
}

/* ============================================
   Game Action Buttons
   ============================================ */
.game-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
}

.game-actions .btn {
    flex: none;
    min-width: 100px;
    max-width: 150px;
}

.btn {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-base);
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

/* Ensure buttons work on iOS */
.btn {
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #c82333);
    color: var(--white);
}

.btn-secondary {
    background: var(--gray-500);
    color: var(--white);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #1e7e34);
    color: var(--white);
}

/* ============================================
   Mobile Bottom Sheet (Word List)
   ============================================ */
.bottom-sheet-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.bottom-sheet-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.bottom-sheet {
    display: none;
    position: fixed;
    bottom: env(safe-area-inset-bottom, 0px);
    left: 0;
    right: 0;
    background: var(--white);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-xl);
    z-index: 999;
    transform: translateY(calc(100% - 80px));
    transition: transform var(--transition-normal);
    max-height: 70dvh;
}

.bottom-sheet.expanded {
    transform: translateY(0);
}

.bottom-sheet-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    cursor: grab;
}

.bottom-sheet-handle::before {
    content: '';
    width: 40px;
    height: 4px;
    background: var(--gray-400);
    border-radius: var(--radius-full);
    margin-bottom: var(--space-sm);
}

.bottom-sheet-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.bottom-sheet-preview h3 {
    margin: 0;
    font-size: var(--text-base);
    color: var(--gray-700);
}

.next-words {
    display: flex;
    gap: var(--space-xs);
    font-size: var(--text-sm);
    color: var(--gray-600);
}

.next-word-pill {
    background: var(--gray-200);
    padding: 2px var(--space-sm);
    border-radius: var(--radius-full);
}

.bottom-sheet-content {
    padding: 0 var(--space-md) var(--space-lg);
    overflow-y: auto;
    max-height: calc(70vh - 80px);
}

.bottom-sheet .word-list {
    grid-template-columns: repeat(3, 1fr);
}

/* ============================================
   Combo & Streak Display
   ============================================ */
.combo-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--text-4xl);
    font-weight: 800;
    color: var(--secondary);
    text-shadow: 2px 2px 0 var(--white), 4px 4px 0 var(--secondary-dark);
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
}

.combo-display.show {
    animation: combo-pop 1s ease-out forwards;
}

.streak-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
    color: var(--white);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: 600;
}

.streak-indicator.hidden {
    display: none;
}

.streak-flame {
    font-size: var(--text-lg);
}

/* ============================================
   Start Game Overlay
   ============================================ */
.start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.95);
    z-index: 100;
    border-radius: var(--radius-md);
}

.start-overlay.hidden {
    display: none;
}

.start-button {
    padding: var(--space-lg) var(--space-2xl);
    font-size: var(--text-2xl);
    font-weight: 700;
    background: linear-gradient(135deg, var(--success), #1e7e34);
    color: var(--white);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-fast);
}

.start-button:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-xl);
}

.start-button:active {
    transform: scale(0.98);
}

/* iOS touch fixes for start button */
.start-button {
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.start-instructions {
    margin-top: var(--space-md);
    font-size: var(--text-base);
    color: var(--gray-600);
    text-align: center;
}

/* ============================================
   Loading State
   ============================================ */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--white);
    z-index: 200;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: var(--space-md);
    color: var(--gray-600);
    font-size: var(--text-lg);
}

/* ============================================
   Celebration Effects
   ============================================ */
.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 2000;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--secondary);
    animation: confetti-fall 3s ease-out forwards;
}

/* ============================================
   Animations
   ============================================ */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes hint-pulse {
    0%, 100% { background: var(--hint-color); }
    50% { background: rgba(220, 53, 69, 0.8); }
}

@keyframes word-found {
    0% {
        transform: scale(1);
        background: var(--success);
    }
    50% {
        transform: scale(1.2);
        background: var(--success-light);
    }
    100% {
        transform: scale(1);
        background: var(--success);
    }
}

@keyframes combo-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -70%) scale(1);
    }
}

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

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

@keyframes slide-up {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes count-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes flash-green {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(40, 167, 69, 0.3); }
}

/* ============================================
   Statistics Page Styles
   ============================================ */
.stats-container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-md);
}

.stats-header {
    text-align: center;
    margin-bottom: var(--space-md);
}

.stats-header h1 {
    margin: 0;
    font-size: var(--text-2xl);
    color: var(--gray-800);
}

.stats-header p {
    display: none;
}

.stats-summary {
    display: flex;
    justify-content: center;
    gap: var(--space-xl);
    flex-wrap: wrap;
}

.stat-highlight {
    text-align: center;
}

.stat-highlight-value {
    display: block;
    font-size: var(--text-4xl);
    font-weight: 800;
    line-height: 1;
}

.stat-highlight-label {
    font-size: var(--text-sm);
    opacity: 0.9;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: slide-up 0.5s ease-out backwards;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

.stat-card-header {
    padding: var(--space-md);
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
}

.stat-card-header h3 {
    margin: 0;
    font-size: var(--text-lg);
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.stat-card-body {
    padding: var(--space-md);
}

/* Progress bars in stats */
.stat-progress {
    margin-bottom: var(--space-md);
}

.stat-progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-xs);
    font-size: var(--text-sm);
}

.stat-progress-label {
    color: var(--gray-600);
}

.stat-progress-value {
    font-weight: 600;
    color: var(--gray-800);
}

.stat-progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.stat-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-full);
    transition: width 1s ease-out;
}

.stat-progress-fill.success {
    background: linear-gradient(90deg, var(--success), var(--success-light));
}

/* Word Results Table */
.word-results-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-lg);
}

.word-results-header {
    padding: var(--space-md);
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.word-results-header h3 {
    margin: 0;
}

.word-results-filters {
    display: flex;
    gap: var(--space-sm);
}

.filter-btn {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-sm);
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.word-results-grid {
    max-height: 400px;
    overflow-y: auto;
}

.word-results-layout {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-lg);
    padding: var(--space-md);
}

.word-result-row {
    display: grid;
    grid-template-columns: minmax(100px, 1.5fr) minmax(90px, 1fr) 70px;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--gray-100);
    align-items: center;
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 14px;
}

.word-result-row > div:nth-child(2) {
    text-align: left;
    font-size: 12px;
    color: var(--gray-600);
}

.word-result-row > div:nth-child(3) {
    text-align: right;
}

.word-result-header {
    background: var(--gray-100);
    font-weight: 600;
    font-size: 11px;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.word-result-header > div {
    white-space: nowrap;
}

.word-result-header > div:nth-child(2) {
    text-align: left;
}

.word-result-header > div:nth-child(3) {
    text-align: right;
}

.word-result-row:hover {
    background: var(--gray-100);
}

.word-result-row.found {
    background: rgba(40, 167, 69, 0.1);
}

.word-result-row.missed {
    background: rgba(220, 53, 69, 0.05);
}

.word-result-word {
    font-weight: 600;
}

.word-result-status {
    font-size: var(--text-lg);
}

.word-result-status.found { color: var(--success); }
.word-result-status.missed { color: var(--danger); }

/* Mini Grid for Stats */
.mini-grid-container {
    padding: var(--space-sm);
    overflow: visible;
}

.mini-grid {
    display: grid;
    gap: 1px;
    background: var(--gray-300);
    border: 1px solid var(--gray-300);
    max-width: 100%;
    width: fit-content;
    margin: 0 auto;
}

.mini-grid-cell {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    font-size: 12px;
    font-weight: 600;
    transition: background var(--transition-fast);
}

.mini-grid-cell.highlight-found {
    background: var(--success);
    color: var(--white);
}

.mini-grid-cell.highlight-missed {
    background: var(--danger);
    color: var(--white);
}

/* Share Button */
.share-section {
    text-align: center;
    padding: var(--space-xl);
    background: var(--gray-100);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
}

.share-buttons {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.share-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--text-base);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.share-btn:hover {
    transform: translateY(-2px);
}

.share-btn.twitter { background: #1da1f2; color: white; }
.share-btn.facebook { background: #4267b2; color: white; }
.share-btn.copy { background: var(--gray-600); color: white; }

/* Animated Counter */
.animated-counter {
    display: inline-block;
    overflow: hidden;
}

.counter-digit {
    display: inline-block;
    animation: count-up 0.5s ease-out backwards;
}

/* ============================================
   Play/Init Page Styles
   ============================================ */
.mode-selection {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    max-width: 600px;
    margin: var(--space-md) auto;
}

.mode-card {
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-normal);
    text-decoration: none;
    color: inherit;
}

.mode-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.mode-card.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.mode-card-image {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
}

.mode-card.competitive .mode-card-image {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
}

.mode-card.casual .mode-card-image {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.mode-card-content {
    padding: var(--space-sm) var(--space-md);
}

.mode-card h2 {
    margin: 0 0 4px;
    font-size: var(--text-base);
}

.mode-card p {
    margin: 0;
    color: var(--gray-600);
    font-size: var(--text-xs);
    line-height: 1.5;
}

/* Pre-game Stats */
.pregame-stats {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    max-width: 500px;
    margin: var(--space-xl) auto;
    overflow: hidden;
}

.pregame-stats-header {
    padding: var(--space-md);
    background: var(--primary);
    color: var(--white);
}

.pregame-stats-header h2 {
    margin: 0;
    font-size: var(--text-lg);
}

.pregame-stats-body {
    padding: var(--space-md);
}

.pregame-stat-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 16px;
}

.pregame-stat-row:last-child {
    border-bottom: none;
}

.pregame-stat-label {
    color: var(--gray-600);
}

.pregame-stat-value {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 16px;
}

.pregame-actions {
    padding: var(--space-md);
    background: var(--gray-100);
}

.sound-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.sound-toggle label {
    color: var(--gray-700);
    font-size: 16px;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gray-400);
    border-radius: var(--radius-full);
    transition: var(--transition-fast);
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--success);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

/* ============================================
   Tablet Styles
   ============================================ */
@media (max-width: 900px) {
    .game-main {
        grid-template-columns: 1fr;
    }

    .game-sidebar {
        display: none;
    }

    .bottom-sheet,
    .bottom-sheet-overlay {
        display: block;
    }

    .game-stats-bar {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }
}

/* ============================================
   Mobile Styles
   ============================================ */
@media (max-width: 600px) {
    /* Override site container for game pages */
    #container_full {
        padding: 0 !important;
    }

    .game-container {
        width: 100%;
        padding: 0;
    }

    .game-wrapper {
        padding: 0;
        width: 100%;
        margin: 0;
    }

    .game-header {
        padding: var(--space-sm) var(--space-md);
        border-radius: 0;
    }

    .game-header h1 {
        font-size: var(--text-lg);
    }

    .game-board-section {
        padding: var(--space-xs);
    }

    .board-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
    }

    .grid-cell {
        font-size: clamp(16px, 6vw, 24px);
        border: none;
    }

    .board-wrapper {
        border: none;
    }

    .timer-display {
        font-size: var(--text-xl);
    }

    .progress-bar-container {
        width: 80px;
    }

    .game-actions {
        position: fixed;
        bottom: calc(100px + env(safe-area-inset-bottom, 0px));
        left: 0;
        right: 0;
        z-index: 100;
        background: var(--white);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        padding: 8px var(--space-md);
    }

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

    /* Hide next-words preview on mobile */
    .next-words {
        display: none !important;
    }

    /* Mobile bottom sheet with two sections */
    .bottom-sheet {
        height: auto;
        max-height: 70dvh;
        transform: translateY(calc(100% - 100px));
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .bottom-sheet.expanded {
        transform: translateY(0);
        overflow-y: auto;
    }

    .bottom-sheet-handle {
        padding: var(--space-xs) var(--space-sm);
        min-height: 100px;
        display: block;
        cursor: pointer;
        flex-shrink: 0;
    }

    .bottom-sheet-content {
        flex-shrink: 0;
    }

    .sheet-drag-indicator {
        width: 40px;
        height: 4px;
        background: var(--gray-300);
        border-radius: 2px;
        margin: 4px auto 6px;
    }

    /* Section labels */
    .section-label {
        font-size: 11px;
        font-weight: 600;
        color: var(--gray-600);
        margin-bottom: 4px;
        text-transform: uppercase;
    }

    .found-label {
        color: var(--success);
    }

    /* Words to find section (visible area) */
    .words-to-find-section {
        width: 100%;
    }

    .words-to-find-section .word-list {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        max-height: none;
        overflow: visible;
    }

    .words-to-find-section .word-item {
        font-size: 13px;
        font-weight: 500;
        padding: 4px 10px;
        background: var(--white);
        border: 1px solid var(--gray-300);
        border-radius: var(--radius-sm);
        white-space: nowrap;
        color: var(--gray-700);
    }

    /* Hide found words section on mobile to save space */
    .bottom-sheet-content {
        display: none;
    }

    .found-words-section .word-list {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .found-words-section .word-item {
        font-size: 13px;
        font-weight: 500;
        padding: 4px 10px;
        background: var(--white);
        border: 1px solid var(--success);
        border-radius: var(--radius-sm);
        white-space: nowrap;
        color: var(--success);
        text-decoration: line-through;
    }

    .empty-found-message {
        text-align: center;
        color: var(--gray-500);
        font-size: 13px;
        padding: var(--space-md);
    }

    .stats-header {
        padding: var(--space-lg);
    }

    .stats-header h1 {
        font-size: var(--text-2xl);
    }

    .stat-highlight-value {
        font-size: var(--text-3xl);
    }

    .stats-summary {
        gap: var(--space-lg);
    }

    .word-results-layout {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    .word-results-layout .mini-grid-container {
        order: -1;
    }

    .word-result-row {
        grid-template-columns: 1.5fr 1fr 60px;
        font-size: 13px;
        gap: var(--space-sm);
        padding: var(--space-xs) var(--space-sm);
    }

    .word-result-row > div:nth-child(2) {
        font-size: 11px;
    }

    .word-results-grid {
        max-height: 300px;
        overflow-y: auto;
    }

    .mode-selection {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-sm);
        padding: 0 var(--space-sm);
    }

    .mode-card-image {
        height: 50px;
        font-size: 28px;
    }

    .mode-card-content {
        padding: var(--space-xs) var(--space-sm);
    }

    .mode-card h2 {
        font-size: var(--text-sm);
    }

    .mode-card p {
        font-size: 10px;
        line-height: 1.4;
    }

}

/* ============================================
   Small Mobile Styles
   ============================================ */
@media (max-width: 380px) {
    .game-stats-bar {
        padding: var(--space-xs);
    }

    .timer-display {
        font-size: var(--text-lg);
    }

    .words-progress {
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
    }

    .progress-text {
        font-size: var(--text-base);
    }

    .grid-cell {
        font-size: clamp(16px, 6vw, 24px);
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .game-actions,
    .bottom-sheet,
    .share-section {
        display: none;
    }

    .stat-card {
        break-inside: avoid;
    }
}

/* ============================================
   Accessibility
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

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

/* Focus styles for keyboard navigation */
.btn:focus,
.grid-cell:focus,
.word-item:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
