
        /* ===== 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;
            --cell-bg: #FFFFFF;
            --cell-text: #212121;
            --cell-border: #E0E0E0;
            --primary: #009688;
            --primary-hover: #00796B;
            --accent: #FFB300;
            --button-bg: #E0E0E0;
            --button-hover: #BDBDBD;
            --button-active: #009688;
            --button-active-text: #FFFFFF;
            --shadow: 0 2px 8px rgba(0,0,0,0.1);
            --radius: 8px;
            --transition: 0.2s ease;
            --match-bg: #C8E6C9;
            --match-border: #4CAF50;
            --match-text: #2E7D32;
            --error-bg: #FFEBEE;
            --error-border: #E57373;
            --selected-border: #009688;
        }

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

        *, *::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: 640px;
            flex: 1;
            padding: 8px 12px 12px;
            display: flex;
            flex-direction: column;
            align-items: center;
            position: relative;
        }

        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-emoji { font-size: 30px; line-height: 1; 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); }

        /* ---------- 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); }
        .diff-btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        /* ---------- Status Row ---------- */
        .status-row {
            width: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 12px;
            margin-bottom: 6px;
            font-size: 13px;
            color: var(--text-secondary);
            flex-wrap: wrap;
        }
        .status-item { font-weight: 600; color: var(--text-color); }
        .status-chip {
            background: var(--surface-color);
            border: 2px solid var(--button-bg);
            border-radius: 999px;
            padding: 4px 14px;
            font-size: 13px;
            font-weight: 600;
            color: var(--text-color);
            cursor: pointer;
            transition: border-color var(--transition);
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }
        .status-chip:hover { border-color: var(--primary); }

        .hint {
            font-size: 12px;
            color: var(--text-secondary);
            margin-bottom: 8px;
            text-align: center;
        }

        /* ---------- Match Layout ---------- */
        .match-layout {
            display: flex;
            gap: 10px;
            width: 100%;
            align-items: flex-start;
            justify-content: center;
        }
        .match-panel {
            flex: 1 1 0;
            min-width: 0;
            display: grid;
            gap: 6px;
            background: var(--surface-color);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            padding: 8px;
            align-content: start;
        }
        .match-card {
            width: 100%;
            perspective: 700px;
            background: none;
            border: none;
            padding: 0;
            cursor: pointer;
            aspect-ratio: 1 / 1;
            -webkit-tap-highlight-color: transparent;
        }
        .card-inner {
            position: relative;
            width: 100%;
            height: 100%;
            transform-style: preserve-3d;
            transition: transform 0.35s ease;
        }
        .match-card.flipped .card-inner,
        .match-card.matched .card-inner { transform: rotateY(180deg); }
        .card-back, .card-face {
            position: absolute;
            inset: 0;
            backface-visibility: hidden;
            -webkit-backface-visibility: hidden;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .card-back {
            background-image: url(playingcard_light.jpg);
            background-size: cover;
            background-position: center;
            border: 1px solid var(--cell-border);
        }
        html.dark .card-back {
            background-image: url(playingcard_dark.jpg);
        }
        .card-face {
            background: var(--cell-bg);
            border: 2px solid var(--cell-border);
            transform: rotateY(180deg);
            font-weight: 700;
            font-size: 15px;
            letter-spacing: 0.5px;
            text-transform: uppercase;
            color: var(--cell-text);
            padding: 4px;
            text-align: center;
            overflow-wrap: anywhere;
        }
        .card-face img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 6px;
            display: block;
        }
        .card-face.small-text { font-size: 11px; }
        .match-card.matched .card-face {
            border-color: var(--match-border);
            background: var(--match-bg);
            color: var(--match-text);
            box-shadow: 0 0 0 2px var(--match-border);
        }
        .match-card.matched { animation: matchPop 0.35s ease; }
        @keyframes matchPop {
            0% { transform: scale(1); }
            50% { transform: scale(1.08); }
            100% { transform: scale(1); }
        }
        .match-card.wrong .card-inner { animation: shakeX 0.4s ease; }
        @keyframes shakeX {
            0%, 100% { transform: rotateY(180deg) translateX(0); }
            25% { transform: rotateY(180deg) translateX(-4px); }
            75% { transform: rotateY(180deg) translateX(4px); }
        }
        .match-card.deny .card-inner { animation: denyShake 0.35s ease; }
        @keyframes denyShake {
            0%, 100% { transform: translateX(0); }
            25% { transform: translateX(-4px); }
            75% { transform: translateX(4px); }
        }

        /* ---------- 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.primary { background: var(--primary); color: white; }
        .ctrl-btn.primary:hover { background: var(--primary-hover); }

        /* ---------- Overlays ---------- */
        .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); }

        /* ---------- 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(--button-bg); }
        .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; }
            .match-layout { flex-direction: column; }
            .match-card { min-width: 0; }
        }
        @media (max-width: 380px) {
            .category-grid { grid-template-columns: repeat(3, 1fr); }
            .card-face { font-size: 11px; }
        }

        /* ---------- 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;
            animation: splashPulse 2s ease-in-out infinite;
        }
        @keyframes splashPulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.05); }
        }
        @media (max-width: 600px) { .splash-logo { width: 140px; } }
        .splash-emoji { font-size: 96px; margin-bottom: 12px; }
        .splash-title {
            font-size: 28px;
            font-weight: 800;
            color: var(--text-color);
            margin-bottom: 4px;
        }
        .splash-publisher {
            font-size: 13px;
            color: var(--primary);
            font-weight: 600;
        }
        .splash-copyright {
            font-size: 10px;
            color: var(--text-secondary);
            margin-top: 8px;
        }

        /* ===== Card Zoom Overlay ===== */
        .zoom-overlay {
            position: fixed;
            inset: 0;
            z-index: 600;
            background: rgba(0, 0, 0, 0.65);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            animation: zoomFadeIn 0.15s ease;
            -webkit-tap-highlight-color: transparent;
        }
        .zoom-overlay.hidden { display: none; }
        .zoom-card {
            max-width: 92vw;
            max-height: 92vh;
            padding: 20px;
            background: var(--surface-color);
            border-radius: 16px;
            box-shadow: var(--shadow);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 12px;
            overflow: hidden;
        }
        .zoom-card img {
            max-width: 80vw;
            max-height: 70vh;
            border-radius: 12px;
            display: block;
        }
        .zoom-word {
            font-size: 24px;
            font-weight: 700;
            color: var(--text-color);
            text-align: center;
            word-break: break-word;
            line-height: 1.2;
            padding: 6px 18px;
            background: var(--cell-bg);
            border: 2px solid var(--cell-border);
            border-radius: 999px;
        }
        .zoom-card.zoom-text {
            font-size: clamp(44px, 13vw, 160px);
            font-weight: 700;
            text-align: center;
            color: var(--text-color);
            word-break: break-word;
            line-height: 1.15;
        }
        .match-card.flipped { cursor: zoom-in; }
        @keyframes zoomFadeIn { from { opacity: 0; } to { opacity: 1; } }

        /* Auto pop: spin the selected card up to full size and back down */
        .zoom-overlay { perspective: 900px; }
        .zoom-card.zoom-pop {
            animation: zoomPopIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
        }
        .zoom-card.zoom-pop-out {
            animation: zoomPopOut 0.5s ease-in forwards;
        }
        @keyframes zoomPopIn {
            0%   { transform: scale(0.25) rotateY(180deg); opacity: 0.3; }
            100% { transform: scale(1) rotateY(360deg); opacity: 1; }
        }
        @keyframes zoomPopOut {
            from { transform: scale(1) rotateY(360deg); opacity: 1; }
            to   { transform: scale(0.25) rotateY(540deg); opacity: 0; }
        }
