
        /* ===== Site Header / Footer (new design) ===== */
        .site-header {
            background-color: #ffffff;
            display: flex; justify-content: space-between; align-items: center;
            height: 64px; padding: 0 24px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.05);
            width: 100%; flex-shrink: 0;
        }
        .site-logo { display: flex; align-items: center; gap: 10px; }
        .site-logo img.bigtoe { height: 60px; width: auto; display: block; }
        .site-logo img.logotext { height: 30px; width: auto; display: block; }
        .site-nav { display: flex; align-items: center; gap: 26px; }
        .site-nav a { text-decoration: none; color: #334155; font-weight: 500; font-size: 0.9rem; transition: color 0.2s; }
        .site-nav a:hover { color: #0d9488; }
        .site-nav a.site-play {
            background: #14b8a6; color: #fff; padding: 8px 18px; border-radius: 999px; font-weight: 600;
        }
        .site-nav a.site-play:hover { background: #0d9488; color: #fff; }
        /* Menu hidden for launch — flip this back to show it */
        .site-nav { display: none; }
        /* Language switch */
        .header-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
        .lang-switch { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
        .lang-switch button {
            border: 1px solid #d5d5d5; background: #fff; color: #555;
            border-radius: 999px; padding: 4px 12px; font-size: 0.8rem;
            font-weight: 600; cursor: pointer; transition: all 0.15s;
        }
        /* Language burger menu (mobile only) */
        .lang-menu { position: relative; }
        .lang-menu-btn {
            display: none;
            border: 1px solid #d5d5d5; background: #fff; color: #555;
            border-radius: 999px; padding: 4px 12px; font-size: 0.8rem;
            font-weight: 600; cursor: pointer; white-space: nowrap;
            transition: all 0.15s;
        }
        .lang-menu-btn:hover { border-color: #0d9488; color: #0d9488; }
        html.dark .lang-menu-btn { background: #1a1a2e; border-color: #3f3f5a; color: #e8e8f0; }
        html.dark .lang-menu-btn:hover { border-color: #14b8a6; color: #5eead4; }
        .lang-switch button:hover { border-color: #0d9488; color: #0d9488; }
        .lang-switch button.active { background: #14b8a6; border-color: #14b8a6; color: #fff; }
        /* Theme toggle (site-wide dark mode) */
        .theme-toggle {
            border: 1px solid #d5d5d5; background: #fff; color: #555;
            border-radius: 999px; padding: 4px 12px; font-size: 0.9rem; line-height: 1.5;
            font-weight: 600; cursor: pointer; transition: all 0.15s; flex-shrink: 0;
        }
        .theme-toggle:hover { border-color: #0d9488; color: #0d9488; }
        .theme-toggle .icon-dark { display: none; }
        /* Site-wide dark theme */
        html.dark .site-header { background: #1a1a2e; box-shadow: 0 2px 5px rgba(0,0,0,0.4); }
        html.dark .site-footer { background: #1a1a2e; border-top-color: #2d2d44; color: #9ca3af; }
        html.dark .site-footer-links a { color: #9ca3af; }
        html.dark .site-footer-links a:hover { color: #5eead4; }
        html.dark .site-nav a { color: #cbd5e1; }
        html.dark .site-nav a:hover { color: #5eead4; }
        html.dark .lang-switch button { background: #1a1a2e; border-color: #3f3f5a; color: #cbd5e1; }
        html.dark .lang-switch button:hover { border-color: #14b8a6; color: #5eead4; }
        html.dark .lang-switch button.active { background: #14b8a6; border-color: #14b8a6; color: #fff; }
        html.dark .theme-toggle { background: #1a1a2e; border-color: #3f3f5a; color: #e8e8f0; }
        html.dark .theme-toggle:hover { border-color: #14b8a6; color: #5eead4; }
        html.dark .theme-toggle .icon-light { display: none; }
        html.dark .theme-toggle .icon-dark { display: inline; }
        /* The wordmark PNG has an opaque white background — invert it in dark mode */
        html.dark .site-logo img.logotext { filter: invert(1) hue-rotate(180deg); }
        .site-footer {
            background-color: #ffffff; border-top: 1px solid #e5e5e5;
            padding: 18px 20px; display: flex; flex-direction: column; align-items: center; gap: 4px;
            font-size: 0.85rem; color: #555; width: 100%; flex-shrink: 0; text-align: center;
        }
        .site-footer-links { display: flex; gap: 20px; }
        .site-footer-links a { text-decoration: none; color: #555; }
        .site-footer-links a:hover { color: #5f9bb9; }
        @media (max-width: 720px) {
            .site-nav { display: none; }
            .site-logo img.bigtoe { height: 44px; }
            .site-logo img.logotext { height: 20px; }
            .lang-menu-btn { display: inline-block; }
            .lang-menu-dd {
                display: none;
                position: absolute; right: 0; top: calc(100% + 8px);
                background: #fff; border: 1px solid #d5d5d5; border-radius: 12px;
                box-shadow: 0 8px 24px rgba(0,0,0,0.15);
                padding: 6px; z-index: 500; min-width: 120px;
            }
            .lang-menu-dd.open { display: block; }
            .lang-menu-dd .lang-switch { flex-direction: column; align-items: stretch; gap: 4px; }
            .lang-menu-dd .lang-switch button { display: block; width: 100%; text-align: left; border: none; }
            html.dark .lang-menu-dd { background: #1a1a2e; border-color: #3f3f5a; }
        }

        /* ===== CSS Variables (Light Mode Default) ===== */
        :root {
            --bg-color: #F5F5F5;
            --surface-color: #FFFFFF;
            --text-color: #212121;
            --text-secondary: #757575;
            --grid-bg: #FFFFFF;
            --cell-bg: #FFFFFF;
            --cell-text: #212121;
            --cell-border: #E0E0E0;
            --cell-selected: #FFF9C4;
            --cell-found: #C8E6C9;
            --cell-found-text: #2E7D32;
            --cell-selecting: #FFECB3;
            --word-found: #4CAF50;
            --word-unfound: #757575;
            --primary: #009688;
            --primary-hover: #00796B;
            --accent: #FFB300;
            --error: #E57373;
            --cell-error-bg: #FFEBEE;
            --cell-error-text: #E57373;
            --button-bg: #E0E0E0;
            --button-hover: #BDBDBD;
            --button-active: #009688;
            --button-active-text: #FFFFFF;
            --header-bg: #009688;
            --header-text: #FFFFFF;
            --shadow: 0 2px 8px rgba(0,0,0,0.1);
            --radius: 8px;
            --transition: 0.2s ease;
        }

        html.dark {
            --bg-color: #121212;
            --surface-color: #1E1E1E;
            --text-color: #E0E0E0;
            --text-secondary: #9E9E9E;
            --grid-bg: #1E1E1E;
            --cell-bg: #1E1E1E;
            --cell-text: #E0E0E0;
            --cell-border: #424242;
            --cell-selected: #3E2723;
            --cell-found: #1B5E20;
            --cell-found-text: #A5D6A7;
            --cell-selecting: #4E342E;
            --word-found: #66BB6A;
            --word-unfound: #9E9E9E;
            --cell-error-bg: #4E1A1A;
            --cell-error-text: #EF9A9A;
            --button-bg: #333333;
            --button-hover: #424242;
            --button-active: #00BFA5;
            --button-active-text: #121212;
            --header-bg: #1E1E1E;
            --header-text: #E0E0E0;
            --shadow: 0 2px 8px rgba(0,0,0,0.3);
        }

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

        body {
            font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
            background: var(--bg-color);
            color: var(--text-color);
            min-height: 100dvh;
            display: flex;
            flex-direction: column;
            align-items: center;
            transition: background var(--transition), color var(--transition);
            -webkit-tap-highlight-color: transparent;
            user-select: none;
        }

        .app-container {
            width: 100%;
            max-width: 700px;
            flex: 1;
            padding: 8px 12px 12px;
            display: flex;
            flex-direction: column;
            align-items: center;
            position: relative;
            overflow: hidden;
        }

        header {
            width: 100%;
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
        }
        .header-brand {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .header-logo {
            height: 36px;
            width: auto;
            flex-shrink: 0;
        }
        .header-text h1 {
            font-size: 20px;
            font-weight: 700;
            line-height: 1.1;
            color: var(--text-color);
        }
        .header-text .publisher {
            font-size: 10px;
            color: var(--primary);
            font-weight: 500;
        }
        .header-right {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .btn-icon {
            background: var(--button-bg);
            border: none;
            border-radius: 50%;
            width: 36px;
            height: 36px;
            font-size: 18px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background var(--transition);
        }
        .btn-icon:hover { background: var(--button-hover); }

        /* ---------- Game Layout ---------- */
        .game-layout {
            display: flex;
            gap: 16px;
            width: 100%;
            align-items: flex-start;
            justify-content: center;
        }

        .grid-panel {
            flex-shrink: 0;
        }

        .word-list-panel {
            flex: 0 0 160px;
            background: var(--surface-color);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            padding: 12px;
            max-height: 520px;
            overflow-y: auto;
        }
        .word-list-panel h3 {
            font-size: 14px;
            font-weight: 700;
            color: var(--text-color);
            margin-bottom: 10px;
            text-align: center;
        }
        .word-list {
            list-style: none;
            display: flex;
            flex-direction: column;
            gap: 4px;
        }
        .word-list li {
            font-size: 13px;
            font-weight: 600;
            letter-spacing: 1px;
            padding: 3px 6px;
            border-radius: 4px;
            color: var(--word-unfound);
            transition: color var(--transition), background var(--transition);
        }
        .word-list li.found {
            color: var(--word-found);
            text-decoration: line-through;
            background: var(--cell-found);
        }

        /* ---------- Grid ---------- */
        .grid-wrapper {
            position: relative;
            background: var(--grid-bg);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            padding: 4px;
            display: inline-block;
        }
        #selectionCanvas {
            position: absolute;
            top: 4px;
            left: 4px;
            pointer-events: none;
            z-index: 10;
        }
        .grid {
            display: grid;
            gap: 1px;
            touch-action: none;
        }
        .cell {
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-family: 'Courier New', 'Consolas', monospace;
            background: var(--cell-bg);
            color: var(--cell-text);
            border: 1px solid var(--cell-border);
            border-radius: 2px;
            cursor: pointer;
            transition: background var(--transition), color var(--transition);
        }
        .cell.selecting {
            background: var(--cell-selecting);
        }
        .cell.selected {
            background: var(--cell-selected);
        }
        .cell.found {
            background: var(--cell-found);
            color: var(--cell-found-text);
        }
        .cell.start-marker {
            outline: 2px solid var(--accent);
            outline-offset: -2px;
            z-index: 1;
        }

        @keyframes flashRed {
            0%, 100% { background: var(--cell-error-bg); color: var(--cell-error-text); }
            50% { background: var(--cell-bg); color: var(--cell-text); }
        }
        .cell.error {
            animation: flashRed 0.35s ease-in-out 3;
        }

        @keyframes hintPulse {
            0%, 100% { background: #FFF176; color: #212121; }
            50% { background: #FFB300; color: #212121; }
        }
        .cell.hint {
            animation: hintPulse 0.7s ease-in-out 7;  /* 7 × 0.7s ≈ 5s */
        }

        /* ---------- Difficulty Bar ---------- */
        .difficulty-bar {
            display: flex;
            gap: 4px;
            width: 100%;
            margin-bottom: 8px;
        }
        .diff-btn {
            flex: 1;
            padding: 7px 4px;
            border: 2px solid var(--button-bg);
            border-radius: var(--radius);
            background: var(--surface-color);
            color: var(--text-color);
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            transition: all var(--transition);
            white-space: nowrap;
        }
        .diff-btn.active {
            background: var(--primary);
            color: var(--button-active-text);
            border-color: var(--primary);
        }
        .diff-btn:hover:not(.active) {
            border-color: var(--primary);
            background: var(--cell-selecting);
        }

        /* ---------- Controls ---------- */
        .controls-bar {
            width: 100%;
            display: flex;
            justify-content: center;
            gap: 10px;
            margin-top: 12px;
            flex-wrap: wrap;
        }
        .ctrl-btn {
            background: var(--button-bg);
            border: none;
            border-radius: 20px;
            padding: 8px 20px;
            font-size: 14px;
            font-weight: 600;
            color: var(--text-color);
            cursor: pointer;
            transition: background var(--transition), color var(--transition);
        }
        .ctrl-btn:hover { background: var(--button-hover); }
        .ctrl-btn:disabled,
        .ctrl-btn:disabled:hover {
            background: var(--button-bg);
            color: var(--text-secondary);
            opacity: 0.45;
            cursor: not-allowed;
            box-shadow: none;
        }
        .ctrl-btn.primary {
            background: var(--primary);
            color: white;
        }
        .ctrl-btn.primary:hover { background: var(--primary-hover); }

        /* ---------- Status ---------- */
        .status-row {
            width: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 16px;
            margin-bottom: 8px;
            font-size: 13px;
            color: var(--text-secondary);
        }
        .status-row span {
            font-weight: 600;
            color: var(--text-color);
        }

        /* ---------- Overlays ---------- */
        .overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.5);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 200;
            transition: opacity 0.3s;
        }
        .overlay.hidden { display: none; }
        .modal {
            background: var(--surface-color);
            border-radius: 16px;
            padding: 24px;
            max-width: 340px;
            width: 90%;
            text-align: center;
            box-shadow: var(--shadow);
        }
        .modal h2 {
            font-size: 20px;
            margin-bottom: 12px;
            color: var(--text-color);
        }
        .modal p {
            font-size: 14px;
            color: var(--text-secondary);
            margin-bottom: 16px;
        }
        .modal button {
            background: var(--primary);
            color: white;
            border: none;
            padding: 10px 28px;
            border-radius: 20px;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            transition: background var(--transition);
        }
        .modal button:hover { background: var(--primary-hover); }

        .celebration-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.6);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 300;
            transition: opacity 0.3s;
        }
        .celebration-overlay.hidden { display: none; }
        .celebration-card {
            background: var(--surface-color);
            border-radius: 16px;
            padding: 32px 24px;
            max-width: 340px;
            width: 90%;
            text-align: center;
            box-shadow: var(--shadow);
        }
        .celebration-card .trophy {
            font-size: 48px;
            margin-bottom: 12px;
        }
        .celebration-card .trophy img {
            width: 140px;
            height: 140px;
            border-radius: 18px;
            object-fit: cover;
            display: block;
            margin: 0 auto;
        }
        .celebration-card h2 {
            font-size: 22px;
            margin-bottom: 8px;
            color: var(--text-color);
        }
        .celebration-card .stats-row {
            display: flex;
            justify-content: center;
            gap: 24px;
            margin: 16px 0;
        }
        .celebration-card .stat .val {
            font-size: 24px;
            font-weight: 700;
            color: var(--primary);
        }
        .celebration-card .stat .lbl {
            font-size: 11px;
            color: var(--text-secondary);
        }
        .celebration-card button {
            background: var(--primary);
            color: white;
            border: none;
            padding: 10px 28px;
            border-radius: 20px;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            margin-top: 8px;
            transition: background var(--transition);
        }
        .celebration-card button:hover { background: var(--primary-hover); }

        .confetti-container {
            position: fixed;
            inset: 0;
            pointer-events: none;
            z-index: 301;
            overflow: hidden;
        }
        .confetti-piece {
            position: absolute;
            width: 10px;
            height: 10px;
            border-radius: 2px;
            animation: confettiFall 3s ease-out forwards;
        }
        @keyframes confettiFall {
            0% { transform: translateY(-100px) rotate(0deg); opacity: 1; }
            100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
        }

        /* ---------- Settings ---------- */
        .settings-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.5);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 200;
            transition: opacity 0.3s;
        }
        .settings-overlay.hidden { display: none; }
        .settings-modal {
            background: var(--surface-color);
            border-radius: 16px;
            padding: 24px;
            max-width: 340px;
            width: 90%;
            box-shadow: var(--shadow);
            max-height: 90vh;
            overflow-y: auto;
        }
        .settings-modal h2 {
            font-size: 20px;
            margin-bottom: 16px;
            color: var(--text-color);
        }
        .settings-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 0;
            border-bottom: 1px solid var(--cell-border);
        }
        .settings-row:last-of-type { border-bottom: none; }
        .settings-label {
            font-size: 14px;
            color: var(--text-color);
            font-weight: 500;
        }
        .toggle-switch {
            position: relative;
            width: 48px;
            height: 26px;
            display: inline-block;
        }
        .toggle-switch input { opacity: 0; width: 0; height: 0; }
        .toggle-slider {
            position: absolute;
            cursor: pointer;
            inset: 0;
            background: var(--button-bg);
            border-radius: 26px;
            transition: var(--transition);
        }
        .toggle-slider::before {
            content: '';
            position: absolute;
            height: 20px;
            width: 20px;
            left: 3px;
            bottom: 3px;
            background: white;
            border-radius: 50%;
            transition: var(--transition);
        }
        .toggle-switch input:checked + .toggle-slider {
            background: var(--primary);
        }
        .toggle-switch input:checked + .toggle-slider::before {
            transform: translateX(22px);
        }
        .settings-close-btn {
            display: block;
            margin: 16px auto 0;
            background: var(--button-bg);
            border: none;
            border-radius: 20px;
            padding: 8px 24px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            color: var(--text-color);
            transition: background var(--transition);
        }
        .settings-close-btn:hover { background: var(--button-hover); }
        .settings-branding {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            margin-top: 12px;
            padding-top: 12px;
            border-top: 1px solid var(--cell-border);
        }
        .settings-branding img { height: 20px; width: auto; }
        .settings-branding span {
            font-size: 11px;
            color: var(--text-secondary);
        }

        /* ---------- Category Selection ---------- */
        .category-grid {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 8px;
            margin: 12px 0;
        }
        .cat-btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 4px;
            padding: 10px 4px;
            border: 2px solid var(--button-bg);
            border-radius: var(--radius);
            background: var(--surface-color);
            cursor: pointer;
            transition: all var(--transition);
            font-size: 22px;
        }
        .cat-btn span {
            font-size: 10px;
            font-weight: 600;
            color: var(--text-color);
            text-align: center;
            line-height: 1.2;
        }
        .cat-btn:hover { border-color: var(--primary); background: var(--cell-selecting); }
        .cat-btn.random-btn { grid-column: span 2; font-size: 18px; }
        .cat-btn.random-btn span { font-size: 12px; }

        @media (max-width: 600px) {
            .category-grid { grid-template-columns: repeat(4, 1fr); }
            .cat-btn { font-size: 18px; padding: 8px 2px; }
            .cat-btn span { font-size: 9px; }
        }
        @media (max-width: 380px) {
            .category-grid { grid-template-columns: repeat(3, 1fr); }
        }

        /* ---------- Splash Screen ---------- */
        .splash-screen {
            position: fixed;
            inset: 0;
            background: var(--bg-color);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 500;
            transition: opacity 0.5s, visibility 0.5s;
        }
        .splash-screen.fade-out { opacity: 0; visibility: hidden; }
        .splash-screen.hidden { display: none; }
        .splash-logo {
            width: 180px;
            height: auto;
            margin-bottom: 12px;
        }
        .splash-logo + .splash-logo {
            width: 140px;
            margin-top: 8px;
        }
        .splash-title {
            font-size: 28px;
            font-weight: 800;
            color: var(--text-color);
            margin-bottom: 4px;
        }
        .splash-subtitle {
            font-size: 14px;
            color: var(--text-secondary);
            margin-bottom: 24px;
        }
        .splash-publisher {
            font-size: 13px;
            color: var(--primary);
            font-weight: 600;
        }
        .splash-copyright {
            font-size: 10px;
            color: var(--text-secondary);
            margin-top: 8px;
        }

        /* ---------- Responsive ---------- */
        @media (max-width: 600px) {
            .app-container { max-width: 100%; padding: 4px 6px 8px; }
            .game-layout {
                flex-direction: column;
                align-items: center;
            }
            .word-list-panel {
                flex: 0 0 auto;
                width: 100%;
                max-width: 500px;
                max-height: none;
            }
            .word-list {
                flex-direction: row;
                flex-wrap: wrap;
                gap: 2px 8px;
                justify-content: center;
            }
            .word-list li { font-size: 11px; letter-spacing: 0.5px; }
            .grid { gap: 0.5px; }
            header h1 { font-size: 17px; }
            .header-logo { height: 28px; }
            .splash-logo { width: 140px; }
            .diff-btn { font-size: 10px; padding: 5px 2px; }
        }

        @media (max-width: 380px) {
            .word-list li { font-size: 10px; }
            .diff-btn { font-size: 9px; }
        }
