/* Nunito, self-hosted. Until 2026-09 index.html pulled this from
   fonts.googleapis.com + fonts.gstatic.com: two extra origins on the render
   path, nothing offline, and only weights 400–800 requested while this file
   uses 900/950/1000 in ~190 places — the browser was faking those from 800.
   The files are Google's own Nunito v32 woff2 (fontRevision 3.602), which is a
   VARIABLE font (wght 200–1000): one file per subset covers every weight, so
   950 and 1000 are real instances, not synthesized. unicode-range values are
   the ones Google serves. Vietnamese + Latin only — the app writes nothing
   else. Cached by sw.js (ASSETS), copied by scripts/deploy.sh, guarded by
   tests/gen-app-integrity.test.js. */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url(../fonts/nunito-var-vietnamese.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url(../fonts/nunito-var-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

        :root {
            --bg-primary: #f0faf4;
            --bg-secondary: #e2f5ea;
            --bg-card: rgba(255, 255, 255, 0.72);
            --text-primary: #1a2e1a;
            --text-secondary: #5a7a5e;
            --border-color: rgba(56, 176, 120, 0.25);
            --accent-green: #2ecc71;
            --accent-green-dark: #1fa85a;
            --accent-blue: #26C6DA;
            --accent-orange: #FF7043;
            --accent-red: #ef5350;
            --accent-purple: #9b59b6;
            --accent-pink: #ec407a;
            --accent-yellow: #FFD54F;
            --success: #2ecc71;
            --error: #ef5350;
            --selected: #e8faf0;
            --selected-border: #2ecc71;
            --matched: #c8f7dc;
            --matched-border: #2ecc71;
            --wrong: #ffcdd2;
            --wrong-border: #ef5350;
            --border-radius: 20px;
            --border-radius-lg: 28px;
            --glass-bg: rgba(255, 255, 255, 0.55);
            --glass-border: rgba(255, 255, 255, 0.45);
            --glass-shadow: 0 8px 32px rgba(31, 80, 50, 0.12);
            --safe-area-bottom: env(safe-area-inset-bottom, 0px);
            --safe-area-top: env(safe-area-inset-top, 0px);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
        }

        /* Removing user-scalable=no from index.html re-arms double-tap-to-zoom,
           and with it the ~300ms wait before a tap registers. This takes the
           wait off the CONTROLS without taking pinch-zoom off the page — a
           child with low vision must still be able to enlarge the 11.5px nav
           labels and the Toán figures, WCAG 1.4.4. Element selectors only, so
           the canvases and pan surfaces that set their own touch-action — the
           math board overlay, the drawing canvas, the raid builder — still win
           on specificity. */
        button, [role="button"], a, label, summary, select,
        input[type="checkbox"], input[type="radio"] {
            touch-action: manipulation;
        }

        html, body {
            /* 100dvh accounts for the dynamic viewport (mobile URL bar
               collapse/expand) so the bottom nav truly sits at the
               bottom — 100% / 100vh leave a gap on iOS Safari.
               The 100vh line MUST stay FIRST: a browser without dvh
               (iOS Safari < 15.4 — iPad Air 1, iPad mini 2/3) throws the
               dvh declaration away and keeps this one. Without a first
               height, html/body fall back to height:auto, the .app shell's
               height:100% resolves to auto, and .screens-container — which
               holds nothing but position:absolute .screen children —
               collapses to 0px: the child sees the bottom nav over a blank
               gradient and nothing else. min-height cannot save it: a
               percentage height only resolves against a real height. */
            height: 100vh;
            height: 100dvh;
            min-height: 100vh;
            overflow: hidden;
        }

        body {
            font-family: 'Nunito', sans-serif;
            background: linear-gradient(160deg, #e8faf0 0%, #f0e6ff 35%, #e2f5ea 65%, #f5eaff 100%);
            color: var(--text-primary);
            line-height: 1.5;
            overscroll-behavior: none;
        }

        .app {
            height: 100%;
            display: flex;
            flex-direction: column;
            padding-top: var(--safe-area-top);
        }

        .screens-container {
            /* Take up all remaining space ABOVE the bottom-nav. The nav
               is a normal flex child below us now (no more fragile
               margin-bottom hack that hardcoded a 64px reservation
               which didn't always match the real nav height). */
            flex: 1;
            min-height: 0; /* allow inner scrolling within flex parent */
            overflow: hidden;
            position: relative;
        }

        .screen {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            overflow-y: auto;
            overflow-x: hidden;
            opacity: 0;
            transform: translateX(20px);
            pointer-events: none;
            transition: opacity 0.3s ease, transform 0.3s ease;
            z-index: 0;
            overflow-anchor: none;
        }

        .screen.active {
            opacity: 1;
            transform: none;
            pointer-events: auto;
            z-index: 1;
        }

        @media (prefers-reduced-motion: reduce) {
            .screen { transition: none; }
            .summer-sun, .pet-cheer, .pet-cheer-dog { animation: none !important; }
        }

        /* ==================== ONBOARDING SCREEN ==================== */
        .onboarding-screen {
            display: flex;
            flex-direction: column;
            padding: 40px 24px;
            padding-top: calc(60px + var(--safe-area-top));
        }

        .onboarding-logo {
            text-align: center;
            margin-bottom: 40px;
        }

        .onboarding-logo .logo-icon {
            font-size: 80px;
            margin-bottom: 16px;
        }

        .onboarding-logo h1 {
            font-size: 36px;
            font-weight: 800;
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .onboarding-logo p {
            color: var(--text-secondary);
            font-size: 16px;
            margin-top: 8px;
        }

        .onboarding-section {
            margin-bottom: 32px;
        }

        .onboarding-section h2 {
            font-size: 18px;
            font-weight: 700;
            margin-bottom: 16px;
            color: var(--text-primary);
        }

        .user-list {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        /* Shown in place of the create form once the device is full. Reads as
           information, not as an error — the child did nothing wrong. */
        .device-full-card {
            text-align: center; padding: 20px 18px; border-radius: 18px;
            background: rgba(255,255,255,.7); border: 1.5px dashed rgba(100,116,139,.45);
        }
        .device-full-icon { font-size: 30px; line-height: 1; margin-bottom: 8px; }
        .device-full-title { font-size: 15px; font-weight: 800; color: #334155; }
        .device-full-sub { font-size: 12.5px; color: #475569; margin-top: 6px; line-height: 1.5; }

        .user-card {
            display: flex;
            align-items: center;
            gap: 16px;
            padding: 16px;
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-radius: var(--border-radius);
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .user-open-btn {
            flex: 1 1 auto;
            min-width: 0;
            display: flex;
            align-items: center;
            gap: 16px;
            padding: 0;
            border: 0;
            background: transparent;
            color: inherit;
            text-align: left;
            font: inherit;
            cursor: pointer;
        }

        .user-info span { display: block; }

        .user-open-btn:focus-visible,
        .delete-user-btn:focus-visible,
        .avatar-option:focus-visible,
        .home-user-avatar:focus-visible {
            outline: 3px solid #2563eb;
            outline-offset: 3px;
        }

        .user-card:active {
            transform: scale(0.98);
        }

        .user-card:hover {
            border-color: var(--accent-green);
        }

        .user-avatar {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--accent-green), var(--accent-blue));
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            color: white;
            font-weight: 800;
        }

        .user-info {
            flex: 1;
        }

        .user-name {
            font-weight: 700;
            font-size: 16px;
            margin-bottom: 2px;
        }

        .user-stats {
            font-size: 13px;
            color: var(--text-secondary);
        }

        .user-arrow {
            color: var(--text-secondary);
            font-size: 20px;
        }

        .divider {
            display: flex;
            align-items: center;
            gap: 16px;
            margin: 24px 0;
        }

        .divider-line {
            flex: 1;
            height: 1px;
            background: var(--border-color);
        }

        .divider-text {
            color: var(--text-secondary);
            font-size: 14px;
            font-weight: 600;
        }

        .create-user-form {
            display: flex;
            flex-direction: column;
            gap: 16px;
        }

        .input-group {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .input-label {
            font-size: 14px;
            font-weight: 600;
            color: var(--text-secondary);
        }

        .input-field {
            padding: 16px;
            border: 2px solid var(--border-color);
            border-radius: var(--border-radius);
            font-size: 16px;
            font-family: inherit;
            font-weight: 600;
            transition: border-color 0.2s ease;
        }

        .input-field:focus {
            outline: none;
            border-color: var(--accent-green);
        }

        .input-field::placeholder {
            color: var(--text-secondary);
            font-weight: 400;
        }

        .avatar-picker {
            display: flex;
            gap: 12px;
            flex-wrap: wrap;
        }

        .avatar-option {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            border: 2px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            cursor: pointer;
            transition: all 0.2s ease;
            background: var(--bg-secondary);
        }

        .avatar-option.selected {
            border-color: var(--accent-green);
            background: var(--matched);
            transform: scale(1.1);
        }

        .avatar-option:active {
            transform: scale(0.95);
        }

        /* Passcode Inputs */
        .passcode-inputs {
            display: flex;
            gap: 12px;
            justify-content: center;
        }

        .passcode-digit {
            width: 55px;
            height: 65px;
            border: 3px solid var(--border-color);
            border-radius: 16px;
            font-size: 28px;
            font-weight: 800;
            text-align: center;
            font-family: inherit;
            background: var(--bg-secondary);
            color: var(--text-primary);
            outline: none;
            transition: all 0.2s ease;
        }

        .passcode-digit:focus {
            border-color: var(--accent-green);
            background: white;
            box-shadow: 0 0 0 3px rgba(102, 187, 106, 0.2);
        }

        .passcode-digit.filled {
            background: var(--matched);
            border-color: var(--accent-green);
        }

        .passcode-digit.error {
            border-color: var(--error);
            background: var(--wrong);
            animation: shake 0.4s ease;
        }

        .passcode-digit-display {
            width: 55px;
            height: 65px;
            border: 3px solid var(--border-color);
            border-radius: 16px;
            font-size: 28px;
            font-weight: 800;
            text-align: center;
            line-height: 59px;
            font-family: inherit;
            background: var(--bg-secondary);
            color: var(--text-primary);
            transition: all 0.2s ease;
            cursor: pointer;
        }

        .passcode-digit-display.active {
            border-color: var(--accent-green);
            background: white;
            box-shadow: 0 0 0 3px rgba(102, 187, 106, 0.2);
        }

        .passcode-digit-display.filled {
            background: var(--matched);
            border-color: var(--accent-green);
        }

        .passcode-digit-display.error {
            border-color: var(--error);
            background: var(--wrong);
            animation: shake 0.4s ease;
        }

        .passcode-error {
            color: var(--error);
            font-size: 13px;
            font-weight: 600;
            text-align: center;
            margin-top: 8px;
            min-height: 20px;
        }

        /* Passcode Modal */
        .passcode-modal {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.6);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 10000;
            padding: 20px;
            visibility: hidden;
            opacity: 0;
            pointer-events: none;
        }

        .passcode-modal.active {
            visibility: visible;
            opacity: 1;
            pointer-events: auto;
        }

        .passcode-modal-content {
            background: white;
            border-radius: var(--border-radius-lg);
            padding: 32px 24px;
            width: 100%;
            max-width: 340px;
            text-align: center;
        }

        .passcode-modal-avatar {
            font-size: 64px;
            margin-bottom: 12px;
        }

        .passcode-modal-name {
            font-size: 20px;
            font-weight: 700;
            margin-bottom: 24px;
            color: var(--text-primary);
        }

        .passcode-modal-label {
            font-size: 14px;
            color: var(--text-secondary);
            margin-bottom: 16px;
            font-weight: 600;
        }

        .passcode-modal-inputs {
            margin-bottom: 16px;
        }

        .passcode-modal-error {
            color: var(--error);
            font-size: 13px;
            font-weight: 600;
            margin-bottom: 16px;
            min-height: 20px;
        }

        .passcode-modal-buttons {
            display: flex;
            gap: 12px;
            margin-top: 20px;
        }

        .passcode-modal-buttons button {
            flex: 1;
            padding: 14px;
            border-radius: 50px;
            font-size: 15px;
            font-weight: 700;
            font-family: inherit;
            cursor: pointer;
        }

        .passcode-cancel-btn {
            background: var(--bg-secondary);
            border: 2px solid var(--border-color);
            color: var(--text-primary);
        }

        .passcode-submit-btn {
            background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
            border: none;
            color: white;
        }

        .primary-btn {
            padding: 18px 36px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 50px;
            font-size: 18px;
            font-weight: 800;
            font-family: inherit;
            cursor: pointer;
            text-transform: uppercase;
            letter-spacing: 1px;
            box-shadow: 0 6px 0 #4a3580, 0 8px 20px rgba(118, 75, 162, 0.3);
            transition: all 0.2s ease;
        }

        .primary-btn:active {
            transform: translateY(4px);
            box-shadow: 0 2px 0 #4a3580;
        }

        .primary-btn:disabled {
            background: var(--border-color);
            box-shadow: 0 4px 0 #ccc;
            cursor: not-allowed;
        }

        .secondary-btn {
            padding: 16px 32px;
            background: var(--bg-secondary);
            color: var(--text-primary);
            border: 2px solid var(--border-color);
            border-radius: var(--border-radius);
            font-size: 16px;
            font-weight: 700;
            font-family: inherit;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .secondary-btn:active {
            transform: scale(0.98);
        }

        .delete-user-btn {
            padding: 8px;
            background: none;
            border: none;
            color: var(--error);
            font-size: 18px;
            cursor: pointer;
            opacity: 0.6;
            transition: opacity 0.2s;
        }

        .delete-user-btn:hover {
            opacity: 1;
        }

        /* ==================== BOTTOM NAV ==================== */
        /* Natural flex child — sits directly under .screens-container.
           No `position: fixed` + no `bottom: 0` so the nav can't get
           a gap below itself on viewports where the old `height: 100%`
           fell short of the actual viewport height. */
        .bottom-nav {
            display: flex;
            flex-shrink: 0;
            background: rgba(255, 255, 255, 0.88);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border-top: 1px solid rgba(124, 58, 237, 0.12);
            padding-bottom: var(--safe-area-bottom);
            box-shadow: 0 -4px 24px rgba(31, 80, 50, 0.1);
            border-radius: 24px 24px 0 0;
            z-index: 300;
            min-height: 68px;
        }

        .nav-item {
            flex: 1;
            min-width: 0;
            min-height: 60px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 3px;
            padding: 7px 2px 5px;
            background: none;
            border: none;
            color: #64748b;
            font-size: 11.5px;
            font-weight: 800;
            transition: color 0.2s ease, background-color 0.2s ease;
            cursor: pointer;
            font-family: inherit;
            -webkit-tap-highlight-color: transparent;
        }

        .nav-item.active {
            color: #6d28d9;
        }

        .nav-item .icon {
            width: 34px;
            height: 30px;
            border-radius: 12px;
            display: grid;
            place-items: center;
            transition: color 0.2s ease, background-color 0.2s ease;
        }

        .nav-item .icon svg {
            width: 23px;
            height: 23px;
            fill: none;
            stroke: currentColor;
            stroke-width: 1.9;
            stroke-linecap: round;
            stroke-linejoin: round;
        }
        .nav-item.active .icon {
            background: rgba(124, 58, 237, 0.13);
        }
        .nav-item.nav-arena .icon {
            color: #fff;
            background: linear-gradient(145deg, #fb923c, #ea580c);
            box-shadow: 0 3px 9px rgba(234, 88, 12, 0.28);
        }
        .nav-item.nav-arena.active { color: #c2410c; }
        .nav-item.nav-arena.active .icon {
            background: linear-gradient(145deg, #f97316, #c2410c);
            box-shadow: 0 0 0 3px rgba(249,115,22,.16), 0 4px 10px rgba(194,65,12,.3);
        }
        .nav-item span:not(.icon) { white-space: nowrap; }
        .nav-item:focus-visible {
            outline: 3px solid #2563eb;
            outline-offset: -4px;
            border-radius: 16px;
        }

        /* Five-destination information architecture. The hub cards keep the
           old modules one tap away without squeezing eight labels into 320px. */
        .nav-hub-screen {
            overflow-y: auto;
            padding: 22px 16px 96px;
            background:
                radial-gradient(circle at 90% 4%, rgba(167,139,250,.2), transparent 31%),
                linear-gradient(180deg, #f8fafc 0%, #eefbf4 100%);
        }
        .nav-hub-header {
            max-width: 640px;
            margin: 0 auto 18px;
            padding: 22px 20px;
            border-radius: 24px;
            color: #fff;
            background: linear-gradient(135deg, #6d28d9, #8b5cf6 58%, #0ea5e9);
            box-shadow: 0 14px 34px rgba(109,40,217,.22);
        }
        .nav-hub-header.math {
            background: linear-gradient(135deg, #075985, #0284c7 54%, #22c55e);
            box-shadow: 0 14px 34px rgba(2,132,199,.22);
        }
        .nav-hub-kicker {
            display: block;
            margin-bottom: 7px;
            font-size: 10px;
            line-height: 1.2;
            letter-spacing: .13em;
            font-weight: 900;
            color: rgba(255,255,255,.8);
        }
        .nav-hub-header h1 {
            margin: 0;
            font-size: clamp(24px, 7vw, 34px);
            line-height: 1.08;
            color: #fff;
        }
        .nav-hub-header p {
            margin: 9px 0 0;
            color: rgba(255,255,255,.9);
            font-size: 13px;
            line-height: 1.45;
        }
        .nav-hub-grid {
            max-width: 640px;
            margin: 0 auto;
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 12px;
        }
        .nav-hub-card {
            position: relative;
            min-width: 0;
            min-height: 164px;
            padding: 16px;
            border: 1px solid rgba(148,163,184,.23);
            border-radius: 21px;
            background: rgba(255,255,255,.9);
            box-shadow: 0 7px 20px rgba(15,23,42,.075);
            color: #0f172a;
            text-align: left;
            font-family: inherit;
            cursor: pointer;
            display: flex;
            flex-direction: column;
            align-items: start;
            transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
        }
        .nav-hub-card:hover {
            border-color: rgba(109,40,217,.35);
            box-shadow: 0 9px 24px rgba(15,23,42,.11);
        }
        .nav-hub-card:active { background: #f8fafc; }
        .nav-hub-card:focus-visible,
        .nav-hub-feature button:focus-visible {
            outline: 3px solid #2563eb;
            outline-offset: 3px;
        }
        .nav-hub-icon {
            width: 48px;
            height: 48px;
            flex: 0 0 48px;
            margin-bottom: 12px;
            border-radius: 15px;
            display: grid;
            place-items: center;
            color: #6d28d9;
            background: #ede9fe;
        }
        .nav-hub-icon svg {
            width: 26px;
            height: 26px;
            fill: none;
            stroke: currentColor;
            stroke-width: 1.8;
            stroke-linecap: round;
            stroke-linejoin: round;
        }
        .nav-hub-card.grammar .nav-hub-icon { color: #0369a1; background: #e0f2fe; }
        .nav-hub-card.grade4 .nav-hub-icon { color: #15803d; background: #dcfce7; }
        .nav-hub-card.verbs .nav-hub-icon { color: #b45309; background: #fef3c7; }
        .nav-hub-card.phrases .nav-hub-icon { color: #047857; background: #d1fae5; }
        .nav-hub-card.wordform .nav-hub-icon { color: #c2410c; background: #ffedd5; }
        .nav-hub-card.rewrite .nav-hub-icon { color: #be185d; background: #fce7f3; }
        .nav-hub-copy {
            width: 100%;
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 5px;
        }
        .nav-hub-copy strong {
            font-size: 16px;
            line-height: 1.2;
            color: #0f172a;
        }
        .nav-hub-copy small {
            font-size: 12px;
            line-height: 1.4;
            color: #475569;
        }
        .nav-hub-arrow {
            position: absolute;
            top: 18px;
            right: 16px;
            color: #64748b;
            font-size: 25px;
            line-height: 1;
        }
        .nav-hub-feature {
            max-width: 640px;
            margin: 0 auto 12px;
            padding: 17px;
            border-radius: 21px;
            color: #ecfdf5;
            background: linear-gradient(135deg, #064e3b, #047857);
            box-shadow: 0 8px 22px rgba(6,78,59,.18);
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 14px;
        }
        .nav-hub-feature div { min-width: 0; }
        .nav-hub-feature-label {
            display: block;
            margin-bottom: 3px;
            color: #a7f3d0;
            font-size: 10.5px;
            font-weight: 900;
            letter-spacing: .12em;
        }
        .nav-hub-feature strong { display: block; font-size: 17px; }
        .nav-hub-feature small { display: block; margin-top: 4px; color: #d1fae5; font-size: 12.5px; }
        .nav-hub-feature button {
            flex: 0 0 auto;
            min-height: 44px;
            padding: 0 15px;
            border: 0;
            border-radius: 14px;
            color: #064e3b;
            background: #fff;
            font-family: inherit;
            font-size: 12px;
            font-weight: 900;
            cursor: pointer;
        }
                                                                                        @media (max-width: 430px) {
            .nav-hub-card {
                min-height: 150px;
                padding: 14px 12px;
            }
            .nav-hub-icon { width: 42px; height: 42px; border-radius: 13px; }
            .nav-hub-copy strong { font-size: 14px; }
            .nav-hub-copy small { font-size: 11px; }
                                            }
        @media (max-width: 350px) {
            .nav-hub-grid { grid-template-columns: 1fr; }
            .nav-hub-card { min-height: 126px; }
            .nav-item { font-size: 10px; }
        }
        @media (prefers-reduced-motion: reduce) {
            .nav-item, .nav-item .icon, .nav-hub-card { transition: none; }
        }

        /* Word form tab — highlight the (BASE) root shown in a question */
        .wf-base {
            font-weight: 800; color: #c2560a;
            background: #fff0e6; padding: 0 6px; border-radius: 6px;
            white-space: nowrap;
        }
        .wordform-screen { padding: 16px; padding-bottom: 90px; }

        /* Word form — typed-answer questions */
        .wf-text-wrap { display: flex; gap: 8px; margin-top: 4px; }
        .wf-text-input {
            flex: 1 1 auto; padding: 13px 14px; font-size: 16px; font-family: inherit;
            border: 2px solid var(--glass-border); border-radius: 12px;
            background: var(--glass-bg, #fff); color: var(--text-primary); outline: none;
        }
        .wf-text-input:focus { border-color: #c2560a; }
        .wf-text-submit {
            flex: 0 0 auto; padding: 0 18px; font-size: 15px; font-weight: 700; font-family: inherit;
            border: none; border-radius: 12px; background: #c2560a; color: #fff; cursor: pointer;
        }
        .wf-text-answer {
            margin-top: 4px; padding: 12px 14px; border-radius: 12px; font-size: 16px;
            border: 2px solid; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline;
        }
        .wf-text-answer.correct { border-color: #58cc02; background: rgba(88,204,2,0.10); }
        .wf-text-answer.wrong { border-color: #ff4b4b; background: rgba(255,75,75,0.08); }
        .wf-text-answer-label { font-size: 12px; font-weight: 700; color: var(--text-secondary); }
        .wf-text-answer-value { font-weight: 800; color: var(--text-primary); }

        /* Word form — the understanding check that follows every question:
           two questions on one card, the second unlocked by the first. */
        /* Both selectors: .grammar-question-tag is defined later in this file and
           capitalises every word, which would render the answer as "Punishment". */
        .grammar-question-tag.wf-follow-tag {
            background: linear-gradient(135deg, #2f80ed, #1d4ed8);
            text-transform: none;
        }
        .wf-follow-recap {
            background: rgba(47,128,237,0.07); border-left: 3px solid #2f80ed;
            border-radius: 10px; padding: 10px 12px; margin-bottom: 16px;
        }
        .wf-recap-label {
            font-size: 11px; font-weight: 800; letter-spacing: .3px;
            color: var(--text-secondary); text-transform: uppercase; margin-bottom: 4px;
        }
        .wf-recap-q { font-size: 15px; line-height: 1.5; color: var(--text-primary); }
        .wf-recap-answer { color: #1d4ed8; font-weight: 800; }
        .wf-recap-you { font-size: 13.5px; font-weight: 600; margin-top: 6px; }
        .wf-recap-you.ok { color: #3d8b00; }
        .wf-recap-you.bad { color: #d63a3a; }
        .wf-recap-you s { opacity: .75; }
        .wf-follow-block + .wf-follow-block,
        .wf-follow-block + .wf-follow-locked { margin-top: 18px; padding-top: 16px; border-top: 2px dashed var(--glass-border); }
        .wf-follow-step {
            display: flex; align-items: center; gap: 7px;
            font-size: 12.5px; font-weight: 800; letter-spacing: .2px;
            color: var(--text-secondary); text-transform: uppercase; margin-bottom: 7px;
        }
        .wf-follow-step-no {
            flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%;
            background: #2f80ed; color: #fff; font-size: 12px;
            display: inline-flex; align-items: center; justify-content: center;
        }
        .wf-follow-block.answered .wf-follow-step-no { background: #58cc02; }
        .wf-follow-q {
            font-size: 16.5px; font-weight: 700; color: var(--text-primary);
            line-height: 1.45; margin-bottom: 10px;
        }
        .wf-follow-locked {
            font-size: 14px; font-weight: 600; color: var(--text-secondary);
            text-align: center; padding: 14px 10px;
        }
        /* Result screen: how much was understood, next to how much was scored. */
        .wf-understand-card {
            background: var(--glass-bg, #fff); border: 2px solid var(--glass-border);
            border-radius: 16px; padding: 14px 16px; margin: 12px 0;
        }
        .wf-understand-title { font-size: 14px; font-weight: 800; color: var(--text-primary); margin-bottom: 10px; }
        .wf-understand-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
        .wf-understand-label { flex: 0 0 auto; font-size: 13px; font-weight: 600; color: var(--text-secondary); width: 46%; }
        .wf-understand-bar { flex: 1 1 auto; height: 8px; border-radius: 4px; background: rgba(127,127,127,0.22); overflow: hidden; }
        .wf-understand-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #2f80ed, #58cc02); }
        .wf-understand-num { flex: 0 0 auto; font-size: 13px; font-weight: 800; color: var(--text-primary); }

        /* Rewrite tab — typed sentence transformation */
        .rewrite-screen { padding: 16px; padding-bottom: 90px; }
        .rw-orig {
            font-size: 16px; font-weight: 700; color: var(--text-primary);
            line-height: 1.5; margin-bottom: 10px;
        }
        .rw-stem {
            font-size: 15.5px; color: var(--text-primary); line-height: 1.5;
            background: rgba(124,58,237,0.07); border-left: 3px solid #7c3aed;
            padding: 8px 12px; border-radius: 8px; margin-bottom: 12px;
        }
        .rw-text-wrap { display: flex; gap: 8px; align-items: stretch; margin-top: 4px; }
        .rw-text-input {
            flex: 1 1 auto; padding: 12px 14px; font-size: 16px; font-family: inherit;
            border: 2px solid var(--glass-border); border-radius: 12px; resize: none;
            background: var(--glass-bg, #fff); color: var(--text-primary); outline: none;
            line-height: 1.4;
        }
        .rw-text-input:focus { border-color: #7c3aed; }
        .rw-text-submit { background: #7c3aed; }

        /* Skills chart (home bottom) */
        .home-skills-panel {
            flex-shrink: 0;   /* keep natural height inside the flex home screen */
            margin: 14px 16px 100px;
            padding: 18px 16px 14px;
            border-radius: 20px;
            background: var(--glass-bg, rgba(255,255,255,0.75));
            border: 1px solid var(--glass-border, rgba(0,0,0,0.06));
            box-shadow: 0 6px 20px rgba(0,0,0,0.06);
        }
                .home-skills-sub { font-size: 12px; color: var(--text-secondary); margin: 2px 0 12px; }
        .home-skill-row {
            display: flex; align-items: center; gap: 10px; margin: 8px 0;
            cursor: pointer; border-radius: 10px; padding: 2px 4px;
        }
        .home-skill-row:active { background: rgba(0,0,0,0.05); }
        .home-skill-label {
            flex: 0 0 108px; font-size: 12.5px; font-weight: 700; color: var(--text-primary);
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }
        .home-skill-bar {
            flex: 1 1 auto; height: 10px; border-radius: 5px;
            background: rgba(0,0,0,0.07); overflow: hidden;
        }
        .home-skill-fill { height: 100%; border-radius: 5px; transition: width 0.5s ease; }
        .home-skill-value {
            flex: 0 0 86px; text-align: right; font-size: 12px; color: var(--text-primary);
        }
        .home-skill-value span { color: var(--text-secondary); font-size: 10.5px; }
        .home-skill-empty { opacity: 0.45; }

        /* Units picture-dictionary practice (Topics tab → Grade 4 sub-tab) */
        .topics-subtabs { margin-bottom: 14px; }
        .units-bar { margin: 0 0 14px; }
        .g4-grid {
            display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
        }
        .g4-card {
            padding: 14px; border-radius: 16px; cursor: pointer; text-align: left;
            background: var(--glass-bg, rgba(255,255,255,0.8)); border: 1.5px solid var(--glass-border);
            font-family: inherit; box-shadow: 0 3px 12px rgba(0,0,0,0.05);
        }
        .g4-card:active { transform: scale(0.97); }
        .g4-card-top { display: flex; align-items: center; justify-content: space-between; }
        .g4-card-unit { font-size: 16px; font-weight: 800; color: var(--text-primary); }
        .g4-card-best {
            font-size: 11px; font-weight: 800; color: #d97706;
            background: rgba(217,119,6,0.12); padding: 2px 8px; border-radius: 999px;
        }
        .g4-card-best.good { color: #16a34a; background: rgba(34,197,94,0.14); }
        .g4-card-emojis { font-size: 22px; margin: 8px 0 6px; line-height: 1.2; }
        .g4-card-meta { font-size: 11.5px; color: var(--text-secondary); }
        /* Progress toward retiring a unit: ten perfect runs. */
        .g4-mastery {
            height: 4px; border-radius: 3px; background: rgba(0,0,0,0.08);
            margin: 6px 0 3px; overflow: hidden;
        }
        .g4-mastery i {
            display: block; height: 100%; border-radius: 3px;
            background: linear-gradient(90deg, #fbbf24, #f59e0b); transition: width 0.4s ease;
        }
        .g4-mastery-label { font-size: 10px; color: var(--text-secondary); font-weight: 700; }
        /* A mastered unit stays visible — it is an achievement, not a removal —
           but it cannot be replayed for easy coins. */
        .g4-card.mastered {
            background: linear-gradient(150deg, #fffbeb, #fef3c7);
            border: 1.5px solid rgba(245, 158, 11, 0.45);
            cursor: default; opacity: 0.92;
        }
        .g4-card.mastered:active { transform: none; }
        .g4-card-best.mastered { color: #b45309; background: rgba(245, 158, 11, 0.18); }
        .g4-mix-card {
            grid-column: 1 / -1;
            background: linear-gradient(135deg, rgba(124,58,237,0.14), rgba(59,130,246,0.10));
            border-color: rgba(124,58,237,0.4);
        }
        .g4-mix-card .g4-card-meta { margin-top: 6px; }
        /* Pre / HK1 / HK2 — the second tab row inside Grade 4. Deliberately
           smaller than the Topics tabs above it so the hierarchy is obvious. */
        .g4-set-tabs { margin-bottom: 12px; }
        .g4-set-tabs .grammar-subtab { padding: 7px 10px; font-size: 13px; border-radius: 12px; }
        /* The book's own unit name ("My friends"), under the number. */
        .g4-card-title {
            font-size: 11.5px; font-weight: 700; color: var(--text-secondary);
            margin-top: 3px; line-height: 1.3;
        }
        /* A word set that has no words yet. */
        .g4-soon {
            padding: 28px 18px; border-radius: 18px; text-align: center;
            background: var(--glass-bg, rgba(255,255,255,0.8));
            border: 1.5px dashed var(--glass-border);
        }
        .g4-soon-icon { font-size: 38px; line-height: 1; }
        .g4-soon-title { margin-top: 10px; font-size: 16px; font-weight: 800; color: var(--text-primary); }
        .g4-soon-sub { margin-top: 6px; font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
        /* ---- owed words: the gate ---- */
        /* A disabled card with no reason reads as a broken app, so the banner
           states the debt and is itself the way to pay it. */
        .unit-owed-banner {
            display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
            margin: 0 0 12px; padding: 12px 14px; border-radius: 14px;
            background: #fff7ed; border: 1.5px solid #fdba74;
            color: #7c2d12; font-size: 13.5px; font-weight: 700; line-height: 1.5;
        }
        .unit-owed-text { flex: 1 1 180px; }
        .unit-owed-btn {
            flex: 0 0 auto; border: none; border-radius: 999px; cursor: pointer;
            padding: 10px 16px; min-height: 44px; font-family: inherit;
            font-size: 13.5px; font-weight: 800; color: #fff; background: #ea580c;
        }
        .unit-owed-btn:active { transform: scale(.97); }
        .g4-card.locked { opacity: .5; cursor: default; filter: grayscale(.5); }
        .phrases-cta.locked { opacity: .5; cursor: default; filter: grayscale(.5); }

        /* ---- the drill ---- */
        .unit-retry-peek { display: flex; justify-content: center; gap: 8px; margin: 10px 0 6px; }
        /* Held down, not tapped. A long press on iOS otherwise raises the
           text-selection callout and the magnifier right over the hint. */
        .unit-peek-btn {
            border: 1.5px solid #c7d2fe; background: #eef2ff; color: #3730a3;
            border-radius: 999px; padding: 8px 14px; min-height: 44px;
            font-family: inherit; font-size: 13px; font-weight: 800; cursor: pointer;
            -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
            touch-action: manipulation;
        }
        .unit-peek-btn.on { background: #3730a3; border-color: #3730a3; color: #fff; }
        /* The hidden state keeps the SAME height as the revealed one, or the
           input jumps under the child's thumb every time they peek. */
        .unit-retry-reveal {
            min-height: 34px; margin: 2px 0 8px; text-align: center;
            font-size: 22px; font-weight: 900; letter-spacing: 1px; color: #1e1b4b;
        }
        .unit-retry-reveal.hidden { visibility: hidden; }

        .unit-retry-done { text-align: center; padding: 26px 16px; }
        .unit-retry-done-emoji { font-size: 44px; line-height: 1; }
        .unit-retry-done-title { margin-top: 8px; font-size: 18px; font-weight: 900; color: var(--text-primary, #1e293b); }
        .unit-retry-done-sub { margin-top: 6px; font-size: 13.5px; color: var(--text-secondary, #475569); }

        .unit-say-btn {
            border: none; background: rgba(124,58,237,0.12); cursor: pointer;
            border-radius: 50px; padding: 2px 9px; font-size: 14px; line-height: 1.4;
            vertical-align: middle; margin: 0 2px;
        }
        .unit-say-btn:active { transform: scale(0.9); }
        .units-history { margin: 0 0 14px; }
        .uh-streak {
            text-align: center; font-size: 14px; padding: 10px; margin-bottom: 10px;
            border-radius: 14px; background: rgba(249,115,22,0.10);
            border: 1.5px solid rgba(249,115,22,0.35); color: var(--text-primary);
        }
        .uh-empty { text-align: center; color: var(--text-secondary); font-size: 13px; padding: 18px 8px; }
        .uh-list { display: flex; flex-direction: column; gap: 6px; }
        .uh-item {
            display: flex; align-items: center; gap: 8px; padding: 10px 12px;
            border-radius: 12px; background: var(--glass-bg, rgba(255,255,255,0.8));
            border: 1.5px solid var(--glass-border); font-size: 12.5px;
        }
        .uh-icon { flex: 0 0 auto; }
        .uh-name { font-weight: 800; color: var(--text-primary); flex: 0 0 auto; }
        .uh-score { color: var(--text-secondary); flex: 1 1 auto; }
        .uh-score.good { color: #16a34a; font-weight: 700; }
        .uh-date { color: var(--text-secondary); font-size: 11px; flex: 0 0 auto; }
        .uh-sync-note { text-align: center; color: var(--text-secondary); font-size: 11px; margin-top: 10px; }
        .unit-reward-card {
            text-align: center; padding: 14px; margin: 10px 0 14px; border-radius: 16px;
            background: linear-gradient(135deg, rgba(251,191,36,0.16), rgba(249,115,22,0.10));
            border: 1.5px solid rgba(251,191,36,0.45);
        }
        .unit-reward-coins { font-size: 28px; font-weight: 900; color: #d97706; }
        .unit-reward-total { font-size: 12.5px; color: var(--text-secondary); margin: 4px 0 10px; }
                        /* Finish-screen celebration: card pops in, coins bounce, emojis rise */
        .reward-pop {
            position: relative; overflow: visible;
            animation: rewardPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
        }
        @keyframes rewardPop {
            from { transform: scale(0.6); opacity: 0; }
            to { transform: scale(1); opacity: 1; }
        }
        .reward-congrats {
            font-size: 16px; font-weight: 900; color: #d97706; margin-bottom: 4px;
            animation: rewardPop 0.55s 0.15s backwards cubic-bezier(0.34, 1.56, 0.64, 1);
        }
        .reward-coins-pop { animation: coinPop 0.7s 0.3s backwards cubic-bezier(0.34, 1.56, 0.64, 1); }
        @keyframes coinPop {
            0% { transform: scale(0); }
            60% { transform: scale(1.35) rotate(-6deg); }
            100% { transform: scale(1); }
        }
        /* ===== Milo, the rigged SVG dog (petart.js) ===== */
        .pd-dog { overflow: visible; transform-origin: 50% 95%; }
        /* idle: gentle breathing + a head that sways a little */
        .pd-body-grp { animation: pdBreathe 3.2s ease-in-out infinite; transform-origin: 50px 88px; }
        .pd-head-grp { animation: pdSway 4.6s ease-in-out infinite; transform-origin: 50px 62px; }
        @keyframes pdBreathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.035, 0.975); } }
        @keyframes pdSway { 0%,100% { transform: rotate(-1.6deg); } 50% { transform: rotate(1.6deg); } }
        /* tail wag — the clearest "I'm happy" signal for a child */
        .pd-tail { transform-origin: 74px 78px; animation: pdWag 0.5s ease-in-out infinite alternate; }
        @keyframes pdWag { from { transform: rotate(-16deg); } to { transform: rotate(22deg); } }
        /* blink: eyelids drop for a moment every few seconds */
        .pd-lid { transform-origin: center top; transform: scaleY(0); animation: pdBlink 5.4s infinite; }
        @keyframes pdBlink { 0%,95.5%,100% { transform: scaleY(0); } 97%,98.5% { transform: scaleY(1); } }
        .pd-tongue { transform-origin: 50px 52px; animation: pdPant 1.6s ease-in-out infinite; }
        @keyframes pdPant { 0%,100% { transform: scaleY(0.75); } 50% { transform: scaleY(1.1); } }
        .pd-shadow { animation: pdShadow 3.2s ease-in-out infinite; transform-origin: 50px 101px; }
        @keyframes pdShadow { 0%,100% { transform: scale(1); opacity: .18; } 50% { transform: scale(0.94); opacity: .14; } }
        .pd-sparkles { animation: pdTwinkle 2s ease-in-out infinite; }
        /* Every-level polish: quiet details that build between outfit rewards. */
        .pd-level-aura {
            transform-origin: 50px 58px;
            animation: pdAuraBreathe 3.6s ease-in-out infinite;
        }
        .pd-coat-shine { filter: drop-shadow(0 0 2px rgba(255,255,255,.8)); }
        .pd-face-shine, .pd-aura-sparks { animation: pdTwinkle 2.6s ease-in-out infinite; }
        .pd-aura-sparks { animation-delay: .45s; }
        @keyframes pdAuraBreathe {
            0%, 100% { transform: scale(.97); opacity: .65; }
            50% { transform: scale(1.04); opacity: 1; }
        }
        /* tier outfit: gems catch the light, jewellery sparkles, hat rides the head */
        .pd-gem { animation: pdGemShine 2.4s ease-in-out infinite; transform-origin: center; }
        @keyframes pdGemShine { 0%,100% { opacity: 1; } 50% { opacity: .72; transform: scale(1.12); } }
        .pd-sparks { animation: pdTwinkle 1.8s ease-in-out infinite; }
        .pd-sparks path:nth-child(2) { animation: pdTwinkle 1.8s ease-in-out .6s infinite; }
        .pd-sparks path:nth-child(3) { animation: pdTwinkle 1.8s ease-in-out 1.2s infinite; }
        .pd-pendant { animation: pdPendant 3s ease-in-out infinite; transform-origin: 50px 62px; }
        @keyframes pdPendant { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
        .pd-hat { transform-origin: 50px 24px; }
        .pd-sad .pd-hat { transform: rotate(-7deg) translateY(2px); }
        @keyframes pdTwinkle { 0%,100% { opacity: .25; } 50% { opacity: 1; } }

        /* hungry / sad: ears droop, tail slows, eyes half-close, blush fades */
        .pd-sad .pd-tail { animation-duration: 2.4s; }
        .pd-sad .pd-ear-l { transform: rotate(26deg); transform-origin: 32px 30px; }
        .pd-sad .pd-ear-r { transform: rotate(-26deg); transform-origin: 68px 30px; }
        .pd-sad .pd-head-grp { transform: translateY(4px); animation: none; }
        .pd-sad .pd-lid { transform: scaleY(0.55); animation: none; }
        .pd-sad .pd-tongue { display: none; }
        .pd-sad .pd-blush { opacity: .18; }
        .pd-sad .pd-mouth { d: path('M42 52 q8 -6 16 0'); }

        /* one-shot reactions */
        .pd-hop { animation: pdHop 0.65s cubic-bezier(0.34, 1.56, 0.64, 1); }
        @keyframes pdHop {
            0%   { transform: translateY(0) scale(1, 1); }
            25%  { transform: translateY(2px) scale(1.1, 0.88); }   /* squash */
            55%  { transform: translateY(-22px) scale(0.93, 1.12); } /* stretch */
            80%  { transform: translateY(1px) scale(1.06, 0.94); }
            100% { transform: translateY(0) scale(1, 1); }
        }
        .pd-hop .pd-tail { animation-duration: 0.16s; }
        .pd-eat .pd-head-grp { animation: pdChew 0.28s ease-in-out 4; }
        @keyframes pdChew { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(2px) scale(1.05, 0.95); } }
        .pd-levelup { animation: pdLevelUp 1.3s ease-in-out; }
        @keyframes pdLevelUp {
            0%   { transform: rotate(0) scale(1); }
            30%  { transform: rotate(-8deg) scale(1.12); }
            60%  { transform: rotate(370deg) scale(1.12); }
            100% { transform: rotate(360deg) scale(1); }
        }
        /* Respect users who prefer less motion (idle loops only stop) */
        @media (prefers-reduced-motion: reduce) {
            .pd-body-grp, .pd-head-grp, .pd-tail, .pd-lid, .pd-tongue, .pd-shadow,
            .pd-sparkles, .pd-gem, .pd-sparks, .pd-pendant, .pd-level-aura,
            .pd-face-shine, .pd-aura-sparks { animation: none; }
        }

        /* ===== Friends (Profile) ===== */
        .friends-section { margin-bottom: 8px; }
        .friend-link-card {
            padding: 14px; border-radius: 14px; margin-bottom: 8px;
            background: rgba(124,58,237,0.08); border: 1.5px solid rgba(124,58,237,0.28);
        }
        .friend-link-msg { font-size: 12.5px; line-height: 1.55; color: var(--text-primary); margin-bottom: 10px; }
        .friend-link-card .friend-invite-btn { width: 100%; min-height: 44px; }
        .friend-link-card .friend-invite-box .friend-invite-btn { width: auto; }
        .friends-empty { font-size: 13px; color: var(--text-secondary); padding: 14px 4px; text-align: center; }
        .friend-invite-box { display: flex; gap: 8px; margin-bottom: 10px; }
        .friend-invite-input {
            flex: 1 1 auto; padding: 10px 12px; border-radius: 12px; font-family: inherit; font-size: 14px;
            border: 1.5px solid var(--glass-border); background: var(--glass-bg, rgba(255,255,255,0.85));
        }
        .friend-invite-btn {
            flex: 0 0 auto; padding: 10px 16px; border-radius: 12px; border: none; cursor: pointer;
            background: linear-gradient(135deg, #7c3aed, #4f46e5); color: #fff; font-weight: 800; font-family: inherit;
        }
        .friend-msg { font-size: 12.5px; margin-bottom: 8px; color: var(--text-primary); }
        .friend-group-title { font-size: 12px; font-weight: 800; color: var(--text-secondary); margin: 12px 0 6px; }
        .friend-row {
            display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 8px;
            border-radius: 14px; background: var(--glass-bg, rgba(255,255,255,0.85));
            border: 1.5px solid var(--glass-border); cursor: pointer;
        }
        .friend-row.invite { border-color: rgba(124,58,237,0.45); }
        .friend-face { flex: 0 0 auto; width: 40px; display: flex; justify-content: center; }
        .friend-info { flex: 1 1 auto; min-width: 0; }
        .friend-name { font-size: 14px; font-weight: 800; color: var(--text-primary); }
        .friend-meta { font-size: 11px; color: var(--text-secondary); }
        .friend-actions { display: flex; gap: 6px; }
        .friend-btn {
            border: none; cursor: pointer; width: 34px; height: 34px; border-radius: 50%;
            font-size: 15px; font-weight: 800; font-family: inherit;
        }
        .friend-btn.accept { background: #22c55e; color: #fff; }
        .friend-btn.decline { background: rgba(0,0,0,0.10); color: var(--text-primary); }
        .friend-go { color: var(--text-secondary); font-size: 18px; }
        .friend-pending { font-size: 11.5px; color: var(--text-secondary); margin-top: 6px; }
        .friend-pending-chip { display: inline-block; margin-right: 6px; }
        .friend-back { background: none; border: none; cursor: pointer; font-family: inherit;
            font-size: 13px; color: var(--text-secondary); padding: 4px 0 10px; }
        .friend-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
        .friend-card-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px; }
        .friend-card-stats > div {
            background: var(--glass-bg, rgba(255,255,255,0.85)); border: 1.5px solid var(--glass-border);
            border-radius: 12px; padding: 10px 4px; text-align: center;
        }
        .friend-card-stats b { display: block; font-size: 17px; color: var(--text-primary); }
        .friend-card-stats span { font-size: 10.5px; color: var(--text-secondary); }
        .friend-days { display: flex; gap: 6px; flex-wrap: wrap; }
        .friend-day { flex: 1 1 0; min-width: 44px; text-align: center; padding: 8px 2px; border-radius: 10px;
            background: rgba(124,58,237,0.10); font-size: 10.5px; color: var(--text-secondary); }
        .friend-day b { display: block; font-size: 14px; color: var(--text-primary); }
        .friend-skill-row { display: flex; justify-content: space-between; font-size: 12.5px;
            padding: 7px 10px; border-radius: 10px; background: var(--glass-bg, rgba(255,255,255,0.7)); margin-bottom: 5px; }

        /* ===== Pet battle ===== */
        /* Arena is the centre destination in the five-item bottom navigation. */
        .pet-battle-screen { padding: 16px 0 90px; }
                                                                                                .pb-offline-copy h2 { margin: 0; color: #172554; font-size: 24px; line-height: 1.15; }
        .pb-offline-copy p { max-width: 510px; margin: 8px 0 18px; color: #475569; font-size: 14px; line-height: 1.55; }
                        @media (max-width: 380px) {
                        .pb-offline-copy h2 { font-size: 22px; }
                    }

                                        .pb-mini-mark.me { background: #38bdf8; box-shadow: 0 0 0 2px rgba(56,189,248,.35); }
        .pb-mini-mark.foe { background: #fb7185; box-shadow: 0 0 0 2px rgba(251,113,133,.35); }
        .pb-mini-mark.shot { background: #fff; width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; }
                                                                        
                                                                        .pb-cup-slot.on { background: rgba(245,158,11,.22); filter: drop-shadow(0 2px 3px rgba(180,83,9,.35)); }
                                                .pb-cup-dream-art.unlocked { opacity: 1; }
                                                                
        /* 🏆 Cup cabinet (Profile) */
        .cup-cabinet { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
        .cup-empty {
            text-align: center; padding: 22px 16px; border-radius: 16px;
            background: rgba(0,0,0,0.03); color: var(--text-secondary); font-size: 13px; line-height: 1.5;
        }
        .cup-empty-icon { font-size: 40px; opacity: 0.35; margin-bottom: 8px; }
        .cup-total { display: flex; gap: 8px; }
        .cup-total > div {
            flex: 1; text-align: center; padding: 10px; border-radius: 14px;
            background: linear-gradient(140deg, #fef3c7, #fde68a);
        }
        .cup-total b { display: block; font-size: 21px; font-weight: 900; color: #b45309; }
        .cup-total span { font-size: 10px; color: #92400e; }
        .cup-shelf { padding: 12px; border-radius: 16px; background: rgba(0,0,0,0.03); }
        .cup-basic-shelf { background: linear-gradient(150deg, #fffbeb, #fef3c7); }
        .cup-ruby-shelf { background: linear-gradient(150deg, #fff1f2, #ffe4e6); }
        .cup-diamond-shelf { background: linear-gradient(150deg, #eff6ff, #dbeafe); }
        .cup-shelf-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
        .cup-shelf-name { font-size: 12.5px; font-weight: 800; color: var(--text-primary); }
        .cup-shelf-count { font-size: 17px; font-weight: 900; color: var(--text-primary); }
        .cup-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-height: 42px; }
        .cup-slot.empty { color: var(--text-secondary); opacity: 0.4; font-size: 20px; padding-left: 4px; }
        .cup-more { font-size: 13px; font-weight: 800; color: var(--text-secondary); margin-left: 4px; }
        .cup { line-height: 1; animation: cup-pop 0.35s ease both; }
        /* Each tier gets its own metal, so a shelf reads at a glance. */
        .cup-basic { filter: drop-shadow(0 2px 3px rgba(180,83,9,0.35)); }
        .cup-ruby { filter: drop-shadow(0 2px 4px rgba(190,18,60,0.45)) hue-rotate(-50deg) saturate(2.2); }
        .cup-diamond { filter: drop-shadow(0 3px 6px rgba(37,99,235,0.5)) hue-rotate(160deg) saturate(1.8) brightness(1.15); }
        @keyframes cup-pop { from { opacity: 0; transform: scale(0.4) translateY(6px); } to { opacity: 1; transform: none; } }
        .cup-shelf-foot { font-size: 11px; color: var(--text-secondary); margin-top: 6px; }
        .cup-merge-btn {
            width: 100%; padding: 9px; border: none; border-radius: 12px; cursor: pointer;
            background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff;
            font-family: inherit; font-size: 12px; font-weight: 800;
            box-shadow: 0 2px 8px rgba(217,119,6,0.35);
        }
        .cup-merge-btn:active { transform: scale(0.97); }

                                                .pb-squad-chip.active { border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18), 0 6px 16px rgba(15,118,110,.22); }
        
                                                                                        .pb-hire-card:hover { border-color: rgba(37,99,235,.35); box-shadow: 0 7px 19px rgba(15,23,42,.12); }
        /* A hired teammate is visibly on the bench, not just a number. */
        .pb-hire-card.has { border-color: #2563eb; background: linear-gradient(135deg, #eff6ff, #fff); }

                                                                                .pb-castle-card.selected { border-color: #7c3aed; box-shadow: 0 0 0 3px #ede9fe, 0 9px 22px rgba(109,40,217,.2); }
                                                                                                                                                                                /* iPad and anything else wide. The app was drawn for a ~390px phone;
           left alone it simply stretches, so on an iPad Pro the "your name"
           field was 976px across — a text box nearly a metre wide for a
           child's first name. Cap the content and centre it so the design
           reads as deliberate instead of inflated. Screens that genuinely
           benefit from room (the battlefield, grammar, exams, topics) get a
           wider cap of their own. */
        @media (min-width: 700px) {
            .screen { max-width: 680px; margin-inline: auto; }
            .pet-battle-screen, .grammar-screen, .exam-screen,
            .topics-screen, .phrases-screen, .wordform-screen, .rewrite-screen { max-width: 920px; }
                        .nav-hub-screen { padding: 30px 28px 108px; }
            .nav-hub-header, .nav-hub-feature, .nav-hub-grid { max-width: 900px; }
            .nav-hub-header { padding: 28px 30px; }
            .nav-hub-header h1 { font-size: 28px; }
            .nav-hub-header p { max-width: 600px; font-size: 14px; }
            .learn-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
            .nav-hub-card { min-height: 172px; padding: 18px; }
            .nav-hub-feature { padding: 19px 22px; }
                                }
        
                                .pb-flag.on { opacity: 1; border-color: #ea580c; background: rgba(234, 88, 12, 0.1); }
                                                        
                                                                                                .pb-hist-item.win { background: rgba(22, 163, 74, 0.07); }
        .pb-hist-item.lose { background: rgba(220, 38, 38, 0.06); }
        .pb-hist-item.draw { background: rgba(100, 116, 139, 0.07); }
                                                                                                                                                                        .pb-hist-turn .hit { color: #dc2626; font-weight: 800; white-space: nowrap; }
        .pb-hist-turn .miss { color: var(--text-secondary); white-space: nowrap; }

        /* Quick connect link — beats typing an accented name exactly */
        .friend-share-btn {
            width: 100%; padding: 12px; border: none; border-radius: 14px;
            background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
            font-family: inherit; font-size: 14px; font-weight: 800; cursor: pointer;
            box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3);
        }
        .friend-share-btn:active { transform: scale(0.97); }
        .friend-share-hint { font-size: 11px; color: var(--text-secondary); text-align: center; margin: 6px 0 12px; }
        .friend-quick-card {
            background: linear-gradient(160deg, #eef2ff, #e0e7ff);
            border: 1.5px solid rgba(99, 102, 241, 0.3);
            border-radius: 16px; padding: 14px; margin-bottom: 12px;
        }
        .friend-quick-title { font-size: 14px; color: var(--text-primary); margin-bottom: 10px; }
        .friend-quick-actions { display: flex; gap: 8px; }
        .friend-quick-actions .friend-invite-btn { flex: 1; }
        .friend-quick-skip {
            padding: 10px 14px; border: none; border-radius: 12px; background: rgba(0, 0, 0, 0.06);
            color: var(--text-secondary); font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
        }

                                                                                                                                                                                                                                                                                .pb-result-card.win { border-color: rgba(34,197,94,0.5); }
        /* A tie is its own outcome, not a defeat in different words. Without
           this the new draw card fell through to the unstyled default while
           its 🤝 sat above green-for-a-win wording. */
        .pb-result-card.draw { border-color: rgba(148,163,184,0.6); }

                                                                                                                                                                                        .pb-hud-side.right { text-align: right; }
                                .pb-hp-fill.me { background: linear-gradient(90deg, #2dd4bf, #16a34a); box-shadow: 0 0 8px rgba(22,163,74,.45); }
        .pb-hp-fill.foe { background: linear-gradient(90deg, #fb7185, #e11d48); box-shadow: 0 0 8px rgba(225,29,72,.4); }
                                        .pb-hud-side.right .pb-hearts { justify-content: flex-end; }
                                                                                                                                                                                                                                .pb-barrel.on { background: linear-gradient(145deg, #fff1a8, #ff9f1c); color: #431407; border-color: #ea580c; box-shadow: 0 4px 0 #c2410c, 0 8px 14px rgba(249,115,22,.18); }
                                        .pb-link.live { background: rgba(34,197,94,0.18); color: #15803d; }
                .pb-link.slow { background: rgba(0,0,0,0.08); color: var(--text-secondary); }
                                                                                                                                                                                
        /* Pet motivation loop: cheering, food quest, quick-feed (petcheer.js) */
        .pet-cheer {
            position: fixed; left: 50%; top: 72px; z-index: 260;
            display: flex; align-items: center; gap: 6px;
            padding: 7px 14px; border-radius: 50px;
            background: rgba(255,255,255,0.95); box-shadow: 0 4px 18px rgba(0,0,0,0.18);
            font-size: 14px; font-weight: 800; color: var(--text-primary);
            opacity: 0; pointer-events: none;
            transform: translate(-50%, -10px) scale(0.7);
        }
        .pet-cheer.show { animation: petCheerHop 1.1s ease-out; }
        .pet-cheer.show .pet-cheer-dog { animation: petHop 0.5s ease-in-out 2; }
        @keyframes petCheerHop {
            0% { opacity: 0; transform: translate(-50%, -10px) scale(0.7); }
            18% { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
            30% { transform: translate(-50%, 0) scale(1); }
            80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
            100% { opacity: 0; transform: translate(-50%, -8px) scale(0.95); }
        }
        @keyframes petHop {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-7px) rotate(-8deg); }
        }
        .pet-cheer-dog { font-size: 20px; display: inline-block; }
        .pet-cheer-label { color: #d97706; }

        .pet-quest-card {
            /* Let the garden finish visually before the information card
               starts. The old negative margin made both rounded boxes look
               stuck together on phones. */
            margin: 12px 16px 26px; padding: 12px 14px; border-radius: 16px;
            background: var(--glass-bg, rgba(255,255,255,0.85));
            border: 1.5px solid var(--glass-border, rgba(0,0,0,0.06));
            box-shadow: 0 3px 14px rgba(0,0,0,0.06);
            position: relative; z-index: 6;
        }
        .pet-quest-card:empty { display: none; }
        .pet-quest-line { margin-top: 0; font-size: 12px; color: var(--text-primary); }
        .pet-quest-line.done { color: #16a34a; font-weight: 700; text-align: center; }
        .pet-quest-ask { font-weight: 700; margin-bottom: 4px; }
        .pet-quest-bar, .pet-evo-bar {
            height: 7px; border-radius: 50px; overflow: hidden;
            background: rgba(0,0,0,0.10);
        }
        .pet-quest-fill { height: 100%; border-radius: 50px; background: linear-gradient(90deg, #fbbf24, #f97316); transition: width 0.4s ease; }
        .pet-evo-fill { height: 100%; border-radius: 50px; background: linear-gradient(90deg, #34d399, #7c3aed); transition: width 0.4s ease; }
        .pet-quest-meta { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }
        /* Coins are already visible in the header and the Feed button carries
           the exact price. Repeating “2052/240 … đủ rồi” wastes the narrow
           homepage card; retain it in post-lesson feed cards only. */
        .pet-quest-card .pet-quest-meta { display: none; }
        .pet-evo-unlock {
            margin-top: 6px; padding: 6px 10px; border-radius: 10px; font-size: 11.5px;
            background: rgba(124,58,237,0.10); color: var(--text-primary);
        }
        .pet-evo-line { margin-top: 10px; font-size: 11.5px; color: var(--text-secondary); }
        .pet-evo-text { margin-bottom: 4px; }
        .pet-evo-next { filter: grayscale(1); opacity: 0.7; }

        .pet-feed-zone {
            margin-top: 12px; padding-top: 12px;
            border-top: 1.5px dashed rgba(217,119,6,0.35);
        }
        .pet-feed-head { display: flex; align-items: center; gap: 10px; text-align: left; }
        .pet-feed-dog { font-size: 34px; }
        .pet-feed-info { flex: 1 1 auto; }
        .pet-feed-name { font-size: 13px; font-weight: 800; margin-bottom: 4px; }
        .pet-hunger-bar { height: 8px; border-radius: 50px; background: rgba(0,0,0,0.10); overflow: hidden; }
        .pet-hunger-fill { height: 100%; border-radius: 50px; background: linear-gradient(90deg, #34d399, #16a34a); transition: width 0.4s ease; }
        .pet-hunger-fill.mid { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
        .pet-hunger-fill.low { background: linear-gradient(90deg, #f87171, #ef4444); }
        .pet-feed-row { display: flex; gap: 6px; margin-top: 10px; }
        .pet-feed-btn {
            flex: 1 1 0; padding: 8px 2px; border-radius: 12px; cursor: pointer;
            border: 1.5px solid rgba(217,119,6,0.35); background: rgba(255,255,255,0.85);
            display: flex; flex-direction: column; align-items: center; gap: 2px;
            font-family: inherit;
        }
        .pet-feed-btn:active { transform: scale(0.94); }
        .pet-feed-btn.locked { opacity: 0.38; cursor: default; }
        .pet-feed-emoji { font-size: 20px; }
        .pet-feed-price { font-size: 10px; font-weight: 800; color: var(--text-secondary); }

        .reward-burst { position: absolute; inset: 0; pointer-events: none; }
        .reward-burst-item {
            position: absolute; bottom: 25%; font-size: 22px; opacity: 0;
            animation: burstUp 1.7s ease-out forwards;
        }
        @keyframes burstUp {
            0% { transform: translateY(0) scale(0.5) rotate(0deg); opacity: 0; }
            15% { opacity: 1; }
            100% { transform: translateY(-110px) scale(1.2) rotate(30deg); opacity: 0; }
        }

        /* Collocation practice (Phrases tab → 🧩 sub-tab) */
        .colloc-lesson { display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
        .colloc-lesson-item { font-size: 13px; line-height: 1.55; color: var(--text-primary); }
        .colloc-hint {
            margin-top: 10px; font-size: 15px; letter-spacing: 1px;
            color: var(--text-secondary);
        }
        .colloc-transform-src {
            font-size: 14.5px; padding: 10px 12px; border-radius: 12px; margin-bottom: 8px;
            background: rgba(14,165,233,0.08); border: 1px solid rgba(14,165,233,0.25);
        }
        .colloc-keyword { font-size: 12.5px; color: var(--text-secondary); margin: 6px 0; }
        .colloc-keyword b { color: #0369a1; letter-spacing: 0.5px; }
        .colloc-frame { font-size: 14.5px; margin-top: 4px; }
        .colloc-correct-answer { margin: 6px 0; }
        .grammar-review-a { font-size: 12.5px; color: var(--text-secondary); margin-top: 4px; }

        /* Tap-a-word: hear + Vietnamese meaning (tapwords.js) */
        .tw {
            cursor: pointer;
            border-bottom: 1.5px dotted rgba(124,58,237,0.45);
            border-radius: 2px;
        }
        .tw:active { background: rgba(124,58,237,0.15); }
        .tw-chip {
            position: fixed; left: 12px; right: 12px;
            bottom: calc(78px + env(safe-area-inset-bottom, 0px));
            z-index: 250;                      /* above overlays (200), below nav (300) */
            display: flex; align-items: center; gap: 10px;
            padding: 10px 14px; border-radius: 16px;
            background: rgba(30, 27, 46, 0.94); color: #fff;
            font-size: 13.5px; line-height: 1.45;
            box-shadow: 0 6px 24px rgba(0,0,0,0.35);
            opacity: 0; pointer-events: none; transform: translateY(8px);
            transition: opacity 0.2s ease, transform 0.2s ease;
        }
        .tw-chip.show { opacity: 1; pointer-events: auto; transform: none; }
        .tw-chip-speak {
            flex: 0 0 auto; border: none; cursor: pointer; font-size: 16px;
            background: rgba(255,255,255,0.14); border-radius: 50%;
            width: 34px; height: 34px;
        }
        .tw-chip-text { flex: 1 1 auto; }
        .tw-chip-pos { color: #c4b5fd; font-size: 12px; }

        .unit-q-card { text-align: center; }
        .unit-q-emoji { font-size: 64px; line-height: 1.2; margin: 6px 0 2px; }
        .unit-q-emoji.unit-q-number { font-size: 54px; font-weight: 800; color: #1cb0f6; }
        .unit-q-vi { font-size: 15px; font-weight: 700; color: var(--text-secondary); margin-bottom: 12px; }
        .unit-gap { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 6px 0 14px; }
        /* Post glossary terms are maths/science CONCEPTS the child meets here
           first, so each card carries a sentence that shows what the word
           means. Blank while answering, filled in with its Vietnamese
           translation once the answer is in. */
        .unit-q-ex {
            font-size: 15px; line-height: 1.55; color: var(--text-primary);
            margin: 2px 10px 10px; padding: 10px 12px;
            background: rgba(124,58,237,0.06); border-radius: 12px;
        }
        .unit-ex-blank {
            display: inline-block; min-width: 74px;
            border-bottom: 2px solid #7c3aed; color: transparent;
            vertical-align: bottom; letter-spacing: 2px;
        }
        .unit-ex-word { color: #2e7d0f; font-weight: 800; }
        .unit-q-exvi {
            font-size: 14px; font-weight: 600; color: var(--text-secondary);
            margin: -4px 10px 12px; padding: 0 12px;
        }
        .unit-gap-ch {
            min-width: 24px; height: 34px; line-height: 34px; padding: 0 2px;
            border-radius: 8px; background: rgba(0,0,0,0.05);
            font-size: 20px; font-weight: 800; color: var(--text-primary);
            font-family: 'Courier New', monospace; text-align: center;
        }
        .unit-gap-ch.blank { background: rgba(124,58,237,0.14); color: #7c3aed; }
        .unit-gap-ch.was-blank { background: rgba(88,204,2,0.18); color: #2e7d0f; }
        .unit-gap-ch.fixed { background: transparent; }
        .unit-gap-space { min-width: 14px; }

        /* Rich stats: overall ring + summary chips */
        .home-skills-summary { display: flex; align-items: center; gap: 14px; margin: 4px 0 14px; }
        .home-skills-ring {
            flex: 0 0 74px; width: 74px; height: 74px; border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
        }
        .home-skills-ring-inner {
            width: 56px; height: 56px; border-radius: 50%;
            background: var(--glass-bg, #fff);
            display: flex; flex-direction: column; align-items: center; justify-content: center;
        }
        .home-skills-ring-inner strong { font-size: 15px; color: var(--text-primary); line-height: 1; }
        .home-skills-ring-inner span { font-size: 10px; color: var(--text-secondary); }
        /* 2-column grid: chips always align in tidy pairs instead of a ragged wrap */
        .home-skills-chips { flex: 1 1 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
        .home-skills-chip {
            padding: 5px 10px; border-radius: 12px; background: rgba(0,0,0,0.05);
            display: flex; flex-direction: column; min-width: 62px;
        }
        .home-skills-chip strong { font-size: 13px; color: var(--text-primary); line-height: 1.2; }
        .home-skills-chip span { font-size: 9.5px; color: var(--text-secondary); white-space: nowrap; }
        .home-skills-chip.chip-best { background: rgba(34,197,94,0.14); }
        .home-skills-chip.chip-focus { background: rgba(239,68,68,0.12); }

        /* Trend arrows + level tags */
        .home-skill-trend { font-size: 10px; margin-left: 2px; }
        .home-skill-trend.up { color: #16a34a; }
        .home-skill-trend.down { color: #ef4444; }
        .home-skill-level {
            display: block; font-style: normal; font-size: 9px; font-weight: 700;
            margin-top: 1px;
        }
        .home-skill-level.lv-excellent { color: #16a34a; }
        .home-skill-level.lv-good { color: #2563eb; }
        .home-skill-level.lv-ok { color: #d97706; }
        .home-skill-level.lv-weak { color: #ef4444; }

        /* 7-day activity mini chart */
        .home-skills-daily { margin-top: 14px; border-top: 1px dashed var(--glass-border, rgba(0,0,0,0.1)); padding-top: 10px; }
        .home-skills-daily-title { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
        .home-skills-daily-bars { display: flex; gap: 6px; align-items: flex-end; }
        .home-skills-day { flex: 1 1 0; text-align: center; }
        .home-skills-day-bar {
            height: 46px; border-radius: 6px; background: rgba(0,0,0,0.05);
            display: flex; align-items: flex-end; overflow: hidden;
        }
        .home-skills-day-fill { width: 100%; background: linear-gradient(180deg, #34d399, #059669); border-radius: 6px 6px 0 0; min-height: 2px; }
        .home-skills-day.today .home-skills-day-fill { background: linear-gradient(180deg, #a78bfa, #7c3aed); }
        .home-skills-day-count { font-size: 9px; font-weight: 700; color: var(--text-primary); min-height: 12px; }
        .home-skills-day-label { font-size: 9px; color: var(--text-secondary); }
        .home-skills-day.today .home-skills-day-label { color: #7c3aed; font-weight: 800; }

        /* ==================== HOME SCREEN ==================== */
        .home-screen {
            padding: 0;
            display: flex;
            flex-direction: column;
            /* Scrollable since the My Skills panel joined the pet + streak
               sections — the v3.38 fits-one-viewport assumption no longer
               holds. (hidden here blocked finger scrolling on iOS.) */
            overflow-y: auto;
        }
        .home-screen .home-header {
            display: none;  /* replaced by pet-hero-topbar */
        }
        .home-screen .summer-sun {
            display: none;  /* replaced by habitat emojis */
        }

        /* Floating background decorations on home */
        .home-screen::before {
            content: '🍀';
            position: absolute;
            top: 120px;
            right: -10px;
            font-size: 40px;
            opacity: 0.12;
            pointer-events: none;
            animation: homeDecoFloat 7s ease-in-out infinite;
        }

        .home-screen::after {
            content: '✨';
            position: absolute;
            top: 350px;
            left: -5px;
            font-size: 30px;
            opacity: 0.12;
            pointer-events: none;
            animation: homeDecoFloat 5s ease-in-out infinite 2s;
        }

        @keyframes homeDecoFloat {
            0%, 100% { transform: translateY(0) rotate(0deg); }
            50% { transform: translateY(-15px) rotate(8deg); }
        }

        .summer-sun {
            position: absolute;
            top: 2px;
            right: 2px;
            width: 100px;
            height: 100px;
            z-index: 2;
            pointer-events: none;
            animation: sunFloat 4s ease-in-out infinite;
            filter: drop-shadow(0 0 20px rgba(255, 213, 79, 0.5));
        }

        .summer-sun img {
            width: 100%;
            height: 100%;
        }

        @keyframes sunFloat {
            0%, 100% { transform: translateY(0) rotate(0deg); }
            50% { transform: translateY(-6px) rotate(5deg); }
        }

        .home-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0;
        }

        .home-user {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .home-user-avatar {
            width: 52px;
            height: 52px;
            border-radius: 50%;
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 26px;
            cursor: pointer;
            transition: transform 0.15s ease;
            box-shadow: 0 4px 16px rgba(46,204,113,0.3);
            border: 3px solid rgba(255,255,255,0.8);
            padding: 0;
            color: inherit;
            font-family: inherit;
        }

        .home-user-avatar:active {
            transform: scale(0.9);
        }

        .home-user-info {
            display: flex;
            flex-direction: column;
        }

        .home-user-greeting {
            font-size: 13px;
            color: var(--text-secondary);
        }

        .home-user-name {
            font-size: 20px;
            font-weight: 800;
            color: var(--text-primary);
        }

        .streak-badge {
            display: flex;
            align-items: center;
            gap: 6px;
            background: linear-gradient(135deg, #9b59b6, #8e44ad);
            padding: 8px 16px;
            border-radius: 24px;
            font-weight: 800;
            font-size: 16px;
            color: white;
            border: 1px solid rgba(255,255,255,0.25);
            box-shadow: 0 4px 16px rgba(155,89,182,0.35);
        }

        .stat-value {
            font-size: 24px;
            font-weight: 800;
            color: white;
            text-shadow: 0 2px 4px rgba(0,0,0,0.15);
        }

        .stat-card:nth-child(1) .stat-value {
            color: white;
        }

        .stat-card:nth-child(3) .stat-value {
            color: white;
        }

        .stat-label {
            font-size: 11px;
            color: rgba(255,255,255,0.85);
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.3px;
        }

        .difficulty-tab {
            flex-shrink: 0;
            padding: 10px 16px;
            border-radius: 25px;
            border: 1px solid var(--glass-border);
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            font-size: 13px;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            gap: 6px;
            box-shadow: 0 2px 12px rgba(31,80,50,0.08);
        }

        .difficulty-tab:active {
            transform: scale(0.95);
        }

        .difficulty-tab.active {
            border-color: transparent;
            color: white;
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        }

        .difficulty-tab[data-level="all"].active {
            background: linear-gradient(135deg, #2ecc71, #1fa85a);
            box-shadow: 0 4px 14px rgba(46,204,113,0.4);
        }

        .difficulty-tab[data-level="basic"].active {
            background: linear-gradient(135deg, #58d68d, #2ecc71);
            box-shadow: 0 4px 14px rgba(46,204,113,0.4);
        }

        .difficulty-tab[data-level="intermediate"].active {
            background: linear-gradient(135deg, #1abc9c, #16a085);
            box-shadow: 0 4px 14px rgba(26,188,156,0.4);
        }

        .difficulty-tab[data-level="upper"].active {
            background: linear-gradient(135deg, #9b59b6, #8e44ad);
            box-shadow: 0 4px 14px rgba(155,89,182,0.4);
        }

        .difficulty-tab[data-level="advanced"].active {
            background: linear-gradient(135deg, #8e44ad, #6c3483);
            box-shadow: 0 4px 14px rgba(142,68,173,0.4);
        }

        .difficulty-tab[data-level="beginning"].active {
            background: linear-gradient(135deg, #27ae60, #1e8449);
            box-shadow: 0 4px 14px rgba(39,174,96,0.4);
        }

        .tab-count {
            background: rgba(0,0,0,0.08);
            padding: 2px 8px;
            border-radius: 12px;
            font-size: 11px;
        }

        .difficulty-tab.active .tab-count {
            background: rgba(255,255,255,0.25);
        }

        .section-title {
            font-size: 18px;
            font-weight: 800;
            margin-bottom: 16px;
            color: var(--text-primary);
        }

        .category-card.completed {
            border-color: rgba(46,204,113,0.4);
            background: linear-gradient(135deg, rgba(46,204,113,0.12) 0%, rgba(255,255,255,0.6) 100%);
        }

        .lesson-dot.completed {
            background: var(--accent-green);
        }

        .lesson-dot.current {
            background: var(--accent-blue);
            animation: pulse 1.5s ease infinite;
        }

        @keyframes pulse {
            0%, 100% { transform: scale(1); opacity: 1; }
            50% { transform: scale(1.2); opacity: 0.8; }
        }

        .lesson-info {
            margin-bottom: 16px;
            position: relative;
            z-index: 1;
        }

        .lesson-number {
            font-size: 24px;
            font-weight: 800;
            margin-bottom: 4px;
            text-shadow: 0 2px 4px rgba(0,0,0,0.15);
        }

        .lesson-words-preview {
            font-size: 14px;
            opacity: 0.9;
        }

        .lesson-difficulty {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 12px;
            position: relative;
            z-index: 1;
        }

        .difficulty-badge {
            background: rgba(255,255,255,0.2);
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 700;
            backdrop-filter: blur(4px);
        }

        .difficulty-band {
            font-size: 12px;
            opacity: 0.9;
        }

        .start-lesson-btn {
            width: 100%;
            background: white;
            color: #333;
            box-shadow: 0 6px 0 rgba(0,0,0,0.1);
            border: none;
            font-size: 16px;
            font-weight: 800;
            position: relative;
            z-index: 1;
        }

        .lesson-start-card .start-lesson-btn {
            color: #333;
            font-size: 16px;
            border-radius: 16px;
            padding: 14px;
        }

        .start-lesson-btn:active {
            transform: translateY(3px);
            box-shadow: 0 3px 0 rgba(0,0,0,0.1);
        }

        .start-lesson-btn::before {
            content: '';
        }

        /* History Tabs */
        .history-tabs {
            display: flex;
            gap: 8px;
            margin-bottom: 16px;
        }

        .history-tab {
            flex: 1;
            padding: 12px 16px;
            border: 1px solid var(--glass-border);
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border-radius: 16px;
            font-size: 14px;
            font-weight: 700;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            box-shadow: 0 2px 12px rgba(31,80,50,0.06);
        }

        .history-tab.active {
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            color: white;
            border-color: transparent;
            box-shadow: 0 4px 16px rgba(46,204,113,0.3);
        }

        .history-tab.active .history-tab-count {
            background: rgba(255,255,255,0.2);
        }

        .empty-history {
            text-align: center;
            padding: 32px;
            color: var(--text-secondary);
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-radius: var(--border-radius);
        }

        .history-table {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border-radius: var(--border-radius);
            overflow: hidden;
            border: 1px solid var(--glass-border);
            box-shadow: 0 4px 16px rgba(31,80,50,0.06);
        }

        .history-row {
            display: flex;
            align-items: center;
            padding: 12px 14px;
            border-bottom: 1px solid var(--border-color);
            cursor: pointer;
            transition: background 0.2s ease;
        }

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

        .history-row:active {
            background: var(--bg-secondary);
        }

        .history-lesson-num {
            width: 36px;
            height: 36px;
            background: var(--bg-secondary);
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 800;
            font-size: 14px;
            color: var(--accent-green);
            flex-shrink: 0;
        }

        .history-info {
            flex: 1;
            margin-left: 12px;
            min-width: 0;
        }

        .history-title {
            font-weight: 700;
            font-size: 14px;
            margin-bottom: 2px;
        }

        .history-date {
            font-size: 11px;
            color: var(--text-secondary);
        }

        .history-stats {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-right: 8px;
        }

        .history-points {
            font-weight: 700;
            color: #FF7043;
            font-size: 14px;
        }

        .history-accuracy {
            font-size: 12px;
            color: var(--text-secondary);
            background: var(--bg-secondary);
            padding: 3px 8px;
            border-radius: 8px;
        }

        .history-accuracy.perfect {
            background: #B2DFDB;
            color: #00695C;
        }

        .history-expand-icon {
            font-size: 12px;
            color: var(--text-secondary);
            transition: transform 0.2s ease;
        }

        .history-row.expanded .history-expand-icon {
            transform: rotate(180deg);
        }

        .history-detail {
            display: none;
            padding: 0 14px 14px 14px;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border-color);
        }

        .history-detail.show {
            display: block;
        }

        .history-words-label {
            font-weight: 600;
            font-size: 12px;
            color: var(--text-primary);
            margin-bottom: 8px;
        }

        .history-words-list {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            margin-bottom: 12px;
        }

        .history-word-tag {
            background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
            padding: 5px 10px;
            border-radius: 16px;
            font-size: 11px;
            font-weight: 600;
            color: #1976d2;
            border: 2px solid #90caf9;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .history-word-tag:active {
            transform: scale(0.95);
            background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
        }

        .relearn-btn {
            width: 100%;
            padding: 12px 16px;
            background: linear-gradient(135deg, #ff9800 0%, #ff5722 100%);
            color: white;
            border: none;
            border-radius: 50px;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
            transition: all 0.2s ease;
        }

        .relearn-btn:active {
            transform: scale(0.95);
        }

        /* History Pagination */
        .history-pagination {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 16px;
            padding: 14px 0 4px;
        }

        .history-page-btn {
            background: var(--bg-card);
            border: 2px solid var(--border-color);
            border-radius: 12px;
            padding: 8px 16px;
            font-family: 'Nunito', sans-serif;
            font-size: 14px;
            font-weight: 700;
            color: var(--accent-green-dark);
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .history-page-btn:active:not(:disabled) {
            transform: scale(0.95);
            background: var(--bg-secondary);
        }

        .history-page-btn:disabled {
            opacity: 0.35;
            cursor: default;
        }

        .history-page-info {
            font-size: 13px;
            font-weight: 700;
            color: var(--text-secondary);
            min-width: 50px;
            text-align: center;
        }

        .mistakes-container.show {
            display: block;
        }

        .review-summary {
            font-size: 14px;
            font-weight: 700;
            color: var(--text-primary);
            margin-bottom: 12px;
            padding: 10px 14px;
            background: linear-gradient(135deg, rgba(155,89,182,0.1), rgba(46,204,113,0.1));
            border: 1px solid var(--glass-border);
            border-radius: 12px;
            text-align: center;
        }

        .review-lesson-card {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-left: 4px solid var(--accent-purple);
            border-radius: var(--border-radius);
            padding: 14px 14px 12px;
            margin-bottom: 12px;
            box-shadow: 0 4px 16px rgba(31,80,50,0.06);
        }

        .review-lesson-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
        }

        .review-lesson-title {
            font-weight: 800;
            font-size: 15px;
            color: var(--text-primary);
        }

        .review-lesson-count {
            background: rgba(155,89,182,0.15);
            color: var(--accent-purple);
            padding: 3px 10px;
            border-radius: 12px;
            font-size: 11px;
            font-weight: 700;
        }

        .review-lesson-words {
            font-size: 13px;
            color: var(--text-secondary);
            margin-bottom: 6px;
            line-height: 1.4;
        }

        .review-lesson-stats {
            font-size: 12px;
            color: var(--accent-purple);
            font-weight: 600;
            margin-bottom: 10px;
        }

        .review-lesson-btn {
            width: 100%;
            padding: 10px 16px;
            background: linear-gradient(135deg, #9b59b6, #8e44ad);
            color: white;
            border: none;
            border-radius: 50px;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            box-shadow: 0 3px 10px rgba(155, 89, 182, 0.3);
            transition: all 0.2s ease;
        }

        .review-lesson-btn:active {
            transform: scale(0.96);
        }

        .clear-mistakes-btn {
            width: 100%;
            padding: 12px 16px;
            background: transparent;
            color: var(--text-secondary);
            border: 2px solid var(--border-color);
            border-radius: 50px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            margin-top: 10px;
        }

        .all-complete-card {
            background: linear-gradient(135deg, #2ecc71, #1abc9c);
            border-radius: var(--border-radius);
            padding: 24px;
            margin-bottom: 24px;
            color: white;
            text-align: center;
            box-shadow: 0 6px 20px rgba(46,204,113,0.25);
        }

        .all-complete-icon {
            font-size: 48px;
            margin-bottom: 12px;
        }

        .all-complete-title {
            font-size: 20px;
            font-weight: 800;
            margin-bottom: 8px;
        }

        .all-complete-subtitle {
            font-size: 14px;
            opacity: 0.9;
        }

        /* ==================== LESSON SCREEN ==================== */
        .lesson-screen {
            display: flex;
            flex-direction: column;
            height: 100%;
            background: var(--bg-primary);
        }

        .lesson-header {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 16px 20px;
            padding-top: calc(16px + var(--safe-area-top));
        }

        .close-btn {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: none;
            border: none;
            color: var(--text-secondary);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            font-weight: 300;
            cursor: pointer;
        }

        .progress-bar-container {
            flex: 1;
            height: 16px;
            background: var(--border-color);
            border-radius: 8px;
            overflow: hidden;
        }

        .progress-bar-fill {
            height: 100%;
            background: var(--accent-green);
            border-radius: 8px;
            transition: width 0.3s ease;
        }

        .lesson-points {
            display: flex;
            align-items: center;
            gap: 4px;
            font-weight: 700;
            color: var(--accent-orange);
        }

        .lesson-content {
            flex: 1;
            padding: 20px;
            display: flex;
            flex-direction: column;
        }

        .lesson-instruction {
            font-size: 22px;
            font-weight: 800;
            margin-bottom: 24px;
            color: var(--text-primary);
        }

        .matching-grid {
            display: flex;
            gap: 12px;
            flex: 1;
        }

        .matching-column {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .match-card {
            flex: 1;
            min-height: 80px;
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 2px solid var(--glass-border);
            border-radius: var(--border-radius-lg);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 12px 10px;
            font-size: 16px;
            font-weight: 700;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s ease;
            word-break: break-word;
            box-shadow: 0 4px 8px rgba(0,0,0,0.08);
        }

        .match-card:active {
            transform: scale(0.97);
        }

        .match-card .card-en {
            display: block;
            font-size: 15px;
            font-weight: 700;
        }

        .match-card .card-ipa {
            display: block;
            font-size: 11px;
            font-weight: 500;
            color: var(--text-secondary);
            margin-top: 2px;
        }

        .match-card .card-emoji {
            font-size: 36px;
            line-height: 1;
            margin-bottom: 6px;
            filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
        }

        .match-card .card-vi {
            font-size: 15px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .match-card .card-example {
            font-size: 10px;
            font-weight: 400;
            color: var(--text-secondary);
            margin-top: 4px;
            font-style: italic;
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .match-card .card-speaker {
            position: absolute;
            top: 4px;
            right: 6px;
            font-size: 14px;
            opacity: 0.6;
            cursor: pointer;
            padding: 4px;
        }

        .match-card .card-speaker:active {
            transform: scale(1.2);
            opacity: 1;
        }

        .match-card {
            position: relative;
        }

        .match-card.selected {
            background: linear-gradient(135deg, rgba(155,89,182,0.15) 0%, rgba(142,68,173,0.1) 100%);
            border-color: #9b59b6;
            box-shadow: 0 0 0 3px rgba(155,89,182,0.25), 0 6px 16px rgba(155,89,182,0.2);
            transform: scale(1.02);
        }

        .match-card.matched {
            background: linear-gradient(135deg, rgba(46,204,113,0.2) 0%, rgba(39,174,96,0.15) 100%);
            border-color: #2ecc71;
            opacity: 0.7;
            pointer-events: none;
            box-shadow: 0 2px 8px rgba(102, 187, 106, 0.3);
        }

        .match-card.wrong {
            background: linear-gradient(135deg, #ffcdd2 0%, #ef9a9a 100%);
            border-color: #ef5350;
            animation: shake 0.4s ease;
            box-shadow: 0 0 0 3px #ffcdd2;
        }

        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            20%, 60% { transform: translateX(-8px); }
            40%, 80% { transform: translateX(8px); }
        }

        /* ==================== LESSON COMPLETE ==================== */
        .lesson-complete {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(180deg, #e8faf0 0%, #e2f5ea 40%, #f5eaff 100%);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 20px;
            /* The bottom bar (68px, z-index 300) is back once the lesson is
               scored, so it paints over the foot of this fixed overlay. Keep
               the Continue button clear of it. */
            padding-bottom: calc(20px + 68px + var(--safe-area-bottom));
            z-index: 200;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }

        .lesson-complete.active {
            opacity: 1;
            pointer-events: auto;
        }

        .complete-icon {
            font-size: 120px;
            margin-bottom: 24px;
            animation: celebrateBounce 0.8s ease infinite;
            filter: drop-shadow(0 4px 8px rgba(255, 193, 7, 0.4));
        }

        @keyframes celebrateBounce {
            0%, 100% { transform: scale(1) rotate(0deg); }
            25% { transform: scale(1.15) rotate(-8deg); }
            50% { transform: scale(1.1) rotate(5deg); }
            75% { transform: scale(1.15) rotate(-3deg); }
        }

        .complete-title {
            font-size: 28px;
            font-weight: 800;
            margin-bottom: 8px;
            color: #1e8449;
        }

        .complete-subtitle {
            font-size: 16px;
            color: var(--text-secondary);
            margin-bottom: 32px;
        }

        .complete-stats {
            display: flex;
            gap: 24px;
            margin-bottom: 40px;
        }

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

        .complete-stat-value {
            font-size: 36px;
            font-weight: 800;
            color: #9b59b6;
            text-shadow: 2px 2px 0 rgba(255,255,255,0.5);
        }

        .complete-stat-label {
            font-size: 14px;
            color: #1a2e1a;
            font-weight: 700;
        }

        .complete-btn {
            width: 100%;
            max-width: 300px;
            background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%) !important;
            box-shadow: 0 6px 0 #1e8449, 0 8px 20px rgba(46, 204, 113, 0.4) !important;
        }

        /* ==================== SPEED CHALLENGE ==================== */
        .speed-challenge-screen {
            padding: 20px;
            padding-bottom: 100px;
        }

        .speed-header {
            text-align: center;
            margin-bottom: 24px;
        }

        .speed-title {
            font-size: 32px;
            font-weight: 800;
            color: #ff6f00;
            text-shadow: 2px 2px 0 rgba(255, 152, 0, 0.3);
        }

        .speed-subtitle {
            font-size: 16px;
            color: var(--text-secondary);
            font-weight: 600;
        }

        .speed-leaderboard {
            background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
            border-radius: var(--border-radius-lg);
            padding: 20px;
            margin-bottom: 24px;
            border: 3px solid #ffc107;
        }

        .leaderboard-title {
            text-align: center;
            font-size: 18px;
            font-weight: 700;
            margin-bottom: 16px;
            color: #ff8f00;
        }

        .leaderboard-stats {
            display: flex;
            justify-content: space-around;
        }

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

        .leaderboard-value {
            display: block;
            font-size: 28px;
            font-weight: 800;
            color: #e65100;
        }

        .leaderboard-label {
            font-size: 12px;
            color: var(--text-secondary);
            font-weight: 600;
        }

        .level-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
        }

        .level-btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 16px;
            border-radius: var(--border-radius-lg);
            border: 3px solid;
            cursor: pointer;
            transition: all 0.2s ease;
            font-family: inherit;
        }

        .level-btn:active {
            transform: scale(0.95);
        }

        .level-btn.level-1 {
            background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
            border-color: #81c784;
        }

        .level-btn.level-2 {
            background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
            border-color: #64b5f6;
        }

        .level-btn.level-3 {
            background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
            border-color: #ffb74d;
        }

        .level-btn.level-4 {
            background: linear-gradient(135deg, #fce4ec 0%, #f8bbd9 100%);
            border-color: #f06292;
        }

        .level-btn.level-5 {
            background: linear-gradient(135deg, #ede7f6 0%, #d1c4e9 100%);
            border-color: #9575cd;
        }

        .level-btn.level-all {
            grid-column: span 2;
            background: linear-gradient(135deg, #fff9c4 0%, #fff176 100%);
            border-color: #ffd54f;
        }

        .level-icon {
            font-size: 32px;
            margin-bottom: 8px;
        }

        .level-name {
            font-size: 16px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .level-verbs {
            font-size: 12px;
            color: var(--text-secondary);
        }

        /* Speed Game Overlay */
        .speed-game-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(180deg, #1a237e 0%, #311b92 100%);
            z-index: 9999;
            display: none;
            flex-direction: column;
            padding: 20px;
            padding-top: calc(20px + var(--safe-area-top));
            padding-bottom: calc(20px + var(--safe-area-bottom));
            overflow-y: auto;
        }

        .speed-game-overlay.active {
            display: flex !important;
        }

        .speed-game-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }

        .speed-exit-btn {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.2);
            border: none;
            color: white;
            font-size: 18px;
            cursor: pointer;
        }

        .speed-game-stats {
            display: flex;
            gap: 10px;
        }

        .speed-score, .speed-streak-display {
            display: flex;
            align-items: center;
            gap: 4px;
            background: rgba(255, 255, 255, 0.2);
            padding: 6px 12px;
            border-radius: 16px;
            color: white;
            font-weight: 700;
            font-size: 14px;
        }

        .speed-progress {
            color: rgba(255, 255, 255, 0.8);
            font-weight: 600;
            font-size: 14px;
        }

        .speed-timer-container {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 12px;
        }

        .speed-timer-clock {
            font-size: 28px;
            font-weight: 800;
            color: #ffeb3b;
            min-width: 45px;
            text-align: center;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        }

        .speed-timer-clock.warning {
            color: #ff9800;
            animation: pulse 0.5s ease infinite;
        }

        .speed-timer-clock.danger {
            color: #f44336;
            animation: pulse 0.3s ease infinite;
        }

        .speed-timer-bar {
            flex: 1;
            height: 12px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 6px;
            overflow: hidden;
        }

        .speed-timer-fill {
            height: 100%;
            background: linear-gradient(90deg, #4caf50 0%, #8bc34a 50%, #ffeb3b 75%, #ff9800 90%, #f44336 100%);
            border-radius: 4px;
            width: 100%;
            transition: width 0.1s linear;
        }

        .speed-game-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
            padding-top: 10px;
            width: 100%;
            max-width: 400px;
            margin: 0 auto;
        }

        .speed-verb-display {
            text-align: center;
            margin-bottom: 16px;
        }

        .verb-label {
            color: rgba(255, 255, 255, 0.7);
            font-size: 12px;
            font-weight: 600;
            margin-bottom: 4px;
        }

        .verb-word {
            font-size: 40px;
            font-weight: 800;
            color: #ffeb3b;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
            margin-bottom: 4px;
        }

        .verb-meaning {
            color: rgba(255, 255, 255, 0.8);
            font-size: 14px;
            font-style: italic;
        }

        .verb-example {
            color: rgba(255, 255, 255, 0.55);
            font-size: 12.5px;
            margin-top: 6px;
            line-height: 1.45;
            max-width: 320px;
            margin-left: auto;
            margin-right: auto;
        }

        .speed-inputs {
            width: 100%;
            max-width: 300px;
            display: flex;
            flex-direction: column;
            gap: 10px;
            margin-bottom: 12px;
        }

        .speed-input-group {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }

        .speed-input-group label {
            color: rgba(255, 255, 255, 0.8);
            font-size: 12px;
            font-weight: 600;
        }

        .speed-input-group input {
            padding: 12px 16px;
            border-radius: 12px;
            border: 3px solid rgba(255, 255, 255, 0.3);
            background: rgba(255, 255, 255, 0.1);
            color: white;
            font-size: 16px;
            font-weight: 700;
            font-family: inherit;
            text-align: center;
            outline: none;
            transition: all 0.2s ease;
        }

        .speed-input-group input:focus {
            border-color: #ffeb3b;
            background: rgba(255, 255, 255, 0.2);
        }

        /* 0.4 alpha measured 2.97:1 against the indigo overlay through the
           field's own white film — under AA, and this is the hint telling a
           child what to type. */
        .speed-input-group input::placeholder {
            color: rgba(255, 255, 255, 0.72);
        }

        .speed-input-group input.correct {
            border-color: #4caf50;
            background: rgba(76, 175, 80, 0.3);
        }

        .speed-input-group input.wrong {
            border-color: #f44336;
            background: rgba(244, 67, 54, 0.3);
        }

        .speed-submit-btn {
            padding: 12px 40px;
            background: linear-gradient(135deg, #4caf50 0%, #43a047 100%);
            color: white;
            border: none;
            border-radius: 50px;
            font-size: 18px;
            font-weight: 800;
            font-family: inherit;
            cursor: pointer;
            box-shadow: 0 4px 0 #2e7d32, 0 6px 20px rgba(76, 175, 80, 0.4);
            transition: all 0.2s ease;
        }

        .speed-submit-btn:active {
            transform: translateY(4px);
            box-shadow: none;
        }

        .speed-submit-btn:disabled {
            background: #666;
            box-shadow: 0 4px 0 #444;
            cursor: not-allowed;
        }

        .speed-feedback {
            margin-top: 12px;
            padding: 12px 20px;
            border-radius: 12px;
            text-align: center;
            font-weight: 700;
            font-size: 15px;
            min-height: 50px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .speed-feedback.correct {
            background: rgba(76, 175, 80, 0.3);
            color: #a5d6a7;
        }

        .speed-feedback.wrong {
            background: rgba(244, 67, 54, 0.3);
            color: #ef9a9a;
        }

        .speed-feedback .correct-answer {
            font-size: 14px;
            margin-top: 8px;
            color: rgba(255, 255, 255, 0.8);
        }

        /* Speed Complete Overlay */
        .speed-complete-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(180deg, #ff6f00 0%, #ff8f00 100%);
            z-index: 10000;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .speed-complete-overlay.active {
            display: flex !important;
        }

        .speed-complete-content {
            text-align: center;
        }

        .speed-complete-icon {
            font-size: 100px;
            animation: bounce 0.6s ease infinite;
        }

        @keyframes bounce {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-20px); }
        }

        .speed-complete-title {
            font-size: 32px;
            font-weight: 800;
            color: white;
            margin: 16px 0;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
        }

        .speed-complete-stats {
            display: flex;
            gap: 24px;
            justify-content: center;
            margin-bottom: 24px;
        }

        .speed-complete-stat {
            text-align: center;
        }

        .speed-complete-stat .stat-value {
            font-size: 36px;
            font-weight: 800;
            color: white;
        }

        .speed-complete-stat .stat-label {
            font-size: 14px;
            color: rgba(255, 255, 255, 0.8);
            font-weight: 600;
        }

        .speed-new-record {
            background: white;
            color: #ff6f00;
            padding: 12px 24px;
            border-radius: 50px;
            font-size: 18px;
            font-weight: 800;
            margin-bottom: 24px;
            animation: pulse 0.5s ease infinite;
        }

        @keyframes pulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.05); }
        }

        /* Speed Challenge History */
        .speed-history-section {
            margin-top: 20px;
        }

        .speed-history-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .speed-history-table {
            background: var(--bg-card);
            border-radius: var(--border-radius);
            overflow: hidden;
            border: 2px solid var(--border-color);
        }

        .speed-history-row {
            display: flex;
            align-items: center;
            padding: 12px 14px;
            border-bottom: 1px solid var(--border-color);
            cursor: pointer;
            transition: background 0.2s ease;
        }

        .speed-history-row:last-child {
            border-bottom: none;
        }

        .speed-history-row:active {
            background: var(--bg-secondary);
        }

        .speed-history-icon {
            width: 36px;
            height: 36px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            flex-shrink: 0;
        }

        .speed-history-icon.level-1 { background: #e8f5e9; }
        .speed-history-icon.level-2 { background: #e3f2fd; }
        .speed-history-icon.level-3 { background: #fff3e0; }
        .speed-history-icon.level-4 { background: #fce4ec; }
        .speed-history-icon.level-5 { background: #ede7f6; }
        .speed-history-icon.level-0 { background: #fff9c4; }

        .speed-history-info {
            flex: 1;
            margin-left: 12px;
            min-width: 0;
        }

        .speed-history-title {
            font-weight: 700;
            font-size: 14px;
            margin-bottom: 2px;
        }

        .speed-history-date {
            font-size: 11px;
            color: var(--text-secondary);
        }

        .speed-history-stats {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-right: 8px;
        }

        .speed-history-score {
            font-weight: 700;
            color: var(--accent-orange);
            font-size: 14px;
        }

        .speed-history-accuracy {
            font-size: 12px;
            color: var(--text-secondary);
            background: var(--bg-secondary);
            padding: 3px 8px;
            border-radius: 8px;
        }

        .speed-history-accuracy.perfect {
            background: #c8e6c9;
            color: var(--accent-green-dark);
        }

        .speed-history-expand {
            font-size: 12px;
            color: var(--text-secondary);
            transition: transform 0.2s ease;
        }

        .speed-history-row.expanded .speed-history-expand {
            transform: rotate(180deg);
        }

        .speed-history-detail {
            display: none;
            padding: 12px 14px;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border-color);
        }

        .speed-history-detail.show {
            display: block;
        }

        .verb-result-list {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .verb-result-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 10px;
            border-radius: 10px;
            background: var(--bg-card);
            font-size: 13px;
        }

        .verb-result-item.correct {
            border-left: 3px solid var(--accent-green);
        }

        .verb-result-item.wrong {
            border-left: 3px solid var(--accent-red);
        }

        .verb-result-icon {
            font-size: 14px;
            flex-shrink: 0;
        }

        .verb-result-text {
            flex: 1;
            min-width: 0;
        }

        .verb-result-forms {
            font-weight: 700;
            color: var(--text-primary);
        }

        .verb-result-user {
            font-size: 11px;
            color: var(--text-secondary);
            margin-top: 2px;
        }

        .verb-result-user .wrong-text {
            color: var(--accent-red);
            text-decoration: line-through;
        }

        /* ==================== PROFILE SCREEN ==================== */
        .profile-screen {
            padding: 20px;
            padding-bottom: 100px;
        }

        .profile-header {
            text-align: center;
            margin-bottom: 24px;
        }

        .profile-avatar {
            width: 100px;
            height: 100px;
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 48px;
            margin: 0 auto 16px;
            box-shadow: 0 8px 24px rgba(46,204,113,0.25);
            border: 3px solid rgba(255,255,255,0.6);
        }

        .profile-name {
            font-size: 24px;
            font-weight: 800;
        }

        .profile-rank {
            font-size: 14px;
            color: var(--text-secondary);
            font-weight: 600;
        }

        .profile-stats-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
            margin-bottom: 24px;
        }

        .profile-stat {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-radius: var(--border-radius);
            padding: 20px;
            text-align: center;
            box-shadow: 0 4px 16px rgba(31,80,50,0.06);
        }

        .profile-stat-icon {
            font-size: 28px;
            margin-bottom: 8px;
        }

        .profile-stat-value {
            font-size: 28px;
            font-weight: 800;
            color: var(--text-primary);
        }

        .profile-stat-label {
            font-size: 12px;
            color: var(--text-secondary);
            font-weight: 600;
        }

        .achievements-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 12px;
            margin-bottom: 24px;
        }

        .achievement {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-radius: 12px;
            padding: 12px;
            text-align: center;
        }

        .achievement.locked {
            opacity: 0.4;
        }

        .achievement-icon {
            font-size: 28px;
        }

        .achievement-name {
            font-size: 9px;
            font-weight: 600;
            color: var(--text-secondary);
            margin-top: 4px;
        }

        .switch-user-btn {
            width: 100%;
            margin-top: 16px;
        }

        /* ==================== TOAST ==================== */
        .toast {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) scale(0.8);
            background: rgba(0, 0, 0, 0.85);
            color: white;
            padding: 20px 32px;
            border-radius: var(--border-radius);
            font-weight: 700;
            font-size: 18px;
            z-index: 500;
            opacity: 0;
            pointer-events: none;
            transition: all 0.3s ease;
        }

        .toast.active {
            opacity: 1;
            transform: translate(-50%, -50%) scale(1);
        }

        /* ==================== CONFETTI ==================== */
        .confetti-container {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            pointer-events: none;
            z-index: 250;
            overflow: hidden;
        }

        .confetti {
            position: absolute;
            width: 10px;
            height: 10px;
            animation: confettiFall 3s ease-out forwards;
        }

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

        /* ==================== MODAL ==================== */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
            z-index: 400;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }

        .modal-overlay.active {
            opacity: 1;
            pointer-events: auto;
        }

        .modal {
            background: var(--bg-primary);
            border-radius: var(--border-radius);
            padding: 24px;
            width: 100%;
            max-width: 320px;
            text-align: center;
            transform: scale(0.9);
            transition: transform 0.3s ease;
        }

        .modal-overlay.active .modal {
            transform: scale(1);
        }

        .modal h3 {
            font-size: 20px;
            margin-bottom: 12px;
        }

        .modal p {
            color: var(--text-secondary);
            margin-bottom: 24px;
            font-size: 14px;
        }

        .modal-buttons {
            display: flex;
            gap: 12px;
        }

        .modal-btn {
            flex: 1;
            padding: 14px;
            border-radius: var(--border-radius);
            font-weight: 700;
            font-family: inherit;
            font-size: 14px;
            cursor: pointer;
            border: none;
        }

        .modal-btn.cancel {
            background: var(--bg-secondary);
            color: var(--text-primary);
        }

        .modal-btn.danger {
            background: var(--error);
            color: white;
        }

        /* ==================== SRS REVIEW CARD ==================== */
        .review-card {
            background: linear-gradient(135deg, #FF6B9D, #C44569);
            border-radius: 20px;
            padding: 16px;
            margin-bottom: 16px;
            color: white;
            box-shadow: 0 6px 20px rgba(255,107,157,0.3);
            position: relative;
            overflow: hidden;
        }

        .review-card::before {
            content: '';
            position: absolute;
            top: -30%;
            right: -15%;
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background: rgba(255,255,255,0.1);
            pointer-events: none;
        }

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

        .review-title {
            font-weight: 700;
            font-size: 15px;
        }

        .review-card.all-caught-up {
            background: linear-gradient(135deg, #82E0AA, #27AE60);
            box-shadow: 0 6px 20px rgba(130,224,170,0.3);
        }

        .review-card.all-caught-up .review-start-btn {
            color: #27AE60;
        }

        /* ==================== COMBO CHAIN ==================== */
        .combo-indicator {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) scale(var(--combo-scale, 1));
            font-size: 32px;
            font-weight: 800;
            color: #FF6D00;
            text-shadow: 0 2px 8px rgba(255, 109, 0, 0.5);
            z-index: 300;
            pointer-events: none;
            animation: comboPopIn 1.2s ease forwards;
        }

        @keyframes comboPopIn {
            0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
            30% { opacity: 1; transform: translate(-50%, -50%) scale(var(--combo-scale, 1.2)); }
            100% { opacity: 0; transform: translate(-50%, -70%) scale(var(--combo-scale, 1)); }
        }

        .combo-break {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 28px;
            font-weight: 800;
            color: var(--accent-red);
            z-index: 300;
            pointer-events: none;
            animation: comboSnap 0.8s ease forwards;
        }

        @keyframes comboSnap {
            0% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
            50% { transform: translate(-50%, -50%) scale(0.9) rotate(5deg); }
            100% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
        }

        /* ==================== DAILY STREAK MODAL (v3.37) ==================== */
        .streak-modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(15, 23, 42, 0.78);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 9000;
            padding: 20px;
            animation: streakOverlayIn 0.25s ease-out;
        }
        .streak-modal-overlay.active { display: flex; }
        @keyframes streakOverlayIn {
            from { opacity: 0; }
            to   { opacity: 1; }
        }
        .streak-modal {
            position: relative;
            background: linear-gradient(160deg, #1e293b 0%, #4c1d95 60%, #be185d 100%);
            color: white;
            border-radius: 24px;
            padding: 28px 22px 22px;
            max-width: 360px;
            width: 100%;
            box-shadow: 0 20px 60px rgba(0,0,0,0.5);
            text-align: center;
            animation: streakModalIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
            max-height: 90vh;
            overflow-y: auto;
        }
        @keyframes streakModalIn {
            from { opacity: 0; transform: translateY(40px) scale(0.85); }
            to   { opacity: 1; transform: none; }
        }
        .streak-modal-close {
            position: absolute;
            top: 8px;
            right: 12px;
            background: rgba(255,255,255,0.10);
            border: none;
            color: white;
            font-size: 24px;
            line-height: 1;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            cursor: pointer;
            transition: background 0.15s;
        }
        .streak-modal-close:hover { background: rgba(255,255,255,0.25); }
        .streak-modal-flame {
            font-size: 56px;
            line-height: 1;
            margin-bottom: 4px;
            animation: streakFlamePulse 2s ease-in-out infinite;
            filter: drop-shadow(0 4px 12px rgba(255,107,53,0.6));
        }
        @keyframes streakFlamePulse {
            0%, 100% { transform: scale(1); }
            50%      { transform: scale(1.10) rotate(-3deg); }
        }
        .streak-modal-streak {
            font-size: 78px;
            font-weight: 900;
            line-height: 1;
            color: #fff;
            text-shadow: 0 4px 16px rgba(0,0,0,0.4);
        }
        .streak-modal-streak.streak-tier-1 { color: #fde68a; }
        .streak-modal-streak.streak-tier-2 { color: #fbbf24; }
        .streak-modal-streak.streak-tier-3 { color: #f97316; text-shadow: 0 4px 24px rgba(249,115,22,0.6); }
        .streak-modal-streak.streak-tier-4 { color: #ef4444; text-shadow: 0 4px 28px rgba(239,68,68,0.7); }
        .streak-modal-unit {
            font-size: 14px;
            font-weight: 800;
            letter-spacing: 3px;
            color: rgba(255,255,255,0.75);
            margin-top: -4px;
            margin-bottom: 14px;
        }
        .streak-modal-greeting {
            font-size: 16px;
            font-weight: 700;
            margin: 0 0 16px;
            line-height: 1.35;
        }
        .streak-modal-calendar {
            display: flex;
            gap: 6px;
            justify-content: center;
            margin-bottom: 16px;
        }
        .streak-modal-day {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            padding: 8px 4px;
            background: rgba(255,255,255,0.08);
            border-radius: 10px;
            transition: background 0.15s;
        }
        .streak-modal-day.studied {
            background: rgba(249,115,22,0.30);
            border: 1px solid rgba(249,115,22,0.50);
        }
        .streak-modal-day.today {
            outline: 2px solid #fbbf24;
            outline-offset: 1px;
        }
        .streak-modal-day-label {
            font-size: 10px;
            font-weight: 700;
            color: rgba(255,255,255,0.75);
            text-transform: uppercase;
        }
        .streak-modal-day-dot {
            font-size: 14px;
            line-height: 1;
        }
        .streak-modal-progress {
            margin-bottom: 14px;
        }
        .streak-modal-progress-bar {
            height: 10px;
            background: rgba(255,255,255,0.12);
            border-radius: 5px;
            overflow: hidden;
            margin-bottom: 6px;
        }
        .streak-modal-progress-fill {
            height: 100%;
            background: linear-gradient(90deg, #fbbf24, #f97316, #ef4444);
            border-radius: 5px;
            transition: width 0.6s ease;
        }
        .streak-modal-progress-label {
            font-size: 12px;
            color: rgba(255,255,255,0.85);
        }
        .streak-modal-progress-label strong {
            color: #fbbf24;
            font-weight: 800;
        }
        .streak-modal-best {
            font-size: 12px;
            color: rgba(255,255,255,0.65);
            margin-bottom: 14px;
        }
        .streak-modal-best strong {
            color: white;
            font-weight: 800;
        }
        .streak-modal-cta {
            display: block;
            width: 100%;
            background: linear-gradient(135deg, #f97316, #ef4444);
            color: white;
            border: none;
            padding: 14px 18px;
            border-radius: 14px;
            font-size: 15px;
            font-weight: 800;
            cursor: pointer;
            box-shadow: 0 6px 20px rgba(249,115,22,0.40);
            font-family: inherit;
            transition: transform 0.05s, box-shadow 0.15s;
        }
        .streak-modal-cta:hover { box-shadow: 0 8px 26px rgba(249,115,22,0.55); }
        .streak-modal-cta:active { transform: scale(0.97); }
        .streak-modal-done {
            background: rgba(34,197,94,0.20);
            border: 1px solid rgba(34,197,94,0.45);
            color: #bbf7d0;
            padding: 12px;
            border-radius: 14px;
            font-size: 13px;
            font-weight: 700;
        }

        /* ==================== STREAK SHIELDS ==================== */
        .shield-display {
            display: inline-block;
            margin-left: 4px;
            font-size: 14px;
            letter-spacing: 2px;
        }

        .shield-display.has-shields {
            animation: shieldPulse 2s ease infinite;
        }

        @keyframes shieldPulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.7; }
        }

        /* ==================== THEME PICKER ==================== */
        .theme-picker {
            display: flex;
            gap: 12px;
            overflow-x: auto;
            padding: 8px 4px;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: none;
        }
        .theme-picker::-webkit-scrollbar { display: none; }

        .theme-card {
            min-width: 100px;
            height: 120px;
            border-radius: 16px;
            background: var(--bg-card);
            border: 2px solid var(--border-color);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 4px;
            cursor: pointer;
            transition: all 0.2s ease;
            flex-shrink: 0;
        }

        .theme-card.active {
            border-color: var(--accent-green);
            box-shadow: 0 0 0 3px rgba(38, 166, 154, 0.2);
        }

        .theme-card.locked {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .theme-card-icon { font-size: 32px; }
        .theme-card-name { font-size: 13px; font-weight: 700; }
        .theme-card-cost { font-size: 11px; color: var(--text-secondary); }

        .pet-info-modal-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.5);
            z-index: 300;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .pet-info-modal {
            background: var(--card-bg, #fff);
            border-radius: 16px;
            padding: 24px 20px;
            max-width: 320px;
            width: 100%;
            position: relative;
            box-shadow: 0 8px 32px rgba(0,0,0,0.2);
        }

        /* .pet-info-close and .pet-info-stages are styled ~7,000 lines below,
           with the rest of the redesigned pet-info modal. The original rules
           that lived here were fully overridden by those and have been
           removed; the two declarations that were NOT overridden (the close
           button's `right`, the stages' `margin-bottom`) moved down with
           them. Do not restyle either one here. */

        .pet-info-stage {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 6px 10px;
            border-radius: 10px;
            background: var(--bg-secondary, #f5f5f5);
        }

        .pet-info-emoji { font-size: 22px; }
        .pet-info-label { font-weight: 600; font-size: 13px; flex: 1; }
        .pet-info-pts { font-size: 12px; color: var(--text-secondary, #888); font-weight: 500; }

        .pet-info-tips {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .pet-info-tip {
            font-size: 12px;
            color: var(--text-secondary, #666);
            line-height: 1.4;
        }

        .pet-creature {
            cursor: pointer;
            display: inline-block;
            position: relative;
            transition: transform 0.2s;
            appearance: none;
            border: 0;
            padding: 0;
            background: transparent;
            color: inherit;
            font: inherit;
            touch-action: manipulation;
        }
        .pet-creature .pd-dog {
            display: block;
            width: auto;
            max-width: min(52vw, 190px);
            height: auto;
        }
        .pet-creature:focus-visible {
            outline: 4px solid #fff;
            outline-offset: 5px;
            border-radius: 42%;
            filter: drop-shadow(0 0 5px rgba(37,99,235,.85));
        }
        .pet-creature img {
            display: block;
            object-fit: contain;
            pointer-events: none;
        }

        .pet-creature.happy {
            animation: petBounce 1.5s ease infinite;
        }

        .pet-creature.sleepy {
            opacity: 0.7;
            animation: petSway 3s ease infinite;
        }

        .pet-creature.sleepy::after {
            content: '💤';
            font-size: 20px;
            position: absolute;
            top: -5px;
            right: calc(50% - 45px);
            animation: petZzz 2s ease infinite;
        }

        .pet-creature.wiggle {
            animation: petWiggle 0.6s ease !important;
        }

        .pet-bubble {
            position: absolute;
            top: -10px;
            left: 50%;
            transform: translateX(-50%);
            background: var(--bg-card);
            border: 2px solid var(--border-color);
            border-radius: 16px;
            padding: 6px 14px;
            font-size: 14px;
            font-weight: 600;
            white-space: nowrap;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            animation: bubblePop 0.3s ease;
            z-index: 10;
        }

        .pet-bubble::after {
            content: '';
            position: absolute;
            bottom: -8px;
            left: 50%;
            transform: translateX(-50%);
            border-left: 8px solid transparent;
            border-right: 8px solid transparent;
            border-top: 8px solid var(--bg-card);
        }

        @keyframes petBounce {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-8px); }
        }

        @keyframes petSway {
            0%, 100% { transform: rotate(0deg); }
            25% { transform: rotate(3deg); }
            75% { transform: rotate(-3deg); }
        }

        @keyframes petZzz {
            0%, 100% { opacity: 0.4; transform: translateY(0); }
            50% { opacity: 1; transform: translateY(-8px); }
        }

        @keyframes petWiggle {
            0%, 100% { transform: rotate(0); }
            20% { transform: rotate(-15deg); }
            40% { transform: rotate(15deg); }
            60% { transform: rotate(-10deg); }
            80% { transform: rotate(10deg); }
        }

        /* ==================== PET HERO ZONE ==================== */
        .pet-hero-zone {
            position: relative;
            width: 100%;
            height: 38dvh;
            min-height: 200px;
            max-height: 300px;
            overflow: hidden;
            overflow: clip;
            border-radius: 0 0 28px 28px;
            flex-shrink: 0;
            transition: filter 1.5s ease;
            isolation: isolate;
        }

        /* 10 Dog Breed Backgrounds — rich 3-stop gradients */
        .pet-hero-zone[data-stage="chihuahua"] { background: linear-gradient(180deg, #c8f0b5 0%, #a8e6a0 50%, #8acc8a 100%); }
        .pet-hero-zone[data-stage="pomeranian"]{ background: linear-gradient(180deg, #fff0f6 0%, #ffc9de 52%, #f783ac 100%); }
        .pet-hero-zone[data-stage="beagle"]    { background: linear-gradient(180deg, #dff0e0 0%, #b5d9b7 50%, #8bbf8e 100%); }
        .pet-hero-zone[data-stage="corgi"]     { background: linear-gradient(180deg, #fff7dd 0%, #ffd58a 52%, #ee9b45 100%); }
        .pet-hero-zone[data-stage="bulldog"]  { background: linear-gradient(180deg, #f8eee7 0%, #d9b99f 52%, #a97b62 100%); }
        .pet-hero-zone[data-stage="husky"]     { background: linear-gradient(180deg, #f0faff 0%, #81d4fa 55%, #0288d1 100%); }
        .pet-hero-zone[data-stage="retriever"] { background: linear-gradient(180deg, #fffde7 0%, #ffe082 50%, #f9a825 100%); }
        .pet-hero-zone[data-stage="shepherd"]  { background: linear-gradient(180deg, #e0f7fa 0%, #4db6ac 55%, #00695c 100%); }
        .pet-hero-zone[data-stage="rottweiler"]{ background: linear-gradient(180deg, #eee9f5 0%, #8d7aa8 55%, #3f3157 100%); }
        .pet-hero-zone[data-stage="tibetan-mastiff"] { background: linear-gradient(180deg, #e8f1f6 0%, #9bb0bd 46%, #60473b 100%); }

        /* Time of day */
        .pet-hero-zone.time-morning   { filter: brightness(1.05) hue-rotate(5deg); }
        .pet-hero-zone.time-afternoon { filter: brightness(1.0); }
        .pet-hero-zone.time-evening   { filter: brightness(0.9) sepia(0.15); }
        .pet-hero-zone.time-night     { filter: brightness(0.6) saturate(0.7); }

        /* Floating habitat emojis */
        .habitat-emojis {
            position: absolute;
            inset: 0;
            pointer-events: none;
            overflow: hidden;
        }
        .habitat-emojis span {
            position: absolute;
            font-size: 24px;
            opacity: 0.55;
            animation: habitatDrift var(--drift-duration, 8s) ease-in-out infinite;
            animation-delay: var(--drift-delay, 0s);
            will-change: transform;
        }
        @keyframes habitatDrift {
            0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0.4; }
            25%  { transform: translateY(-14px) translateX(6px) rotate(8deg); opacity: 0.65; }
            50%  { transform: translateY(-22px) translateX(-5px) rotate(-4deg); opacity: 0.55; }
            75%  { transform: translateY(-10px) translateX(8px) rotate(6deg); opacity: 0.65; }
            100% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0.4; }
        }

        /* Night mode stars */
        .pet-hero-zone.time-night .habitat-emojis span {
            animation: starTwinkle 3s ease-in-out infinite;
            animation-delay: var(--drift-delay, 0s);
        }
        @keyframes starTwinkle {
            0%, 100% { opacity: 0.3; transform: scale(0.9); }
            50%       { opacity: 0.9; transform: scale(1.1); }
        }

        /* Hero top bar — glassmorphism HUD inside the close-up pet habitat. */
        .pet-hero-topbar {
            position: sticky;
            top: 0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 8px max(10px, env(safe-area-inset-right))
                     8px max(10px, env(safe-area-inset-left));
            background: linear-gradient(to bottom, rgba(0,0,0,0.25) 0%, transparent 100%);
            z-index: 10;
        }
        .pet-hero-left, .pet-hero-right {
            display: flex;
            align-items: center;
            gap: 6px;
            min-width: 0;
        }
        .pet-hero-right { gap: 4px; }
        .pet-hero-avatar {
            width: 44px; height: 44px;
            border-radius: 50%;
            background: rgba(255,255,255,0.25);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            cursor: pointer;
            backdrop-filter: blur(4px);
            border: 2px solid rgba(255,255,255,0.4);
            transition: transform 0.15s ease;
            padding: 0;
            flex: 0 0 44px;
        }
        .pet-hero-avatar:active { transform: scale(0.9); }
                        .pet-hero-identity {
            min-width: 0;
            max-width: 120px;
            padding: 5px 8px 6px;
            border: 1px solid rgba(255,255,255,.38);
            border-radius: 13px;
            color: #fff;
            background: rgba(17,24,39,.38);
            box-shadow: 0 4px 12px rgba(15,23,42,.12);
            backdrop-filter: blur(7px);
        }
        .pet-identity-name {
            display: flex;
            align-items: baseline;
            justify-content: space-between;
            gap: 6px;
            line-height: 1.05;
        }
        .pet-identity-name strong {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 12px;
        }
        .pet-identity-name > span { font-size: 10px; font-weight: 900; color: #fde68a; }
        .pet-identity-style {
            display: flex;
            align-items: center;
            gap: 5px;
            margin-top: 4px;
            font-size: 9px;
            font-weight: 700;
            color: rgba(255,255,255,.82);
            white-space: nowrap;
        }
        .pet-identity-style > span:first-child {
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .pet-polish-meter { display: inline-flex; gap: 2px; flex: 0 0 auto; }
        .pet-polish-pip {
            width: 4px;
            height: 4px;
            border-radius: 50%;
            background: rgba(255,255,255,.3);
            box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);
        }
        .pet-polish-pip.active {
            background: #fde047;
            box-shadow: 0 0 5px rgba(253,224,71,.9);
        }
        .pet-hero-streak {
            background: rgba(0,0,0,0.35);
            color: #FF8A65;
            font-size: 13px;
            font-weight: 700;
            padding: 5px 10px;
            border-radius: 20px;
            backdrop-filter: blur(4px);
            transition: background 0.5s ease, color 0.5s ease, box-shadow 0.5s ease;
        }
        /* Streak Tier 1: 3-6 days — warm orange glow */
        .pet-hero-streak.streak-tier-1 {
            background: rgba(255, 109, 0, 0.5);
            color: #FFE082;
            box-shadow: 0 0 8px rgba(255,109,0,0.5);
        }
        /* Streak Tier 2: 7-13 days — red pulse */
        .pet-hero-streak.streak-tier-2 {
            background: rgba(198, 40, 40, 0.55);
            color: #FFCC80;
            animation: streakTier2Pulse 2s ease-in-out infinite;
        }
        @keyframes streakTier2Pulse {
            0%, 100% { box-shadow: 0 0 8px rgba(198,40,40,0.4); }
            50%      { box-shadow: 0 0 16px rgba(198,40,40,0.8); }
        }
        /* Streak Tier 3: 14-29 days — gold shimmer */
        .pet-hero-streak.streak-tier-3 {
            background: linear-gradient(135deg, rgba(183,118,0,0.6), rgba(255,193,7,0.6));
            background-size: 200% 200%;
            color: #FFF9C4;
            animation: streakTier3Shimmer 3s ease infinite;
        }
        @keyframes streakTier3Shimmer {
            0%   { background-position: 0% 50%; }
            50%  { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }
        /* Streak Tier 4: 30+ days — rainbow */
        .pet-hero-streak.streak-tier-4 {
            background: linear-gradient(135deg, #e53935, #fb8c00, #fdd835, #43a047, #1e88e5, #8e24aa);
            background-size: 300% 300%;
            color: #fff;
            font-weight: 900;
            animation: streakRainbow 3s linear infinite;
        }
        @keyframes streakRainbow {
            0%   { background-position: 0% 50%; }
            50%  { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }
        .pet-hero-coins {
            background: rgba(0,0,0,0.35);
            color: #FFD54F;
            font-size: 13px;
            font-weight: 700;
            padding: 5px 12px;
            border-radius: 20px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 4px;
            backdrop-filter: blur(4px);
            transition: transform 0.15s ease;
            animation: coinPulse 4s ease infinite;
            border: 0;
            min-height: 44px;
            font-family: inherit;
        }
        .pet-hero-coins:active { transform: scale(0.92); }
        @keyframes coinPulse {
            0%, 90%, 100% { box-shadow: none; }
            95% { box-shadow: 0 0 0 3px rgba(255,213,79,0.4); }
        }
        .pet-hero-info {
            width: 44px; height: 44px;
            border-radius: 50%;
            border: none;
            background: rgba(255,255,255,0.2);
            color: white;
            font-size: 16px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            backdrop-filter: blur(4px);
        }

        /* Pet hero stage — the creature area */
        .pet-hero-stage {
            position: absolute;
            /* Clear of the hearts/XP strip below — the drawn dog is taller
               than the emoji it replaced. */
            bottom: 78px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
            z-index: 5;
            overflow: visible;
        }

        /* Shop button in hero */
        .pet-bottom-strip {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 6px;
        }
        .pet-bottom-left {
            flex: 1;
        }
        .pet-shop-btn-hero {
            background: rgba(255,255,255,0.25);
            color: white;
            border: 2px solid rgba(255,255,255,0.4);
            border-radius: 18px;
            padding: 6px 18px;
            font-size: 13px;
            font-weight: 700;
            cursor: pointer;
            backdrop-filter: blur(4px);
            transition: transform 0.15s;
            flex-shrink: 0;
            min-height: 44px;
            font-family: inherit;
        }
        .pet-shop-btn-hero:active { transform: scale(0.94); }

        /* XP bar at bottom of hero zone */
        .pet-hero-xpbar {
            position: absolute;
            bottom: 10px;
            left: 16px; right: 16px;
            z-index: 8;
        }
        .pet-hero-xp-track {
            height: 8px;
            background: rgba(0,0,0,0.2);
            border-radius: 6px;
            overflow: hidden;
        }
        .pet-hero-xp-fill {
            height: 100%;
            background: linear-gradient(90deg, rgba(255,255,255,0.5), rgba(255,255,255,0.9));
            border-radius: 6px;
            transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
        }
        .pet-hero-xp-label {
            display: block;
            text-align: center;
            font-size: 11px;
            font-weight: 600;
            color: rgba(255,255,255,0.7);
            margin-top: 2px;
        }

        /* ==================== PET ANIMATIONS ==================== */

        /* Idle breathing — always on */
        .pet-creature:not(.pet-tapped):not(.wiggle) {
            animation: petBreath 3.5s ease-in-out infinite;
            transform-origin: bottom center;
            will-change: transform;
        }

        /* Tap squish */
        .pet-creature.pet-tapped {
            animation: petSquish 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
        }
        @keyframes petSquish {
            0%   { transform: scale(1.0, 1.0); }
            25%  { transform: scale(1.15, 0.85); }
            60%  { transform: scale(0.92, 1.08); }
            100% { transform: scale(1.0, 1.0); }
        }
        @keyframes petBreath {
            0%, 100% { transform: scaleY(1) scaleX(1); }
            40%      { transform: scaleY(1.04) scaleX(0.98); }
            60%      { transform: scaleY(1.04) scaleX(0.98); }
        }

        /* Happy bounce overrides breathing */
        .pet-creature.happy:not(.pet-tapped) {
            animation: petHeroBounce 1.8s ease infinite !important;
        }
        @keyframes petHeroBounce {
            0%, 100% { transform: translateY(0) scale(1.0); }
            40%      { transform: translateY(-10px) scale(0.97); }
            60%      { transform: translateY(-8px) scale(0.98); }
            80%      { transform: translateY(-2px) scale(1.01); }
        }

        /* Sleepy/hungry sway */
        .pet-creature.sleepy:not(.pet-tapped),
        .pet-creature.hungry:not(.pet-tapped) {
            animation: petSway 3.5s ease-in-out infinite !important;
        }
        .pet-creature.starving:not(.pet-tapped) {
            filter: grayscale(0.5) brightness(0.75);
            animation: petSway 2.5s ease-in-out infinite !important;
        }

        /* Breed glow effects (applied to container, affects img child) */
        .pet-creature[data-stage="pomeranian"]{ filter: drop-shadow(0 0 8px rgba(255,182,193,0.6)); }
        .pet-creature[data-stage="retriever"] { filter: drop-shadow(0 0 10px rgba(255,215,0,0.5)); }
        .pet-creature[data-stage="bulldog"]   { filter: drop-shadow(0 5px 8px rgba(92,57,38,0.38)); }
        .pet-creature[data-stage="husky"]     { filter: drop-shadow(0 0 12px rgba(135,206,250,0.7)); }
        .pet-creature[data-stage="shepherd"]  { filter: drop-shadow(0 0 12px rgba(50,205,50,0.6)); }
        .pet-creature[data-stage="rottweiler"]{ filter: drop-shadow(0 6px 12px rgba(38,25,23,0.48)); }
        .pet-creature[data-stage="tibetan-mastiff"] { filter: drop-shadow(0 8px 16px rgba(55,35,27,0.52)); }

        /* CSS image filters for variant breeds (differentiate reused base images) */
        .pet-creature[data-stage="husky"] img     { filter: hue-rotate(190deg) saturate(0.7) brightness(1.1); }
        .pet-creature[data-stage="tibetan-mastiff"] img { filter: saturate(1.08) contrast(1.06); }

        /* CSS decorations for premium stages */
        .pet-creature[data-stage="husky"]::before {
            content: "❄️";
            position: absolute;
            font-size: 20px;
            top: -8px;
            right: -12px;
            animation: iceFloat 3s ease-in-out infinite;
            pointer-events: none;
            z-index: 3;
        }

        @keyframes iceFloat {
            0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.8; }
            50% { transform: translateY(-8px) rotate(15deg); opacity: 1; }
        }
        @keyframes crownFloat {
            0%, 100% { transform: translateX(-50%) translateY(0); }
            50% { transform: translateX(-50%) translateY(-6px); }
        }

        @keyframes rainbowGlow {
            0%   { filter: drop-shadow(0 0 18px rgba(255,0,0,0.6)); }
            16%  { filter: drop-shadow(0 0 18px rgba(255,165,0,0.6)); }
            33%  { filter: drop-shadow(0 0 18px rgba(255,255,0,0.6)); }
            50%  { filter: drop-shadow(0 0 18px rgba(0,255,0,0.6)); }
            66%  { filter: drop-shadow(0 0 18px rgba(0,0,255,0.6)); }
            83%  { filter: drop-shadow(0 0 18px rgba(148,0,211,0.6)); }
            100% { filter: drop-shadow(0 0 18px rgba(255,0,0,0.6)); }
        }
        @keyframes diamondSparkle {
            0%, 100% { filter: drop-shadow(0 0 20px rgba(255,215,0,0.7)) brightness(1); }
            50%      { filter: drop-shadow(0 0 30px rgba(255,215,0,1)) brightness(1.15); }
        }

        /* Heart burst particles */
        .heart-burst {
            position: absolute;
            top: 20%;
            left: 50%;
            transform: translateX(-50%);
            pointer-events: none;
            font-size: 20px;
            z-index: 20;
        }
        .heart-burst span {
            position: absolute;
            opacity: 0;
            animation: heartFly var(--fly-dur, 0.8s) ease forwards;
            animation-delay: var(--fly-delay, 0s);
        }
        @keyframes heartFly {
            0%   { transform: translate(0, 0) scale(0.5); opacity: 1; }
            80%  { opacity: 0.8; }
            100% { transform: translate(var(--fly-x, 0), var(--fly-y, -40px)) scale(1.2); opacity: 0; }
        }

        /* Speech bubble (repositioned for hero) */
        .pet-bubble {
            position: absolute;
            top: -16px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(255,255,255,0.95);
            border: none;
            border-radius: 18px;
            padding: 8px 16px;
            font-size: 13px;
            font-weight: 600;
            white-space: nowrap;
            box-shadow: 0 4px 16px rgba(0,0,0,0.15);
            animation: bubblePop 0.3s ease;
            z-index: 15;
            color: #333;
        }
        .pet-bubble::after {
            content: '';
            position: absolute;
            bottom: -7px;
            left: 50%;
            transform: translateX(-50%);
            border-left: 7px solid transparent;
            border-right: 7px solid transparent;
            border-top: 7px solid rgba(255,255,255,0.95);
        }

        /* ==================== HOMEPAGE STREAK PANEL (v3.38) ==================== */
        .streak-panel {
            /* Natural height — the whole home screen scrolls now (v3.88.2).
               The old flex:1 + inner overflow let flexbox crush this panel
               to a sliver once the skills panel was added below it. */
            flex: none;
            margin-top: -20px;
            padding: 20px 16px 24px;
            background: var(--bg-primary, #f5f5f5);
            border-radius: 24px 24px 0 0;
            position: relative;
            z-index: 15;
            box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
        }
        .home-streak-card {
            background: linear-gradient(160deg, #1e293b 0%, #4c1d95 60%, #be185d 100%);
            color: white;
            border-radius: 22px;
            padding: 22px 18px;
            box-shadow: 0 10px 30px rgba(76, 29, 149, 0.30);
            position: relative;
            overflow: hidden;
        }
        .home-streak-card::before {
            content: '';
            position: absolute;
            top: -40%;
            right: -20%;
            width: 240px;
            height: 240px;
            background: radial-gradient(circle, rgba(251,191,36,0.25) 0%, transparent 70%);
            pointer-events: none;
        }
        .home-streak-head {
            text-align: center;
            position: relative;
            z-index: 1;
        }
                                .home-streak-number.streak-tier-1 span { color: #fde68a; }
        .home-streak-number.streak-tier-2 span { color: #fbbf24; text-shadow: 0 4px 16px rgba(251,191,36,0.45); }
        .home-streak-number.streak-tier-3 span { color: #f97316; text-shadow: 0 4px 22px rgba(249,115,22,0.55); }
        .home-streak-number.streak-tier-4 span { color: #ef4444; text-shadow: 0 4px 28px rgba(239,68,68,0.65); }
                .home-streak-week {
            display: flex;
            gap: 6px;
            justify-content: center;
            margin-bottom: 16px;
            position: relative;
            z-index: 1;
        }
        .home-streak-day {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            padding: 8px 4px;
            background: rgba(255,255,255,0.08);
            border-radius: 10px;
        }
        .home-streak-day.studied {
            background: rgba(249,115,22,0.30);
            border: 1px solid rgba(249,115,22,0.50);
        }
        .home-streak-day.today {
            outline: 2px solid #fbbf24;
            outline-offset: 1px;
        }
        .home-streak-day-label {
            font-size: 10px;
            font-weight: 700;
            color: rgba(255,255,255,0.75);
            text-transform: uppercase;
        }
        .home-streak-day-dot {
            font-size: 14px;
            line-height: 1;
        }
                                                                .home-streak-cta {
            display: block;
            width: 100%;
            background: linear-gradient(135deg, #f97316, #ef4444);
            color: white;
            border: none;
            padding: 14px 18px;
            border-radius: 14px;
            font-size: 15px;
            font-weight: 800;
            cursor: pointer;
            box-shadow: 0 6px 20px rgba(249,115,22,0.45);
            font-family: inherit;
            position: relative;
            z-index: 1;
            transition: transform 0.05s, box-shadow 0.15s;
        }
        .home-streak-cta:hover { box-shadow: 0 8px 26px rgba(249,115,22,0.60); }
        .home-streak-cta:active { transform: scale(0.97); }
        .home-streak-done {
            background: rgba(34,197,94,0.20);
            border: 1px solid rgba(34,197,94,0.45);
            color: #bbf7d0;
            padding: 13px;
            border-radius: 14px;
            font-size: 13px;
            font-weight: 700;
            text-align: center;
            position: relative;
            z-index: 1;
        }

                        .difficulty-chip {
            flex-shrink: 0;
            padding: 6px 14px;
            border-radius: 20px;
            border: 2px solid transparent;
            background: var(--card-bg, #fff);
            font-size: 12px;
            font-weight: 700;
            color: var(--text-secondary, #888);
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            gap: 4px;
            white-space: nowrap;
            box-shadow: 0 2px 8px rgba(0,0,0,0.06);
        }
        .difficulty-chip.active {
            background: linear-gradient(135deg, #764ba2, #667eea);
            color: white;
            border-color: transparent;
            box-shadow: 0 3px 12px rgba(118, 75, 162, 0.35);
        }
                .difficulty-chip.active .chip-count {
            background: rgba(255,255,255,0.25);
        }

        /* Reduced motion */
        @media (prefers-reduced-motion: reduce) {
            .pet-creature, .habitat-emojis span, .heart-burst span,
            .pet-hero-coins, .pet-hero-streak, .hunger-heart, .pet-trash-btn {
                animation: none !important;
                transition: none !important;
            }
        }

        /* Accessory positions — slot-based, scale with dog size */
        .pet-wrapper {
            position: relative;
            display: inline-block;
        }
        .pet-accessory {
            position: absolute;
            pointer-events: none;
            z-index: 2;
            line-height: 1;
            /* font-size set dynamically via inline style */
        }
        /* Equipped accessories are draggable around the dog inside the
           pet-hero-zone box. pointer-events:auto re-enables touch/mouse
           (the base class disables them), touch-action:none stops the
           page from scrolling while dragging on mobile. */
        .pet-accessory.draggable-pet-acc {
            pointer-events: auto;
            cursor: grab;
            touch-action: none;
        }
        .pet-accessory.acc-dragging {
            cursor: grabbing;
            z-index: 50;
            filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
        }
        /* Anatomical slots — JS inline styles override with per-breed anchors.
           These are CSS fallbacks only. */
        .pet-accessory.acc-head   { top: -18%; left: 50%; transform: translateX(-50%); }
        .pet-accessory.acc-eyes   { top: 24%;  left: 50%; transform: translateX(-50%); }
        .pet-accessory.acc-neck   { top: 64%;  left: 50%; transform: translateX(-50%); }
        /* Ambient slots — zone-based, same for all breeds */
        .pet-accessory.acc-body   { top: 20%; left: 50%; transform: translateX(-50%); z-index: 0; opacity: 0.85; }
        .pet-accessory.acc-effect { top: -20%; left: 50%; transform: translateX(-50%); animation: effectFloat 2.5s ease-in-out infinite; }
        .pet-accessory.acc-toy    { bottom: -8%; right: -8%; transform: rotate(15deg); }

        @keyframes effectFloat {
            0%, 100% { transform: translateX(-50%) translateY(0); }
            50%      { transform: translateX(-50%) translateY(-4px); }
        }

        /* Draggable accessories on pet — override pointer-events: none */
        .draggable-pet-acc {
            pointer-events: auto;
            cursor: grab;
            touch-action: none;
            user-select: none;
            z-index: 3;
            transition: filter 0.15s, z-index 0s;
        }
        .draggable-pet-acc:active,
        .acc-dragging {
            cursor: grabbing;
            z-index: 10 !important;
            filter: drop-shadow(0 4px 8px rgba(0,0,0,0.35));
            animation: none !important; /* stop effectFloat etc. during drag */
        }
        .acc-dragging {
            transform: translate(-50%, -50%) scale(1.15) !important;
        }

                        .acc-slot {
            font-size: 22px;
            cursor: pointer;
            border-radius: 8px;
            padding: 2px 4px;
            border: 2px solid transparent;
        }
        .acc-slot.equipped {
            border-color: var(--accent-green);
            background: rgba(76,175,80,0.1);
        }

        /* Pet naming form */
        .pet-name-form {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
            padding: 8px;
        }
        .pet-name-input {
            border: 2px solid var(--accent-green);
            border-radius: 20px;
            padding: 6px 14px;
            font-size: 15px;
            font-weight: 700;
            text-align: center;
            outline: none;
            width: 160px;
        }
        .pet-name-btn {
            background: var(--accent-green);
            color: white;
            border: none;
            border-radius: 20px;
            padding: 6px 20px;
            font-size: 13px;
            font-weight: 700;
            cursor: pointer;
        }

        /* Evolution overlay */
        .evolution-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.7);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            cursor: pointer;
        }
                        
        @keyframes evolutionPop {
            0%   { transform: scale(0); opacity: 0; }
            70%  { transform: scale(1.2); opacity: 1; }
            100% { transform: scale(1); opacity: 1; }
        }
        @keyframes confettiFall {
            0%   { transform: translateY(-40px) rotate(0deg); opacity: 1; }
            100% { transform: translateY(120vh) rotate(720deg); opacity: 0; }
        }

                .pet-shop-modal {
            background: var(--card-bg, #fff);
            border-radius: 16px;
            padding: 20px 16px;
            max-width: 340px;
            width: 100%;
            position: relative;
            box-shadow: 0 8px 32px rgba(0,0,0,0.2);
            max-height: 80vh;
            overflow-y: auto;
        }

        /* .shop-tabs is styled ~5,800 lines below (a 3-column grid). Every
           declaration that used to be here was overridden by it, so nothing
           had to move. */
        .shop-tab {
            flex: 1;
            padding: 6px 0;
            border: 2px solid var(--border-color, #ddd);
            background: none;
            border-radius: 10px;
            font-size: 13px;
            font-weight: 700;
            cursor: pointer;
            color: var(--text-secondary);
        }
        .shop-tab.active {
            background: var(--accent-green, #4CAF50);
            color: white;
            border-color: var(--accent-green, #4CAF50);
        }

        /* Accessory category filter pills */
        .shop-categories {
            display: flex;
            flex-wrap: wrap;
            gap: 4px;
            margin-bottom: 10px;
        }
        .shop-cat-pill {
            padding: 3px 8px;
            border: 1px solid var(--border-color, #ddd);
            background: none;
            border-radius: 12px;
            font-size: 10px;
            font-weight: 700;
            cursor: pointer;
            color: var(--text-secondary);
            white-space: nowrap;
        }
        .shop-cat-pill.active {
            background: var(--accent-green, #4CAF50);
            color: white;
            border-color: var(--accent-green, #4CAF50);
        }

        .shop-items {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .shop-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 10px;
            border-radius: 12px;
            background: var(--bg-secondary, #f5f5f5);
            transition: opacity 0.2s;
        }
        .shop-item.disabled { opacity: 0.5; }
        .shop-item.owned { background: rgba(76,175,80,0.08); }

        .shop-item-emoji {
            font-size: 24px;
            flex-shrink: 0;
        }

                .shop-item-name {
            font-size: 13px;
            font-weight: 700;
        }
        .shop-item-desc {
            font-size: 11px;
            color: var(--text-secondary);
        }

        .shop-buy-btn {
            padding: 4px 10px;
            border: none;
            border-radius: 8px;
            font-size: 11px;
            font-weight: 700;
            cursor: pointer;
            background: linear-gradient(135deg, #FFD700, #FFA000);
            color: #5D4037;
            white-space: nowrap;
            flex-shrink: 0;
        }
        .shop-buy-btn.disabled {
            background: #ccc;
            color: #888;
            cursor: default;
        }
        .shop-buy-btn.owned {
            background: var(--accent-green, #4CAF50);
            color: white;
        }
        .shop-buy-btn.equipped {
            background: #ef5350;
            color: white;
        }
        .shop-buy-btn:active:not(.disabled) { transform: scale(0.95); }

        /* ===== HUNGER HEARTS (Option A) ===== */
        .hunger-hearts-row {
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 2px;
            font-size: 13px;
        }
        .hunger-heart {
            transition: transform 0.3s, opacity 0.3s;
            display: inline-block;
        }
        .hunger-heart.empty {
            opacity: 0.25;
            filter: grayscale(1);
            font-size: 11px;
        }
        .hunger-heart.full {
            animation: heartPulse 2s ease-in-out infinite;
        }
        .hunger-heart.full:nth-child(2) { animation-delay: 0.15s; }
        .hunger-heart.full:nth-child(3) { animation-delay: 0.3s; }
        .hunger-heart.full:nth-child(4) { animation-delay: 0.45s; }
        .hunger-heart.full:nth-child(5) { animation-delay: 0.6s; }
        @keyframes heartPulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.15); }
        }
        .hunger-label {
            font-size: 10px;
            margin-left: 6px;
            color: var(--text-secondary);
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        .hunger-label.hunger-warning {
            color: #ef5350;
            animation: hungerBlink 1s ease-in-out infinite;
        }
        @keyframes hungerBlink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.4; }
        }

        /* ===== FLYING FOOD ANIMATION (Option A) ===== */
        .flying-food {
            position: fixed;
            font-size: 36px;
            z-index: 9999;
            pointer-events: none;
            filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
        }

        /* ===== DOG CHOMP ANIMATION (Option A) ===== */
        .pet-chomp img {
            animation: petChomp 0.5s ease-in-out !important;
        }
        @keyframes petChomp {
            0%   { transform: scale(1) rotate(0deg); }
            15%  { transform: scale(1.12, 0.88) rotate(-2deg); }
            30%  { transform: scale(0.92, 1.08) rotate(2deg); }
            50%  { transform: scale(1.08, 0.92) rotate(-1deg); }
            70%  { transform: scale(0.96, 1.04) rotate(1deg); }
            100% { transform: scale(1) rotate(0deg); }
        }

        /* Feed burst particles (reuses heart-burst pattern) */
        .feed-burst {
            position: absolute;
            top: 50%;
            left: 50%;
            pointer-events: none;
            z-index: 10;
        }
        .feed-burst span {
            position: absolute;
            font-size: 18px;
            opacity: 0;
            animation: feedParticleFly var(--fly-dur, 0.8s) ease-out var(--fly-delay, 0s) forwards;
        }
        @keyframes feedParticleFly {
            0%   { opacity: 1; transform: translate(0, 0) scale(0.5); }
            60%  { opacity: 1; }
            100% { opacity: 0; transform: translate(var(--fly-x, 30px), var(--fly-y, -40px)) scale(1.2); }
        }

        /* ===== FEAST BONUS HINT (Option B) ===== */
        .feast-bonus-hint {
            color: #f59e0b;
            font-weight: 700;
            font-size: 10px;
        }

        /* ===== BOTTOM DRAWER for Food Shop (Option E) ===== */
        .pet-shop-drawer-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.25);
            z-index: 310; /* Above bottom nav (300) */
            display: flex;
            flex-direction: column;
            justify-content: flex-end;
        }
        .pet-shop-drawer-overlay .pet-shop-modal {
            max-width: 100%;
            max-height: 55vh;
            border-radius: 20px 20px 0 0;
            transform: translateY(100%);
            transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
            box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
            padding: 12px 16px 16px;
        }
        .pet-shop-drawer-overlay.open .pet-shop-modal {
            transform: translateY(0);
        }
        /* Drawer handle */
        .pet-shop-drawer-overlay .pet-shop-modal::before {
            content: '';
            display: block;
            width: 40px;
            height: 4px;
            background: var(--text-secondary, #999);
            border-radius: 2px;
            margin: 0 auto 8px;
            opacity: 0.4;
        }

        /* ===== DRAG-TO-FEED (Option E) ===== */
        .draggable-food {
            user-select: none;
            position: relative;
        }
        .draggable-food .food-drag-handle {
            cursor: grab;
            touch-action: none;
        }
        .draggable-food .food-drag-handle:active {
            cursor: grabbing;
            transform: scale(0.96);
        }

        .drag-food-ghost {
            position: fixed;
            font-size: 48px;
            z-index: 9999;
            pointer-events: none;
            transform: translate(-50%, -50%) scale(1.2);
            filter: drop-shadow(0 6px 12px rgba(0,0,0,0.35));
            transition: transform 0.08s ease-out;
        }
        .drag-food-ghost.snap-back {
            transition: all 0.3s ease-in;
            opacity: 0;
            transform: translate(-50%, -50%) scale(0.3) rotate(180deg);
        }

        /* Drop target hint on dog */
        .drop-target-hint {
            animation: dropHintPulse 1.2s ease-in-out infinite !important;
        }
        .drop-target-hint::after {
            content: '🍽️';
            position: absolute;
            top: -8px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 16px;
            animation: dropHintBounce 0.8s ease-in-out infinite;
            z-index: 5;
        }
        @keyframes dropHintPulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.06); }
        }
        @keyframes dropHintBounce {
            0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.6; }
            50% { transform: translateX(-50%) translateY(-6px); opacity: 1; }
        }

        /* Dog excited wiggle when food is near */
        .drop-target-near {
            animation: dropNearWiggle 0.25s ease-in-out infinite !important;
        }
        .drop-target-near img {
            filter: brightness(1.15) !important;
        }
        .drop-target-near::after {
            content: '😋' !important;
            font-size: 20px !important;
            animation: none !important;
            opacity: 1 !important;
        }
        @keyframes dropNearWiggle {
            0%, 100% { transform: rotate(-4deg) scale(1.05); }
            50% { transform: rotate(4deg) scale(1.05); }
        }

        /* ==================== PET POOP SYSTEM ==================== */

        .pet-poop {
            position: absolute;
            font-size: 28px;
            transform: translate(-50%, -50%);
            cursor: grab;
            z-index: 4;
            animation: poopPlop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
            user-select: none;
            -webkit-user-select: none;
            touch-action: none;
            padding: 10px;
            margin: -10px;
        }
        .pet-poop:active { cursor: grabbing; }

        @keyframes poopPlop {
            0%   { transform: translate(-50%, -50%) scale(0) rotate(-30deg); opacity: 0; }
            60%  { transform: translate(-50%, -50%) scale(1.15) rotate(5deg); opacity: 1; }
            100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
        }

        .poop-stink {
            position: absolute;
            top: -14px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 16px;
            animation: stinkWaft 2s ease-in-out infinite;
            pointer-events: none;
        }
        @keyframes stinkWaft {
            0%, 100% { transform: translateX(-50%) translateY(0) rotate(-5deg); opacity: 0.4; }
            50%      { transform: translateX(-50%) translateY(-8px) rotate(5deg); opacity: 0.8; }
        }

        .pet-poop.stinky {
            animation: poopStinkyIdle 3s ease-in-out infinite;
        }
        @keyframes poopStinkyIdle {
            0%, 100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
            25%      { transform: translate(-50%, -50%) scale(1.03) rotate(-2deg); }
            75%      { transform: translate(-50%, -50%) scale(0.97) rotate(2deg); }
        }

        .poop-cleaning {
            animation: poopClean 0.4s ease-in forwards !important;
            pointer-events: none !important;
        }
        @keyframes poopClean {
            0%   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
            50%  { transform: translate(-50%, -50%) scale(1.3); opacity: 0.8; }
            100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
        }

        .drag-poop-ghost {
            position: fixed;
            font-size: 42px;
            z-index: 9999;
            pointer-events: none;
            transform: translate(-50%, -50%) scale(1.1);
            filter: drop-shadow(0 6px 12px rgba(0,0,0,0.35));
            transition: transform 0.08s ease-out;
        }
        .drag-poop-ghost.snap-back {
            transition: all 0.3s ease-in;
            opacity: 0;
            transform: translate(-50%, -50%) scale(0.3) rotate(180deg);
        }

        .pet-trash-btn {
            background: rgba(255,255,255,0.25);
            color: white;
            border: 2px solid rgba(255,255,255,0.4);
            border-radius: 18px;
            padding: 6px 14px;
            font-size: 18px;
            cursor: pointer;
            backdrop-filter: blur(4px);
            transition: transform 0.15s, box-shadow 0.2s;
            flex-shrink: 0;
            margin-right: 6px;
            animation: trashInvite 2s ease-in-out infinite;
            min-width: 44px;
            min-height: 44px;
        }
        .pet-trash-btn:active { transform: scale(0.94); }

        .pet-hero-avatar:focus-visible, .pet-hero-coins:focus-visible,
        .pet-hero-info:focus-visible, .pet-shop-btn-hero:focus-visible,
        .pet-trash-btn:focus-visible {
            outline: 3px solid #fff;
            outline-offset: 2px;
            box-shadow: 0 0 0 5px rgba(37,99,235,.72);
        }

        @media (max-width: 360px) {
            .pet-hero-identity { max-width: 92px; padding-inline: 6px; }
            .pet-hero-avatar { display: none; }
            .pet-hero-topbar { padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
            .pet-hero-coins { padding-inline: 8px; }
            .pet-hero-streak { padding-inline: 8px; }
            .pet-shop-btn-hero { padding-inline: 12px; }
        }

        @keyframes trashInvite {
            0%, 100% { transform: scale(1) rotate(0deg); }
            25%      { transform: scale(1.05) rotate(-3deg); }
            75%      { transform: scale(1.05) rotate(3deg); }
        }

        .trash-drop-hint {
            animation: trashHintPulse 1s ease-in-out infinite !important;
            box-shadow: 0 0 12px rgba(255,255,255,0.6);
        }
        @keyframes trashHintPulse {
            0%, 100% { transform: scale(1); box-shadow: 0 0 8px rgba(255,255,255,0.4); }
            50%      { transform: scale(1.15); box-shadow: 0 0 20px rgba(255,255,255,0.8); }
        }

        .trash-drop-near {
            animation: trashNearWiggle 0.2s ease-in-out infinite !important;
            background: rgba(255,255,255,0.5) !important;
            box-shadow: 0 0 20px rgba(76,175,80,0.6) !important;
            border-color: rgba(76,175,80,0.8) !important;
        }
        @keyframes trashNearWiggle {
            0%, 100% { transform: rotate(-6deg) scale(1.2); }
            50%      { transform: rotate(6deg) scale(1.2); }
        }

        .clean-burst {
            position: absolute;
            top: 50%;
            left: 50%;
            pointer-events: none;
            z-index: 10;
        }
        .clean-burst span {
            position: absolute;
            font-size: 18px;
            opacity: 0;
            animation: feedParticleFly var(--fly-dur, 0.8s) ease-out var(--fly-delay, 0s) forwards;
        }

        /* ==================== STREAK SHIELD SAVED OVERLAY ==================== */
        .shield-saved-overlay {
            position: fixed;
            inset: 0;
            background: linear-gradient(135deg, rgba(46,204,113,0.85), rgba(155,89,182,0.85));
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1100;
            opacity: 0;
            transition: opacity 0.4s ease;
            padding: 24px;
        }
        .shield-saved-overlay.active { opacity: 1; }
        .shield-saved-card {
            background: var(--glass-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid var(--glass-border);
            border-radius: 28px;
            padding: 32px 24px;
            text-align: center;
            max-width: 360px;
            width: 100%;
            box-shadow: 0 20px 60px rgba(0,0,0,0.3);
            animation: shieldPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
        }
        @keyframes shieldPop {
            0% { transform: scale(0.7); opacity: 0; }
            100% { transform: scale(1); opacity: 1; }
        }
        .shield-saved-icon {
            font-size: 80px;
            margin-bottom: 12px;
            filter: drop-shadow(0 4px 12px rgba(46,204,113,0.5));
            animation: shieldFloat 2.5s ease-in-out infinite;
        }
        @keyframes shieldFloat {
            0%, 100% { transform: translateY(0) rotate(0deg); }
            50% { transform: translateY(-8px) rotate(5deg); }
        }
        .shield-saved-title {
            font-size: 28px;
            font-weight: 800;
            margin-bottom: 12px;
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .shield-saved-msg {
            font-size: 15px;
            color: var(--text-primary);
            margin-bottom: 16px;
            line-height: 1.5;
        }
        .shield-saved-remaining {
            font-size: 13px;
            color: var(--text-secondary);
            margin-bottom: 20px;
            font-weight: 600;
        }
        .shield-saved-btn {
            background: linear-gradient(135deg, #2ecc71, #27ae60);
            color: white;
            border: none;
            padding: 14px 32px;
            border-radius: 50px;
            font-size: 16px;
            font-weight: 800;
            cursor: pointer;
            box-shadow: 0 6px 18px rgba(46,204,113,0.4);
            transition: transform 0.15s ease;
        }
        .shield-saved-btn:active { transform: scale(0.96); }

        /* ==================== SHIELD SHOP ==================== */
        .shield-shop-intro {
            background: linear-gradient(135deg, rgba(46,204,113,0.1), rgba(155,89,182,0.1));
            border: 1px solid var(--glass-border);
            border-radius: 16px;
            padding: 14px;
            font-size: 13px;
            line-height: 1.5;
            color: var(--text-primary);
            margin-bottom: 12px;
            text-align: center;
        }
        .shield-tip {
            font-size: 12px;
            color: var(--text-secondary);
            text-align: center;
            margin-top: 10px;
            padding: 10px;
            background: rgba(255,255,255,0.4);
            border-radius: 12px;
        }

        /* ==================== WEEKLY RECAP MODAL ==================== */
        .weekly-recap-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.55);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1050;
            opacity: 0;
            transition: opacity 0.3s ease;
            padding: 20px;
        }
        .weekly-recap-overlay.active { opacity: 1; }
        .weekly-recap-card {
            background: linear-gradient(160deg, #ffffff 0%, #f5eaff 50%, #e2f5ea 100%);
            border-radius: 28px;
            padding: 28px 22px;
            max-width: 380px;
            width: 100%;
            max-height: 88vh;
            overflow-y: auto;
            box-shadow: 0 20px 60px rgba(0,0,0,0.25);
            animation: shieldPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
            position: relative;
        }
        .recap-close {
            position: absolute;
            top: 14px;
            right: 14px;
            background: rgba(0,0,0,0.08);
            border: none;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            font-size: 18px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .recap-header {
            text-align: center;
            margin-bottom: 18px;
        }
        .recap-emoji {
            font-size: 56px;
            margin-bottom: 8px;
            filter: drop-shadow(0 4px 12px rgba(155,89,182,0.3));
        }
        .recap-title {
            font-size: 22px;
            font-weight: 800;
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .recap-week-range {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: 4px;
        }
        .recap-stats-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            margin-bottom: 18px;
        }
        .recap-stat {
            background: rgba(255,255,255,0.7);
            border: 1px solid var(--glass-border);
            border-radius: 16px;
            padding: 14px 10px;
            text-align: center;
        }
        .recap-stat-value {
            font-size: 22px;
            font-weight: 800;
            color: var(--text-primary);
        }
        .recap-stat-label {
            font-size: 11px;
            color: var(--text-secondary);
            font-weight: 600;
            margin-top: 2px;
        }
        .recap-days-row {
            display: flex;
            gap: 6px;
            justify-content: center;
            margin-bottom: 18px;
        }
        .recap-day-pill {
            flex: 1;
            text-align: center;
            padding: 8px 4px;
            border-radius: 10px;
            background: rgba(255,255,255,0.6);
            border: 1px solid var(--glass-border);
            font-size: 11px;
            font-weight: 700;
            color: var(--text-secondary);
        }
        .recap-day-pill.active {
            background: linear-gradient(135deg, #2ecc71, #27ae60);
            color: white;
            border-color: transparent;
            box-shadow: 0 2px 8px rgba(46,204,113,0.3);
        }
        .recap-day-pill .recap-day-dot {
            display: block;
            font-size: 16px;
            margin-bottom: 2px;
        }
        .recap-message {
            background: linear-gradient(135deg, rgba(46,204,113,0.1), rgba(155,89,182,0.1));
            border-radius: 14px;
            padding: 14px;
            text-align: center;
            font-size: 14px;
            line-height: 1.5;
            color: var(--text-primary);
            margin-bottom: 16px;
        }
        .recap-actions {
            display: flex;
            gap: 10px;
        }
        .recap-btn {
            flex: 1;
            border: none;
            padding: 12px;
            border-radius: 50px;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            transition: transform 0.15s ease;
        }
        .recap-btn:active { transform: scale(0.96); }
        .recap-btn-primary {
            background: linear-gradient(135deg, #2ecc71, #27ae60);
            color: white;
            box-shadow: 0 4px 14px rgba(46,204,113,0.35);
        }
        .recap-btn-secondary {
            background: rgba(255,255,255,0.6);
            border: 1px solid var(--glass-border);
            color: var(--text-primary);
        }
        .recap-history-list {
            display: flex;
            flex-direction: column;
            gap: 10px;
            margin-top: 12px;
        }
        .recap-history-item {
            background: rgba(255,255,255,0.6);
            border: 1px solid var(--glass-border);
            border-radius: 14px;
            padding: 12px 14px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: pointer;
            transition: transform 0.15s ease;
        }
        .recap-history-item:active { transform: scale(0.98); }
        .recap-history-week {
            font-size: 13px;
            font-weight: 700;
            color: var(--text-primary);
        }
        .recap-history-stats {
            font-size: 11px;
            color: var(--text-secondary);
            margin-top: 2px;
        }
        .recap-history-arrow {
            font-size: 18px;
            color: var(--accent-purple);
        }
        .recap-history-btn {
            width: 100%;
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            color: var(--text-primary);
            padding: 14px 18px;
            border-radius: 16px;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            text-align: left;
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
            box-shadow: 0 4px 16px rgba(31,80,50,0.06);
            transition: transform 0.15s ease;
        }
        .recap-history-btn:active { transform: scale(0.98); }

        /* Level-up overlay */
        .level-up-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.85);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            cursor: pointer;
            animation: fadeIn 0.3s ease;
        }
        .level-up-text {
            color: #FFD700;
            font-size: 28px;
            font-weight: 900;
            text-shadow: 0 0 20px rgba(255,215,0,0.5);
            animation: evolutionPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
        }
        .level-up-level {
            color: white;
            font-size: 20px;
            font-weight: 700;
            margin-top: 4px;
        }
        .level-up-title {
            color: rgba(255,255,255,0.7);
            font-size: 14px;
            margin-top: 8px;
        }
        .level-up-evolution {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-top: 16px;
        }
        .level-up-stage-name {
            color: #FFD700;
            font-size: 16px;
            font-weight: 700;
            margin-top: 8px;
        }
        .level-up-confetti {
            position: absolute;
            top: 10%;
            left: 50%;
            transform: translateX(-50%);
            font-size: 28px;
            letter-spacing: 8px;
            animation: confettiFall 3s linear infinite;
        }

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        /* Coins earned on lesson complete */
        .complete-coins {
            font-size: 18px;
            font-weight: 800;
            color: #F57F17;
            margin: 4px 0 8px;
            animation: coinPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        @keyframes coinPop {
            0% { transform: scale(0); opacity: 0; }
            70% { transform: scale(1.3); opacity: 1; }
            100% { transform: scale(1); }
        }

        /* Streak bonus label in lesson complete */
        .complete-streak-bonus {
            font-size: 14px;
            font-weight: 700;
            color: #FF8A65;
            margin: 2px 0 6px;
            animation: coinPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        /* Streak milestone overlay */
        .streak-milestone-msg {
            color: rgba(255,255,255,0.9);
            font-size: 16px;
            margin-top: 12px;
            max-width: 280px;
            text-align: center;
            line-height: 1.4;
        }
        .streak-milestone-rewards {
            display: flex;
            gap: 12px;
            margin-top: 16px;
            flex-wrap: wrap;
            justify-content: center;
        }
        .streak-reward-item {
            background: rgba(255,255,255,0.15);
            padding: 6px 14px;
            border-radius: 20px;
            color: #FFD54F;
            font-weight: 700;
            font-size: 14px;
        }
        .streak-acc-unlock {
            color: #FF8A65;
            background: rgba(255,138,101,0.2);
            animation: streakAccPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
        }
        @keyframes streakAccPop {
            0% { transform: scale(0); }
            70% { transform: scale(1.2); }
            100% { transform: scale(1); }
        }
        .streak-next-hint {
            color: rgba(255,255,255,0.6);
            font-size: 13px;
            margin-top: 14px;
        }

        /* Best streak in profile */
        .profile-stat-best {
            font-size: 10px;
            color: #999;
            margin-top: 2px;
        }

        /* Pet info current stage highlight */
        .pet-info-stage.current {
            background: rgba(76,175,80,0.15);
            border: 1px solid rgba(76,175,80,0.3);
        }
        .pet-info-stage.locked {
            opacity: 0.5;
        }

        .wotd-label { font-size: 12px; font-weight: 700; opacity: 0.9; text-transform: uppercase; }
        .wotd-emoji { font-size: 36px; margin: 4px 0; }
        .wotd-word { font-size: 20px; font-weight: 800; }

        .wotd-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.7);
            z-index: 200;
            display: none;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            cursor: pointer;
        }

        .wotd-overlay.active { display: flex; }

        .wotd-panel {
            background: white;
            border-radius: 24px;
            padding: 32px;
            max-width: 320px;
            width: 90%;
            text-align: center;
            animation: panelSlide 0.3s ease;
        }

        .wotd-panel-emoji { font-size: 56px; }
        .wotd-panel-word { font-size: 28px; font-weight: 800; margin: 8px 0; color: var(--text-primary); }
        .wotd-panel-ipa { font-size: 16px; color: var(--text-secondary); margin-bottom: 12px; }
        .wotd-panel-vi { font-size: 22px; font-weight: 700; color: var(--accent-purple); margin-bottom: 12px; }
        .wotd-panel-example { font-size: 15px; color: var(--text-secondary); font-style: italic; line-height: 1.5; }
        .wotd-panel-prompt { font-size: 20px; font-weight: 700; color: var(--accent-green); margin-bottom: 12px; }
        .wotd-panel-challenge { font-size: 15px; color: var(--text-primary); line-height: 1.6; }

        .wotd-speak-btn {
            display: inline-block;
            margin-top: 12px;
            padding: 8px 20px;
            background: var(--accent-green);
            color: white;
            border: none;
            border-radius: 20px;
            font-family: inherit;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
        }

        .wotd-dots {
            display: flex;
            gap: 8px;
            margin-top: 16px;
        }

        .wotd-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: rgba(255,255,255,0.4);
        }

        .wotd-dot.active { background: white; }

        .wotd-tap-hint {
            color: rgba(255,255,255,0.5);
            font-size: 13px;
            margin-top: 16px;
        }

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

        /* ==================== STICKER BOOK ==================== */
        .sticker-counter {
            font-size: 13px;
            color: var(--text-secondary);
            margin-bottom: 8px;
        }

        .sticker-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 10px;
            margin-bottom: 16px;
        }

        .sticker-item {
            width: 100%;
            aspect-ratio: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background: var(--bg-card);
            border-radius: 16px;
            border: 2px solid var(--border-color);
        }

        .sticker-item.locked {
            opacity: 0.35;
            filter: grayscale(1);
        }

        .sticker-item.rare {
            border-color: gold;
            animation: holographic 3s linear infinite;
            box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
        }

        .sticker-emoji { font-size: 28px; }
        .sticker-name { font-size: 10px; font-weight: 600; margin-top: 2px; color: var(--text-secondary); }

        @keyframes holographic {
            0% { border-color: gold; box-shadow: 0 0 8px rgba(255, 215, 0, 0.4); }
            33% { border-color: #ff69b4; box-shadow: 0 0 8px rgba(255, 105, 180, 0.4); }
            66% { border-color: #00bfff; box-shadow: 0 0 8px rgba(0, 191, 255, 0.4); }
            100% { border-color: gold; box-shadow: 0 0 8px rgba(255, 215, 0, 0.4); }
        }

        /* ==================== DAILY CHALLENGE ==================== */
        .daily-challenge-card {
            background: linear-gradient(135deg, #FFB300, #FF8F00);
            border-radius: var(--border-radius);
            padding: 16px;
            margin: 8px 0;
            color: white;
            box-shadow: 0 4px 15px rgba(255, 179, 0, 0.3);
        }

        .dc-header {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 8px;
        }

        .dc-icon { font-size: 24px; }
        .dc-title { font-size: 16px; font-weight: 800; }
        .dc-streak { font-size: 13px; opacity: 0.9; margin-bottom: 10px; }
        .dc-done { font-size: 14px; font-weight: 700; }

        .dc-start-btn {
            background: white !important;
            color: #FF8F00 !important;
        }

        /* Treasure Chest */
        .treasure-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.8);
            z-index: 200;
            display: none;
            align-items: center;
            justify-content: center;
            padding-bottom: calc(68px + var(--safe-area-bottom)); /* clear of the bottom bar */
        }

        .treasure-overlay.active { display: flex; }

        .treasure-content {
            text-align: center;
            color: white;
        }

        .treasure-chest {
            font-size: 72px;
            margin-bottom: 16px;
            animation: chestOpen 1s ease;
        }

        .chest-lid {
            display: inline-block;
            animation: lidLift 0.8s ease forwards;
        }

        .chest-body { display: block; margin-top: -10px; }

        .chest-coin {
            position: absolute;
            font-size: 24px;
            left: 50%;
            top: 50%;
            animation: coinBurst 1s ease forwards;
        }

        .treasure-points {
            font-size: 28px;
            font-weight: 800;
            color: #FFD54F;
            margin: 12px 0 4px;
        }

        .treasure-bonus {
            font-size: 16px;
            opacity: 0.8;
            margin-bottom: 16px;
        }

        @keyframes chestOpen {
            0% { transform: scale(0.5); }
            50% { transform: scale(1.1); }
            100% { transform: scale(1); }
        }

        @keyframes lidLift {
            0% { transform: translateY(0) rotate(0); }
            100% { transform: translateY(-15px) rotate(-20deg); }
        }

        @keyframes coinBurst {
            0% { transform: translate(0, 0) scale(0); opacity: 1; }
            100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
        }

        /* ==================== SENTENCE BUILDER ==================== */
        .sentence-builder-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.85);
            z-index: 200;
            display: none;
            align-items: center;
            justify-content: center;
            padding-bottom: calc(68px + var(--safe-area-bottom)); /* clear of the bottom bar */
        }

        .sentence-builder-overlay.active { display: flex; }

        .sb-content {
            background: white;
            border-radius: 24px;
            padding: 24px;
            max-width: 360px;
            width: 92%;
            max-height: 85vh;
            overflow-y: auto;
            text-align: center;
        }

        .sb-header { margin-bottom: 12px; }
        .sb-title { font-size: 16px; font-weight: 700; color: var(--text-secondary); }
        .sb-word { font-size: 24px; font-weight: 800; margin-top: 4px; }

        .sb-sentence {
            background: var(--bg-secondary);
            border-radius: 16px;
            padding: 16px;
            margin: 12px 0;
            font-size: 16px;
            line-height: 1.8;
            min-height: 60px;
            word-wrap: break-word;
        }

        .sb-palette {
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 6px;
            margin: 12px 0;
        }

        .sb-emoji-btn {
            font-size: 22px;
            padding: 6px;
            border: none;
            background: var(--bg-primary);
            border-radius: 10px;
            cursor: pointer;
            transition: transform 0.1s;
        }

        .sb-emoji-btn:active { transform: scale(0.9); }

        .sb-actions {
            display: flex;
            gap: 8px;
            margin-top: 12px;
            align-items: center;
            justify-content: center;
        }

        .sb-undo-btn, .sb-skip-btn {
            padding: 8px 16px;
            border: none;
            background: var(--bg-primary);
            border-radius: 12px;
            font-family: inherit;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
        }

        .sb-save-btn {
            flex: 1;
        }

        .sentence-card {
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            padding: 10px 14px;
            margin-bottom: 8px;
            text-align: left;
        }

        .sentence-card-word {
            font-size: 12px;
            font-weight: 700;
            color: var(--accent-purple);
            margin-bottom: 4px;
        }

        .sentence-card-text {
            font-size: 14px;
            line-height: 1.5;
        }

        .sentences-list {
            margin-bottom: 16px;
        }

        /* ==================== BATTLE MODE ==================== */
        .battle-card {
            background: linear-gradient(135deg, #ef5350, #FF7043);
            border-radius: var(--border-radius);
            padding: 16px;
            margin: 8px 0;
            color: white;
            text-align: center;
            box-shadow: 0 4px 15px rgba(239, 83, 80, 0.3);
        }

        .battle-card-header {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            margin-bottom: 6px;
        }

        .battle-card-icon { font-size: 24px; }
        .battle-card-title { font-size: 16px; font-weight: 800; }
        .battle-record { font-size: 13px; opacity: 0.9; margin-bottom: 10px; }

        .battle-start-btn {
            background: white !important;
            color: #ef5350 !important;
        }

        .battle-setup-overlay,
        .battle-game-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.85);
            z-index: 200;
            display: none;
            align-items: center;
            justify-content: center;
        }

        .battle-setup-overlay.active,
        .battle-game-overlay.active { display: flex; }

        .battle-setup-content {
            background: white;
            border-radius: 24px;
            padding: 24px;
            max-width: 340px;
            width: 90%;
            text-align: center;
        }

        .battle-setup-content h2 { margin-bottom: 16px; }

        .battle-no-opponents {
            color: var(--text-secondary);
            margin-bottom: 16px;
        }

        .battle-user-list {
            margin-bottom: 16px;
        }

        .battle-user-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 12px;
            border-radius: 12px;
            cursor: pointer;
            transition: background 0.2s;
        }

        .battle-user-item:hover { background: var(--bg-secondary); }
        .battle-user-avatar { font-size: 28px; }
        .battle-user-name { flex: 1; font-weight: 700; text-align: left; }
        .battle-user-points { font-size: 13px; color: var(--text-secondary); }

        .battle-game-content {
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            padding: 16px;
        }

        .battle-game-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            color: white;
            padding: 8px 0;
        }

        .battle-player-tag {
            font-size: 14px;
            font-weight: 700;
            background: rgba(255,255,255,0.2);
            padding: 4px 12px;
            border-radius: 12px;
        }

        .battle-timer {
            font-size: 18px;
            font-weight: 800;
            color: #FFD54F;
        }

        .battle-matching-grid {
            flex: 1;
            display: flex;
            gap: 8px;
            overflow-y: auto;
            padding: 8px 0;
        }

        /* .match-card is shared with the lesson screen, where its translucent
           --glass-bg reads as near-white over the light page. Battle mode puts
           the very same card on rgba(0,0,0,0.85), where it resolves to grey and
           the IPA line drops to 1.77:1. Give it an opaque floor HERE only, so
           the frosted look on the lesson screen is untouched. */
        .battle-matching-grid .match-card {
            background: #ffffff;
        }

        .battle-matching-grid .matching-column {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .battle-ready-content {
            text-align: center;
            color: white;
        }

        .battle-player-num {
            font-size: 16px;
            opacity: 0.8;
        }

        .battle-player-name {
            font-size: 32px;
            font-weight: 800;
            margin: 8px 0 20px;
        }

        .battle-go-btn {
            font-size: 18px;
            padding: 14px 40px;
        }

        .battle-results-content {
            text-align: center;
            color: white;
            max-width: 360px;
            width: 90%;
        }

        .battle-results-title {
            font-size: 24px;
            margin-bottom: 8px;
        }

        .battle-winner-name {
            font-size: 28px;
            font-weight: 800;
            color: #FFD54F;
            margin-bottom: 16px;
        }

        .battle-scores {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 16px;
        }

        .battle-score-card {
            flex: 1;
            background: rgba(255,255,255,0.15);
            border-radius: 16px;
            padding: 16px;
        }

        .battle-score-card.winner {
            border: 2px solid gold;
            box-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
        }

        .battle-score-name { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
        .battle-score-accuracy { font-size: 28px; font-weight: 800; }
        .battle-score-time { font-size: 13px; opacity: 0.8; }
        .battle-vs { font-size: 18px; font-weight: 800; opacity: 0.6; }

        .battle-reward {
            font-size: 18px;
            font-weight: 700;
            color: #FFD54F;
            margin-bottom: 16px;
        }

        /* ==================== WORD HUNT ==================== */
        .word-hunt-card {
            background: linear-gradient(135deg, #00897B, #26A69A);
            border-radius: var(--border-radius);
            padding: 16px;
            margin: 8px 0;
            color: white;
            text-align: center;
            box-shadow: 0 4px 15px rgba(0, 137, 123, 0.3);
        }

        .wh-card-header {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            margin-bottom: 6px;
        }

        .wh-card-icon { font-size: 24px; }
        .wh-card-title { font-size: 16px; font-weight: 800; }
        .wh-card-desc { font-size: 13px; opacity: 0.9; margin-bottom: 10px; }

        .wh-start-btn {
            background: white !important;
            color: #00897B !important;
        }

        .word-hunt-overlay {
            position: fixed;
            inset: 0;
            background: linear-gradient(180deg, #004D40 0%, #00695C 100%);
            z-index: 200;
            display: none;
            flex-direction: column;
        }

        .word-hunt-overlay.active { display: flex; }

        .wh-game-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 16px;
            color: white;
            padding-top: calc(12px + var(--safe-area-top));
        }

        .wh-timer {
            font-size: 22px;
            font-weight: 800;
            color: #A5D6A7;
        }

        .wh-timer.danger { color: #ef5350; animation: pulse 1s infinite; }

        .wh-found {
            font-size: 16px;
            font-weight: 700;
            color: white;
        }

        .wh-targets {
            display: flex;
            gap: 8px;
            padding: 8px 16px;
            overflow-x: auto;
        }

        .wh-target {
            background: rgba(255,255,255,0.15);
            border-radius: 12px;
            padding: 6px 12px;
            color: white;
            font-weight: 700;
            flex-shrink: 0;
        }

        .wh-target.found {
            background: rgba(76, 175, 80, 0.4);
        }

        .wh-target.found .wh-target-word {
            text-decoration: line-through;
            opacity: 0.7;
        }

        .wh-target-vi {
            display: block;
            font-size: 11px;
            font-weight: 400;
            opacity: 0.8;
        }

        .wh-grid {
            display: grid;
            grid-template-columns: repeat(10, 1fr);
            gap: 2px;
            max-width: 380px;
            margin: 12px auto;
            padding: 0 8px;
            touch-action: none;
            user-select: none;
            -webkit-user-select: none;
        }

        .wh-cell {
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255,255,255,0.15);
            border-radius: 6px;
            color: white;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            transition: background 0.15s;
        }

        .wh-cell.selected {
            background: rgba(33, 150, 243, 0.6);
            transform: scale(1.05);
        }

        .wh-cell.found {
            background: rgba(76, 175, 80, 0.5);
        }

        .wh-cell.wrong {
            background: rgba(239, 83, 80, 0.5);
            animation: shake 0.3s ease;
        }

        .wh-meaning-popup {
            position: fixed;
            bottom: 100px;
            left: 50%;
            transform: translateX(-50%);
            background: white;
            color: var(--text-primary);
            padding: 10px 20px;
            border-radius: 16px;
            font-weight: 700;
            font-size: 16px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.3);
            display: none;
            z-index: 210;
        }

        .wh-meaning-popup.active { display: block; animation: panelSlide 0.3s ease; }

        .wh-complete {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: white;
            text-align: center;
            padding: 24px;
        }

        .wh-complete-icon { font-size: 64px; margin-bottom: 16px; }
        .wh-complete h2 { font-size: 24px; margin-bottom: 8px; }
        .wh-complete-score { font-size: 18px; opacity: 0.9; margin-bottom: 4px; }
        .wh-complete-points { font-size: 24px; font-weight: 800; color: #FFD54F; margin-bottom: 20px; }

        /* ==================== PROFILE BACK BUTTON ==================== */
        .profile-back-btn {
            position: sticky;
            top: 0;
            z-index: 10;
            display: flex;
            align-items: center;
            gap: 4px;
            background: var(--bg-primary);
            border: none;
            font-family: 'Nunito', sans-serif;
            font-size: 16px;
            font-weight: 700;
            color: var(--accent-green-dark);
            padding: 12px 20px;
            cursor: pointer;
        }

        .profile-back-btn:active { opacity: 0.7; }

        /* ==================== TOPIC VOCABULARY CARDS ==================== */
        .topic-cards-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
            margin-bottom: 20px;
        }

        .topic-card {
            border-radius: 16px;
            padding: 14px 10px 12px;
            text-align: center;
            cursor: pointer;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            box-shadow: 0 3px 10px rgba(0,0,0,0.08);
            border: 2px solid rgba(0,0,0,0.04);
            position: relative;
            overflow: hidden;
        }

        .topic-card:active {
            transform: scale(0.95);
        }

        .topic-card-img {
            width: 72px;
            height: 72px;
            margin: 0 auto 8px;
        }

        .topic-card-img svg {
            width: 100%;
            height: 100%;
        }

        .topic-card-emoji {
            width: 72px;
            height: 72px;
            margin: 0 auto 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 42px;
            line-height: 1;
        }

        .topic-category-header {
            font-size: 18px;
            font-weight: 800;
            color: #1a1a2e;
            margin: 24px 0 12px;
            padding-bottom: 8px;
            border-bottom: 2px solid rgba(0,0,0,0.06);
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .topic-category-header:first-child {
            margin-top: 8px;
        }

        .topic-cat-count {
            font-size: 13px;
            font-weight: 600;
            color: #999;
            margin-left: 4px;
        }

        .topic-card-word {
            font-size: 15px;
            font-weight: 800;
            color: #1a1a2e;
            margin-bottom: 2px;
            letter-spacing: 0.3px;
        }

        .topic-card-ipa {
            font-size: 11px;
            color: #666;
            margin-bottom: 4px;
            font-style: italic;
        }

        .topic-card-vi {
            font-size: 12px;
            color: #444;
            font-weight: 600;
        }

        .topic-practice-section {
            display: flex;
            flex-direction: column;
            gap: 10px;
            margin-top: 8px;
            margin-bottom: 24px;
        }

        .topic-practice-btn {
            width: 100%;
            padding: 14px 20px;
            border-radius: 14px;
            border: 2px solid rgba(0,0,0,0.06);
            background: white;
            font-size: 15px;
            font-weight: 700;
            color: #333;
            cursor: pointer;
            transition: all 0.2s ease;
            box-shadow: 0 3px 8px rgba(0,0,0,0.06);
        }

        .topic-practice-btn:active {
            transform: scale(0.97);
        }

        .topic-practice-all {
            background: linear-gradient(135deg, #FF8A65, #F4511E);
            color: white;
            border-color: transparent;
            box-shadow: 0 4px 12px rgba(244,81,30,0.3);
        }

        @media (min-width: 400px) {
            .topic-cards-grid {
                grid-template-columns: repeat(3, 1fr);
            }
        }

        /* ==================== TOPICS SCREEN (NEW v3.12) ==================== */
        .topics-screen {
            padding: 20px 16px 100px;
        }
        .topics-header {
            text-align: center;
            margin-bottom: 18px;
        }
        .topics-title {
            font-size: 26px;
            font-weight: 800;
            margin-bottom: 4px;
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .topics-subtitle {
            font-size: 13px;
            color: var(--text-secondary);
        }
                        .topics-diff-tab.active {
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            color: white;
            border-color: transparent;
            box-shadow: 0 4px 12px rgba(46,204,113,0.3);
        }
        .topics-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
        }
        @media (min-width: 400px) {
            .topics-grid { grid-template-columns: repeat(3, 1fr); }
        }
        .topic-card {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-left: 4px solid var(--topic-color, var(--accent-purple));
            border-radius: 18px;
            padding: 14px 10px;
            text-align: center;
            cursor: pointer;
            transition: transform 0.15s ease, box-shadow 0.2s ease;
            box-shadow: 0 3px 12px rgba(31,80,50,0.06);
            font-family: inherit;
        }
        .topic-card:active {
            transform: scale(0.96);
        }
        .topic-card:hover {
            box-shadow: 0 6px 20px rgba(31,80,50,0.12);
        }
        .topic-card-empty {
            opacity: 0.4;
            cursor: not-allowed;
        }
        .topic-card-icon {
            font-size: 32px;
            margin-bottom: 6px;
            filter: drop-shadow(0 2px 6px rgba(0,0,0,0.08));
        }
        .topic-card-name {
            font-size: 12px;
            font-weight: 800;
            color: var(--text-primary);
            line-height: 1.2;
            margin-bottom: 4px;
            min-height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .topic-card-count {
            font-size: 11px;
            color: var(--text-secondary);
            font-weight: 600;
        }
        .topic-card-progress {
            font-size: 10px;
            font-weight: 800;
            color: #2ecc71;
            margin-top: 4px;
            background: rgba(46,204,113,0.12);
            padding: 2px 8px;
            border-radius: 10px;
            display: inline-block;
        }
        .topic-detail-progress {
            font-size: 13px;
            font-weight: 700;
            color: #2ecc71;
            margin-top: 6px;
        }
        .topic-lesson-status {
            font-size: 11px;
            font-weight: 700;
            padding: 3px 10px;
            border-radius: 10px;
            display: inline-block;
            margin-bottom: 6px;
        }
        .topic-lesson-status.status-perfect {
            background: linear-gradient(135deg, rgba(255,214,10,0.2), rgba(255,159,28,0.2));
            color: #b8860b;
        }
        .topic-lesson-status.status-done {
            background: rgba(46,204,113,0.15);
            color: #1e8449;
        }
        .topic-lesson-perfect {
            border-left-color: #FFD60A !important;
        }
        .topic-lesson-done {
            border-left-color: #2ecc71 !important;
        }

        /* ========== SR-AWARE TOPICS (v3.26) ========== */
        /* Daily review banner */
        .topics-sr-banner-slot {
            margin-bottom: 12px;
        }
        .topics-sr-banner {
            display: flex;
            gap: 12px;
            align-items: center;
            width: 100%;
            text-align: left;
            background: linear-gradient(135deg, rgba(58,134,255,0.10), rgba(108,92,231,0.10));
            border: 1px solid rgba(58,134,255,0.25);
            border-radius: 14px;
            padding: 12px 14px;
            cursor: pointer;
            transition: transform 0.05s, box-shadow 0.15s;
            font-family: inherit;
        }
        .topics-sr-banner-due {
            background: linear-gradient(135deg, rgba(245,158,11,0.14), rgba(217,119,6,0.10));
            border-color: rgba(245,158,11,0.40);
            box-shadow: 0 4px 14px rgba(245,158,11,0.15);
        }
        .topics-sr-banner-due:hover {
            transform: translateY(-1px);
            box-shadow: 0 6px 18px rgba(245,158,11,0.25);
        }
        .topics-sr-banner-due:active {
            transform: scale(0.99);
        }
                .topics-sr-banner-clear {
            background: linear-gradient(135deg, rgba(34,197,94,0.10), rgba(16,185,129,0.10));
            border-color: rgba(34,197,94,0.30);
            cursor: default;
        }
        .topics-sr-banner-icon {
            font-size: 28px;
            flex-shrink: 0;
        }
        .topics-sr-banner-text {
            flex: 1;
        }
        .topics-sr-banner-title {
            font-size: 14px;
            font-weight: 800;
            color: #1e293b;
            line-height: 1.3;
        }
        .topics-sr-banner-sub {
            font-size: 12px;
            color: #475569;
            margin-top: 2px;
        }
        .topics-sr-banner-arrow {
            font-size: 22px;
            color: #94a3b8;
            font-weight: 800;
            margin-left: auto;
        }
        /* Topic of the day */
        .topics-totd {
            display: flex;
            gap: 10px;
            align-items: center;
            width: 100%;
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-left: 4px solid var(--topic-color, #6c5ce7);
            border-radius: 12px;
            padding: 10px 12px;
            margin-top: 8px;
            cursor: pointer;
            font-family: inherit;
            text-align: left;
            transition: transform 0.05s;
        }
        .topics-totd:active {
            transform: scale(0.98);
        }
        .topics-totd-label {
            font-size: 11px;
            font-weight: 800;
            text-transform: uppercase;
            color: #92400e;
            background: rgba(245,158,11,0.15);
            padding: 2px 8px;
            border-radius: 6px;
            flex-shrink: 0;
        }
        .topics-totd-name {
            font-size: 13px;
            font-weight: 700;
            color: #1e293b;
        }
        .topics-totd-meta {
            margin-left: auto;
            font-size: 11px;
            color: #64748b;
            font-weight: 600;
        }

        /* Topic card SR badges */
        .topic-card-sr-row {
            display: flex;
            justify-content: center;
            gap: 4px;
            margin-top: 4px;
            flex-wrap: wrap;
        }
        .topic-card-due {
            font-size: 10px;
            font-weight: 800;
            color: #b45309;
            background: rgba(245,158,11,0.15);
            padding: 2px 6px;
            border-radius: 8px;
        }
        .topic-card-struggle {
            font-size: 10px;
            font-weight: 800;
            color: #b91c1c;
            background: rgba(239,68,68,0.12);
            padding: 2px 6px;
            border-radius: 8px;
        }
        .topic-card-mastery {
            margin-top: 6px;
            height: 4px;
            background: rgba(148,163,184,0.20);
            border-radius: 2px;
            overflow: hidden;
        }
        .topic-card-mastery-fill {
            height: 100%;
            background: linear-gradient(90deg, var(--topic-color, #6c5ce7), #10b981);
            border-radius: 2px;
            transition: width 0.4s ease;
        }
        .topic-card-mastery-label {
            font-size: 9px;
            font-weight: 700;
            color: var(--text-secondary, #64748b);
            margin-top: 2px;
            text-align: center;
        }
        .topic-card-warm {
            box-shadow: 0 0 0 1px rgba(245,158,11,0.30), 0 3px 12px rgba(245,158,11,0.10);
        }
        .topic-card-hot {
            box-shadow: 0 0 0 2px rgba(239,68,68,0.40), 0 4px 14px rgba(239,68,68,0.18);
            animation: topicCardPulse 2.4s ease-in-out infinite;
        }
        @keyframes topicCardPulse {
            0%, 100% { box-shadow: 0 0 0 2px rgba(239,68,68,0.40), 0 4px 14px rgba(239,68,68,0.18); }
            50%      { box-shadow: 0 0 0 2px rgba(239,68,68,0.60), 0 6px 20px rgba(239,68,68,0.28); }
        }

        /* Topic detail SR hub */
        .topic-sr-hub {
            background: linear-gradient(135deg, rgba(58,134,255,0.06), rgba(108,92,231,0.06));
            border: 1px solid rgba(58,134,255,0.20);
            border-radius: 14px;
            padding: 14px;
            margin-bottom: 16px;
        }
        .topic-sr-hub-title {
            font-size: 14px;
            font-weight: 800;
            color: #1e293b;
            margin-bottom: 10px;
        }
        .topic-sr-hub-empty {
            text-align: center;
            color: #64748b;
            font-size: 13px;
            background: rgba(148,163,184,0.08);
            border: 1px dashed rgba(148,163,184,0.40);
            border-radius: 10px;
            padding: 14px;
        }
        .topic-sr-review-btn {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 2px;
            width: 100%;
            background: linear-gradient(135deg, #f59e0b, #d97706);
            color: white;
            border: none;
            border-radius: 12px;
            padding: 14px 16px;
            font-size: 16px;
            font-weight: 800;
            cursor: pointer;
            box-shadow: 0 4px 14px rgba(245,158,11,0.30);
            transition: transform 0.05s, box-shadow 0.15s;
            font-family: inherit;
            text-align: left;
        }
        .topic-sr-review-btn:active {
            transform: scale(0.98);
        }
        .topic-sr-review-btn:hover {
            box-shadow: 0 6px 20px rgba(245,158,11,0.42);
        }
        .topic-sr-review-btn-sub {
            font-size: 12px;
            font-weight: 600;
            opacity: 0.92;
        }
        .topic-sr-review-clear {
            text-align: center;
            color: #047857;
            background: rgba(16,185,129,0.10);
            border: 1px solid rgba(16,185,129,0.30);
            border-radius: 10px;
            padding: 12px;
            font-size: 13px;
            font-weight: 700;
        }
        .topic-sr-stacks {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 8px;
            margin-top: 12px;
        }
        .topic-sr-stack {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            background: white;
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            padding: 10px 6px;
            cursor: pointer;
            transition: transform 0.05s, border-color 0.15s;
            font-family: inherit;
        }
        .topic-sr-stack.stack-learning { border-bottom: 3px solid #10b981; }
        .topic-sr-stack.stack-reviewing { border-bottom: 3px solid #3b82f6; }
        .topic-sr-stack.stack-mature { border-bottom: 3px solid #6c5ce7; }
        .topic-sr-stack:not(.disabled):active { transform: scale(0.96); }
        .topic-sr-stack.disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }
        .topic-sr-stack-icon {
            font-size: 24px;
        }
        .topic-sr-stack-count {
            font-size: 22px;
            font-weight: 800;
            color: #1e293b;
            line-height: 1;
        }
        .topic-sr-stack-label {
            font-size: 11px;
            font-weight: 700;
            color: #475569;
            text-align: center;
            line-height: 1.3;
        }
        .topic-sr-stack-meta {
            font-weight: 500;
            color: #94a3b8;
            font-size: 10px;
        }
        .topic-sr-struggle-btn {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 2px;
            width: 100%;
            background: linear-gradient(135deg, #ef4444, #dc2626);
            color: white;
            border: none;
            border-radius: 12px;
            padding: 12px 14px;
            margin-top: 10px;
            font-size: 14px;
            font-weight: 800;
            cursor: pointer;
            box-shadow: 0 4px 14px rgba(239,68,68,0.25);
            font-family: inherit;
            text-align: left;
        }
        .topic-sr-struggle-btn:active { transform: scale(0.98); }
        .topic-sr-struggle-btn-sub {
            font-size: 11px;
            font-weight: 600;
            opacity: 0.92;
        }
        .topic-sr-mastery {
            margin-top: 12px;
            background: white;
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            padding: 10px 12px;
        }
        .topic-sr-mastery-head {
            display: flex;
            justify-content: space-between;
            font-size: 13px;
            font-weight: 800;
            color: #1e293b;
            margin-bottom: 6px;
        }
        .topic-sr-mastery-pct {
            color: #6c5ce7;
        }
        .topic-sr-mastery-bar {
            height: 8px;
            background: rgba(148,163,184,0.20);
            border-radius: 4px;
            overflow: hidden;
            margin-bottom: 4px;
        }
        .topic-sr-mastery-fill {
            height: 100%;
            background: linear-gradient(90deg, #f59e0b, #6c5ce7, #10b981);
            border-radius: 4px;
            transition: width 0.6s ease;
        }
        .topic-sr-mastery-meta {
            font-size: 11px;
            color: #64748b;
            font-weight: 600;
        }

        /* Lesson card SR additions */
        .topic-lesson-warm {
            border-left-color: #f59e0b !important;
            background: linear-gradient(135deg, rgba(245,158,11,0.05), transparent);
        }
        .topic-lesson-hot {
            border-left-color: #ef4444 !important;
            background: linear-gradient(135deg, rgba(239,68,68,0.06), transparent);
        }
        .topic-lesson-mastered {
            border-left-color: #6c5ce7 !important;
            background: linear-gradient(135deg, rgba(108,92,231,0.05), transparent);
        }
        .topic-lesson-status.status-mastered {
            background: linear-gradient(135deg, rgba(108,92,231,0.20), rgba(58,134,255,0.20));
            color: #4c1d95;
        }
        /* Shown only in the moment a hidden gem is found — never on a card. */
        .topic-bonus-again { font-size: 12px; opacity: .85; }

        .topic-lesson-due-chip {
            display: inline-block;
            font-size: 11px;
            font-weight: 800;
            color: #b45309;
            background: rgba(245,158,11,0.15);
            padding: 2px 8px;
            border-radius: 8px;
            margin-left: 6px;
        }
        .topic-lesson-replay-due-btn {
            display: block;
            width: 100%;
            background: linear-gradient(135deg, #f59e0b, #d97706);
            color: white;
            border: none;
            border-radius: 8px;
            padding: 8px 12px;
            margin-top: 6px;
            font-size: 12px;
            font-weight: 700;
            cursor: pointer;
            font-family: inherit;
            transition: transform 0.05s;
        }
        .topic-lesson-replay-due-btn:active {
            transform: scale(0.98);
        }

        /* Topic detail view */
        .topics-detail:empty { display: none; }
        .topic-detail-back {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            color: var(--text-primary);
            padding: 8px 16px;
            border-radius: 50px;
            font-size: 13px;
            font-weight: 700;
            cursor: pointer;
            margin-bottom: 14px;
        }
        .topic-detail-header {
            text-align: center;
            padding: 24px 16px;
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-top: 5px solid var(--topic-color, var(--accent-purple));
            border-radius: 22px;
            margin-bottom: 16px;
            box-shadow: 0 4px 16px rgba(31,80,50,0.08);
        }
        .topic-detail-icon {
            font-size: 56px;
            margin-bottom: 8px;
            filter: drop-shadow(0 4px 12px rgba(0,0,0,0.1));
        }
        .topic-detail-name {
            font-size: 22px;
            font-weight: 800;
            color: var(--text-primary);
            margin-bottom: 4px;
        }
        .topic-detail-meta {
            font-size: 13px;
            color: var(--text-secondary);
            font-weight: 600;
        }
                                                .topic-detail-list-title {
            font-size: 15px;
            font-weight: 800;
            margin-bottom: 10px;
            color: var(--text-primary);
        }
        .topic-words-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .topic-word-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 10px 12px;
            background: var(--glass-bg);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            border: 1px solid var(--glass-border);
            border-radius: 14px;
        }
        .topic-word-emoji {
            font-size: 26px;
            flex-shrink: 0;
            width: 36px;
            text-align: center;
        }
        .topic-word-text {
            flex: 1;
            min-width: 0;
        }
        .topic-word-en {
            font-size: 14px;
            font-weight: 700;
            color: var(--text-primary);
            margin-bottom: 1px;
        }
        .topic-word-vi {
            font-size: 12px;
            color: var(--text-secondary);
            font-weight: 500;
        }
        .topic-word-speak {
            background: rgba(46,204,113,0.12);
            border: none;
            font-size: 16px;
            padding: 6px 10px;
            border-radius: 50px;
            cursor: pointer;
        }
        .topic-word-speak:active {
            background: rgba(46,204,113,0.25);
            transform: scale(0.92);
        }

        /* ==================== GRAMMAR SCREEN (NEW v3.14) ==================== */
        .grammar-screen {
            padding: 20px 16px 110px;
            overflow-y: auto;
        }
        .grammar-header {
            text-align: center;
            margin-bottom: 16px;
        }
        .grammar-title {
            font-size: 26px;
            font-weight: 800;
            margin-bottom: 4px;
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .grammar-subtitle {
            font-size: 13px;
            color: var(--text-secondary);
        }
        .grammar-subtabs {
            display: flex;
            gap: 8px;
            margin-bottom: 16px;
        }
        .grammar-subtab {
            flex: 1;
            padding: 10px;
            border: 1px solid var(--glass-border);
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border-radius: 16px;
            font-size: 14px;
            font-weight: 700;
            color: var(--text-secondary);
            cursor: pointer;
            font-family: inherit;
            transition: all 0.2s ease;
        }
        .grammar-subtab.active {
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            color: white;
            border-color: transparent;
            box-shadow: 0 4px 12px rgba(46,204,113,0.3);
        }
        .grammar-body { }

        /* Bulk expand/collapse bar above the unit list */
        .grammar-units-bulk-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 4px 4px 10px;
            margin-bottom: 4px;
        }
        .grammar-units-bulk-label {
            font-size: 12px;
            font-weight: 700;
            color: var(--text-secondary, #64748b);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        .grammar-units-bulk-btn {
            background: transparent;
            border: 1px solid rgba(108,92,231,0.4);
            color: var(--accent-purple, #6c5ce7);
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 700;
            cursor: pointer;
            font-family: inherit;
            transition: background 0.15s;
        }
        .grammar-units-bulk-btn:hover {
            background: rgba(108,92,231,0.08);
        }

        /* Unit cards */
        .grammar-unit-card {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-left: 5px solid var(--unit-color, var(--accent-purple));
            border-radius: 20px;
            padding: 12px 16px;
            margin-bottom: 10px;
            box-shadow: 0 4px 16px rgba(31,80,50,0.06);
            transition: padding 0.2s ease, box-shadow 0.2s ease;
        }
        .grammar-unit-card.expanded {
            padding: 16px;
            box-shadow: 0 6px 22px rgba(31,80,50,0.10);
        }
        /* Header is now a button (clickable) — keep button defaults from
           leaking and align contents. */
        .grammar-unit-header {
            display: flex;
            align-items: center;
            gap: 12px;
            width: 100%;
            background: transparent;
            border: none;
            padding: 0;
            margin: 0 0 6px 0;
            cursor: pointer;
            font-family: inherit;
            text-align: left;
        }
        .grammar-unit-card.expanded .grammar-unit-header {
            margin-bottom: 8px;
        }
        .grammar-unit-header:hover .grammar-unit-name {
            color: var(--accent-purple, #6c5ce7);
        }
        .grammar-unit-icon {
            font-size: 32px;
            flex-shrink: 0;
        }
        .grammar-unit-card.expanded .grammar-unit-icon {
            font-size: 36px;
        }
        .grammar-unit-text { flex: 1; min-width: 0; }
        .grammar-unit-name {
            font-size: 15px;
            font-weight: 800;
            color: var(--text-primary);
            margin-bottom: 2px;
            transition: color 0.15s;
        }
        .grammar-unit-card.expanded .grammar-unit-name {
            font-size: 16px;
        }
        .grammar-unit-desc {
            font-size: 12px;
            color: var(--text-secondary);
            line-height: 1.4;
            /* When collapsed, truncate the description to one line so cards
               stay short — the user can expand to see the full text. */
            display: -webkit-box;
            -webkit-line-clamp: 1;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        .grammar-unit-card.expanded .grammar-unit-desc {
            -webkit-line-clamp: unset;
            display: block;
            overflow: visible;
        }
        .grammar-unit-toggle {
            flex-shrink: 0;
            font-size: 13px;
            color: var(--text-secondary, #64748b);
            background: rgba(108,92,231,0.08);
            border-radius: 50%;
            width: 26px;
            height: 26px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: transform 0.2s ease, background 0.15s;
        }
        .grammar-unit-card.expanded .grammar-unit-toggle {
            background: rgba(108,92,231,0.18);
            color: var(--accent-purple, #6c5ce7);
        }
        .grammar-unit-header:hover .grammar-unit-toggle {
            background: rgba(108,92,231,0.20);
            color: var(--accent-purple, #6c5ce7);
        }
        /* Animate the expanded body so the open feels smooth */
        .grammar-unit-body {
            animation: grammarUnitOpen 0.25s ease-out;
        }
        @keyframes grammarUnitOpen {
            from { opacity: 0; transform: translateY(-6px); }
            to   { opacity: 1; transform: translateY(0); }
        }
        .grammar-unit-stats {
            font-size: 13px;
            color: var(--text-primary);
            background: rgba(46,204,113,0.08);
            padding: 6px 12px;
            border-radius: 10px;
            margin-bottom: 0;
        }
        .grammar-unit-card.expanded .grammar-unit-stats {
            margin-bottom: 10px;
        }
        .grammar-unit-actions {
            display: flex;
            gap: 8px;
            margin-bottom: 8px;
        }
        .grammar-quiz-btn {
            flex: 1;
            padding: 11px;
            border: none;
            border-radius: 50px;
            font-size: 13px;
            font-weight: 800;
            cursor: pointer;
            transition: transform 0.15s ease;
            font-family: inherit;
        }
        .grammar-quiz-btn:active { transform: scale(0.96); }
        .grammar-btn-primary {
            background: linear-gradient(135deg, #2ecc71, #27ae60);
            color: white;
            box-shadow: 0 4px 12px rgba(46,204,113,0.3);
        }
        .grammar-btn-secondary {
            background: linear-gradient(135deg, #9b59b6, #8e44ad);
            color: white;
            box-shadow: 0 4px 12px rgba(155,89,182,0.3);
        }
        .grammar-unit-meta {
            font-size: 11px;
            color: var(--text-secondary);
            text-align: center;
            font-weight: 600;
        }

        /* Empty state */
        .grammar-empty {
            text-align: center;
            padding: 40px 20px;
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-radius: 20px;
        }
        .grammar-empty-icon { font-size: 48px; margin-bottom: 12px; }
        .grammar-empty-title { font-size: 16px; font-weight: 800; color: var(--text-primary); margin-bottom: 6px; }
        .grammar-empty-sub { font-size: 13px; color: var(--text-secondary); }

        /* History list */
        .grammar-history-list { display: flex; flex-direction: column; gap: 8px; }
        .grammar-history-item {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-left: 4px solid #888;
            border-radius: 14px;
            padding: 12px 14px;
            display: flex;
            align-items: center;
            gap: 12px;
            cursor: pointer;
            transition: transform 0.15s ease;
        }
        .grammar-history-item:active { transform: scale(0.98); }
        .grammar-history-item.history-tier-perfect { border-left-color: #FFD60A; }
        .grammar-history-item.history-tier-great   { border-left-color: #2ecc71; }
        .grammar-history-item.history-tier-ok      { border-left-color: #1abc9c; }
        .grammar-history-item.history-tier-weak    { border-left-color: #ef5350; }
        .grammar-history-emoji { font-size: 28px; flex-shrink: 0; }
        .grammar-history-text { flex: 1; min-width: 0; }
        .grammar-history-unit {
            font-size: 14px;
            font-weight: 800;
            color: var(--text-primary);
            margin-bottom: 2px;
        }
        .grammar-history-meta {
            font-size: 12px;
            color: var(--text-secondary);
            font-weight: 600;
        }
        .grammar-history-arrow {
            font-size: 22px;
            color: var(--accent-purple);
            font-weight: 800;
        }

        /* Quiz screen */
        /* Top bar: Exit on the left, Next on the right (visible only after
           the user submits an answer). Sticky to the top of the scroll
           container so the Next button stays in reach during long
           explanations. */
        .grammar-quiz-topbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 8px;
            margin-bottom: 12px;
            position: sticky;
            top: 0;
            z-index: 50;
            padding: 6px 0;
            background: linear-gradient(180deg, var(--surface, #f8fafc) 70%, rgba(248,250,252,0));
        }
        .grammar-back-btn {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            color: var(--text-primary);
            padding: 8px 14px;
            border-radius: 50px;
            font-size: 13px;
            font-weight: 700;
            cursor: pointer;
            font-family: inherit;
        }
        .grammar-next-btn-top {
            background: linear-gradient(135deg, #10b981, #059669);
            color: white;
            border: none;
            padding: 9px 18px;
            border-radius: 50px;
            font-size: 14px;
            font-weight: 800;
            cursor: pointer;
            font-family: inherit;
            box-shadow: 0 4px 14px rgba(16,185,129,0.35);
            transition: transform 0.05s, box-shadow 0.15s;
            animation: nextBtnPulseIn 0.35s ease-out;
        }
        .grammar-next-btn-top:hover {
            box-shadow: 0 6px 20px rgba(16,185,129,0.45);
        }
        .grammar-next-btn-top:active {
            transform: scale(0.96);
        }
        @keyframes nextBtnPulseIn {
            0%   { transform: scale(0.6); opacity: 0; }
            60%  { transform: scale(1.08); opacity: 1; }
            100% { transform: scale(1);    opacity: 1; }
        }
        .grammar-back-btn-bottom {
            background: var(--glass-bg);
            border: 1px solid var(--glass-border);
            color: var(--text-primary);
            padding: 12px;
            border-radius: 50px;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            font-family: inherit;
            width: 100%;
            margin-top: 16px;
        }
        .grammar-quiz-header { margin-bottom: 14px; }
        .grammar-quiz-unit {
            font-size: 13px;
            color: var(--accent-purple);
            font-weight: 800;
            margin-bottom: 4px;
        }
        .grammar-quiz-progress {
            font-size: 14px;
            color: var(--text-primary);
            font-weight: 700;
            margin-bottom: 6px;
        }
        .grammar-progress-bar {
            background: rgba(155,89,182,0.15);
            height: 6px;
            border-radius: 3px;
            overflow: hidden;
        }
        .grammar-progress-fill {
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            height: 100%;
            transition: width 0.3s ease;
        }
        .grammar-question-card {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-radius: 20px;
            padding: 18px;
            margin-bottom: 14px;
            box-shadow: 0 4px 16px rgba(31,80,50,0.06);
        }
        .grammar-question-tag {
            display: inline-block;
            font-size: 11px;
            font-weight: 700;
            color: white;
            background: linear-gradient(135deg, #9b59b6, #8e44ad);
            padding: 3px 10px;
            border-radius: 10px;
            margin-bottom: 10px;
            text-transform: capitalize;
        }
        .grammar-question-text {
            font-size: 17px;
            font-weight: 700;
            color: var(--text-primary);
            margin-bottom: 14px;
            line-height: 1.5;
        }
        .grammar-options { display: flex; flex-direction: column; gap: 8px; }
        .grammar-option {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 12px 14px;
            background: rgba(255,255,255,0.6);
            border: 2px solid var(--glass-border);
            border-radius: 14px;
            cursor: pointer;
            font-family: inherit;
            font-size: 14px;
            text-align: left;
            transition: all 0.15s ease;
        }
        .grammar-option:active:not(:disabled) {
            transform: scale(0.98);
            background: rgba(155,89,182,0.08);
        }
        .grammar-option:hover:not(:disabled) {
            border-color: var(--accent-purple);
            background: rgba(155,89,182,0.05);
        }
        .grammar-option:disabled { cursor: default; }
        .grammar-option.correct {
            background: rgba(46,204,113,0.15);
            border-color: #2ecc71;
        }
        .grammar-option.wrong {
            background: rgba(239,83,80,0.12);
            border-color: #ef5350;
        }
        .grammar-option-letter {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 26px;
            height: 26px;
            border-radius: 50%;
            background: var(--accent-purple);
            color: white;
            font-weight: 800;
            font-size: 13px;
            flex-shrink: 0;
        }
        .grammar-option.correct .grammar-option-letter { background: #2ecc71; }
        .grammar-option.wrong .grammar-option-letter { background: #ef5350; }
        .grammar-option-text { flex: 1; color: var(--text-primary); font-weight: 600; }

        /* Explanation box */
        .grammar-explanation {
            border-radius: 16px;
            padding: 14px;
            margin-bottom: 14px;
            box-shadow: 0 3px 10px rgba(31,80,50,0.06);
        }
        .grammar-explanation.correct {
            background: linear-gradient(135deg, rgba(46,204,113,0.18), rgba(46,204,113,0.06));
            border-left: 4px solid #2ecc71;
        }
        .grammar-explanation.wrong {
            background: linear-gradient(135deg, rgba(239,83,80,0.18), rgba(239,83,80,0.06));
            border-left: 4px solid #ef5350;
        }
        .grammar-explanation-header {
            font-size: 15px;
            font-weight: 800;
            margin-bottom: 6px;
            color: var(--text-primary);
        }
        .grammar-explanation-body {
            font-size: 14px;
            line-height: 1.5;
            color: var(--text-primary);
        }
        .grammar-next-btn {
            width: 100%;
            padding: 14px;
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            color: white;
            border: none;
            border-radius: 50px;
            font-size: 15px;
            font-weight: 800;
            cursor: pointer;
            box-shadow: 0 6px 18px rgba(46,204,113,0.35);
            font-family: inherit;
        }
        .grammar-next-btn:active { transform: scale(0.97); }

        /* Locked until the student has heard the answer (js/answer-audio.js).
           Greyed and flat so it reads as "not yet", not as a broken button. */
        .grammar-next-btn:disabled {
            background: #cbd5e1;
            color: #94a3b8;
            box-shadow: none;
            cursor: not-allowed;
        }
        .grammar-next-btn:disabled:active { transform: none; }

                /* Every container that prints typeset maths belongs in this list; one
           left out does not go unstyled, it goes to the browser default —
           0.83em at normal weight with `line-height: normal`, which also grows
           the line by 0.18em. The results screen was the one that really hurt:
           `.grammar-review-q` drew the exponent at weight 700 and
           `.grammar-review-explain` at weight 400, so the child met x² one way
           during practice and a thinner, larger one in the review five seconds
           later. (`.grammar-option-text` is belt-and-braces: js/math.js emits
           it together with `math-formula`, so options were already covered.) */
        .math-formula sup, .math-formula sub,
        .grammar-question-text sup, .grammar-question-text sub,
        .grammar-option-text sup, .grammar-option-text sub,
        .grammar-review-q sup, .grammar-review-q sub,
        .grammar-review-explain sup, .grammar-review-explain sub,
        .grammar-explanation sup, .grammar-explanation sub,
        .math-hint-def sup, .math-hint-def sub,
        .math-lesson-body sup, .math-lesson-body sub {
            font-size: 0.75em;
            vertical-align: super;
            line-height: 0;
            font-weight: 800;
            margin-left: 0.5px;
        }
        /* An index rides low, not high — same size and weight as an exponent so
           x₁ and x² look like they belong to the same notation. `line-height: 0`
           is what keeps either of them from growing the line. */
        .math-formula sub,
        .grammar-question-text sub,
        .grammar-option-text sub,
        .grammar-review-q sub,
        .grammar-review-explain sub,
        .grammar-explanation sub,
        .math-hint-def sub,
        .math-lesson-body sub { vertical-align: sub; }
        .grammar-question-text sup { font-size: 0.72em; }

                                                                        /* The hook. Fallback rendering: the √ character itself, sized so its
           ink tops out on the bar. That sizing can only ever be right for ONE
           font — Georgia's √ ink ascent is 0.832em, Times New Roman's 0.913em,
           the generic serif Android falls back to 0.930em — so the browsers
           that can do better get the drawn hook below instead. */
        .math-root-symbol {
            display: inline-block;
            vertical-align: baseline;
            font-family: Georgia, 'Times New Roman', serif;
            font-size: 1.05em;
            line-height: 1;
        }
        .math-root:has(.math-frac) .math-root-symbol { font-size: 2.09em; }
                        /* …and the typed hook has to follow the bar up: 1.12em of bar ÷
           0.832em of Georgia ink ascent. Only the fallback needs this — the
           drawn hook below stretches on its own. */
        .math-root:has(sup) .math-root-symbol { font-size: 1.35em; }

        /* Where masks work, the hook is DRAWN rather than typed, and built to
           the radicand's own height. That buys two things the glyph cannot:
           it is identical on every device instead of depending on which serif
           the phone happens to have, and it grows with its content — the √ of
           √(4/25) reaches down past the denominator, where a glyph left "25"
           dangling 0.78em below the hook's tip.
           The condition also tests `selector(:has(*))`, because this layer only
           works as a whole: a browser with masks but without `:has()` kept the
           .58em gutter and the zero line-height while dropping the mask rule and
           the two `:has()` rules that lift the bar — a radical with no hook and
           a sliced exponent. Firefox before 121 (ESR 115 included), Chrome ≤104,
           Safari ≤15.3 and Samsung Internet ≤20 land there; they now take the
           typed fallback whole. */
        @supports (((mask-image: url("data:image/svg+xml,%3Csvg/%3E")) or (-webkit-mask-image: url("data:image/svg+xml,%3Csvg/%3E"))) and (selector(:has(*)))) {
                        .math-root-symbol {
                position: absolute;
                left: 0;
                top: 0;
                bottom: 0;
                width: .58em;
                font-size: 1em;
                /* The √ character stays in the DOM so the formula still copies
                   and still reads aloud; it is only pushed out of sight. */
                text-indent: -999em;
                overflow: hidden;
                background-color: currentColor;
                /* TWO mask layers, drawn the way TeX builds a tall radical:
                   a HOOK of fixed size pinned to the bottom, and a VERTICAL
                   extender running from the hook's shoulder up to the bar.
                   The first version stretched one SVG to the whole box with
                   preserveAspectRatio="none", so the stroke thinned as the
                   radical grew — √(4/25) at 2.8em had a visibly lighter hook
                   than √9. A vertical line keeps its width at any length, and
                   the hook never scales, so the stroke is the same weight at
                   every height. The hook's rising stroke turns vertical for its
                   last .26em (x 48–58 of a 58-wide box) and the extender is the
                   same .10em wide, overlapping that segment, so there is no
                   seam. Layers union by default; nothing else to declare. */
                -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2058%20100'%3E%3Cpath%20d='M0,50%20L11,42%20L31,80%20L48,26%20L48,0%20L58,0%20L58,30%20L38,100%20L29,100%20L7,58%20Z'%20fill='%23000'/%3E%3C/svg%3E"), linear-gradient(#000, #000);
                mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2058%20100'%3E%3Cpath%20d='M0,50%20L11,42%20L31,80%20L48,26%20L48,0%20L58,0%20L58,30%20L38,100%20L29,100%20L7,58%20Z'%20fill='%23000'/%3E%3C/svg%3E"), linear-gradient(#000, #000);
                -webkit-mask-repeat: no-repeat, no-repeat;
                mask-repeat: no-repeat, no-repeat;
                -webkit-mask-size: .58em 1em, .10em calc(100% - .74em);
                mask-size: .58em 1em, .10em calc(100% - .74em);
                -webkit-mask-position: left bottom, right top;
                mask-position: left bottom, right top;
            }
            /* The fallback sizes the hook by font-size; the drawn one is sized by
               its box, so those two must be neutralised — and in their own rule.
               A selector list is dropped WHOLE if any selector in it is invalid,
               so keeping `:has()` out of the mask rule above is what stops a
               browser that lacks `:has()` from inheriting the .58em gutter with
               no hook drawn in it. */
            .math-root-symbol,
            .math-root:has(sup) .math-root-symbol,
            .math-root:has(.math-frac) .math-root-symbol { font-size: 1em; }
                    }
                        @media (max-width: 420px) {
            .grammar-question-text { line-height: 1.7; }
                                }

                        .math-hist-stat strong { display: block; font-size: 20px; color: var(--primary, #4f46e5); }
        
                .nav-hub-header.math { position: relative; }
        /* The arrow is absolutely placed, so the first line has to step around
           it — otherwise the kicker reads "‹ATH WARS". */
        .nav-hub-header.math.with-back .nav-hub-kicker { padding-left: 42px; }
        
.mf-wallet strong { font-size: 17px; }
.mf-friend-copy strong { display: block; font-size: 16px; color: #1f2937; }
.mf-note.ready { color: #17914f; }
.mf-lock small { display: block; font-size: 9px; font-weight: 950; letter-spacing: .06em; color: #7a8798; }
.mf-lock b { display: block; font-size: 13px; font-weight: 950; font-variant-numeric: tabular-nums; }
.mf-bet p, .mf-invite p { margin: 0 0 14px; font-size: 14px; line-height: 1.5; color: #5d6b7c; }
.mf-stake .win { background: #e6f8ee; color: #11743f; }
.mf-stake .lose { background: #fdecea; color: #a5342a; }
.mf-stake b { display: block; font-size: 20px; }
.mf-score small { display: block; font-size: 9px; letter-spacing: .07em; opacity: .75; }
.mf-score b { font-size: 22px; }
.mf-score.me { background: #e7f2ff; color: #17558f; }
.mf-clock.low { background: #d3392b; animation: nr-ready-pulse 1s ease-in-out infinite alternate; }
.mf-result-score strong { display: block; font-size: 34px; color: #1f2937; }
.mf-result-score b { color: #b6c0cc; }
.mf-result p { margin: 0 0 12px; font-size: 14px; line-height: 1.5; color: #5d6b7c; }
.mf-result-coins.up { background: #e6f8ee; color: #11743f; }
.mf-result-coins.down { background: #fdecea; color: #a5342a; }
@media (max-width: 420px) {
      .mf-stake b { font-size: 17px; }
}
        
                .wars-clock.low { color: #d63a3a; background: rgba(214,58,58,0.14); }
                                        
                                                                                                                                        .wars-mean b { font-size: 20px; color: var(--text-primary); }
        
                                        .math-hint-body {
            border: 1.5px solid rgba(255,193,7,0.45); border-top: none;
            border-radius: 0 0 12px 12px; background: rgba(255,193,7,0.07);
            padding: 4px 14px 12px;
        }
                                        .math-hint-def b { color: var(--text-primary); }

                                                                                                                                                                                                                                                                                                                                                                .math-answer-part.active { border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,.10); }
                                .math-answer-box.filled { border-color: #94a3b8; background: #f8fafc; }
                                                                                                        .math-written-grade p { grid-column: 1 / -1; margin: 0; font-weight: 800; color: var(--text-primary); }
                                
                                                        .math-review-head p { margin: 4px 0 0; color: var(--text-secondary, #64748b); font-size: 13px; }
                                .math-review-chip strong { color: #dc2626; font-size: 14px; }
                                                                                                                                .math-wrong-note b { color: #d63a3a; }
        
        /* Grade 4 — the words that keep coming back wrong. */
        .g4-wrong-panel { margin-top: 16px; }
        .g4-wrong-list { display: flex; flex-direction: column; gap: 6px; }
        .g4-wrong-chip {
            display: flex; align-items: center; gap: 8px; width: 100%;
            padding: 9px 12px; border-radius: 12px; cursor: pointer; text-align: left;
            font-family: inherit; font-size: 14.5px; color: var(--text-primary);
            background: var(--glass-bg, rgba(255,255,255,0.8));
            border: 1.5px solid var(--glass-border);
        }
        .g4-wrong-emoji { flex: 0 0 auto; font-size: 20px; }
        .g4-wrong-en { flex: 0 0 auto; font-weight: 800; }
        .g4-wrong-vi {
            flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--text-secondary);
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        .g4-wrong-count {
            flex: 0 0 auto; font-style: normal; font-size: 13px; font-weight: 800;
            color: #d63a3a; background: rgba(214,58,58,0.10);
            border-radius: 8px; padding: 3px 7px;
        }
        .g4-wrong-more { font-size: 12.5px; color: var(--text-secondary, #64748b); padding: 8px 4px 0; }

                                                                                                                .math-hist-side strong { display: block; font-size: 14px; color: var(--text-primary, #1e293b); }

                                        .math-key:active { transform: scale(0.94); background: rgba(124, 58, 237, 0.14); }
                                /* "x^n" is a mode, not a character — it stays lit while the digits
           that follow are landing as exponents. */
        .math-key-pow.active {
            background: #7c3aed; border-color: #7c3aed; color: #fff;
        }

        /* Sub-topic label above a question ("Lũy thừa"), reusing the row chip
           but reading as a caption rather than a data row. */
        .math-topic-badge {
            display: inline-block;
            font-size: 13px;
            font-weight: 800;
            color: var(--accent-purple, #7c3aed);
            background: rgba(124, 58, 237, 0.10);
            border-radius: 999px;
            padding: 4px 12px;
            margin-bottom: 8px;
        }

                        .math-lesson-body { font-size: 15px; line-height: 1.7; }

                                                                        .math-mistakes ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
                                        
        /* The listen-to-continue row.
           It carries its own OPAQUE surface rather than a translucent tint:
           this row appears on the light quiz screens and inside the dark
           purple speed-challenge overlay, and a see-through background left
           the text unreadable on the dark one. A solid chip reads correctly
           on any backdrop. */
        .answer-gate {
            display: flex;
            align-items: center;
            gap: 10px;
            margin: 12px 0 10px;
            padding: 10px 14px;
            border-radius: 16px;
            background: #eff6ff;
            border: 1px dashed #60a5fa;
        }
        .answer-gate.heard {
            background: #ecfdf5;
            border-color: #34d399;
            border-style: solid;
        }
        .answer-gate-btn {
            flex: 0 0 auto;
            width: 46px;
            height: 46px;
            border-radius: 50%;
            border: none;
            background: linear-gradient(135deg, #3b82f6, #2563eb);
            color: #fff;
            font-size: 20px;
            cursor: pointer;
            font-family: inherit;
            box-shadow: 0 4px 12px rgba(37,99,235,0.35);
            animation: answerGateNudge 1.6s ease-in-out infinite;
        }
        .answer-gate.heard .answer-gate-btn {
            background: linear-gradient(135deg, #10b981, #059669);
            box-shadow: 0 4px 12px rgba(16,185,129,0.30);
            animation: none;
        }
        .answer-gate-btn:active { transform: scale(0.94); }
        .answer-gate-hint {
            font-size: 14px;
            font-weight: 700;
            color: #1e40af;
            line-height: 1.3;
        }
        .answer-gate.heard .answer-gate-hint { color: #047857; }

        /* A gentle pulse draws the eye to the one control that unblocks the
           quiz. Stops once tapped, and honours reduced-motion. */
        @keyframes answerGateNudge {
            0%, 100% { transform: scale(1); }
            50%      { transform: scale(1.08); }
        }
        @media (prefers-reduced-motion: reduce) {
            .answer-gate-btn { animation: none; }
        }

        /* Result screen */
        .grammar-result-card {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-radius: 24px;
            padding: 28px 18px;
            text-align: center;
            box-shadow: 0 8px 28px rgba(31,80,50,0.08);
        }
        .grammar-result-emoji {
            font-size: 72px;
            margin-bottom: 8px;
        }
        .grammar-result-title {
            font-size: 22px;
            font-weight: 800;
            margin-bottom: 6px;
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .grammar-result-score {
            font-size: 42px;
            font-weight: 900;
            color: var(--text-primary);
            margin-bottom: 0;
        }
        .grammar-result-pct {
            font-size: 16px;
            color: var(--text-secondary);
            font-weight: 700;
            margin-bottom: 10px;
        }

        /* ===== Phrases tab (prepositions) ===== */
        .phrases-wrap { padding: 4px 0 12px; }
        .phrases-hero { text-align: center; margin-bottom: 14px; }
        .phrases-hero-icon { font-size: 46px; line-height: 1; }
        .phrases-hero h1 {
            font-size: 24px; font-weight: 900; margin: 4px 0 4px;
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
        }
        .phrases-sub { font-size: 12.5px; color: var(--text-secondary); line-height: 1.45; max-width: 330px; margin: 0 auto; }

        /* Primary CTA */
        .phrases-cta {
            display: flex; align-items: center; gap: 12px; width: 100%;
            border: none; cursor: pointer; text-align: left;
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            color: #fff; border-radius: 18px; padding: 16px 18px; margin-bottom: 10px;
            box-shadow: 0 8px 22px rgba(155,89,182,0.28);
        }
        .phrases-cta:active { transform: scale(0.98); }
        .phrases-cta:focus-visible {
            outline: 3px solid #166534;
            outline-offset: 3px;
        }
        .phrases-cta-icon { font-size: 26px; }
        .phrases-cta-text { display: flex; flex-direction: column; flex: 1; }
        .phrases-cta-text strong { font-size: 17px; font-weight: 800; }
        .phrases-cta-text small { font-size: 12px; opacity: 0.9; }
        .phrases-cta-arrow { font-size: 26px; font-weight: 700; opacity: 0.85; }
                .phrases-cta-secondary {
            flex: 1; border: 1px solid var(--glass-border); background: var(--glass-bg);
            color: var(--text-primary); font-size: 13px; font-weight: 700;
            border-radius: 12px; padding: 11px 10px; cursor: pointer;
        }
        .phrases-cta-secondary:active { transform: scale(0.98); }
        .phrases-review-btn { width: 100%; margin-top: 10px; }

        /* Categories (collapsible) */
        .phrases-cats-wrap { margin-bottom: 16px; }
        .phrases-cats-wrap > summary {
            list-style: none; cursor: pointer; font-size: 13px; font-weight: 700;
            color: var(--text-secondary); padding: 4px 2px;
        }
        .phrases-cats-wrap > summary::-webkit-details-marker { display: none; }
        .phrases-cats-wrap > summary::after { content: ' ▾'; }
        .phrases-cats-wrap[open] > summary::after { content: ' ▴'; }
        .phrases-cats {
            background: var(--glass-bg); border: 1px solid var(--glass-border);
            border-radius: 16px; padding: 4px 14px; margin-top: 8px;
        }
        .phrases-cat-row {
            display: flex; justify-content: space-between; align-items: center;
            padding: 9px 0; font-size: 14px; color: var(--text-primary);
            border-bottom: 1px solid var(--glass-border);
        }
        .phrases-cat-row:last-child { border-bottom: none; }
        .phrases-cat-row strong { color: var(--accent-purple); font-weight: 800; }

        .phrases-blank { color: var(--accent-purple); font-weight: 900; letter-spacing: 1px; }
        .phrases-vi { font-size: 13px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; line-height: 1.4; }
        .phrases-pct { color: var(--text-secondary); font-weight: 600; }
        .phrases-quiz-header { display: flex; align-items: center; gap: 10px; }
        .phrases-quiz-header .grammar-progress-bar { flex: 1; }

        /* Section titles + counts */
        .phrases-section-title {
            font-size: 15px; font-weight: 800; color: var(--text-primary);
            margin: 18px 0 10px; display: flex; align-items: center; gap: 8px;
        }
        .phrases-count {
            font-size: 12px; font-weight: 800; color: var(--accent-purple);
            background: rgba(155,89,182,0.12); border-radius: 10px; padding: 1px 8px;
        }
        .phrases-empty {
            font-size: 13px; color: var(--text-secondary); text-align: center;
            padding: 18px 12px; background: var(--glass-bg);
            border: 1px dashed var(--glass-border); border-radius: 14px;
        }

        /* Words to review */
        .phrases-review-words {
            background: var(--glass-bg); border: 1px solid var(--glass-border);
            border-radius: 16px; padding: 12px 14px; margin-top: 18px;
        }
        .phrases-review-words .phrases-section-title { margin-top: 0; }
        .phrases-word-chips { display: flex; flex-wrap: wrap; gap: 7px; }
        .phrases-word-chip {
            font-size: 12.5px; font-weight: 700; color: var(--text-primary);
            background: rgba(231,76,60,0.10); border: 1px solid rgba(231,76,60,0.25);
            border-radius: 999px; padding: 4px 10px;
        }
        .phrases-word-chip i { font-style: normal; color: #e74c3c; font-weight: 800; margin-left: 5px; font-size: 11px; }

        /* Session review */
        .phrases-review-line { font-size: 12.5px; color: var(--text-secondary); margin: 4px 0 6px; }
        .phrases-review-line s { color: #e74c3c; }
        .phrases-review-line b { color: #2ecc71; }

        /* Lessons tab — searchable study list */
        .phrases-search-wrap { position: sticky; top: 0; z-index: 5; padding: 2px 0 8px; background: var(--bg-gradient, transparent); }
        .phrases-search {
            width: 100%; box-sizing: border-box; font-family: inherit; font-size: 14px;
            color: var(--text-primary); background: var(--glass-bg);
            border: 1px solid var(--glass-border); border-radius: 14px; padding: 12px 14px;
        }
        .phrases-search:focus { outline: none; border-color: var(--accent-purple); }
        .phrases-search-count { font-size: 11.5px; color: var(--text-secondary); font-weight: 700; margin: 6px 2px 0; }
        .phrases-lesson-group { margin-bottom: 4px; }
        .phrases-lesson {
            background: var(--glass-bg); border: 1px solid var(--glass-border);
            border-radius: 14px; padding: 11px 14px; margin-bottom: 8px;
        }
        .phrases-lesson-term { font-size: 15px; font-weight: 800; color: var(--accent-purple); }
        .phrases-lesson-vi { font-size: 13px; font-weight: 700; color: var(--text-primary); margin: 3px 0 5px; line-height: 1.4; }
        .phrases-lesson-ex { font-size: 13px; color: var(--text-secondary); font-style: italic; line-height: 1.45; }
        .grammar-result-unit {
            font-size: 13px;
            color: var(--text-primary);
            font-weight: 700;
            margin-bottom: 6px;
        }
        .grammar-result-coins {
            font-size: 13px;
            color: #b8860b;
            font-weight: 700;
            margin-bottom: 18px;
        }
        .math-perfect-bonus {
            display: grid;
            grid-template-columns: 1fr auto;
            align-items: center;
            gap: 3px 12px;
            margin: -6px 0 18px;
            padding: 13px 15px;
            border: 2px solid #f4bf35;
            border-radius: 16px;
            background: linear-gradient(135deg, #fff9d9 0%, #ffed9e 100%);
            color: #65420c;
            box-shadow: 0 7px 16px rgba(180, 118, 0, 0.14);
        }
        .math-perfect-bonus__title {
            font-size: 15px;
            font-weight: 900;
        }
        .math-perfect-bonus strong {
            grid-row: 1 / span 2;
            grid-column: 2;
            font-size: 20px;
            color: #9a5600;
            white-space: nowrap;
        }
        .math-perfect-bonus > span:last-child {
            font-size: 12px;
            font-weight: 700;
            opacity: 0.78;
        }
        /* Coin-earned banner on Exam results + Verbs complete overlay */
        .exam-result-coins {
            font-size: 15px; font-weight: 800; color: #b8860b;
            margin-top: 6px;
        }
        /* Sits on the orange completion overlay, not on a light card like its
           two siblings above — the inherited #b8860b was 1.17:1 there, i.e.
           invisible. White on a dark pill instead: 7.5:1, and it matches the
           white title and stats around it. */
        .speed-complete-coins {
            display: inline-block;
            font-size: 16px; font-weight: 800; color: #ffffff;
            background: rgba(0, 0, 0, 0.45);
            padding: 4px 14px;
            border-radius: 999px;
            margin: 10px 0 4px;
        }
        .grammar-result-actions {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .grammar-result-date {
            font-size: 11px;
            color: var(--text-secondary);
            margin-top: 4px;
        }
        .grammar-result-header {
            text-align: center;
            margin-bottom: 16px;
            padding: 18px;
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-radius: 20px;
        }
        .grammar-result-header h2 {
            font-size: 16px;
            margin-bottom: 6px;
        }

        /* Review list */
        .grammar-review-list {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .grammar-review-item {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-radius: 16px;
            padding: 14px;
            border-left: 4px solid #888;
        }
        .grammar-review-item.correct { border-left-color: #2ecc71; }
        .grammar-review-item.wrong { border-left-color: #ef5350; }
        .grammar-review-header {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 12px;
            margin-bottom: 8px;
            flex-wrap: wrap;
        }
        .grammar-review-num { font-weight: 800; color: var(--text-primary); }
        .grammar-review-status { font-weight: 700; }
        .grammar-review-item.correct .grammar-review-status { color: #1e8449; }
        .grammar-review-item.wrong .grammar-review-status   { color: #c0392b; }
        .grammar-review-tag {
            background: rgba(155,89,182,0.12);
            color: var(--accent-purple);
            padding: 2px 8px;
            border-radius: 8px;
            font-weight: 700;
            text-transform: capitalize;
        }
        .grammar-review-q {
            font-size: 14px;
            font-weight: 700;
            color: var(--text-primary);
            margin-bottom: 8px;
            line-height: 1.4;
        }
        .grammar-review-answers { margin-bottom: 8px; }
        .grammar-review-line {
            font-size: 13px;
            padding: 6px 10px;
            border-radius: 8px;
            margin-bottom: 4px;
        }
        .grammar-review-line.line-correct { background: rgba(46,204,113,0.12); color: #1e8449; }
        .grammar-review-line.line-wrong   { background: rgba(239,83,80,0.10); color: #c0392b; }
        .grammar-review-explain {
            font-size: 13px;
            line-height: 1.5;
            color: var(--text-primary);
            background: rgba(155,89,182,0.08);
            padding: 10px 12px;
            border-radius: 10px;
        }
        .grammar-page-ref {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: 6px;
            padding: 6px 10px;
            background: rgba(58,134,255,0.10);
            border-left: 3px solid #3a86ff;
            border-radius: 6px;
            font-style: italic;
        }

        /* ========== GRAMMAR TIP (v3.40 — Vietnamese mnemonic) ========== */
        .grammar-tip {
            margin-top: 10px;
            padding: 12px;
            background: linear-gradient(135deg, rgba(251,191,36,0.10), rgba(249,115,22,0.08));
            border-left: 4px solid #fbbf24;
            border-radius: 10px;
            color: #1f2937;
        }
        .grammar-tip-title {
            font-size: 14px;
            font-weight: 800;
            margin-bottom: 8px;
            color: #92400e;
        }
        .grammar-tip-body { font-size: 13px; line-height: 1.5; }
        .grammar-tip .tip-row {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            margin-bottom: 8px;
        }
        .grammar-tip .tip-row:last-child { margin-bottom: 0; }
        .grammar-tip .tip-tag {
            flex-shrink: 0;
            display: inline-block;
            min-width: 44px;
            text-align: center;
            font-size: 12px;
            font-weight: 800;
            font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
            padding: 3px 6px;
            border-radius: 6px;
            color: white;
            line-height: 1.25;
        }
        .grammar-tip .tip-tag-iz { background: linear-gradient(135deg, #f97316, #ea580c); }
        .grammar-tip .tip-tag-s  { background: linear-gradient(135deg, #6c5ce7, #4c1d95); }
        .grammar-tip .tip-tag-z  { background: linear-gradient(135deg, #10b981, #059669); }
        .grammar-tip em {
            font-style: normal;
            font-weight: 700;
            color: #b45309;
            padding: 0 4px;
            background: rgba(251,191,36,0.20);
            border-radius: 4px;
        }
        .grammar-tip strong { color: #1e293b; }
        .grammar-tip .tip-eg {
            display: block;
            font-size: 12px;
            color: #475569;
            font-style: italic;
            margin-top: 2px;
        }

        /* ========== LESSONS SUB-TAB (theory notes) ========== */
        .grammar-lessons-intro {
            display: flex;
            gap: 12px;
            align-items: center;
            background: linear-gradient(135deg, rgba(58,134,255,0.10), rgba(167,139,250,0.10));
            border: 1px solid rgba(58,134,255,0.25);
            border-radius: 14px;
            padding: 14px;
            margin-bottom: 16px;
        }
        .grammar-lessons-intro-icon {
            font-size: 32px;
            flex-shrink: 0;
        }
        .grammar-lessons-intro-text {
            font-size: 14px;
            line-height: 1.45;
            color: #475569;
        }
        .grammar-lessons-intro-text strong {
            color: #1e293b;
        }
        .lesson-unit-group {
            background: white;
            border: 1px solid #e5e7eb;
            border-left: 5px solid #3a86ff;
            border-radius: 14px;
            padding: 10px 14px;
            margin-bottom: 10px;
            box-shadow: 0 2px 6px rgba(0,0,0,0.04);
            transition: padding 0.2s ease, box-shadow 0.2s ease;
        }
        .lesson-unit-group.expanded {
            padding: 14px;
            box-shadow: 0 4px 14px rgba(0,0,0,0.07);
        }
        /* Header is now a button (clickable to toggle). Reset button styles. */
        .lesson-unit-header {
            display: flex;
            gap: 8px;
            align-items: center;
            width: 100%;
            background: transparent;
            border: none;
            padding: 0;
            margin: 0;
            cursor: pointer;
            font-family: inherit;
            text-align: left;
        }
        .lesson-unit-group.expanded .lesson-unit-header {
            margin-bottom: 4px;
        }
        .lesson-unit-header:hover .lesson-unit-title {
            color: #6c5ce7;
        }
        .lesson-unit-icon {
            font-size: 22px;
            flex-shrink: 0;
        }
        .lesson-unit-title {
            flex: 1;
            font-size: 15px;
            font-weight: 700;
            color: #1e293b;
            transition: color 0.15s;
        }
        .lesson-unit-group.expanded .lesson-unit-title {
            font-size: 17px;
        }
        .lesson-unit-count {
            flex-shrink: 0;
            font-size: 11px;
            font-weight: 700;
            color: #64748b;
            background: rgba(108,92,231,0.08);
            padding: 2px 8px;
            border-radius: 8px;
            white-space: nowrap;
        }
        .lesson-unit-toggle {
            flex-shrink: 0;
            font-size: 13px;
            color: #64748b;
            background: rgba(108,92,231,0.08);
            border-radius: 50%;
            width: 26px;
            height: 26px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s, color 0.15s;
        }
        .lesson-unit-group.expanded .lesson-unit-toggle {
            background: rgba(108,92,231,0.18);
            color: #6c5ce7;
        }
        .lesson-unit-header:hover .lesson-unit-toggle {
            background: rgba(108,92,231,0.20);
            color: #6c5ce7;
        }
        .lesson-unit-body {
            animation: lessonUnitOpen 0.25s ease-out;
            margin-top: 8px;
        }
        @keyframes lessonUnitOpen {
            from { opacity: 0; transform: translateY(-6px); }
            to   { opacity: 1; transform: translateY(0); }
        }
        .lesson-unit-intro {
            font-size: 13px;
            color: #64748b;
            margin-bottom: 12px;
            line-height: 1.4;
        }
        .lesson-unit-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .lesson-ican-block {
            background: linear-gradient(135deg, rgba(245,158,11,0.10), rgba(217,119,6,0.10));
            border: 1px solid rgba(245,158,11,0.30);
            border-radius: 10px;
            padding: 10px 12px;
            margin-bottom: 12px;
        }
        .lesson-ican-summary {
            font-size: 13px;
            font-weight: 700;
            color: #92400e;
            cursor: pointer;
            list-style: none;
            user-select: none;
        }
        .lesson-ican-summary::-webkit-details-marker {
            display: none;
        }
        .lesson-ican-summary::before {
            content: '▸ ';
            display: inline-block;
            transition: transform 0.15s;
        }
        .lesson-ican-block[open] .lesson-ican-summary::before {
            content: '▾ ';
        }
        .lesson-ican-list {
            margin: 8px 0 0 0;
            padding-left: 22px;
            display: flex;
            flex-direction: column;
            gap: 4px;
        }
        .lesson-ican-item {
            font-size: 13px;
            color: #78350f;
            line-height: 1.5;
        }
        .lesson-item {
            display: flex;
            flex-direction: column;
            gap: 6px;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            padding: 10px 12px;
            text-align: left;
            cursor: pointer;
            transition: background 0.15s, border-color 0.15s, transform 0.05s;
        }
        .lesson-item:hover {
            background: #eef2ff;
            border-color: #c7d2fe;
        }
        .lesson-item:active {
            transform: scale(0.98);
        }
        .lesson-item-head {
            display: flex;
            gap: 8px;
            align-items: center;
        }
        .lesson-item-id {
            background: #3a86ff;
            color: white;
            font-size: 12px;
            font-weight: 700;
            padding: 2px 8px;
            border-radius: 999px;
            flex-shrink: 0;
        }
        .lesson-item-title {
            font-size: 14px;
            font-weight: 600;
            color: #1e293b;
            flex: 1;
        }
        .lesson-item-page {
            font-size: 11px;
            color: #94a3b8;
            font-weight: 500;
            flex-shrink: 0;
        }
        .lesson-item-tags {
            display: flex;
            flex-wrap: wrap;
            gap: 4px;
        }
        .lesson-item-tag {
            font-size: 11px;
            background: rgba(58,134,255,0.10);
            color: #1e40af;
            padding: 2px 7px;
            border-radius: 999px;
            font-weight: 500;
        }

        /* Lesson detail view */
        .lesson-detail {
            display: flex;
            flex-direction: column;
            gap: 14px;
            padding-bottom: 24px;
        }
        /* Top bar: [← All] + sibling-lesson chips */
        .lesson-detail-topbar {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: nowrap;
            overflow-x: auto;
            scrollbar-width: none;
        }
        .lesson-detail-topbar::-webkit-scrollbar { display: none; }
        .lesson-back-btn {
            flex-shrink: 0;
            background: transparent;
            border: 1px solid #cbd5e1;
            color: #475569;
            font-size: 13px;
            font-weight: 600;
            padding: 6px 12px;
            border-radius: 8px;
            cursor: pointer;
            transition: background 0.15s;
        }
        .lesson-back-btn:hover {
            background: #f1f5f9;
        }
        .lesson-sibling-chips {
            display: flex;
            gap: 6px;
            flex-shrink: 0;
        }
        .lesson-sibling-chip {
            min-width: 38px;
            padding: 6px 10px;
            border-radius: 8px;
            border: 1px solid #cbd5e1;
            background: white;
            color: #475569;
            font-size: 12px;
            font-weight: 700;
            cursor: pointer;
            transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
            font-family: inherit;
        }
        .lesson-sibling-chip:hover:not(.active) {
            background: #eef2ff;
            border-color: #c7d2fe;
            color: #3730a3;
        }
        .lesson-sibling-chip:active:not(.active) {
            transform: scale(0.94);
        }
        .lesson-sibling-chip.active {
            background: linear-gradient(135deg, #3a86ff, #6c5ce7);
            color: white;
            border-color: transparent;
            cursor: default;
            box-shadow: 0 2px 8px rgba(58,134,255,0.35);
        }
        .lesson-detail-header {
            background: linear-gradient(135deg, #3a86ff, #6c5ce7);
            color: white;
            border-radius: 14px;
            padding: 18px;
            text-align: center;
        }
        .lesson-detail-id {
            display: inline-block;
            background: rgba(255,255,255,0.25);
            font-size: 13px;
            font-weight: 700;
            letter-spacing: 0.5px;
            padding: 3px 10px;
            border-radius: 999px;
            margin-bottom: 8px;
        }
        .lesson-detail-title {
            font-size: 22px;
            font-weight: 700;
            margin-bottom: 4px;
        }
        .lesson-detail-meta {
            font-size: 12px;
            opacity: 0.9;
        }
        .lesson-section {
            background: white;
            border: 1px solid #e5e7eb;
            border-radius: 12px;
            padding: 14px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.04);
        }
        .lesson-section-vocab {
            border-left: 4px solid #10b981;
        }
        .lesson-section-pron {
            border-left: 4px solid #f59e0b;
        }
        .lesson-section-grammar {
            border-left: 4px solid #6c5ce7;
        }
        .lesson-section-head {
            display: flex;
            gap: 8px;
            align-items: center;
            margin-bottom: 10px;
        }
        .lesson-section-icon {
            font-size: 18px;
        }
        .lesson-section-title {
            font-size: 15px;
            font-weight: 700;
            color: #1e293b;
        }
        .lesson-section-rule {
            font-size: 14px;
            color: #334155;
            line-height: 1.55;
            margin-bottom: 10px;
        }
        .lesson-section-note {
            margin-top: 10px;
            background: rgba(245,158,11,0.10);
            border-left: 3px solid #f59e0b;
            padding: 8px 10px;
            font-size: 13px;
            color: #78350f;
            border-radius: 6px;
            line-height: 1.45;
        }
        .lesson-word-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
        }
        .lesson-word-chip {
            font-size: 13px;
            font-weight: 500;
            background: #ecfdf5;
            color: #065f46;
            border: 1px solid #a7f3d0;
            padding: 4px 10px;
            border-radius: 999px;
        }
        .lesson-form-table {
            display: flex;
            flex-direction: column;
            gap: 6px;
            margin-bottom: 12px;
            background: #faf5ff;
            border-radius: 8px;
            padding: 10px;
        }
        .lesson-form-row {
            display: flex;
            gap: 10px;
            align-items: flex-start;
            font-size: 13.5px;
        }
        .lesson-form-label {
            background: #6c5ce7;
            color: white;
            font-weight: 700;
            min-width: 28px;
            text-align: center;
            padding: 2px 6px;
            border-radius: 6px;
            font-size: 12px;
            flex-shrink: 0;
        }
        .lesson-form-text {
            color: #1e293b;
            line-height: 1.5;
            flex: 1;
        }
        .lesson-example-list {
            margin: 0;
            padding-left: 20px;
            display: flex;
            flex-direction: column;
            gap: 6px;
        }
        .lesson-example-list li {
            font-size: 13.5px;
            color: #334155;
            line-height: 1.5;
        }
        .lesson-practice-btn {
            background: linear-gradient(135deg, #10b981, #059669);
            color: white;
            border: none;
            padding: 14px 20px;
            border-radius: 12px;
            font-size: 15px;
            font-weight: 700;
            cursor: pointer;
            box-shadow: 0 4px 12px rgba(16,185,129,0.3);
            transition: transform 0.05s, box-shadow 0.15s;
        }
        .lesson-practice-btn:hover {
            box-shadow: 0 6px 18px rgba(16,185,129,0.4);
        }
        .lesson-practice-btn:active {
            transform: scale(0.98);
        }
        .lesson-practice-none {
            text-align: center;
            color: #94a3b8;
            font-size: 13px;
            padding: 16px;
            background: #f8fafc;
            border-radius: 10px;
            border: 1px dashed #cbd5e1;
        }

        /* ========== MISTAKE BANK CARD (T1.2) ========== */
        .grammar-mistakes-card {
            background: linear-gradient(135deg, rgba(239,71,111,0.10), rgba(255,159,28,0.10));
            border: 1px solid rgba(239,71,111,0.25);
            border-left: 4px solid #ef476f;
            border-radius: 16px;
            padding: 14px;
            margin-bottom: 14px;
            display: grid;
            grid-template-columns: auto 1fr;
            grid-template-rows: auto auto;
            gap: 4px 12px;
            align-items: center;
        }
        .grammar-mistakes-icon {
            font-size: 36px;
            grid-row: span 2;
        }
        .grammar-mistakes-text { min-width: 0; }
        .grammar-mistakes-title {
            font-size: 16px;
            font-weight: 800;
            color: var(--text-primary);
        }
        .grammar-mistakes-sub {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: 2px;
        }
        .grammar-mistakes-bookmark {
            color: #ff9f1c;
            font-weight: 700;
        }
        .grammar-mistakes-actions {
            grid-column: 1 / -1;
            display: flex;
            gap: 8px;
            margin-top: 8px;
        }
        .grammar-mistakes-empty-cta {
            font-size: 12px;
            color: var(--text-secondary);
            font-style: italic;
            padding: 8px 0;
        }

        /* ========== AGGREGATE STATS BANNER (T2.6) ========== */
        .grammar-stats-banner {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 6px;
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-radius: 14px;
            padding: 10px 8px;
            margin-bottom: 12px;
        }
        .stats-cell {
            text-align: center;
            padding: 4px;
        }
        .stats-num {
            font-size: 18px;
            font-weight: 800;
            color: var(--text-primary);
        }
        .stats-lbl {
            font-size: 9px;
            color: var(--text-secondary);
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-top: 2px;
        }
        .stats-cell.weak-cell .stats-num {
            color: #c0392b;
        }

        /* ========== WEAK TOPICS (T1.3) ========== */
        .grammar-weak-topics {
            background: rgba(239,71,111,0.06);
            border: 1px solid rgba(239,71,111,0.18);
            border-radius: 14px;
            padding: 10px;
            margin-bottom: 12px;
        }
        .grammar-weak-topics-title {
            font-size: 13px;
            font-weight: 800;
            color: var(--text-primary);
            margin-bottom: 8px;
        }
        .grammar-weak-topic {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 10px;
            background: rgba(255,255,255,0.5);
            border: 1px solid var(--glass-border);
            border-radius: 10px;
            margin-bottom: 6px;
            cursor: pointer;
            transition: transform 0.15s ease;
        }
        .grammar-weak-topic:active { transform: scale(0.98); }
        .grammar-weak-topic:last-child { margin-bottom: 0; }
        .weak-topic-icon { font-size: 18px; }
        .weak-topic-name {
            flex: 1;
            font-size: 13px;
            font-weight: 700;
            color: var(--text-primary);
        }
        .weak-topic-misses {
            font-size: 11px;
            font-weight: 700;
            color: #c0392b;
            background: rgba(239,83,80,0.12);
            padding: 2px 8px;
            border-radius: 10px;
        }
        .weak-topic-arrow {
            font-size: 12px;
            color: var(--accent-purple);
        }

        /* ========== FILTER CHIPS (T2.7-8) ========== */
        .grammar-filters {
            margin-bottom: 12px;
        }
        .grammar-filter-row {
            display: flex;
            gap: 6px;
            overflow-x: auto;
            padding-bottom: 4px;
            -webkit-overflow-scrolling: touch;
            margin-bottom: 6px;
        }
        .filter-chip {
            flex-shrink: 0;
            padding: 6px 12px;
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-radius: 18px;
            font-size: 12px;
            font-weight: 700;
            color: var(--text-secondary);
            cursor: pointer;
            white-space: nowrap;
            font-family: inherit;
            transition: all 0.15s ease;
        }
        .filter-chip.active {
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            color: white;
            border-color: transparent;
            box-shadow: 0 2px 8px rgba(46,204,113,0.3);
        }

        /* ========== TIME-BUCKET LABELS (T2.9) ========== */
        .grammar-bucket-label {
            font-size: 12px;
            font-weight: 800;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.7px;
            margin: 14px 4px 6px;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .grammar-bucket-label .bucket-count {
            background: rgba(155,89,182,0.15);
            color: var(--accent-purple);
            padding: 1px 8px;
            border-radius: 10px;
            font-size: 11px;
        }

        /* ========== BOOKMARK BUTTON (T1.5) ========== */
        .grammar-bookmark-btn {
            margin-left: auto;
            background: transparent;
            border: none;
            font-size: 18px;
            color: var(--text-secondary);
            cursor: pointer;
            padding: 2px 6px;
            border-radius: 6px;
            font-family: inherit;
            transition: transform 0.15s ease;
        }
        .grammar-bookmark-btn:active { transform: scale(0.85); }
        .grammar-bookmark-btn.bookmarked {
            color: #ff9f1c;
            text-shadow: 0 1px 4px rgba(255,159,28,0.4);
        }

        /* ========== RE-PRACTICE BUTTON (T1.4) ========== */
        .grammar-result-actions {
            margin-bottom: 12px;
        }

        /* ==================== ARRANGEMENT TILES (NEW v3.14.2) ==================== */
        .arr-answer-zone {
            min-height: 64px;
            background: linear-gradient(135deg, rgba(46,204,113,0.06), rgba(155,89,182,0.06));
            border: 2px dashed rgba(155,89,182,0.35);
            border-radius: 14px;
            padding: 10px;
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            align-items: center;
            margin-bottom: 14px;
        }
        .arr-pool-label {
            font-size: 12px;
            color: var(--text-secondary);
            font-weight: 700;
            margin-bottom: 6px;
        }
        .arr-pool-zone {
            min-height: 50px;
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            padding: 8px;
            background: rgba(255,255,255,0.4);
            border-radius: 12px;
            border: 1px solid var(--glass-border);
        }
        .arr-tile {
            display: inline-block;
            padding: 9px 14px;
            border-radius: 12px;
            font-family: inherit;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            transition: transform 0.12s ease, box-shadow 0.15s ease;
            border: 2px solid transparent;
            white-space: nowrap;
        }
        .arr-tile:active:not(:disabled) {
            transform: scale(0.94);
        }
        .arr-tile-pool {
            background: linear-gradient(135deg, #ffffff, #f5eaff);
            color: var(--text-primary);
            border-color: rgba(155,89,182,0.3);
            box-shadow: 0 2px 6px rgba(155,89,182,0.15);
        }
        .arr-tile-pool:hover:not(:disabled) {
            border-color: var(--accent-purple);
            box-shadow: 0 3px 12px rgba(155,89,182,0.25);
        }
        .arr-tile-answer {
            background: linear-gradient(135deg, rgba(46,204,113,0.18), rgba(46,204,113,0.08));
            color: var(--text-primary);
            border-color: rgba(46,204,113,0.35);
            box-shadow: 0 2px 6px rgba(46,204,113,0.12);
        }
        .arr-tile-answer.correct {
            background: linear-gradient(135deg, rgba(46,204,113,0.3), rgba(46,204,113,0.15));
            border-color: #2ecc71;
        }
        .arr-tile-answer.wrong {
            background: linear-gradient(135deg, rgba(239,83,80,0.25), rgba(239,83,80,0.1));
            border-color: #ef5350;
        }
        .arr-placeholder {
            color: var(--text-secondary);
            font-size: 13px;
            font-style: italic;
            opacity: 0.7;
            padding: 6px 10px;
        }
        .arr-controls {
            display: flex;
            gap: 8px;
        }
        .arr-clear-btn {
            padding: 12px 20px;
            background: var(--glass-bg);
            border: 1px solid var(--glass-border);
            color: var(--text-primary);
            border-radius: 50px;
            font-size: 13px;
            font-weight: 700;
            cursor: pointer;
            font-family: inherit;
        }
        .arr-clear-btn:disabled { opacity: 0.4; cursor: not-allowed; }
        .arr-submit-btn {
            flex: 1;
            padding: 12px 20px;
            background: linear-gradient(135deg, #2ecc71, #9b59b6);
            color: white;
            border: none;
            border-radius: 50px;
            font-size: 14px;
            font-weight: 800;
            cursor: pointer;
            box-shadow: 0 4px 14px rgba(46,204,113,0.35);
            font-family: inherit;
        }
        .arr-submit-btn:disabled {
            background: var(--glass-bg);
            color: var(--text-secondary);
            box-shadow: none;
            cursor: not-allowed;
        }
        .arr-correct-sentence {
            font-style: italic;
            font-size: 14px;
            color: #1e8449;
            background: rgba(46,204,113,0.12);
            padding: 8px 12px;
            border-radius: 10px;
            margin: 8px 0;
        }
        .topic-word-level {
            font-size: 11px;
            opacity: 0.7;
            margin-left: 4px;
        }

        /* Lesson chunk cards (sorted easy→hard) */
        .topic-lessons-list {
            display: flex;
            flex-direction: column;
            gap: 10px;
            margin-bottom: 18px;
        }
        .topic-lesson-card {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-left: 4px solid var(--topic-color, var(--accent-purple));
            border-radius: 16px;
            padding: 14px;
            box-shadow: 0 3px 12px rgba(31,80,50,0.06);
        }
        .topic-lesson-card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 6px;
        }
        .topic-lesson-card-num {
            font-size: 14px;
            font-weight: 800;
            color: var(--text-primary);
        }
        .topic-lesson-card-diff {
            font-size: 11px;
            font-weight: 700;
            color: var(--text-secondary);
            background: rgba(155,89,182,0.1);
            padding: 3px 9px;
            border-radius: 12px;
        }
        .topic-lesson-card-preview {
            font-size: 12px;
            color: var(--text-secondary);
            line-height: 1.4;
            margin-bottom: 10px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }
        .topic-lesson-start-btn {
            width: 100%;
            padding: 10px;
            background: linear-gradient(135deg, #2ecc71, #27ae60);
            color: white;
            border: none;
            border-radius: 50px;
            font-size: 13px;
            font-weight: 800;
            cursor: pointer;
            box-shadow: 0 3px 10px rgba(46,204,113,0.3);
            transition: transform 0.15s ease;
            font-family: inherit;
        }
        .topic-lesson-start-btn:active { transform: scale(0.96); }

        /* ==================== TOPICS REVIEW CARD ==================== */
        .topics-review-card {
            margin-bottom: 14px;
        }
        .topics-review-btn {
            width: 100%;
            background: linear-gradient(135deg, rgba(155,89,182,0.15), rgba(46,204,113,0.15));
            border: 1px solid var(--glass-border);
            border-left: 4px solid var(--accent-purple);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border-radius: 18px;
            padding: 14px 16px;
            display: flex;
            align-items: center;
            gap: 12px;
            cursor: pointer;
            box-shadow: 0 4px 14px rgba(155,89,182,0.12);
            transition: transform 0.15s ease;
            font-family: inherit;
            text-align: left;
        }
        .topics-review-btn:active { transform: scale(0.98); }
        .review-btn-icon {
            font-size: 32px;
            flex-shrink: 0;
        }
        .review-btn-text {
            flex: 1;
            min-width: 0;
        }
        .review-btn-title {
            font-size: 15px;
            font-weight: 800;
            color: var(--text-primary);
        }
        .review-btn-sub {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: 2px;
            font-weight: 600;
        }
        .review-btn-arrow {
            font-size: 24px;
            color: var(--accent-purple);
            font-weight: 800;
        }
        .topics-review-empty {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 14px 16px;
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--glass-border);
            border-radius: 18px;
        }
        .review-empty-icon {
            font-size: 26px;
        }
        .review-empty-title {
            font-size: 14px;
            font-weight: 800;
            color: var(--text-primary);
        }
        .review-empty-sub {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: 2px;
        }
        .review-mistakes-badge {
            background: rgba(239,71,111,0.15) !important;
            color: #c0392b !important;
        }
        .review-wrong-count {
            color: #c0392b;
            font-weight: 700;
        }
        .review-lesson-chunk {
            border-left-color: var(--accent-purple) !important;
        }
        .review-clear-all-btn {
            width: 100%;
            margin-top: 16px;
            padding: 12px;
            background: transparent;
            color: var(--text-secondary);
            border: 1px solid var(--glass-border);
            border-radius: 50px;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            font-family: inherit;
        }

        /* ==================== EXAM SCREEN ==================== */
        .exam-screen { padding: 20px; padding-bottom: 100px; }
        .exam-home { padding: 4px; }
        .exam-header { margin-bottom: 20px; }
        .exam-header-row { display: flex; align-items: center; gap: 12px; }
        .exam-title { font-size: 26px; font-weight: 800; color: var(--text-primary); margin: 0; }
        .exam-subtitle { font-size: 14px; color: var(--text-secondary); margin: 4px 0 0; }
        .exam-back-btn, .exam-quit-btn {
            width: 38px; height: 38px; border-radius: 50%;
            border: 1px solid var(--glass-border); background: var(--glass-bg, rgba(255,255,255,0.6));
            color: var(--text-primary); font-size: 18px; cursor: pointer; flex: 0 0 auto;
            display: flex; align-items: center; justify-content: center;
        }

        .exam-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
        .exam-card {
            display: flex; align-items: center; gap: 14px; width: 100%;
            padding: 16px; border-radius: 18px; cursor: pointer; text-align: left;
            background: var(--glass-bg, rgba(255,255,255,0.7));
            border: 1px solid var(--glass-border);
            box-shadow: 0 4px 14px rgba(0,0,0,0.06);
            font-family: inherit;
        }
        .exam-card:active { transform: scale(0.99); }
                .exam-card-icon { font-size: 30px; flex: 0 0 auto; }
        .exam-card-info { flex: 1 1 auto; min-width: 0; }
        .exam-card-title { font-size: 17px; font-weight: 800; color: var(--text-primary); }
        .exam-card-sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
        .exam-card-meta { font-size: 12.5px; color: var(--text-secondary); margin-top: 6px; font-weight: 600; }
        .exam-card-best { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 700; color: #58cc02; }

        /* PTNK: the same exam cards, grouped under a year heading. The two
           badges say what a child needs before tapping — which track, and
           whether the key is the published one or a cross-checked solve. */
        .ptnk-year { margin: 18px 4px 8px; }
        .ptnk-year:first-of-type { margin-top: 4px; }
        .ptnk-track { font-weight: 700; }
        .ptnk-card.ptnk-chuyen .ptnk-track { color: #7c3aed; }
        .ptnk-card.ptnk-kc .ptnk-track { color: #0369a1; }
        .ptnk-key-note { color: #b45309; font-weight: 600; }
        .ptnk-omitted { margin-top: 4px; font-size: 12px; color: #9a3412; }
        /* The one-line rule under the Practice button on Reading / Cloze /
           Error Correction: which level is being served and how to unlock
           the next. */
        .practice-rule { margin: 6px 4px 0; font-size: 13px; color: #6b7280; }
        /* The Chuyên tier (Word Form / Rewrite): a badge on the home when an
           admin has switched it on for this child, and on a key-word
           transformation the key word as a chip beside the sentence. */
        .tier-badge { margin: 10px auto 0; display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: #4c1d95; background: #ede9fe; }
        .rw-key { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 800; letter-spacing: .04em; color: #4c1d95; background: #ede9fe; vertical-align: middle; }
        .rw-key-hint { margin: 4px 0 8px; font-size: 12.5px; color: #6b7280; }
        .nav-hub-card.ptnk .nav-hub-icon { color: #7c3aed; background: #ede9fe; }
        .nav-hub-card.reading .nav-hub-icon { color: #0f766e; background: #ccfbf1; }
        .nav-hub-card.cloze .nav-hub-icon { color: #b45309; background: #fef3c7; }
        .nav-hub-card.errors .nav-hub-icon { color: #be123c; background: #ffe4e6; }
        .nav-hub-card.grammarvocab .nav-hub-icon { color: #6d28d9; background: #ede9fe; }
        .nav-hub-card.phonetics .nav-hub-icon { color: #0e7490; background: #cffafe; }
        /* Phonetics & Stress: the four compared words, hearable once answered. */
        .exam-hear { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
        .exam-hear-btn { border: 1px solid var(--border, #e2e8f0); background: var(--card-bg, #fff); color: inherit; border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
        .exam-hear-btn:active { transform: scale(0.97); }
        .exam-hear-ipa { opacity: .7; font-size: 13px; }
        .exam-card-go { font-size: 26px; color: var(--text-secondary); flex: 0 0 auto; }

        .exam-history-btn {
            width: 100%; padding: 14px; border-radius: 16px; cursor: pointer;
            background: transparent; border: 1.5px solid var(--glass-border);
            color: var(--text-primary); font-size: 15px; font-weight: 700; font-family: inherit;
        }

        /* Quiz header (during exam) */
        .exam-quiz-header { position: sticky; top: 0; z-index: 20; padding: 10px 2px 8px;
            background: var(--bg-primary, transparent); backdrop-filter: blur(6px); }
        .exam-quiz-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
        .exam-quiz-count { font-size: 14px; font-weight: 700; color: var(--text-secondary); }
        .exam-timer {
            font-size: 16px; font-weight: 800; color: var(--text-primary);
            padding: 6px 12px; border-radius: 50px; background: rgba(88,204,2,0.15);
        }
        .exam-timer-warning { color: #fff; background: #ff4b4b; animation: examPulse 1s infinite; }
        @keyframes examPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
        .exam-progress { height: 6px; border-radius: 3px; background: rgba(0,0,0,0.1); overflow: hidden; }
        .exam-progress-bar { height: 100%; background: #58cc02; transition: width 0.3s ease; }

        .exam-question-card { margin-top: 12px; }
        .exam-section-tag {
            display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
            text-transform: uppercase; color: #1cb0f6; background: rgba(28,176,246,0.12);
            padding: 3px 10px; border-radius: 50px; margin-bottom: 10px;
        }
        .exam-question-text { white-space: normal; }
        .exam-passage {
            font-size: 14px; line-height: 1.6; color: var(--text-primary);
            background: rgba(0,0,0,0.04); border: 1px solid var(--glass-border);
            border-radius: 12px; padding: 12px 14px; margin-bottom: 14px;
            max-height: 240px; overflow-y: auto;
        }
        .exam-wordbank { font-size: 13px; margin-bottom: 12px; }
        .exam-wordbank-label { font-weight: 700; color: var(--text-secondary); margin-right: 4px; }
        .exam-wordbank-item {
            display: inline-block; margin: 3px 4px 0 0; padding: 3px 10px;
            background: rgba(206,130,255,0.15); color: #a855f7; border-radius: 50px;
            font-size: 12.5px; font-weight: 600;
        }

        /* Text-answer input */
        .exam-text-wrap { display: flex; gap: 8px; margin-top: 12px; }
        .exam-text-input {
            flex: 1 1 auto; padding: 13px 14px; font-size: 16px; font-family: inherit;
            border: 2px solid var(--glass-border); border-radius: 12px;
            background: var(--glass-bg, #fff); color: var(--text-primary); outline: none;
        }
        .exam-text-input:focus { border-color: #1cb0f6; }
        .exam-text-submit {
            flex: 0 0 auto; padding: 0 18px; font-size: 15px; font-weight: 700; font-family: inherit;
            border: none; border-radius: 12px; background: #1cb0f6; color: #fff; cursor: pointer;
        }
        .exam-text-answer {
            margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-size: 15px;
            border: 2px solid; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline;
        }
        .exam-text-answer.correct { border-color: #58cc02; background: rgba(88,204,2,0.1); }
        .exam-text-answer.wrong { border-color: #ff4b4b; background: rgba(255,75,75,0.08); }
        .exam-text-answer-label { font-size: 12px; font-weight: 700; color: var(--text-secondary); }
        .exam-text-answer-value { font-weight: 700; color: var(--text-primary); }

        /* Results */
        .exam-result { padding: 8px 2px; text-align: center; }
        .exam-result-emoji { font-size: 56px; }
        .exam-result-grade { font-size: 22px; font-weight: 800; color: var(--text-primary); margin-top: 4px; }
        .exam-result-score { font-size: 46px; font-weight: 800; color: #58cc02; margin-top: 8px; line-height: 1; }
        .exam-result-score span { font-size: 24px; color: var(--text-secondary); }
        .exam-result-pct { font-size: 14px; color: var(--text-secondary); margin-top: 6px; }
        .exam-result-time { font-size: 14px; color: var(--text-secondary); margin-top: 4px; font-weight: 600; }
        .exam-result-auto { font-size: 13px; color: #ff4b4b; font-weight: 700; margin-top: 8px; }
        .exam-result-actions { display: flex; gap: 10px; margin: 18px 0 6px; }
        /* Under "Làm lại": a retake of the same paper never counts toward the
           daily task (js/exam.js retakeExam) — say so before the tap. */
        .exam-retake-note { font-size: 12px; color: var(--text-secondary); margin: 0 0 6px; line-height: 1.4; }
        .exam-btn-primary, .exam-btn-secondary {
            flex: 1 1 0; padding: 14px; border-radius: 14px; font-size: 15px; font-weight: 700;
            cursor: pointer; font-family: inherit; border: none;
        }
        .exam-btn-primary { background: #58cc02; color: #fff; }
        .exam-btn-secondary { background: transparent; color: var(--text-primary); border: 1.5px solid var(--glass-border); }

        .exam-review-title { font-size: 17px; font-weight: 800; color: var(--text-primary); margin: 22px 0 12px; text-align: left; }
        .exam-review-list { display: flex; flex-direction: column; gap: 10px; text-align: left; }
        .exam-review-item {
            padding: 12px 14px; border-radius: 14px; border-left: 4px solid;
            background: var(--glass-bg, rgba(255,255,255,0.6)); border: 1px solid var(--glass-border);
        }
        .exam-review-item.correct { border-left: 4px solid #58cc02; }
        .exam-review-item.wrong { border-left: 4px solid #ff4b4b; }
        .exam-review-q { font-size: 14px; font-weight: 600; color: var(--text-primary); line-height: 1.5; }
        .exam-review-num {
            display: inline-block; min-width: 22px; height: 22px; line-height: 22px; text-align: center;
            background: rgba(0,0,0,0.08); border-radius: 50%; font-size: 12px; font-weight: 800; margin-right: 6px;
        }
        .exam-review-line { font-size: 13.5px; color: var(--text-primary); margin-top: 6px; display: flex; gap: 6px; align-items: center; }
        .exam-review-badge { font-weight: 800; }
        .exam-review-badge.ok { color: #58cc02; }
        .exam-review-badge.no { color: #ff4b4b; }
        .exam-review-explain { font-size: 13px; color: var(--text-secondary); margin-top: 8px; line-height: 1.55; }

        /* History list */
        .exam-history-list { display: flex; flex-direction: column; gap: 10px; }
        .exam-history-empty { text-align: center; color: var(--text-secondary); font-size: 14px; padding: 40px 10px; line-height: 1.6; }
        .exam-history-item {
            display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
            padding: 14px 16px; border-radius: 14px; cursor: pointer; text-align: left; font-family: inherit;
            background: var(--glass-bg, rgba(255,255,255,0.7)); border: 1px solid var(--glass-border);
        }
        .exam-history-left { min-width: 0; }
        .exam-history-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
        .exam-history-date { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
        .exam-history-right { text-align: right; flex: 0 0 auto; }
        .exam-history-score { font-size: 16px; font-weight: 800; color: var(--text-primary); }
        .exam-history-pct { font-size: 12px; font-weight: 700; }
        .exam-history-pct.pass { color: #58cc02; }
        .exam-history-pct.fail { color: #ff9600; }
        .exam-history-clear {
            width: 100%; margin-top: 16px; padding: 12px; border-radius: 14px; cursor: pointer;
            background: transparent; border: 1.5px solid var(--glass-border);
            color: var(--text-secondary); font-size: 13px; font-weight: 700; font-family: inherit;
        }

        /* ---- Exam lessons (Vietnamese grammar notes) ---- */
        .exam-lesson-list { display: flex; flex-direction: column; gap: 10px; }
        .exam-lesson-card {
            display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
            padding: 14px 16px; border-radius: 16px; cursor: pointer; font-family: inherit;
            background: var(--glass-bg, rgba(255,255,255,0.7)); border: 1px solid var(--glass-border);
            box-shadow: 0 3px 12px rgba(0,0,0,0.05);
        }
        .exam-lesson-card:active { transform: scale(0.99); }
        .exam-lesson-icon { font-size: 26px; flex: 0 0 auto; }
        .exam-lesson-info { flex: 1 1 auto; min-width: 0; }
        .exam-lesson-title { font-size: 15.5px; font-weight: 700; color: var(--text-primary); line-height: 1.35; }
        .exam-lesson-meta { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }

        .exam-lesson-detail { padding: 6px 2px 90px; }
        .exam-lesson-detail-title { font-size: 21px; font-weight: 800; color: var(--text-primary); margin: 10px 0 4px; line-height: 1.3; }
        .exam-lesson-detail-meta { font-size: 12.5px; font-weight: 700; color: #1cb0f6; margin-bottom: 14px; }
        .exam-lesson-content { font-size: 15px; line-height: 1.7; color: var(--text-primary); }
        .exam-lesson-content h4 {
            font-size: 15.5px; font-weight: 800; color: var(--text-primary);
            margin: 18px 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--glass-border);
        }
        .exam-lesson-content p { margin: 8px 0; }
        .exam-lesson-content ul { margin: 8px 0; padding-left: 22px; }
        .exam-lesson-content li { margin: 5px 0; }
        .exam-lesson-content table {
            width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13.5px;
            display: block; overflow-x: auto;
        }
        .exam-lesson-content th, .exam-lesson-content td {
            border: 1px solid var(--glass-border); padding: 7px 10px; text-align: left; vertical-align: top;
        }
        .exam-lesson-content th { background: rgba(28,176,246,0.1); font-weight: 700; }
        .exam-lesson-content b, .exam-lesson-content strong { color: var(--text-primary); }
        .exam-lesson-back-bottom { margin-top: 22px; }

/* Screen-reader-only live region. Night Raid's announcements used this class
   for months while it was never defined, so every announce() printed itself
   in plain text at the bottom of the battle screen. */
.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;clip-path:inset(50%);overflow:hidden;white-space:nowrap}

/* ── Math board (bảng nháp) ─────────────────────────────────────────── */
.math-board-overlay {
    /* Fixed already resolves in visual-viewport coordinates on iOS. Never add
       visualViewport.offsetTop here: Safari has already applied that offset,
       so doing it again drags both the paper and its input coordinates down. */
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    z-index: 2000;
    display: flex; flex-direction: column;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #fffef7;   /* warm paper, not stark white */
    -webkit-user-select: none; user-select: none;
    -webkit-touch-callout: none;
    overscroll-behavior: contain;
    /* pan-x pan-y = children may still scroll (long-stem strip, toolbar) but
       a pinch that starts anywhere on the board can never zoom the page.
       Zoomed was how the header vanished: the visual viewport slid down and
       "Thu nhỏ" became unreachable. The JS overlay guard covers the same
       gesture on browsers that ignore touch-action for two-finger drags. */
    touch-action: pan-x pan-y;
}
.math-board-overlay.hidden { display: none; }
/* Navigation is neither useful nor safe while a child is writing. Hiding it
   also means it can never reserve screen space or receive an accidental tap
   under the full-screen board. */
/* Do not let a stale root class hide navigation after the board DOM has
   already closed. :has() ties the reservation to the visible overlay itself. */
html.math-board-open:has(#mathBoardOverlay:not(.hidden)) #bottomNav { display: none !important; }
.math-board-overlay * {
    -webkit-user-select: none; user-select: none;
    -webkit-touch-callout: none;
}
.math-board-icon.active { border-color: #4f46e5; background: #e0e7ff; }
.math-board-write-tool.active {
    color: #fff; border-color: #4338ca; background: #4f46e5;
    box-shadow: 0 2px 8px rgba(79,70,229,.25);
}
.math-board-eraser.active { background: #be123c; border-color: #9f1239; }
.math-board-tool.active,
.math-board-keyboard-toggle.active {
    color: #fff; border-color: #4338ca; background: #4f46e5;
    box-shadow: 0 2px 8px rgba(79, 70, 229, .24);
}
.math-board-key:active { transform: translateY(1px); box-shadow: 0 1px 0 #c7d2fe; }
.math-board-key.active { color: #fff; background: #4f46e5; border-color: #4338ca; box-shadow: 0 2px 0 #3730a3; }
.math-board-formula-note.active {
    border: 2px solid #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,.12);
}

/* ========================================================================== */
/* PET PLAYROOM — child-friendly dog collection, treats and dress-up          */
/* ========================================================================== */
.pet-level-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    min-height: 25px;
    padding: 3px 9px;
    border: 2px solid rgba(255, 255, 255, .78);
    border-radius: 999px;
    background: linear-gradient(145deg, #fef3c7, #fbbf24);
    color: #713f12 !important;
    font-size: 13px !important;
    line-height: 1;
    box-shadow: 0 3px 0 #d97706, 0 5px 10px rgba(120, 53, 15, .2);
}
.pet-level-chip small { font-size: 10px; font-weight: 950; letter-spacing: .06em; }

.pet-creature .pd-dog {
    filter: drop-shadow(0 8px 5px rgba(74, 45, 25, .18));
    transform-origin: 50% 88%;
}
.pet-creature .pd-body-shine,
.pet-creature .pd-head-shine { mix-blend-mode: screen; }
.pet-creature:focus-visible {
    outline: 4px solid #fff;
    outline-offset: 5px;
    border-radius: 45%;
    box-shadow: 0 0 0 8px #7c3aed;
}
.pet-accessory-glyph {
    display: block;
    filter: drop-shadow(0 2px 1px rgba(31, 41, 55, .28));
    transform-origin: center;
}
.pet-accessory.acc-head .pet-accessory-glyph { transform: rotate(-4deg) scale(1.08); }
.pet-accessory.acc-eyes .pet-accessory-glyph { transform: scaleX(1.12); }
.pet-accessory.acc-neck .pet-accessory-glyph { transform: rotate(3deg); }
.pet-accessory.acc-toy .pet-accessory-glyph { transform: rotate(-12deg); }

.pet-info-modal-overlay,
.pet-shop-drawer-overlay {
    background: rgba(36, 20, 64, .56);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.pet-info-modal,
.pet-shop-modal {
    width: min(720px, calc(100vw - 24px));
    max-width: 720px;
    border: 2px solid rgba(255, 255, 255, .9);
    border-radius: 28px;
    padding: 18px;
    background:
        radial-gradient(circle at 8% 2%, rgba(253, 224, 71, .2), transparent 28%),
        radial-gradient(circle at 92% 10%, rgba(196, 181, 253, .35), transparent 30%),
        linear-gradient(180deg, #fffdf6, #f5f3ff);
    box-shadow: 0 20px 60px rgba(41, 20, 72, .28), inset 0 2px 0 #fff;
}
.pet-info-close {
    position: sticky;
    top: 0;
    /* Carried over from the duplicate block deleted near .pet-info-modal:
       it was cascading onto this button, so it stays to keep the rendering
       byte-identical. Inert while the modal scrolls only vertically; it is
       what pins the button off the right edge if it ever scrolls sideways. */
    right: 12px;
    float: right;
    z-index: 12;
    width: 44px;
    height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 2px solid #fff;
    border-radius: 50%;
    background: linear-gradient(145deg, #fff, #ede9fe);
    color: #5b21b6;
    font-size: 18px;
    font-weight: 900;
    box-shadow: 0 4px 0 #c4b5fd, 0 6px 12px rgba(91, 33, 182, .18);
    cursor: pointer;
}
.pet-info-close:active { transform: translateY(3px); box-shadow: 0 1px 0 #c4b5fd; }
.pet-info-close:focus-visible,
.shop-tab:focus-visible,
.shop-cat-pill:focus-visible,
.shop-buy-btn:focus-visible {
    outline: 3px solid #111827;
    outline-offset: 3px;
}

.pet-collection-hero {
    min-height: 150px;
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    margin: 4px 34px 18px 0;
    padding: 15px 18px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, .75);
    border-radius: 24px;
    background: linear-gradient(135deg, #60a5fa, #8b5cf6 62%, #ec4899);
    color: #fff;
    box-shadow: 0 7px 0 #6d28d9, 0 12px 22px rgba(109, 40, 217, .24);
}
.pet-collection-dog {
    min-height: 120px;
    display: grid;
    place-items: end center;
    border-radius: 50% 50% 44% 44%;
    background: radial-gradient(circle at 50% 65%, rgba(255,255,255,.42), transparent 62%);
}
.pet-collection-dog svg { max-width: 126px; height: auto; filter: drop-shadow(0 8px 4px rgba(44, 24, 79, .22)); }
.pet-collection-kicker {
    display: block;
    margin-bottom: 4px;
    color: #fef08a;
    font-size: 11px;
    font-weight: 950;
    letter-spacing: .12em;
}
.pet-collection-hero h3 { margin: 0; font-size: clamp(22px, 4vw, 30px); line-height: 1.1; }
.pet-collection-hero p { margin: 6px 0 0; color: rgba(255,255,255,.9); font-size: 13px; font-weight: 650; line-height: 1.4; }
.pet-collection-section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 20px 2px 10px;
}
.pet-collection-section-title span { color: #312e81; font-size: 17px; font-weight: 950; }
.pet-collection-section-title small { color: #6b7280; font-size: 11px; font-weight: 750; }
.pet-info-stages {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    /* Carried over from the duplicate block deleted near .pet-info-modal.
       This one is VISIBLE: home.js renders two .pet-info-stages grids back to
       back (evolution stages, then foods) and this is the gap between them. */
    margin-bottom: 16px;
}
.pet-info-stage,
.pet-evolution-card,
.pet-food-mini {
    min-width: 0;
    min-height: 152px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    padding: 10px 8px;
    border: 2px solid #ede9fe;
    border-radius: 20px;
    background: linear-gradient(160deg, #fff, #faf5ff);
    box-shadow: 0 5px 0 #ddd6fe, 0 8px 14px rgba(76, 29, 149, .08);
    text-align: center;
}
.pet-info-stage.current {
    border-color: #f59e0b;
    background: linear-gradient(160deg, #fff7d6, #fffbeb);
    box-shadow: 0 5px 0 #f59e0b, 0 8px 16px rgba(245, 158, 11, .2);
}
.pet-info-stage.locked { opacity: 1; filter: none; background: #f3f4f6; border-color: #d1d5db; box-shadow: 0 5px 0 #cbd5e1; }
.pet-info-stage.locked .pet-evolution-art { opacity: .42; filter: grayscale(1); }
.pet-evolution-art {
    min-height: 86px;
    display: grid;
    place-items: end center;
}
.pet-evolution-art svg { max-width: 82px; height: auto; filter: drop-shadow(0 5px 3px rgba(75, 42, 24, .16)); }
.pet-info-label { color: #1f2937; font-size: 13px; font-weight: 900; line-height: 1.2; }
.pet-info-pts { color: #6b7280; font-size: 10px; font-weight: 750; }
.pet-evolution-state {
    margin-top: 3px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #ede9fe;
    color: #5b21b6;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.pet-info-stage.current .pet-evolution-state { background: #fbbf24; color: #713f12; }
.pet-info-stage.locked .pet-evolution-state { background: #e5e7eb; color: #4b5563; }
.pet-food-mini {
    min-height: 138px;
    background: #fffaf5;
    background: linear-gradient(160deg, #fff, color-mix(in srgb, var(--food-color) 12%, white));
}
.pet-food-mini-art { width: 74px; height: 74px; display: grid; place-items: center; }
.pet-food-mini-art svg { width: 70px; height: 70px; filter: drop-shadow(0 5px 3px rgba(93, 50, 28, .14)); }

.pet-shop-modal {
    max-height: min(86dvh, 780px);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.pet-shop-drawer-overlay .pet-shop-modal {
    width: min(760px, 100%);
    max-width: 760px;
    max-height: min(74dvh, 720px);
    margin-inline: auto;
    padding: 14px max(14px, env(safe-area-inset-left)) calc(18px + env(safe-area-inset-bottom));
    border-radius: 30px 30px 0 0;
    border-bottom: 0;
}
.pet-shop-drawer-overlay .pet-shop-modal.food-drag-shop {
    max-height: min(56dvh, 590px);
}
.pet-shop-drawer-overlay {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: linear-gradient(180deg, rgba(36,20,64,.04) 0 38%, rgba(36,20,64,.2) 55%, rgba(36,20,64,.58) 100%);
}
.pet-hero-zone.drop-target-hint {
    animation: none !important;
    box-shadow: inset 0 0 0 5px rgba(254,240,138,.9), inset 0 0 34px rgba(254,240,138,.24);
}
.pet-hero-zone.drop-target-hint::after { display: none; }
.pet-hero-zone.drop-target-near {
    box-shadow: inset 0 0 0 7px rgba(134,239,172,.98), inset 0 0 46px rgba(34,197,94,.32);
}
.shop-hero {
    min-height: 118px;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    margin: 2px 34px 14px 0;
    padding: 12px 16px;
    border: 2px solid rgba(255,255,255,.76);
    border-radius: 24px;
    background: linear-gradient(135deg, #7c3aed, #4f46e5 54%, #0ea5e9);
    color: #fff;
    box-shadow: 0 7px 0 #4338ca, 0 11px 20px rgba(67, 56, 202, .24);
}
.shop-hero-dog {
    position: relative;
    height: 94px;
    display: grid;
    place-items: end center;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.45), transparent 68%);
}
.shop-hero-dog svg { max-width: 90px; height: auto; filter: drop-shadow(0 6px 3px rgba(31, 21, 68, .25)); }
.shop-hero-copy > span { color: #fef08a; font-size: 10px; font-weight: 950; letter-spacing: .12em; }
.shop-hero-copy h3 { margin: 2px 0 3px; font-size: clamp(18px, 3.5vw, 25px); line-height: 1.12; }
.shop-hero-copy p { margin: 0; color: rgba(255,255,255,.86); font-size: 11px; font-weight: 650; line-height: 1.35; }
.shop-wallet {
    align-self: start;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 9px;
    border: 2px solid #fff7c2;
    border-radius: 999px;
    background: linear-gradient(145deg, #fde68a, #f59e0b);
    color: #713f12;
    font-size: 13px;
    box-shadow: 0 4px 0 #b45309;
}
.shop-wallet > span,
.shop-buy-btn > span { color: #fbbf24; text-shadow: 0 1px 0 #92400e; }
.shop-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 5px;
    border: 1px solid #ddd6fe;
    border-radius: 17px;
    background: #ede9fe;
    margin-bottom: 12px;
}
.shop-tab {
    min-height: 44px;
    padding: 8px 7px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    color: #5b4a73;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
}
.shop-tab.active {
    border-color: transparent;
    background: #fff;
    color: #5b21b6;
    box-shadow: 0 3px 0 #c4b5fd, 0 4px 9px rgba(76, 29, 149, .12);
}
.shop-categories {
    display: flex;
    flex-wrap: nowrap;
    gap: 7px;
    margin: 0 0 13px;
    padding: 2px 2px 7px;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
}
.shop-categories::-webkit-scrollbar { display: none; }
.shop-cat-pill {
    flex: 0 0 auto;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    scroll-snap-align: start;
    border: 2px solid #ddd6fe;
    border-radius: 999px;
    background: #fff;
    color: #5b4a73;
    font-size: 12px;
    font-weight: 850;
    box-shadow: 0 3px 0 #ddd6fe;
    cursor: pointer;
}
.shop-cat-pill.active { border-color: #7c3aed; background: #7c3aed; color: #fff; box-shadow: 0 3px 0 #4c1d95; }
.shop-items.food-grid,
.shop-items.accessory-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 12px;
}
.shop-item.shop-card {
    min-width: 0;
    min-height: 252px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
    border: 2px solid #ede9fe;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 6px 0 #ddd6fe, 0 9px 15px rgba(76, 29, 149, .09);
    opacity: 1;
    transition: transform .18s ease, box-shadow .18s ease;
}
.shop-item.shop-card.disabled { opacity: .68; }
.shop-item.shop-card.owned { border-color: #86efac; background: #f0fdf4; box-shadow: 0 6px 0 #86efac; }
.shop-item.shop-card.equipped { border-color: #60a5fa; background: #eff6ff; box-shadow: 0 6px 0 #60a5fa; }
@media (hover: hover) {
    .shop-item.shop-card:not(.disabled):hover { transform: translateY(-3px); box-shadow: 0 9px 0 #ddd6fe, 0 13px 19px rgba(76, 29, 149, .12); }
}
.shop-food-art,
.shop-accessory-art {
    position: relative;
    min-height: 102px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 17px;
    background: #f5f3ff;
    background: linear-gradient(145deg, #fff, color-mix(in srgb, var(--food-color, #c4b5fd) 23%, white));
}
.shop-food-art::after {
    content: '';
    position: absolute;
    width: 76px;
    height: 22px;
    bottom: 7px;
    border-radius: 50%;
    background: rgba(79, 70, 229, .1);
    filter: blur(2px);
}
.shop-food-art svg { position: relative; z-index: 1; width: 84px; height: 84px; filter: drop-shadow(0 7px 4px rgba(100, 56, 30, .2)); }
.food-drag-handle { transition: transform .16s ease, box-shadow .16s ease; }
.food-drag-handle:focus-visible,
.pet-hero-zone:focus-visible {
    outline: 3px solid #111827;
    outline-offset: 3px;
}
.food-drag-grip {
    position: absolute;
    left: 8px;
    bottom: 7px;
    z-index: 3;
    padding: 3px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .9);
    color: #6d28d9;
    font-size: 12px;
    font-weight: 950;
    letter-spacing: -2px;
    box-shadow: 0 2px 0 #c4b5fd;
}
.shop-xp-burst {
    position: absolute;
    top: 7px;
    right: 7px;
    z-index: 2;
    padding: 4px 7px;
    border-radius: 999px;
    background: #fff;
    color: #5b21b6;
    font-size: 10px;
    font-weight: 950;
    box-shadow: 0 2px 0 #c4b5fd;
}
.shop-accessory-art { background: linear-gradient(145deg, #eef2ff, #fdf2f8); }
.shop-sticker {
    position: relative;
    width: 78px;
    height: 78px;
    display: grid;
    place-items: center;
    border: 4px solid #fff;
    border-radius: 24px 28px 22px 30px;
    background: linear-gradient(145deg, #bfdbfe, #ddd6fe);
    box-shadow: 0 6px 0 #a5b4fc, 0 9px 15px rgba(79, 70, 229, .2);
    transform: rotate(-3deg);
}
.shop-sticker-glyph { font-size: 43px; line-height: 1; filter: drop-shadow(0 3px 1px rgba(37, 25, 65, .2)); transform: rotate(3deg); }
.shop-sticker-spark { position: absolute; color: #fff; font-size: 14px; font-weight: 900; }
.shop-sticker-spark.one { left: 5px; top: 5px; }
.shop-sticker-spark.two { right: 7px; bottom: 6px; font-size: 10px; }
.shop-sticker.rarity-rare { background: linear-gradient(145deg, #67e8f9, #60a5fa); box-shadow-color: #3b82f6; }
.shop-sticker.rarity-epic { background: linear-gradient(145deg, #e879f9, #8b5cf6); }
.shop-sticker.rarity-legendary { background: linear-gradient(145deg, #fde68a, #fb7185); box-shadow: 0 6px 0 #f59e0b, 0 9px 15px rgba(245, 158, 11, .24); }
.shop-sticker.rarity-special { background: linear-gradient(145deg, #86efac, #22d3ee); }
.shop-item-info { flex: 1; min-width: 0; }
.shop-item-name { color: #1f2937; font-size: 14px; font-weight: 950; line-height: 1.2; }
.shop-item-desc { margin-top: 3px; color: #6b7280; font-size: 11px; line-height: 1.35; }
.shop-item-meta { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 5px; margin-top: 4px; color: #6b7280; font-size: 9px; font-weight: 800; }
.shop-rarity { padding: 3px 6px; border-radius: 999px; background: #e0e7ff; color: #4338ca; font-size: 10px; font-weight: 950; text-transform: uppercase; letter-spacing: .03em; }
.shop-rarity.rarity-rare { background: #cffafe; color: #0e7490; }
.shop-rarity.rarity-epic { background: #f3e8ff; color: #7e22ce; }
.shop-rarity.rarity-legendary { background: #fef3c7; color: #b45309; }
.shop-rarity.rarity-special { background: #dcfce7; color: #15803d; }
.shop-buy-btn {
    width: 100%;
    min-height: 44px;
    margin-top: auto;
    padding: 8px 10px;
    border: 2px solid #fff3b0;
    border-radius: 14px;
    background: linear-gradient(145deg, #fde047, #f59e0b);
    color: #713f12;
    font-size: 12px;
    font-weight: 950;
    box-shadow: 0 4px 0 #b45309, 0 6px 10px rgba(180, 83, 9, .16);
    cursor: pointer;
}
.shop-buy-btn.owned { border-color: #bbf7d0; background: linear-gradient(145deg, #4ade80, #16a34a); color: #fff; box-shadow: 0 4px 0 #15803d; }
.shop-buy-btn.equipped { border-color: #fecaca; background: linear-gradient(145deg, #fb7185, #e11d48); color: #fff; box-shadow: 0 4px 0 #9f1239; }
.shop-buy-btn.disabled,
.shop-buy-btn:disabled { border-color: #e5e7eb; background: #e5e7eb; color: #6b7280; box-shadow: 0 4px 0 #cbd5e1; cursor: not-allowed; }
.shop-buy-btn:active:not(:disabled):not(.disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #b45309; }
.shop-food-drag-meta {
    min-height: 44px;
    margin-top: auto;
    padding: 7px 9px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    border: 2px dashed #a78bfa;
    border-radius: 14px;
    background: #f5f3ff;
    color: #5b21b6;
}
.shop-food-price,
.shop-food-drag-cue { display: inline-flex; align-items: center; gap: 4px; font-weight: 950; }
.shop-food-price { color: #92400e; font-size: 12px; }
.shop-food-price > span { color: #fbbf24; text-shadow: 0 1px 0 #92400e; }
.shop-food-drag-cue { font-size: 9px; letter-spacing: .035em; text-align: right; }
.shop-food-drag-meta.locked { border-color: #d1d5db; background: #f3f4f6; color: #6b7280; }

@media (min-width: 700px) {
    .pet-info-stages { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .shop-items.food-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .shop-items.accessory-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .shop-item.shop-card { min-height: 265px; }
    .shop-items.food-grid .shop-item.shop-card { min-height: 248px; }
}
@media (max-width: 520px) {
    .pet-info-modal, .pet-shop-modal { width: calc(100vw - 16px); padding: 13px; border-radius: 24px; }
    .pet-collection-hero { grid-template-columns: 100px minmax(0, 1fr); min-height: 130px; gap: 9px; margin-right: 30px; padding: 10px; }
    .pet-collection-dog { min-height: 100px; }
    .pet-collection-dog svg { max-width: 102px; }
    .shop-hero { grid-template-columns: 76px minmax(0, 1fr); min-height: 102px; gap: 8px; margin-right: 30px; padding: 9px; }
    .shop-hero-dog { height: 78px; }
    .shop-hero-dog svg { max-width: 74px; }
    .shop-wallet { position: absolute; top: 65px; right: 14px; z-index: 4; }
    .shop-item.shop-card { min-height: 244px; padding: 9px; }
    .shop-food-art, .shop-accessory-art { min-height: 88px; }
    .shop-food-art svg { width: 72px; height: 72px; }
    .shop-sticker { width: 68px; height: 68px; }
    .shop-sticker-glyph { font-size: 37px; }
}
@media (max-height: 620px) {
    .pet-shop-drawer-overlay .pet-shop-modal.food-drag-shop { max-height: 58dvh; }
}
@media (max-width: 350px) {
    .shop-items.food-grid,
    .shop-items.accessory-grid { grid-template-columns: 1fr; }
    .shop-item.shop-card { min-height: 232px; }
    .pet-collection-hero, .shop-hero { grid-template-columns: 1fr; text-align: center; }
    .pet-collection-dog { display: none; }
    .shop-hero-dog { display: none; }
    .shop-wallet { top: 62px; }
}
@media (prefers-reduced-motion: reduce) {
    .shop-item.shop-card,
    .pet-info-close,
    .shop-buy-btn { transition: none !important; }
    .food-drag-handle { transition: none !important; }
    .pet-creature .pd-tail,
    .pet-creature .pd-ear,
    .pet-creature .pd-dog,
    .pet-accessory.acc-effect { animation: none !important; }
}
.pb-night-raid-copy h2{font-size:clamp(20px,4vw,29px);line-height:1.06;margin:5px 0;color:#fff}.pb-night-raid-copy p{font-size:13px;line-height:1.42;margin:0 0 12px;color:#bdcce2}.nr-home,.nr-scout{width:min(1120px,100%);margin:0 auto;padding:8px max(16px,env(safe-area-inset-left)) 28px}
.nr-feature-icon.live{background:rgba(176,105,255,.14);color:#d5a8ff}.nr-node-scene.moonlit-village{background:linear-gradient(145deg,#285a82,#162b58)}.nr-node-scene.haunted-forest{background:linear-gradient(145deg,#60468e,#241a49)}.nr-node-scene.storm-kingdom{background:linear-gradient(145deg,#53677b,#1d2c3b)}.nr-route-node.current .nr-node-scene{border-color:#ffd66f;box-shadow:0 0 0 5px rgba(255,214,111,.14),0 13px 30px rgba(0,0,0,.42)}.nr-route-node.locked{opacity:.42;filter:saturate(.3);cursor:not-allowed}.nr-stars i.on{background:#ffd05b}.nr-route-legend .moon{background:#66c5ff}.nr-route-legend .forest{background:#a883e7}.nr-route-legend .storm{background:#879daf}
.nr-battle{position:fixed;inset:0;z-index:3500;background:#071326;color:#fff;display:grid;grid-template-rows:auto minmax(0,1fr) auto;padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);overscroll-behavior:contain}.nr-unit-card.selected{border-color:#ffd266;background:#26304a;box-shadow:inset 0 0 0 2px rgba(255,210,102,.16)}.nr-unit-portrait.fox i{background:#ff9c4a;clip-path:polygon(0 20%,25% 0,50% 15%,75% 0,100% 20%,90% 100%,10% 100%)}.nr-unit-portrait.bat i{background:#b99aff;clip-path:polygon(0 20%,38% 38%,50% 0,62% 38%,100% 20%,78% 100%,22% 100%)}/* Scrolling lives on the body, NOT the card: the banner hangs above the card
   edge and an overflow on the card decapitated it. */
.nr-pop-body{max-height:min(72dvh,560px);overflow-y:auto;overscroll-behavior:contain;padding:44px 18px 16px;border-radius:26px}
.nr-charge.charging{cursor:wait;filter:saturate(.75)}
.nr-build-grid{min-width:620px;display:grid;grid-template-columns:repeat(8,1fr);grid-template-rows:repeat(5,68px);gap:4px;margin-left:7px}.nr-build-cell .trap{position:absolute;left:50%;bottom:7px;width:34px;height:8px;transform:translateX(-50%);background:repeating-linear-gradient(110deg,#aeb8c3 0 4px,#4e5965 4px 8px);clip-path:polygon(0 100%,10% 0,20% 100%,30% 0,40% 100%,50% 0,60% 100%,70% 0,80% 100%,90% 0,100% 100%)}.nr-build-cell .piece{position:absolute;left:50%;bottom:10px;transform:translateX(-50%);width:38px;height:42px;border-radius:8px;background:#a36a3e;border:3px solid #52372c}.nr-build-cell .piece.stone-wall{background:#96a3af;border-color:#43505b}.nr-build-cell .piece.pebble-pup{border-radius:50% 50% 42% 42%;background:#dda255}.nr-build-cell .piece.water-cannon{border-radius:50%;background:#42bfe8}.nr-dog-lane button.selected{background:#f1b850;color:#1d160c;border-color:#ffd878}.nr-build-symbol.stone-wall{background:#96a3af;border-color:#43505b}.nr-build-symbol.spike-trap{height:14px;clip-path:polygon(0 100%,12% 0,24% 100%,36% 0,48% 100%,60% 0,72% 100%,84% 0,100% 100%);background:#c1ccd7;border:0}.nr-build-symbol.pebble-pup{border-radius:50%;background:#dda255}.nr-build-symbol.water-cannon{border-radius:50%;background:#42bfe8}@keyframes nr-spin{to{transform:rotate(360deg)}}
.nr-battle :is(button,canvas):focus-visible{outline:3px solid #fff0a7;outline-offset:3px}
@media (max-width:700px){.pb-night-raid-copy p{font-size:12px}.nr-home,.nr-scout{padding-left:12px;padding-right:12px}}
@media (max-width:600px) and (max-aspect-ratio:1/1){.nr-battle{grid-template-rows:auto minmax(0,1fr) 112px}}
@media (min-width:768px){.nr-home{padding-top:16px}.nr-build-grid{grid-template-rows:repeat(5,72px)}}

.nr-feature-icon.reports{background:rgba(255,193,91,.14);color:#ffd278}
.nr-edit-toggle.active{background:linear-gradient(145deg,#ffe89a,#ffc65b);border-color:#e8ad3b;color:#644211;box-shadow:0 5px 0 #d59830}.nr-island-board.editing .nr-iso-cell{pointer-events:auto}.nr-island-board.editing .nr-iso-cell>i{opacity:1}.nr-island-board.editing:after{content:"Chạm ô sáng để đặt công trình";position:absolute;z-index:5;left:50%;bottom:14px;transform:translateX(-50%);padding:8px 13px;border-radius:999px;background:rgba(47,68,37,.82);color:#fff;font-size:11px;font-weight:850;white-space:nowrap;backdrop-filter:blur(6px)}@media (max-width:700px){.nr-island-board.editing:after{bottom:8px;font-size:10px}}

.nr-power-strip .damage,.nr-builder-scoreboard .damage{background:#fff0e5;color:#a94717}.nr-power-strip .defense,.nr-builder-scoreboard .defense{background:#e7f2ff;color:#1760a4}.nr-builder-scoreboard>.coins{background:#fff6d8;color:#6e5112}.nr-matchup.danger{border-color:#ff7b65}.nr-auto-stat.damage{background:#51251f;color:#ffb07e}.nr-auto-stat.defense{background:#163b62;color:#8dccff}@media(max-width:700px){.nr-builder-scoreboard>.coins{grid-column:1/-1;display:flex;align-items:center;justify-content:space-between}.nr-builder-scoreboard>.coins strong{font-size:24px}}

.nr-home-fab{width:66px;height:62px;padding:0;border:2px solid #fff8c9;border-radius:17px;background:linear-gradient(145deg,#ffd967,#f57f27);color:#5b350c;box-shadow:0 5px 0 #b95b20,0 10px 20px rgba(89,53,20,.24);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;font-weight:1000;font-size:10px;letter-spacing:.04em;line-height:1;white-space:nowrap;cursor:pointer;touch-action:manipulation}
.nr-home-fab svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2.3}
.nr-home-fab:active{transform:translateY(3px);box-shadow:0 2px 0 #b95b20}
.nr-home-fab.raid{border-color:#ffca5a;background:linear-gradient(135deg,#ff8b2e,#ef3f35);color:#fff;box-shadow:0 5px 0 #9e271f,0 10px 22px rgba(255,77,42,.3)}
.nr-home-fab.raid:active{box-shadow:0 2px 0 #9e271f}
@media(min-width:768px){.nr-home-fab{width:74px;height:68px;font-size:10.5px}.nr-home-fab svg{width:25px;height:25px}}

.nr-collect-all.ready{background:linear-gradient(145deg,#ffde70,#f69a2d);color:#5a360f;animation:nr-ready-pulse 1.2s ease-in-out infinite alternate}.nr-collect-all:disabled{cursor:default;opacity:.78}@keyframes nr-ready-pulse{to{box-shadow:0 8px 26px rgba(255,175,45,.58)}}
.nr-production-badge.ready{background:linear-gradient(145deg,#ffd959,#f18729);color:#5d370c;animation:nr-ready-pulse 1s ease-in-out infinite alternate}.nr-production-badge.ready,.nr-production-badge.shown{display:block}
@media(prefers-reduced-motion:reduce){.nr-collect-all.ready,.nr-production-badge.ready{animation:none}}

/* `hidden` alone loses to .nr-home-fab's own display:flex, so a sealed
   castle kept showing a live-looking TIẾN QUÂN button. */
.nr-home-fab[hidden]{display:none}

/* Rename the dog: a small ✎ beside the name on the home hero. */
.pet-name-edit{width:26px;height:26px;margin-left:2px;padding:0;border:1px solid rgba(255,255,255,.35);border-radius:9px;background:rgba(255,255,255,.16);color:#fff;font-size:13px;line-height:1;cursor:pointer;flex:0 0 auto}
.pet-name-edit:active{background:rgba(255,255,255,.3)}
.pet-name-cancel{opacity:.82;filter:saturate(.6)}

/* ── Home hero: the dog's name above its five hearts ── */
.pet-hearts-name{max-width:150px;margin-bottom:2px;font-size:12px;font-weight:900;color:#fff;text-shadow:0 1px 4px rgba(0,0,0,.4);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* ── Home hero topbar: ONE control size ──
   Avatar, identity card, coins, streak and info were five different pills.
   Everything is now 44px tall with the same dark-glass background and the
   same rounded language. Appended last on purpose: overrides the originals. */
.pet-hero-identity{height:44px;max-width:132px;padding:3px 10px 4px;display:flex;flex-direction:column;justify-content:center;border-radius:22px;background:rgba(0,0,0,.35)}
.pet-identity-name{align-items:center}
.pet-name-edit{width:20px;height:20px;margin-left:0;border-radius:7px;font-size:11px;display:inline-flex;align-items:center;justify-content:center}
.pet-identity-style{margin-top:2px}
.pet-hero-coins{height:44px;min-height:44px;padding:0 13px;border-radius:22px}
.pet-hero-streak{height:44px;min-height:44px;padding:0 12px;border-radius:22px;display:flex;align-items:center;gap:4px}
.pet-hero-info{background:rgba(0,0,0,.35);border:2px solid rgba(255,255,255,.25)}

/* ── Trophy cabinet: sell a cup for coins, with a make-sure dialog ── */
.cup-sell-btn{margin-top:7px;width:100%;min-height:38px;border:1px solid #f2d38b;border-radius:12px;background:#fff8e3;color:#8a5d13;font-weight:900;font-size:12px;cursor:pointer}
.cup-sell-btn:active{background:#ffedbf}
.cup-sell-backdrop{position:fixed;inset:0;z-index:4000;display:grid;place-items:center;padding:18px;background:rgba(10,14,24,.55);backdrop-filter:blur(3px)}
.cup-sell-dialog{width:min(360px,100%);padding:18px;border-radius:22px;background:#fff;color:#2b2b33;text-align:center;box-shadow:0 24px 60px rgba(0,0,0,.35)}
.cup-sell-icon{font-size:34px;margin-bottom:6px}
.cup-sell-dialog h3{margin:0 0 6px;font-size:18px}
.cup-sell-dialog p{margin:0 0 14px;font-size:13px;line-height:1.5;color:#565664}
.cup-sell-actions{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.cup-sell-actions button{min-height:48px;border-radius:14px;font-weight:900;cursor:pointer;font-size:13px}
.cup-sell-cancel{border:1px solid #d6d9e2;background:#f4f5f9;color:#3c3f4c}
.cup-sell-confirm{border:0;background:linear-gradient(135deg,#ffca4f,#f59f22);color:#5b3a06;box-shadow:0 4px 0 #c77c14}
.cup-sell-confirm:active{transform:translateY(2px);box-shadow:0 2px 0 #c77c14}

/* The walk trail. Sits UNDER the dog so a print never covers the paw that
   made it, and every node deletes itself when its animation ends. Sizes are
   in cqw so prints stay proportional as the child pinches the yard. */
/* The raid yard, shrunk into the home habitat. The map is normally sized in
   pixels by the builder; here it simply fills whatever box it is given. */
/* The stage is positioned by an ID rule, which outranks any class — so the
   yard override has to carry the ID too or it lands half a screen to the left. */
#petHeroStage.yard-mode,.pet-hero-stage.yard-mode{inset:0;left:0;top:0;right:0;bottom:0;width:100%;height:100%;display:block;transform:none}

/* The animated mini-yard is already a GPU-composited surface. iOS Safari can
   flash or mis-size it when a second full-screen backdrop-filter is added on
   top, so the homepage shop gets an opaque, stable scrim. */
.pet-shop-drawer-overlay.yard-shop-overlay,
.pet-info-modal-overlay.yard-shop-overlay{z-index:1000;height:100vh;height:100dvh;-webkit-backdrop-filter:none;backdrop-filter:none;background:rgba(36,20,64,.78);isolation:isolate}
.pet-shop-drawer-overlay.yard-shop-overlay{
  background:linear-gradient(180deg,rgba(36,20,64,.04) 0 38%,rgba(36,20,64,.2) 55%,rgba(36,20,64,.58) 100%)}
.pet-info-modal-overlay.yard-shop-overlay{padding:max(12px,env(safe-area-inset-top)) 10px max(12px,env(safe-area-inset-bottom));overflow:hidden}
.pet-info-modal-overlay.yard-shop-overlay .pet-shop-modal{width:min(760px,100%);max-height:calc(100dvh - max(24px,env(safe-area-inset-top) + env(safe-area-inset-bottom)));margin:auto;transform:none}

.pb-arena-yard.nr-mini-yard .nr-builder-map.nr-mini-map{height:100%;width:auto;aspect-ratio:4/3;background:transparent;box-shadow:none;transform:translate(-50%,-50%)}
.pb-arena-yard .nr-mini-map{isolation:auto}
.pb-arena-yard .nr-mini-map>.nr-board-art{clip-path:polygon(12% 7%,88% 7%,90% 10%,92% 22%,93% 45%,94% 75%,95% 100%,5% 100%,6% 75%,7% 45%,8% 22%,10% 10%);mix-blend-mode:darken;filter:drop-shadow(0 8px 12px rgba(43,82,24,.25))}
.pb-dog-info-heading h2{margin:0;font-size:clamp(18px,4vw,25px);line-height:1.15}

.go-bot-1{right:4%}
@media(min-width:700px){.go-bot-1{right:8%}}
@media(max-height:560px) and (min-width:560px){.go-bot-1{right:4%}}

/* Ghost Offering owns the entire Arena content box. The normal Arena lobby
   reserves 90px below its cards; retaining that padding produced the blank
   band above the bottom navigation on tall iPhones. */
.pet-battle-screen.go-event-active{padding:0!important;overflow:hidden;max-width:none!important;width:100%;margin:0!important}
.pet-battle-screen.go-event-active .go-loading{height:100%;min-height:0;background:#10142c;color:#fff}

/* A deferred question bank (js/lazy-data.js) is still downloading. Brief and
   quiet: on a warm cache this is usually never seen. */
.lazy-loading {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted, #7c8aa5);
  font-weight: 600;
}
/* The screen's own stylesheet (css/arena.css, css/night-raid.css,
   css/math.css) is still downloading. switchScreen (js/app.js) sets this
   while a sheet is pending and clears it when the sheet has arrived; only the
   loading notice above stays visible in between, so the screen is never seen
   unstyled. visibility, not display: the modules measure their layout on
   render and are told to re-measure (a resize event) once the sheet is in. */
.screen.lazy-css-pending > :not(.lazy-loading) { visibility: hidden; }

/* ── Daily Task (admin-assigned) ─────────────────────────────────────── */
.daily-task-card:empty { display: none; }
/* Spacing around the day's card follows the one rhythm the rest of Home uses
   (14px, the streak → skills gap). Without this the card sat flush under the
   pet stage and the streak panel — whose -20px top margin exists to tuck it
   under the stage when there is NO card — climbed 6px up over the card. */
.daily-task-card:not(:empty) { margin-top: 14px; }
.daily-task-card:not(:empty) + .streak-panel { margin-top: 0; }
/* The day's assigned work sits at the top of Home and has to LOOK like the
   thing to do next — the glass card it used to be read as one more panel in a
   scroll of panels, and a child skimmed past it. Warm fill, thicker border and
   a soft glow lift it off the page without shouting; once every task is done
   it turns green and calms down, because at that point it is a receipt rather
   than an instruction. */
.dt-card {
    display: flex; align-items: center; gap: 13px; width: calc(100% - 32px);
    margin: 0 16px 14px; padding: 15px 16px; border-radius: 20px; text-align: left;
    background: linear-gradient(135deg, #fff3d6 0%, #ffe6c7 55%, #ffd9e6 100%);
    border: 2.5px solid #f59e0b;
    box-shadow: 0 6px 22px rgba(245, 158, 11, 0.30), 0 2px 6px rgba(0,0,0,0.06);
    font: inherit; color: inherit; cursor: pointer;
    position: relative; overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
}
.dt-card:active { transform: scale(0.985); box-shadow: 0 3px 12px rgba(245,158,11,0.28); }
/* A slow sheen that says "new/unfinished" without animating anything the eye
   has to track. Stops entirely when the work is done, and for anyone who has
   asked the system to reduce motion. */
.dt-card::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,0.55) 50%, transparent 70%);
    transform: translateX(-100%); animation: dtSheen 3.6s ease-in-out infinite;
}
@keyframes dtSheen { 0%, 62% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .dt-card::after { animation: none; opacity: 0; } }
.dt-card.done::after { animation: none; opacity: 0; }
.dt-card.done {
    background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
    border-color: #22c55e; box-shadow: 0 4px 16px rgba(34, 197, 94, 0.26);
}
.dt-card-icon {
    font-size: 26px; flex: 0 0 auto; width: 46px; height: 46px; border-radius: 14px;
    display: grid; place-items: center; background: rgba(255,255,255,0.75);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}
.dt-card-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dt-card-body strong { font-size: 17px; font-weight: 800; color: #7c2d12; letter-spacing: -0.2px; }
.dt-card-body small { color: #9a3412; font-size: 13px; font-weight: 600; }
.dt-card.done .dt-card-body strong { color: #14532d; }
.dt-card.done .dt-card-body small { color: #15803d; }

.daily-task-screen { padding: 16px 16px 90px; overflow-y: auto; }
.dt-head { position: relative; text-align: center; margin-bottom: 14px; }
.dt-head h2 { margin: 6px 0 2px; font-size: 22px; }
.dt-head p { margin: 0; color: #888; font-size: 13px; }
.dt-head .close-btn { position: absolute; left: 0; top: 0; }
.dt-list { display: flex; flex-direction: column; gap: 10px; }
.dt-task {
    padding: 12px 14px; border-radius: 14px; background: #fff;
    border: 1.5px solid rgba(0,0,0,0.06); box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.dt-task.done { background: #f0fdf4; border-color: #86efac; }
.dt-task-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dt-task-top span { font-weight: 700; white-space: nowrap; }
.dt-task.done .dt-task-top span { color: #16a34a; }
.dt-bar { height: 8px; border-radius: 999px; background: rgba(0,0,0,0.08); margin: 8px 0 4px; overflow: hidden; }
.dt-bar i { display: block; height: 100%; background: linear-gradient(90deg, #f59e0b, #22c55e); border-radius: 999px; }
.dt-task small { color: #777; }
.dt-go, .dt-shield-btn {
    display: block; width: 100%; margin-top: 10px; padding: 11px; border: 0; border-radius: 12px;
    background: #2563eb; color: #fff; font: inherit; font-weight: 700; cursor: pointer;
}
.dt-shield-btn { background: #7c3aed; margin-top: 8px; }
.dt-empty { text-align: center; color: #888; padding: 24px 0; }
.dt-reward { margin-top: 14px; text-align: center; font-weight: 700; color: #16a34a; }
.dt-reward.muted { color: #888; font-weight: 500; }

/* Home card: the gift count is a corner bubble on the 📋 icon; the collection
   chip on the right is the tap target into Kho Khiên & Kiếm. Title and chip
   are a notch smaller than before so both fit on one line at 375px. */
.dt-card-icon { position: relative; overflow: visible; }
.dt-card-badge {
    position: absolute; top: -7px; right: -8px; min-width: 22px; height: 22px; padding: 0 6px;
    border-radius: 999px; background: #dc2626; color: #fff; font-size: 12px; font-weight: 900; font-style: normal;
    display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(220,38,38,0.35);
}
.dt-card-body strong { font-size: 16px; }

/* ── Task screen — a day the child WANTS to finish ───────────────────── */
/* Hero: one ring, one sentence. Amber while there is work, green once done. */
.dt-hero {
    display: flex; align-items: center; gap: 14px; margin-bottom: 14px; padding: 14px 16px;
    border-radius: 20px; border: 2.5px solid #f59e0b;
    background: linear-gradient(135deg, #fff3d6 0%, #ffe6c7 55%, #ffd9e6 100%);
    box-shadow: 0 6px 22px rgba(245,158,11,0.25);
}
.dt-hero.done {
    border-color: #22c55e; background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
    box-shadow: 0 6px 22px rgba(34,197,94,0.25);
}
.dt-ring-wrap { position: relative; width: 72px; height: 72px; flex: 0 0 auto; display: grid; place-items: center; }
.dt-ring { position: absolute; inset: 0; width: 72px; height: 72px; transform: rotate(-90deg); }
.dt-ring .track { fill: none; stroke: rgba(255,255,255,0.75); stroke-width: 7; }
.dt-ring .fill { fill: none; stroke: #f59e0b; stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.dt-hero.done .dt-ring .fill { stroke: #22c55e; }
.dt-ring-wrap b { position: relative; font-size: 17px; font-weight: 900; color: #7c2d12; }
.dt-hero.done .dt-ring-wrap b { color: #14532d; }
.dt-hero-text { flex: 1; min-width: 0; }
.dt-hero-text strong { display: block; font-size: 18px; font-weight: 800; color: #7c2d12; letter-spacing: -0.2px; }
.dt-hero-text small { display: block; margin-top: 2px; color: #9a3412; font-weight: 600; }
.dt-hero.done .dt-hero-text strong { color: #14532d; }
.dt-hero.done .dt-hero-text small { color: #15803d; }

/* The unopened gift — the door to Kho Khiên & Kiếm. */
.dt-gift-cta {
    display: flex; align-items: center; gap: 12px; width: 100%; margin: 0 0 14px; padding: 12px 14px;
    min-height: 60px; border-radius: 16px; border: 2px solid #f59e0b; background: #fff8ea;
    color: #7c2d12; font: inherit; font-weight: 800; text-align: left; cursor: pointer;
    box-shadow: 0 4px 14px rgba(245,158,11,0.22);
}
.dt-gift-cta:active { transform: scale(0.985); }
.dt-gift-cta .dt-gift-emoji { font-size: 30px; line-height: 1; animation: amGiftWiggle 3s ease-in-out infinite; }
.dt-gift-cta strong { display: block; font-size: 16px; }
.dt-gift-cta small { display: block; font-weight: 600; color: #9a3412; }
.dt-gift-cta > span:last-child { margin-left: auto; font-size: 22px; }

/* Task rows as check rows: a big circle that fills green when the row is done. */
.dt-task { display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 10px; }
.dt-check {
    flex: 0 0 auto; width: 30px; height: 30px; margin-top: 1px; border-radius: 50%;
    border: 2.5px solid #fcd34d; background: #fffbeb; display: grid; place-items: center;
    color: #fff; font-weight: 900; font-size: 16px; transition: background .25s ease, border-color .25s ease;
}
.dt-task.done .dt-check { background: #22c55e; border-color: #22c55e; }
.dt-task-main { flex: 1; min-width: 0; }
.dt-task-top strong { font-size: 15px; }
.dt-task-top span { color: #b45309; }
.dt-task small { display: block; margin-top: 2px; }
.dt-go { min-height: 44px; }

/* Collection strip: two mini cards (lit when owned, dashed when not), the
   shield's state as a pill, then the door to the full armory. */
.dt-armory { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.dt-mini {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; min-height: 44px;
    border-radius: 16px; border: 2px dashed #cbd5e1; background: #f8fafc; color: #64748b;
    font: inherit; cursor: pointer;
}
.dt-mini.has.shield {
    border: 2px solid #c4b5fd; background: linear-gradient(160deg, #ede9fe, #ddd6fe); color: #4c1d95;
    box-shadow: 0 4px 14px rgba(124,58,237,0.22);
}
.dt-mini.has.sword {
    border: 2px solid #fda4af; background: linear-gradient(160deg, #ffe4e6, #fecdd3); color: #881337;
    box-shadow: 0 4px 14px rgba(220,38,38,0.18);
}
.dt-mini-icon { font-size: 30px; line-height: 1; }
.dt-mini:not(.has) .dt-mini-icon { filter: grayscale(1); opacity: .4; }
.dt-mini b { font-size: 18px; font-weight: 900; }
.dt-mini small { font-size: 12px; font-weight: 700; }
.dt-armory-side { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; }
.dt-pill {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 12px;
    border-radius: 999px; background: #f1f5f9; color: #475569; font-weight: 700; font-size: 13px; text-align: center;
}
.dt-pill.on { background: #ede9fe; color: #6d28d9; box-shadow: inset 0 0 0 1.5px #c4b5fd; }
.dt-armory .dt-shield-btn { margin-top: 0; min-height: 44px; }
.dt-armory-link {
    display: block; width: 100%; padding: 11px; min-height: 44px; border: 1.5px solid #c4b5fd; border-radius: 12px;
    background: #fff; color: #6d28d9; font: inherit; font-weight: 700; cursor: pointer;
}

@keyframes amGiftWiggle {
    0%, 84%, 100% { transform: rotate(0); }
    88% { transform: rotate(-12deg); }
    92% { transform: rotate(12deg); }
    96% { transform: rotate(-6deg); }
}
@media (prefers-reduced-motion: reduce) {
    .dt-gift-cta .dt-gift-emoji { animation: none; }
        .dt-ring .fill { transition: none; }
}

.nr-home-fab.armory { position: relative; overflow: visible; }
.nr-home-fab .nr-fab-emoji { font-size: 22px; line-height: 1; }

.pb-night-raid-copy h2 { color: #23442d; }
.pb-night-raid-copy p { color: #60775a; }
.nr-home:not(.nr-builder), .nr-scout { color: #26452f; }

/* Farm on the castle grid: per-day sprites, wilt, task-day badges */
.nr-production-badge.wilted{background:#7a5a3a;color:#ffe9c9}
.nr-replant.ready{background:linear-gradient(145deg,#73cd58,#3ca845);color:#fff}

.nr-zone-chips button.active{background:#3f6046;color:#fff}

.nr-task-bar.done{background:#dcf6bd;color:#2f5d22}.nr-task-bar.wilted{background:#f6e3c6;color:#6b4a1f}
.nr-collect-all.wilted{background:linear-gradient(145deg,#f0b46a,#c97a2a);color:#fff;cursor:pointer}

/* Daily Task: the garden strip */
.dt-farm{display:grid;grid-template-columns:56px minmax(0,1fr) auto;align-items:center;gap:10px;margin:10px 14px 0;padding:10px 12px;border-radius:18px;background:#eef7dd;color:#2f4632}
.dt-farm.wilted{background:#f6e3c6;color:#6b4a1f}
.dt-farm-art{width:56px;height:56px;object-fit:contain;display:grid;place-items:center;font-size:30px}
.dt-farm-text strong{display:block;font-size:13px}.dt-farm-text small{display:block;font-size:12px;opacity:.85}
.dt-farm-go{min-height:36px;padding:0 12px;border:0;border-radius:999px;background:#3f6046;color:#fff;font-weight:950;cursor:pointer}
.dt-seed-reward{display:grid;grid-template-columns:64px minmax(0,1fr) auto;align-items:center;gap:11px;margin:12px 14px 0;padding:12px;border:2px solid #e4c45d;border-radius:20px;background:linear-gradient(145deg,#fff9d9,#edf8cf);color:#344d38;box-shadow:0 8px 20px rgba(74,91,44,.12)}
.dt-seed-reward.earned{border-color:#5fbd59;background:linear-gradient(145deg,#eaffd9,#ccefa9)}
.dt-seed-reward>img,.dt-seed-placeholder{width:64px;height:64px;object-fit:contain;display:grid;place-items:center;font-size:34px;filter:drop-shadow(0 5px 4px rgba(66,70,40,.18))}
.dt-seed-copy{min-width:0}.dt-seed-copy>span{display:block;color:#77703a;font-size:9px;font-weight:1000;letter-spacing:.09em}.dt-seed-copy>strong{display:block;margin:2px 0;font-size:17px}.dt-seed-copy>small{display:block;color:#52614a;font-size:11px;line-height:1.35}
.dt-seed-steps{display:grid;grid-template-columns:1fr 1fr;gap:5px;margin-top:7px}.dt-seed-steps i{height:7px;border-radius:999px;background:#d7ddbd}.dt-seed-steps i.done{background:#64b64f}
.dt-seed-reward>button{min-width:84px;min-height:44px;padding:0 12px;border:0;border-radius:14px;background:#3f6046;color:#fff;font-size:11px;font-weight:950;cursor:pointer}
@media(max-width:520px){.dt-seed-reward{grid-template-columns:54px minmax(0,1fr);padding:10px}.dt-seed-reward>img,.dt-seed-placeholder{width:54px;height:54px}.dt-seed-reward>button{grid-column:1/-1;width:100%}}

/* ── Home progress cards — reference-matched compact layout ─────────── */
.daily-task-card:not(:empty){margin-top:14px}
.dt-card{
    display:block;width:calc(100% - 32px);margin:0 16px 14px;padding:14px 13px 11px;
    border:2px solid #63c77a;border-radius:20px;text-align:initial;
    background:linear-gradient(145deg,#f2fff6 0%,#e4f9eb 62%,#f4fff7 100%);
    box-shadow:0 8px 24px rgba(40,119,67,.14);overflow:visible;color:#205b31;
}
.dt-card::after{content:none}
.dt-card:not(.done){border-color:#e6bd55;background:linear-gradient(145deg,#fffbed,#fff3d2 65%,#fffaf0);box-shadow:0 8px 24px rgba(164,117,28,.13)}
.dt-card-head{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:10px}
.dt-card-open{
    min-width:0;min-height:44px;padding:0;border:0;background:transparent;color:inherit;font:inherit;
    display:flex;align-items:center;gap:10px;text-align:left;cursor:pointer
}
.dt-card-icon{
    position:relative;overflow:visible;display:block;width:auto;height:auto;flex:0 0 auto;
    padding:0;border-radius:0;background:transparent;box-shadow:none;font-size:30px;line-height:1
}
.dt-card-open>strong{min-width:0;color:#17672f;font-size:17px;font-weight:900;letter-spacing:-.2px}
.dt-card:not(.done) .dt-card-open>strong{color:#725018}
.dt-card-badge{top:-8px;right:-9px;min-width:21px;height:21px;padding:0 5px;font-size:11px}
.dt-card-progress{
    min-width:50px;padding:8px 12px;border-radius:999px;background:rgba(255,255,255,.74);
    color:#253331;font-size:15px;font-weight:900;text-align:center;box-shadow:0 3px 12px rgba(48,89,60,.06)
}
.dt-card-body{display:block;text-align:center;padding:9px 4px 10px}
.dt-card-body>strong{display:block;color:#16813a!important;font-size:15px;font-weight:900;line-height:1.35}
.dt-card:not(.done) .dt-card-body>strong{color:#835d1b!important}
.dt-card-body>small{display:block;margin-top:3px;color:#385b43!important;font-size:13px;font-weight:600;line-height:1.35}
.dt-card:not(.done) .dt-card-body>small{color:#705e39!important}
.dt-card-primary{
    width:100%;min-height:46px;padding:10px 16px;border:0;border-radius:13px;
    background:linear-gradient(135deg,#2eb545,#22a83b);color:#fff;font:inherit;font-size:15px;font-weight:900;
    box-shadow:0 5px 12px rgba(32,157,57,.25);cursor:pointer;transition:transform .12s ease,filter .12s ease
}
.dt-card:not(.done) .dt-card-primary{background:linear-gradient(135deg,#f1b332,#de9221);box-shadow:0 5px 12px rgba(187,119,21,.23)}
.dt-card-primary:active{transform:scale(.985);filter:brightness(.96)}
.dt-card-armory{
    width:100%;min-height:40px;margin:7px 0 -4px;padding:5px 8px;border:0;background:transparent;
    color:#327943;font:inherit;font-size:12px;font-weight:700;text-align:center;cursor:pointer
}
.dt-card:not(.done) .dt-card-armory{color:#715d31}

.streak-panel{
    flex:none;margin:0;padding:0 16px;background:transparent;border-radius:0;box-shadow:none;position:relative;z-index:15
}
.home-streak-card{
    padding:18px 13px 15px;border-radius:20px;
    background:linear-gradient(135deg,#232148 0%,#332566 52%,#4c228a 100%);
    box-shadow:0 9px 24px rgba(40,29,91,.25);overflow:hidden
}
.home-streak-card::before{top:-80px;right:-70px;width:220px;height:220px;background:radial-gradient(circle,rgba(138,91,210,.24),transparent 68%)}
.home-streak-head{display:flex;align-items:center;justify-content:space-between;gap:12px;text-align:left}
.home-streak-total{display:flex;align-items:baseline;gap:7px;min-width:0;color:#fff;white-space:nowrap}
.home-streak-fire{align-self:center;font-size:36px;line-height:1;filter:drop-shadow(0 3px 5px rgba(0,0,0,.22))}
.home-streak-total>strong{font-size:39px;font-weight:900;line-height:1}
.home-streak-total>span:last-child{font-size:13px;font-weight:800;color:rgba(255,255,255,.86)}
.home-streak-next{flex:0 0 auto;color:rgba(255,255,255,.72);font-size:11.5px;font-weight:600;line-height:1.4;text-align:left}
.home-streak-next strong{color:#fff;font-weight:800}
.home-streak-week{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:5px;margin:18px 0 11px}
.home-streak-day{
    min-width:0;min-height:44px;padding:6px 2px 5px;gap:3px;border:1px solid transparent;border-radius:9px;
    background:rgba(139,91,210,.24)
}
.home-streak-day.studied{background:rgba(139,91,210,.34);border-color:transparent}
.home-streak-day.today{outline:0;border:2px solid #ffd62f;padding:5px 1px 4px;box-shadow:0 0 0 1px rgba(255,214,47,.12)}
.home-streak-day-label{font-size:10px;color:rgba(255,255,255,.75);text-transform:none}
.home-streak-day-dot{font-size:14px;color:rgba(255,255,255,.72);line-height:1}
.home-streak-day.studied .home-streak-day-dot{color:#ffb82e}
.home-streak-done{padding:0;border:0;border-radius:0;background:transparent;color:rgba(255,255,255,.76);font-size:12px;font-weight:700}
.home-streak-cta{
    min-height:42px;padding:9px 16px;border:1px solid rgba(255,255,255,.18);border-radius:12px;
    background:rgba(255,255,255,.12);box-shadow:none;font-size:13px
}
.home-streak-cta:hover{box-shadow:none;background:rgba(255,255,255,.17)}

.home-skills-panel{
    flex-shrink:0;margin:14px 16px 100px;padding:0;border:0;border-radius:17px;
    background:rgba(255,255,255,.88);box-shadow:0 7px 22px rgba(40,34,87,.09);overflow:hidden
}
.home-skills-compact{
    width:100%;min-height:68px;padding:11px 15px;border:1px solid rgba(93,72,160,.09);border-radius:17px;
    background:linear-gradient(135deg,rgba(255,255,255,.96),rgba(249,247,255,.94));color:#26333d;
    display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:11px;
    font:inherit;text-align:left;cursor:pointer
}
.home-skills-compact-icon{font-size:24px;line-height:1}
.home-skills-compact>strong{font-size:16px;font-weight:900}
.home-skills-compact-link{color:#8152d2;font-size:13px;font-weight:800;white-space:nowrap}
.home-skills-compact-link i{display:inline-block;margin-left:5px;font-size:25px;font-style:normal;font-weight:400;line-height:.6;vertical-align:-2px;transition:transform .18s ease}
.home-skills-compact[aria-expanded="true"] .home-skills-compact-link i{transform:rotate(90deg)}
.home-skills-details{padding:4px 16px 16px;border-top:1px solid rgba(93,72,160,.08)}
.home-skills-details .home-skills-sub{margin-top:10px}

@media(max-width:380px){
    .dt-card{width:calc(100% - 24px);margin-left:12px;margin-right:12px}
    .dt-card-open>strong{font-size:15px}.dt-card-progress{min-width:46px;padding:7px 9px;font-size:14px}
    .streak-panel{padding:0 12px}.home-streak-card{padding-left:10px;padding-right:10px}
    .home-streak-fire{font-size:31px}.home-streak-total>strong{font-size:34px}.home-streak-total>span:last-child{font-size:11px}
    .home-streak-next{font-size:10px}.home-streak-week{gap:3px}
    .home-skills-panel{margin-left:12px;margin-right:12px}.home-skills-compact{padding-left:12px;padding-right:12px}
}
@media(prefers-reduced-motion:reduce){.dt-card-primary,.home-skills-compact-link i{transition:none}}

/* A production control is useful only when the child can act on it. Keep the
   ready harvest and wilt recovery buttons, but let the idle state occupy no
   estate space. The timer will remove `disabled` when a field becomes ready. */
.nr-collect-all:disabled{display:none}
