        body { font-family: 'Inter', sans-serif; overflow: hidden; touch-action: none; }
        .tile {
            position: relative;
            transition: all 0.2s ease-in-out; -webkit-user-select: none; user-select: none;
            box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
        }

        #line-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }

        /* Bonus Tile Styles */
        .bonus-label {
            position: absolute;
            top: 2px;
            right: 4px;
            font-size: 0.65rem;
            font-weight: 900;
            color: white;
            padding: 0px 4px;
            border-radius: 4px;
        }
        .tile.bonus-DL { background-color: #3b82f6 !important; }
        .tile.bonus-TL { background-color: #ef4444 !important; }
        .tile.bonus-DW { background-color: #f59e0b !important; }
        .tile.bonus-Time { background-color: #22c55e !important; }

        /* Selected state — comes after bonus rules so it wins at equal specificity */
        .tile.selected {
            background: linear-gradient(45deg, #60a5fa, #3b82f6);
            color: white; transform: scale(1.08); border-color: #2563eb !important;
            box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.2), 0 4px 6px -4px rgb(0 0 0 / 0.1);
        }

        /* Animations */

@keyframes shake-sm {
    0%, 100% { transform: translate(-50%, -50%) translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-50%, -50%) translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translate(-50%, -50%) translateX(5px); }
}
.animate-shake {
    animation: shake-sm 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes fade-in-out {
    0%, 100% { opacity: 0; transform: translateY(10px); }
    10%, 90% { opacity: 1; transform: translateY(0); }
}
.game-message {
    animation: fade-in-out 2s ease-in-out forwards;
}

      /* --- START: Tutorial-specific CSS --- */
.tut-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    font-weight: 700;
    font-size: 1.125rem;
    color: #1e293b;
    background-color: white;
    border: 2px solid #cbd5e1;
    transition: all 0.3s ease-in-out;
    position: relative;
    -webkit-user-select: none;
    user-select: none;
}
.tut-tile sub {
    font-size: 0.6rem;
    font-weight: 600;
    margin-left: 2px;
    opacity: 0.8;
}
.tut-tile.highlight {
    transform: scale(1.1);
    background: linear-gradient(45deg, #60a5fa, #3b82f6);
    color: white;
    border-color: #2563eb;
}
.bonus-tl-tut { background-color: #ef4444 !important; color: white !important; }
.bonus-dw-tut { background-color: #f59e0b !important; color: white !important; }
.bonus-dl-tut { background-color: #3b82f6 !important; color: white !important; }
.bonus-time-tut { background-color: #22c55e !important; color: white !important; }
.tut-tile .bonus-label {
    position: absolute;
    top: 1px;
    right: 1px;
    font-size: 0.45rem;
    font-weight: 900;
    padding: 0px 2px;
    border-radius: 3px;
    color: white;
    background-color: rgba(0, 0, 0, 0.25);
}
@keyframes bounce-sm {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}
.scroll-prompt-arrow {
    animation: bounce-sm 1.5s infinite;
}
.line-segment {
    position: absolute;
    background-color: rgba(59, 130, 246, 0.7);
    height: 6px;
    border-radius: 3px;
    transform-origin: left center;
    opacity: 0;
    transition: opacity 0.1s ease-in-out;
    z-index: 5;
}
@keyframes fly-up-score {
    0% { transform: translate(-50%, 0) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50px) scale(0.6); opacity: 0; }
}
.flying-score-tut {
    position: absolute;
    left: 50%;
    top: 40%;
    background: linear-gradient(45deg, #f59e0b, #d97706);
    color: white;
    padding: 4px 12px;
    border-radius: 9999px;
    font-weight: bold;
    font-size: 1rem;
    z-index: 20;
    animation: fly-up-score 1.5s ease-out forwards;
}
/* --- END: Tutorial-specific CSS --- */

@keyframes pulse-text-glow {
  0%, 100% {
    transform: scale(1.05);
    text-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
  }
  50% {
    transform: scale(1.15);
    text-shadow: 0 0 14px rgba(239, 68, 68, 0.8);
  }
}

.timer-warning {
  animation: pulse-text-glow 1s infinite;
}

        @keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
        .animate-pulse { animation: pulse 1s infinite; }
        @keyframes fly-to-score {
            0% { transform: translate(0, 0) scale(1.2); opacity: 1; }
            100% { transform: translate(0, -180px) scale(0.5); opacity: 0; }
        }
        .flying-score {
            position: absolute; background: linear-gradient(45deg, #facc15, #f59e0b); color: white;
            padding: 8px 16px; border-radius: 9999px; font-weight: bold; font-size: 1.25rem;
            z-index: 100; animation: fly-to-score 1.5s ease-in-out forwards; pointer-events: none;
        }
        @keyframes pop-in {
            0% { transform: scale(0.8); opacity: 0; }
            100% { transform: scale(1); opacity: 1; }
        }
        .current-letter { animation: pop-in 0.2s ease-out; }
        .modal-enter { animation: pop-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
        .tab-button.active {
            background-color: #3b82f6;
            color: white;
        }

        /* Tutorial Animation */
        .tutorial-tile.highlight {
            background: linear-gradient(45deg, #60a5fa, #3b82f6);
            color: white;
            transform: scale(1.08);
            border-color: #2563eb;
        }
        @keyframes fly-up-tutorial {
            0% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
            100% { transform: translate(-50%, -200%) scale(0.5); opacity: 0; }
        }

        @keyframes bounce {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-8px); }
        }
        .animate-bounce-slow {
            animation: bounce 1.5s infinite;
        }

        .particle {
            position: fixed;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #facc15;
            z-index: 101;
            animation: particle-anim 1.2s ease-out forwards;
        }

        @keyframes particle-anim {
            to {
                transform: var(--transform-end);
                opacity: 0;
            }
        }

/* --- Dark Mode Toggle Switch --- */
.dark-toggle-track {
    width: 44px;
    height: 24px;
    background-color: #cbd5e1;
    border-radius: 9999px;
    position: relative;
    transition: background-color 0.2s;
    cursor: pointer;
    flex-shrink: 0;
}
.dark-toggle-track.active { background-color: #3b82f6; }
.dark-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 9999px;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.dark-toggle-track.active .dark-toggle-thumb { transform: translateX(20px); }

/* --- Dark Mode --- */
html.dark body { background-color: #0f172a; color: #e2e8f0; }
html.dark .bg-white { background-color: #1e293b !important; }
html.dark .bg-slate-100 { background-color: #1e293b !important; }
html.dark .bg-slate-200 { background-color: #334155 !important; }
html.dark .text-slate-800 { color: #e2e8f0 !important; }
html.dark .text-slate-700 { color: #cbd5e1 !important; }
html.dark .text-slate-600 { color: #94a3b8 !important; }
html.dark .text-slate-500 { color: #94a3b8 !important; }
html.dark .text-slate-400 { color: #64748b !important; }
html.dark .border-slate-200 { border-color: #334155 !important; }
html.dark .border-slate-300 { border-color: #475569 !important; }
html.dark .hover\:bg-slate-50:hover { background-color: #334155 !important; }
html.dark .hover\:bg-slate-100:hover { background-color: #334155 !important; }
html.dark .hover\:text-slate-800:hover { color: #e2e8f0 !important; }
html.dark .shadow-lg { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -4px rgba(0,0,0,0.4) !important; }
html.dark .shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0,0,0,0.6) !important; }
html.dark .shadow-md { box-shadow: 0 4px 6px -1px rgba(0,0,0,0.4) !important; }
html.dark .shadow-sm { box-shadow: 0 1px 2px rgba(0,0,0,0.4) !important; }
html.dark .tile { background-color: #334155 !important; border-color: #475569 !important; color: #e2e8f0 !important; }
html.dark .tut-tile { background-color: #334155; border-color: #475569; color: #e2e8f0; }
html.dark #tutorial-word-builder span { background-color: #334155 !important; color: #93c5fd !important; }
html.dark .shadow-inner { box-shadow: inset 0 2px 4px rgba(0,0,0,0.4) !important; }
html.dark .dark-toggle-track { background-color: #475569; }
html.dark .dark-toggle-track.active { background-color: #3b82f6; }
html.dark #daily-stats-box,
html.dark #accordion-trigger { border: 1px solid rgba(255,255,255,0.15) !important; }
html.dark .auth-input { background-color: #334155 !important; border-color: #475569 !important; color: #e2e8f0 !important; }
html.dark .auth-input::placeholder { color: #64748b !important; }

/* iOS Safari zooms the whole page in on focus of any input/select/textarea
   with a computed font-size under 16px, and doesn't reliably zoom back out
   after blur — forcing 16px here prevents that page-wide zoom. */
.auth-input { font-size: 16px !important; }

/* Additional text colors */
html.dark .text-slate-900 { color: #f1f5f9 !important; }
html.dark .text-black { color: #e2e8f0 !important; }

/* Bonus tiles keep their colors in dark mode (slightly darker hue) */
html.dark .tile.bonus-DL { background-color: #2563eb !important; }
html.dark .tile.bonus-TL { background-color: #dc2626 !important; }
html.dark .tile.bonus-DW { background-color: #d97706 !important; }
html.dark .tile.bonus-Time { background-color: #16a34a !important; }

/* bg-slate-50 rows */
html.dark .bg-slate-50 { background-color: #293548 !important; }
html.dark .bg-blue-100 { background-color: #1e3a5f !important; }

/* Scoreboard border during gameplay */
html.dark #scoreboard { border: 1px solid #475569; }

/* Home screen stat boxes (Day Streak / Your High / Leaderboard) */
html.dark #modal-content .bg-white.rounded-lg.shadow-sm { border: 1px solid #475569; }

/* Border-t / border-b in dark mode */
html.dark .border-t { border-top-color: #334155 !important; }
html.dark .border-b { border-bottom-color: #334155 !important; }

/* Leaderboard standings: dark pill + light outline + white text */
html.dark #leaderboard-list-simple li {
    background-color: #334155;
    border: 1px solid #475569;
    border-radius: 0.5rem;
    margin-bottom: 2px;
    color: #e2e8f0;
}
html.dark #leaderboard-list-simple li.bg-blue-100 {
    background-color: #1e3a5f !important;
    border-color: #3b82f6 !important;
}

/* Stats list items: same treatment */
html.dark #profile-tab-content ol li {
    background-color: #334155 !important;
    border: 1px solid #475569;
    border-radius: 0.375rem;
    color: #e2e8f0;
    margin-bottom: 2px;
}

/* Profile modal: input fields (name + password) */
html.dark #stats-modal input[type="text"],
html.dark #stats-modal input[type="password"] {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
html.dark #stats-modal input[type="text"]::placeholder,
html.dark #stats-modal input[type="password"]::placeholder { color: #64748b; }

/* Profile modal: Save / Update Password buttons — darker hue of light-mode color */
html.dark #stats-modal .bg-slate-800 {
    background-color: #0f172a !important;
    border: 1px solid #334155 !important;
}
html.dark #stats-modal .hover\:bg-slate-700:hover { background-color: #1e293b !important; }

/* Stats tab: Games / Avg Score / Avg Length container outline.
   Tighter padding/gap than light mode claws back the couple of px that
   bold white-on-dark text needs to avoid wrapping (dark text on a light
   background renders slightly narrower than light text on dark). */
html.dark #profile-tab-content .bg-slate-100.rounded-lg {
    border: 1px solid #475569;
    padding: 0.5rem;
    gap: 0.25rem;
}

html.dark #mode-dropdown-inner {
    background: #1e293b !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

/* Home screen Daily Puzzle button: brighter blue for contrast on the dark card */
html.dark #mode-daily-btn { color: #60a5fa !important; border-color: #60a5fa !important; }
html.dark #mode-daily-btn:hover { background-color: #1e3a5f !important; }

/* Challenge results Rematch button. Plain CSS on the id rather than Tailwind
   utilities: dist/style.css is gitignored and can be deployed stale, which
   left this button white-on-white in prod (bg-indigo-400 missing from the
   deployed build). */
#challenge-rematch-btn { background-color: #22c55e; }
#challenge-rematch-btn:hover { background-color: #16a34a; }
