/* ============================================================
   HỌC XANH - DUOLINGO DESIGN SYSTEM (WEB VERSION)
   Redesigned for rich, premium, playful educational web interface.
   ============================================================ */

/* NOTE: Nunito font được load qua <link> trong base.html (không dùng @import để tránh block render) */

@font-face {
    font-family: 'Material Symbols Outlined';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/static/fonts/MaterialSymbolsOutlined.woff2') format('woff2');
}

:root {
    /* Duolingo Bright Color Palette */
    --duo-green: #58cc02;
    --duo-green-border: #46a302;
    --duo-green-light: #d7ffb8;
    
    --duo-blue: #1cb0f6;
    --duo-blue-border: #1899d6;
    --duo-blue-light: #ddf4ff;
    
    --duo-orange: #ff9600;
    --duo-orange-border: #e68500;
    --duo-orange-light: #ffebcc;
    
    --duo-pink: #ff4b4b;
    --duo-pink-border: #ea2b2b;
    --duo-pink-light: #ffdfe0;
    
    --duo-purple: #7856ff;
    --duo-purple-border: #613be3;
    --duo-purple-light: #e8e0ff;
    
    --duo-yellow: #ffc800;
    --duo-yellow-border: #e6b400;
    --duo-yellow-light: #fff5cc;

    --duo-gray: #e5e5e5;
    --duo-gray-border: #afafaf;
    --duo-gray-light: #f7f7f7;
    
    --duo-dark: #3c3c3c;
    --duo-dark-muted: #777777;
    --duo-border-color: #e5e5e5;
    --duo-bg-color: #ffffff;
    
    --font-primary: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* Chiều cao viewport thực — cập nhật bởi capacitor-app.js / utils */
    --hx-app-height: 100dvh;
    --hx-safe-top: env(safe-area-inset-top, 0px);
    --hx-safe-right: env(safe-area-inset-right, 0px);
    --hx-safe-bottom: env(safe-area-inset-bottom, 0px);
    --hx-safe-left: env(safe-area-inset-left, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-primary);
    -webkit-tap-highlight-color: transparent;
}

html {
    width: 100%;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    background-color: var(--duo-bg-color);
    color: var(--duo-dark);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    min-height: var(--hx-app-height, 100dvh);
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    touch-action: manipulation;
}

img, video, svg, canvas {
    max-width: 100%;
    height: auto;
}

/* ============================================================
   LAYOUT SYSTEM (Desktop Sidebar, Main, Right Sidebar)
   ============================================================ */
.duo-wrapper {
    display: flex;
    min-height: var(--hx-app-height, 100dvh);
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    position: relative;
    min-width: 0;
}

/* Left Sidebar */
.duo-sidebar {
    width: 256px;
    height: 100vh;
    position: sticky;
    top: 0;
    border-right: 2px solid var(--duo-border-color);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: stretch; /* Explicitly stretch children */
    z-index: 100;
    background: white;
    flex-shrink: 0;
}

.duo-logo {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 16px;
    margin-bottom: 32px;
    text-decoration: none;
    width: 100%;
}

.duo-logo-img {
    width: 76px;
    height: 76px;
    object-fit: contain;
}

.duo-logo-text {
    font-size: 26px;
    font-weight: 900;
    color: var(--duo-green);
    letter-spacing: -0.5px;
    text-transform: uppercase;
}

.duo-nav-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none;
    width: 100%;
}

.duo-nav-item {
    width: 100%;
}

.duo-nav-item a {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    padding: 12px 16px;
    color: var(--duo-dark-muted);
    font-size: 15px;
    font-weight: 800;
    text-transform: uppercase;
    text-decoration: none;
    border-radius: 12px;
    border: 2px solid transparent;
    transition: all 0.1s ease;
    width: 100%;
}

/* Material Symbols Font-Family Override to prevent FOIT and Font Overrides */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined' !important;
    font-weight: normal !important;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

.duo-nav-item a:hover {
    background-color: var(--duo-gray-light);
}

.duo-nav-item.active a {
    color: var(--duo-blue);
    background-color: var(--duo-blue-light);
    border: 2px solid var(--duo-blue);
}

.duo-nav-item.admin-nav a {
    color: var(--duo-purple);
}
.duo-nav-item.admin-nav.active a {
    background-color: var(--duo-purple-light);
    border: 2px solid var(--duo-purple);
}

.duo-nav-icon {
    font-size: 24px;
}

/* Center Content & Right Sidebar Container */
.duo-main-container {
    flex: 1;
    min-width: 0;
    display: flex;
    padding: 0;
}

/* Middle Column (Content) */
.duo-content-col {
    flex: 1;
    max-width: 600px;
    min-width: 0;
    min-height: var(--hx-app-height, 100dvh);
    margin: 0 auto;
    padding: 24px 16px 80px 16px;
}

/* Right Column (Stats/Quests/Leagues) */
.duo-stats-col {
    width: 368px;
    padding: 24px 24px 80px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-left: none;
    flex-shrink: 0;
}

/* Dashboard mobile — carousel vuốt ngang, gọn chiều cao */
.dashboard-mobile-carousel-wrap {
    display: none;
    width: 100%;
    overflow: visible;
    margin-left: -12px;
    margin-right: -12px;
}

.dashboard-mobile-carousel {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: scroll;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 2px 12px 4px;
}

.dashboard-mobile-carousel::-webkit-scrollbar {
    display: none;
}

.dashboard-mobile-slide {
    flex: 0 0 88%;
    flex-shrink: 0;
    max-width: 88%;
    scroll-snap-align: center;
    scroll-snap-stop: always;
    padding: 10px 12px !important;
    min-height: 0;
}

.dashboard-mobile-slide-head {
    font-size: 12px;
    font-weight: 800;
    color: var(--duo-dark);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.dashboard-mobile-stat-row {
    display: flex;
    gap: 8px;
}

.dashboard-mobile-stat-pill {
    flex: 1;
    min-width: 0;
    background: var(--duo-bg);
    border-radius: 12px;
    padding: 8px 10px;
    border: 2px solid var(--duo-border-color);
}

.dashboard-mobile-stat-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: var(--duo-dark-muted);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.dashboard-mobile-stat-value {
    display: block;
    font-size: 16px;
    font-weight: 900;
    color: var(--duo-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dashboard-mobile-quest-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dashboard-mobile-quest-item {
    font-size: 12px;
    font-weight: 700;
    color: var(--duo-dark-muted);
    padding-left: 10px;
    border-left: 3px solid var(--duo-gray-border);
}

.dashboard-mobile-quest-item.done {
    color: var(--duo-green);
    border-left-color: var(--duo-green);
}

.dashboard-mobile-leader-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dashboard-mobile-leader-list > div {
    font-size: 12px !important;
}

.dashboard-mobile-leader-link {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    color: var(--duo-blue);
    text-decoration: none;
    margin-top: 6px;
}

.dashboard-mobile-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 6px;
}

.dashboard-mobile-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--duo-gray-border);
    transition: background 0.2s, transform 0.2s;
}

.dashboard-mobile-dot.active {
    background: var(--duo-blue);
    transform: scale(1.2);
}

@media (max-width: 992px) {
    .duo-main-container {
        flex-direction: column;
    }
    .duo-stats-col {
        display: flex !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding: 0 12px calc(80px + var(--hx-safe-bottom)) 12px !important;
        margin: 0;
        gap: 16px;
        border: none !important;
    }
    .duo-content-col {
        padding-bottom: 16px !important;
        max-width: 100% !important;
    }
}

/* ============================================================
   BUTTONS (Duolingo 3D Effect)
   ============================================================ */
.duo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 800;
    text-transform: uppercase;
    border-radius: 16px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: filter 0.2s, transform 0.1s;
    user-select: none;
    text-decoration: none;
    outline: none;
}

.duo-btn:hover {
    filter: brightness(1.05);
}

.duo-btn:active {
    transform: translateY(2px) !important;
}

/* Green Button */
.duo-btn-green {
    background-color: var(--duo-green);
    color: white;
    border-bottom: 4px solid var(--duo-green-border);
}
.duo-btn-green:active {
    border-bottom: 2px solid var(--duo-green-border);
}

/* Blue Button */
.duo-btn-blue {
    background-color: var(--duo-blue);
    color: white;
    border-bottom: 4px solid var(--duo-blue-border);
}
.duo-btn-blue:active {
    border-bottom: 2px solid var(--duo-blue-border);
}

/* Orange Button */
.duo-btn-orange {
    background-color: var(--duo-orange);
    color: white;
    border-bottom: 4px solid var(--duo-orange-border);
}
.duo-btn-orange:active {
    border-bottom: 2px solid var(--duo-orange-border);
}

/* Gray / Secondary Button */
.duo-btn-gray {
    background-color: white;
    color: var(--duo-dark-muted);
    border: 2px solid var(--duo-gray);
    border-bottom: 4px solid var(--duo-gray);
}
.duo-btn-gray:active {
    border-bottom: 2px solid var(--duo-gray);
}

/* Disabled Button */
.duo-btn:disabled {
    background-color: var(--duo-gray) !important;
    border-color: var(--duo-gray-border) !important;
    border-bottom-width: 4px !important;
    color: var(--duo-gray-border) !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* ============================================================
   CARDS (Clean White cards with thick borders)
   ============================================================ */
.duo-card {
    background-color: white;
    border: 2px solid var(--duo-border-color);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 4px 0 rgba(0,0,0,0.02);
    margin-bottom: 16px;
    transition: transform 0.1s ease, border-color 0.1s ease;
}

.duo-card-interactive {
    cursor: pointer;
}
.duo-card-interactive:hover {
    border-color: var(--duo-blue);
    transform: translateY(-2px);
}

/* ============================================================
   TOP STATS ROW & PILLS
   ============================================================ */
.duo-stats-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: white;
    padding: 10px 16px;
    border-radius: 16px;
    border: 2px solid var(--duo-border-color);
    margin-bottom: 16px;
}

.duo-stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 800;
    color: var(--duo-dark);
    text-decoration: none;
}

.duo-stat-icon {
    font-size: 24px;
    display: flex;
}

/* Specific colors */
.duo-stat-points { color: var(--duo-orange); }
.duo-stat-rank { color: var(--duo-green); }
.duo-stat-hearts { color: var(--duo-pink); }

/* ============================================================
   SNAKE MAP / LEARNING PATH
   ============================================================ */
.duo-map-header {
    background-color: var(--duo-blue);
    color: white;
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 32px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 6px 0 var(--duo-blue-border);
}

.duo-map-header h1 {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.duo-map-header p {
    font-size: 14px;
    opacity: 0.9;
    font-weight: 600;
}

/* Select Grade dropdown */
.duo-select-container {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: visible;
}

.duo-select-grade {
    flex: 1;
    height: 48px;
    border-radius: 14px;
    border: 2px solid var(--duo-border-color);
    border-bottom: 4px solid var(--duo-border-color);
    padding: 0 16px;
    font-weight: 800;
    font-size: 16px;
    color: var(--duo-dark);
    outline: none;
    background: white;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%233c3c3c' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
}

.duo-select-grade:focus {
    border-color: var(--duo-blue);
}

/* Custom Dropdown for Grade Selection */
.duo-custom-select {
    position: relative;
    flex: 1;
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.duo-custom-select-search {
    position: sticky;
    top: 0;
    background: white;
    z-index: 2;
    padding: 10px;
    margin: 0;
    border-bottom: 2px solid var(--duo-border-color);
    box-sizing: border-box;
}

.duo-custom-select-search input {
    display: block;
    width: 100%;
    max-width: 100%;
    border: 2px solid var(--duo-border-color);
    border-radius: 12px;
    padding: 10px 14px;
    font-family: inherit;
    font-weight: 700;
    font-size: 16px;
    color: var(--duo-dark);
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.duo-custom-select-search input:focus {
    border-color: var(--duo-blue);
}

.duo-custom-select-trigger {
    width: 100%;
    height: 48px;
    border-radius: 14px;
    border: 2px solid var(--duo-border-color);
    border-bottom: 4px solid var(--duo-border-color);
    padding: 0 16px;
    font-weight: 800;
    font-size: 16px;
    color: var(--duo-dark);
    outline: none;
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.1s ease;
}

.duo-custom-select-trigger:hover {
    background-color: var(--duo-gray-light);
}

.duo-custom-select-trigger.open {
    border-color: var(--duo-blue-border);
    border-bottom-color: var(--duo-blue-border);
}

.duo-custom-select-trigger.open .dropdown-arrow {
    transform: rotate(180deg);
}

.duo-custom-select-trigger .dropdown-arrow {
    transition: transform 0.2s ease;
    font-size: 20px;
    color: var(--duo-dark-muted);
}

.duo-custom-select-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    background: white;
    border: 2px solid var(--duo-border-color);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 2000;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 250px;
    display: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    box-sizing: border-box;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.duo-custom-select-menu.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.duo-custom-select-item {
    padding: 12px 16px;
    font-weight: 700;
    font-size: 15px;
    color: var(--duo-dark);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.duo-custom-select-item:hover {
    background-color: var(--duo-gray-light);
}

.duo-custom-select-item.selected {
    background-color: var(--duo-green-light);
    color: var(--duo-green-border);
    font-weight: 800;
}

/* Subject Tabs */
.duo-subject-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 24px;
    scrollbar-width: none;
}
.duo-subject-tabs::-webkit-scrollbar { display: none; }

.duo-subject-tab {
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 14px;
    background-color: white;
    border: 2px solid var(--duo-border-color);
    border-bottom: 4px solid var(--duo-border-color);
    color: var(--duo-dark-muted);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.duo-subject-tab.active {
    background-color: var(--duo-blue-light);
    border-color: var(--duo-blue);
    border-bottom-width: 4px;
    color: var(--duo-blue);
}

/* The actual Snake Path container */
.duo-map-path {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 12px 0 40px;
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

.duo-round-section {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.duo-round-banner {
    width: calc(100% + 0px);
    max-width: 460px;
    border-radius: 20px;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 0px;
    position: relative;
    z-index: 10;
    box-shadow: 0 6px 20px rgba(0,0,0,0.14);
    transition: transform 0.2s;
}

.duo-round-banner:hover {
    transform: translateY(-2px);
}

.duo-round-banner-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.duo-round-banner-text {
    flex: 1;
}

.duo-round-banner-label {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.85;
    margin-bottom: 2px;
}

.duo-round-banner-title {
    font-size: 16px;
    font-weight: 900;
    line-height: 1.2;
}

.duo-round-banner-desc {
    font-size: 13px;
    font-weight: 600;
    opacity: 0.8;
    margin-top: 2px;
}

/* Round color themes */
.duo-round-1 { background: linear-gradient(135deg, #58cc02, #46a302); color: white; }
.duo-round-2 { background: linear-gradient(135deg, #1cb0f6, #1899d6); color: white; }
.duo-round-3 { background: linear-gradient(135deg, #ff9600, #e68500); color: white; }
.duo-round-4 { background: linear-gradient(135deg, #7856ff, #613be3); color: white; }
.duo-round-5 { background: linear-gradient(135deg, #ff4b4b, #ea2b2b); color: white; }

/* Banner is clickable */
.duo-round-banner {
    cursor: pointer;
}

/* Chevron arrow on banner */
.duo-round-chevron {
    font-size: 22px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    opacity: 0.9;
}

/* Lessons container — collapsible (display:none khi đóng — tránh flex không thu gọn) */
.duo-round-section:not(.open) .duo-round-lessons {
    display: none;
}

.duo-round-lessons {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    overflow: hidden;
    padding-top: 24px;
    padding-bottom: 24px;
}

/* Open state */
.duo-round-section.open .duo-round-lessons {
    display: flex;
}

.duo-round-section.open .duo-round-chevron {
    transform: rotate(180deg);
}

/* Divider between rounds */
.duo-round-divider {
    width: 3px;
    height: 16px;
    background: linear-gradient(to bottom, var(--duo-border-color), transparent);
    border-radius: 2px;
    margin: 4px auto;
}

.duo-map-node-wrapper {
    position: relative;
    z-index: 5;
}

/* Winding Snake margins — scoped to lessons container children */
.duo-round-lessons .duo-map-node-wrapper:nth-child(8n+1) { margin-left: 0; }
.duo-round-lessons .duo-map-node-wrapper:nth-child(8n+2) { margin-left: 60px; }
.duo-round-lessons .duo-map-node-wrapper:nth-child(8n+3) { margin-left: 100px; }
.duo-round-lessons .duo-map-node-wrapper:nth-child(8n+4) { margin-left: 60px; }
.duo-round-lessons .duo-map-node-wrapper:nth-child(8n+5) { margin-left: 0; }
.duo-round-lessons .duo-map-node-wrapper:nth-child(8n+6) { margin-left: -60px; }
.duo-round-lessons .duo-map-node-wrapper:nth-child(8n+7) { margin-left: -100px; }
.duo-round-lessons .duo-map-node-wrapper:nth-child(8n+8) { margin-left: -60px; }

/* The Circle Node button */
.duo-map-node {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    outline: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
    transition: transform 0.1s;
}

.duo-map-node:active {
    transform: translateY(2px);
}

/* Unlocked colors */
.duo-map-node-unlocked {
    background-color: var(--duo-green);
    border-bottom: 8px solid var(--duo-green-border);
    color: white;
}
.duo-map-node-unlocked:active {
    border-bottom-width: 4px;
}

/* Completed gold colors */
.duo-map-node-completed {
    background-color: var(--duo-yellow);
    border-bottom: 8px solid var(--duo-yellow-border);
    color: var(--duo-dark);
}
.duo-map-node-completed:active {
    border-bottom-width: 4px;
}

/* Locked gray colors */
.duo-map-node-locked {
    background-color: var(--duo-gray);
    border-bottom: 8px solid var(--duo-gray-border);
    color: var(--duo-gray-border);
    cursor: not-allowed;
}
.duo-map-node-locked:active {
    transform: none;
}

/* Circle Progress Ring around the Node */
.duo-node-ring {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 92px;
    height: 92px;
    pointer-events: none;
    transform: rotate(-90deg);
}

.duo-node-icon {
    font-size: 34px;
}

.duo-node-check {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background-color: var(--duo-yellow);
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--duo-dark);
    font-size: 14px;
    font-weight: 900;
}

/* Tooltip Popup */
.duo-node-tooltip {
    position: absolute;
    bottom: calc(100% + 14px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    width: 250px;
    background: white;
    border: 2px solid var(--duo-border-color);
    border-radius: 20px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.duo-node-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px;
    border-style: solid;
    border-color: white transparent transparent transparent;
}
.duo-node-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px;
    border-style: solid;
    border-color: var(--duo-border-color) transparent transparent transparent;
    z-index: -1;
}

.duo-node-tooltip.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) scale(1);
}

.duo-tooltip-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--duo-dark);
    margin-bottom: 4px;
}

.duo-tooltip-sub {
    font-size: 13px;
    color: var(--duo-dark-muted);
    margin-bottom: 12px;
}

/* ============================================================
   FULLSCREEN LESSON PLAYER
   ============================================================ */
.duo-player-overlay {
    position: fixed;
    inset: 0;
    background-color: white;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding-top: var(--hx-safe-top);
    padding-left: var(--hx-safe-left);
    padding-right: var(--hx-safe-right);
    box-sizing: border-box;
}

.duo-player-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Header with progress & hearts */
.duo-player-header {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.duo-player-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--duo-gray-border);
    font-size: 24px;
    font-weight: 800;
    transition: color 0.1s;
    outline: none;
}
.duo-player-close:hover {
    color: var(--duo-dark);
}

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

.duo-progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--duo-green);
    border-radius: 8px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Light gleam effect on progress bar */
.duo-progress-bar::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 8px;
    right: 8px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

/* Content Area */
.duo-player-body {
    flex: 1;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
}

/* Dialogue bubble style for Mascot questions */
.duo-mascot-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.duo-mascot-avatar {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background-color: var(--duo-green-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    border: 2px solid var(--duo-green);
}

.duo-bubble {
    flex: 1;
    min-width: 0;
    background: white;
    border: 2px solid var(--duo-border-color);
    border-radius: 20px;
    padding: 16px 20px;
    position: relative;
    font-size: 18px;
    font-weight: 700;
    color: var(--duo-dark);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.duo-math-expr {
    display: block;
    margin-top: 6px;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1.35;
    color: var(--duo-dark);
    font-variant-numeric: tabular-nums;
}

.duo-bubble::after {
    content: '';
    position: absolute;
    right: 100%;
    top: 24px;
    border-width: 8px;
    border-style: solid;
    border-color: transparent white transparent transparent;
}
.duo-bubble::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 23px;
    border-width: 10px;
    border-style: solid;
    border-color: transparent var(--duo-border-color) transparent transparent;
    z-index: -1;
}

/* Quiz visual — sao, chấm, ô vuông cho câu đếm hình */
.duo-quiz-visual-wrap {
    width: 100%;
    max-width: 100%;
    margin: 0 0 16px;
}

.duo-quiz-visual {
    position: relative;
    width: 100%;
    min-height: 140px;
    max-height: 200px;
    border-radius: 16px;
    border: 2px solid var(--duo-border-color);
    background: linear-gradient(180deg, #f7fbff 0%, #ffffff 100%);
    overflow: hidden;
    box-sizing: border-box;
}

.duo-quiz-visual-stars,
.duo-quiz-visual-dots,
.duo-quiz-visual-circles,
.duo-quiz-visual-triangles {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 140px;
}

.duo-quiz-star,
.duo-quiz-dot,
.duo-quiz-circle,
.duo-quiz-triangle {
    position: absolute;
    transform: translate(-50%, -50%);
    user-select: none;
    pointer-events: none;
}

.duo-quiz-star {
    font-size: 28px;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.12));
}

.duo-quiz-dot,
.duo-quiz-circle {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--duo-blue);
    border: 2px solid var(--duo-blue-border);
}

.duo-quiz-circle {
    background: var(--duo-orange-light);
    border-color: var(--duo-orange);
}

.duo-quiz-triangle {
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 22px solid var(--duo-purple);
}

.duo-quiz-visual-blocks {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    padding: 16px;
    min-height: auto;
    max-height: none;
    align-content: center;
}

.duo-quiz-visual-blocks.duo-quiz-decimal {
    grid-template-columns: repeat(10, 1fr);
    gap: 6px;
    padding: 20px 12px;
}

.duo-quiz-block {
    aspect-ratio: 1;
    border-radius: 8px;
    border: 2px solid var(--duo-border-color);
    background: white;
}

.duo-quiz-block.filled {
    background: var(--duo-green-light);
    border-color: var(--duo-green);
    box-shadow: inset 0 -3px 0 var(--duo-green-border);
}

/* Choices Grid */
.duo-choices-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 30px;
}

.duo-choice-card {
    background-color: white;
    border: 2px solid var(--duo-border-color);
    border-bottom: 4px solid var(--duo-border-color);
    border-radius: 16px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    color: var(--duo-dark);
    user-select: none;
    transition: border-color 0.1s, background-color 0.1s;
}

.duo-choice-card:hover {
    background-color: var(--duo-gray-light);
}

.duo-choice-card:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.duo-choice-key {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 2px solid var(--duo-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    color: var(--duo-dark-muted);
}

/* Selection state */
.duo-choice-card.selected {
    border-color: var(--duo-blue);
    border-bottom-color: var(--duo-blue-border);
    background-color: var(--duo-blue-light);
    color: var(--duo-blue);
}
.duo-choice-card.selected .duo-choice-key {
    border-color: var(--duo-blue);
    color: var(--duo-blue);
}

/* Footer Banner */
.duo-player-footer {
    border-top: 2px solid var(--duo-border-color);
    padding: 24px 20px;
    background-color: white;
}

.duo-footer-inner {
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Sliding feedback bar — Duolingo-style compact strip */
.duo-feedback-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    transform: translateY(100%);
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}

.duo-feedback-panel.show {
    transform: translateY(0);
    pointer-events: auto;
}

.duo-feedback-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 96px;
    box-sizing: border-box;
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
    max-width: 720px;
    margin: 0 auto;
}

.duo-feedback-leading {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.duo-feedback-status-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.22);
    color: white;
}

.duo-feedback-status-icon .material-symbols-outlined {
    font-size: 22px;
    font-weight: 700;
}

.duo-feedback-copy {
    min-width: 0;
    flex: 1;
}

.duo-feedback-title {
    font-size: 17px;
    font-weight: 800;
    line-height: 1.25;
    margin: 0;
}

.duo-feedback-desc {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    margin: 4px 0 0;
    opacity: 0.92;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.duo-feedback-desc[hidden] {
    display: none !important;
}

.duo-feedback-trail {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.duo-feedback-btn-next,
.duo-feedback-btn-tutor {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 44px;
    padding: 0 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    cursor: pointer;
    border: none;
    transition: filter 0.15s, transform 0.1s;
}

.duo-feedback-btn-next:active,
.duo-feedback-btn-tutor:active {
    transform: translateY(1px);
}

.duo-feedback-btn-tutor {
    display: none;
    min-height: 40px;
    padding: 0 14px;
    background: rgba(255, 255, 255, 0.15);
    color: inherit;
    border: 2px solid rgba(255, 255, 255, 0.45);
    font-size: 12px;
}

.duo-feedback-btn-tutor .material-symbols-outlined {
    font-size: 18px;
}

.duo-feedback-btn-tutor.is-visible {
    display: inline-flex;
}

/* Correct — solid green strip, white text */
.duo-feedback-correct {
    background: var(--duo-green);
    color: white;
    border-top: 2px solid var(--duo-green-border);
}

.duo-feedback-correct .duo-feedback-btn-next {
    background: white;
    color: var(--duo-green-border);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}

.duo-feedback-correct .duo-feedback-btn-next:active {
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

/* Wrong — solid pink strip */
.duo-feedback-wrong {
    background: var(--duo-pink);
    color: white;
    border-top: 2px solid var(--duo-pink-border);
}

.duo-feedback-wrong .duo-feedback-btn-next {
    background: white;
    color: var(--duo-pink-border);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
}

.duo-feedback-wrong .duo-feedback-btn-tutor {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.5);
}

/* Wrong + explanation: align top when có 2 dòng chữ */
.duo-feedback-detail .duo-feedback-bar {
    align-items: flex-start;
}

.duo-feedback-detail .duo-feedback-trail {
    padding-top: 4px;
}

.duo-player-overlay:has(.duo-feedback-panel.show) #floating-tutor-btn {
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 520px) {
    .duo-feedback-bar {
        padding-left: 14px;
        padding-right: 14px;
        gap: 10px;
    }
    .duo-feedback-title {
        font-size: 16px;
    }
    .duo-feedback-btn-next {
        padding: 0 16px;
        min-height: 42px;
        font-size: 12px;
    }
    .duo-feedback-btn-tutor span:last-child {
        display: none;
    }
    .duo-feedback-btn-tutor {
        padding: 0 10px;
        min-width: 40px;
    }
}

/* ============================================================
   LOGIN SPLASH SCREEN
   ============================================================ */
.duo-login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    max-width: 450px;
    margin: 0 auto;
    text-align: center;
}

.duo-login-mascot {
    font-size: 84px;
    margin-bottom: 16px;
    animation: bounce 2s infinite ease-in-out;
}

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

.duo-login-title {
    font-size: 32px;
    font-weight: 900;
    color: var(--duo-green);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.duo-login-subtitle {
    font-size: 15px;
    color: var(--duo-dark-muted);
    margin-bottom: 32px;
}

.duo-form-group {
    width: 100%;
    margin-bottom: 14px;
    text-align: left;
}

.duo-input {
    width: 100%;
    height: 52px;
    border: 2px solid var(--duo-border-color);
    border-radius: 16px;
    padding: 0 16px;
    font-size: 16px;
    font-weight: 700;
    color: var(--duo-dark);
    outline: none;
    background-color: var(--duo-gray-light);
    transition: all 0.2s;
}

.duo-input:focus {
    background-color: white;
    border-color: var(--duo-blue);
}

.duo-tabs-nav {
    display: flex;
    width: 100%;
    border-bottom: 2px solid var(--duo-border-color);
    margin-bottom: 24px;
}

.duo-tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    font-weight: 800;
    font-size: 16px;
    color: var(--duo-dark-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

.duo-tab-btn.active {
    color: var(--duo-green);
    border-bottom-color: var(--duo-green);
}

/* ============================================================
   NUTRITION LOG / DIARY
   ============================================================ */
.duo-nutrition-pills {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.duo-nutri-card {
    background-color: white;
    border: 2px solid var(--duo-border-color);
    border-radius: 16px;
    padding: 12px;
    text-align: center;
}

.duo-nutri-val {
    font-size: 18px;
    font-weight: 900;
    color: var(--duo-orange);
}

.duo-nutri-lbl {
    font-size: 11px;
    color: var(--duo-dark-muted);
    text-transform: uppercase;
}

/* ============================================================
   SHOP GRID
   ============================================================ */
.duo-shop-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.duo-shop-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background-color: white;
    border: 2px solid var(--duo-border-color);
    border-radius: 16px;
    gap: 16px;
}

.duo-shop-avatar {
    width: 52px;
    height: 52px;
    border-radius: 0;
    background-color: transparent;
    border: none;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    line-height: 1;
    flex-shrink: 0;
    overflow: visible;
}

.duo-shop-avatar .duo-avatar-3d,
.duo-shop-avatar img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    display: block;
}

.duo-shop-details {
    flex: 1;
}

.duo-shop-name {
    font-size: 16px;
    font-weight: 800;
    color: var(--duo-dark);
}

.duo-shop-desc {
    font-size: 13px;
    color: var(--duo-dark-muted);
}

.duo-shop-price {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 900;
    color: var(--duo-orange);
    font-size: 15px;
}

/* ============================================================
   LEADERBOARD & LEAGUES
   ============================================================ */
.duo-podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
    padding: 30px 10px 10px 10px;
    background-color: var(--duo-blue-light);
    border-radius: 20px;
    border: 2px solid var(--duo-blue);
    margin-bottom: 24px;
}

.duo-podium-spot {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.duo-podium-avatar {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

.duo-podium-avatar-lg {
    width: 80px;
    height: 80px;
}

.duo-league-gem {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.duo-league-gem-img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    filter: drop-shadow(0 6px 8px rgba(0,0,0,0.25));
}

.duo-avatar-3d {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: none;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.22));
    pointer-events: none;
}

.duo-avatar-medal {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 26px;
    height: 26px;
    object-fit: contain;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

.duo-podium-name {
    font-size: 13px;
    font-weight: 800;
    margin-top: 6px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

.duo-podium-score {
    font-size: 11px;
    font-weight: 700;
    color: var(--duo-orange);
}

.duo-podium-box {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 900;
    color: white;
    border-radius: 12px 12px 0 0;
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.35), 0 6px 0 rgba(0,0,0,0.12);
    transform: perspective(200px) rotateX(4deg);
    transform-origin: bottom center;
}

.spot-1st .duo-podium-box { height: 70px; background-color: var(--duo-yellow); border: 2px solid var(--duo-yellow-border); color: var(--duo-dark); }
.spot-2nd .duo-podium-box { height: 50px; background-color: var(--duo-gray-border); border: 2px solid #999; }
.spot-3rd .duo-podium-box { height: 40px; background-color: #cd7f32; border: 2px solid #b36e2b; }

.duo-leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.duo-leader-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background-color: white;
    border: 2px solid var(--duo-border-color);
    border-radius: 16px;
    gap: 12px;
}

.duo-leader-rank {
    width: 24px;
    font-weight: 900;
    font-size: 15px;
    color: var(--duo-dark-muted);
    text-align: center;
}

.duo-leader-avatar {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
    flex-shrink: 0;
    position: relative;
}

.duo-leader-name {
    flex: 1;
    font-weight: 800;
}

.duo-leader-score {
    font-weight: 900;
    color: var(--duo-orange);
}

.duo-stats-avatar {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.duo-stats-avatar .duo-avatar-3d {
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
}

/* ============================================================
   CHAT INTERFACE (AI TUTOR)
   ============================================================ */
.duo-chat-box {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px);
    border: 2px solid var(--duo-border-color);
    border-radius: 20px;
    overflow: hidden;
    background-color: var(--duo-gray-light);
}

.duo-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.duo-chat-msg {
    display: flex;
    gap: 12px;
    max-width: 80%;
}

.duo-chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.duo-chat-msg.bot {
    align-self: flex-start;
}

.duo-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.duo-chat-msg.bot .duo-chat-avatar { background-color: var(--duo-green-light); border: 1.5px solid var(--duo-green); }
.duo-chat-msg.user .duo-chat-avatar { background-color: var(--duo-blue-light); border: 1.5px solid var(--duo-blue); }

.duo-chat-text {
    background-color: white;
    border: 2px solid var(--duo-border-color);
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    color: var(--duo-dark);
}

.duo-chat-msg.user .duo-chat-text {
    background-color: var(--duo-blue);
    border-color: var(--duo-blue-border);
    color: white;
}

.duo-chat-input-bar {
    padding: 12px 16px;
    background-color: white;
    border-top: 2px solid var(--duo-border-color);
    display: flex;
    gap: 10px;
}

/* ============================================================
   MOBILE APP SHELL (header + tab bar)
   ============================================================ */
.duo-mobile-header {
    display: none;
}

/* Mobile Bottom Navigation — 8 mục, lưới 4×2 căn đều */
.duo-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background-color: white;
    border-top: 2px solid var(--duo-border-color);
    z-index: 100;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    align-items: stretch;
    justify-items: stretch;
    padding: 4px 2px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
    box-sizing: border-box;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}

.duo-bottom-nav-item {
    display: flex;
    width: 100%;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--duo-dark-muted);
    font-weight: 800;
    font-size: 8px;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.15;
    padding: 6px 2px;
    border: none;
    background: none;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

#bnav-aitutor {
    font-size: 7px;
    line-height: 1.1;
}

.duo-bottom-nav-item.active {
    color: var(--duo-blue);
    background: var(--duo-blue-light);
    border-radius: 10px;
}

.duo-bottom-nav-icon {
    font-size: 20px;
    line-height: 1;
    margin-bottom: 3px;
}

.duo-bottom-nav-item .material-symbols-outlined {
    font-size: 24px;
    margin-bottom: 2px;
}

@media (max-width: 768px) {
    .duo-sidebar {
        display: none !important; /* Hide desktop sidebar */
    }
    .duo-wrapper {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 100dvh;
    }
    .app-shell .duo-mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: sticky;
        top: 0;
        z-index: 200;
        min-height: 52px;
        padding: 8px 14px;
        padding-top: calc(8px + env(safe-area-inset-top));
        background: white;
        border-bottom: 2px solid var(--duo-border-color);
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    }
    .duo-mobile-header-brand {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }
    .duo-mobile-header-logo {
        width: 32px;
        height: 32px;
        object-fit: contain;
        flex-shrink: 0;
    }
    .duo-mobile-header-title {
        font-size: 16px;
        font-weight: 900;
        color: var(--duo-dark);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .duo-mobile-header-points {
        flex-shrink: 0;
        background: var(--duo-orange-light);
        color: var(--duo-orange-border);
        border: 2px solid var(--duo-orange);
        border-radius: 999px;
        padding: 6px 12px;
        font-size: 13px;
        font-weight: 900;
    }
    .duo-main-container {
        margin-left: 0 !important;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: clip;
        flex-direction: column;
    }
    .page-aside-first .duo-stats-col {
        order: -1;
        padding-top: 4px !important;
        padding-bottom: 8px !important;
    }
    body.page-nutrition .duo-stats-col {
        padding-top: 0 !important;
        padding-bottom: 12px !important;
    }
    body.page-nutrition .duo-stats-col .duo-card {
        padding: 16px !important;
    }
    body.page-nutrition .duo-stats-col svg {
        width: 120px;
        height: 120px;
    }
    body.page-nutrition .duo-content-col {
        padding-top: 0 !important;
    }
    body.page-shop .duo-stats-col {
        display: none !important;
    }
    .duo-bottom-nav {
        display: none !important;
    }
    .app-shell .duo-map-header {
        padding: 14px 16px;
        margin-bottom: 12px;
    }
    .app-shell .duo-map-header h1 {
        font-size: 18px;
        line-height: 1.25;
    }
    .app-shell .duo-map-header p {
        font-size: 12px;
        line-height: 1.45;
        margin-top: 6px;
    }
    .dashboard-mobile-carousel-wrap {
        display: block;
        margin-bottom: 10px;
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        overflow-x: clip;
    }
    /* Tránh trùng: panel đầu trang đã có điểm + top tuần */
    body.page-dashboard .duo-stats-col {
        display: none !important;
    }
    .duo-content-col {
        width: 100%;
        max-width: 100% !important;
        min-width: 0;
        overflow-x: clip;
        padding: 12px 12px calc(76px + var(--hx-safe-bottom)) 12px !important;
    }
    .duo-stats-col {
        padding-bottom: 8px !important;
    }
    body.immersive-open #bottom-nav,
    body.immersive-open #mobile-header {
        display: none !important;
    }
    .duo-shop-item {
        display: grid;
        grid-template-columns: 56px 1fr;
        gap: 10px 12px;
        align-items: start;
    }
    .duo-shop-item > div:last-child {
        grid-column: 1 / -1;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100%;
    }
    .duo-shop-item .duo-btn {
        min-height: 40px;
        padding: 0 16px !important;
    }
    .duo-map-path,
    .duo-round-lessons,
    .duo-map-header,
    .duo-select-container {
        max-width: 100%;
    }
    .duo-subject-tabs {
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x;
        scroll-snap-type: x proximity;
        max-width: none;
        margin-left: -12px;
        margin-right: -12px;
        padding-left: 12px;
        padding-right: 12px;
        padding-bottom: 12px;
        margin-bottom: 16px;
    }
    .duo-subject-tab {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        scroll-snap-align: start;
        padding: 10px 16px !important;
        font-size: 13px !important;
        line-height: 1.2;
        text-align: center;
    }
    #floating-tutor-btn {
        bottom: calc(92px + env(safe-area-inset-bottom)) !important;
        right: 16px !important;
    }
    #tutor-chat-panel .duo-card,
    #tutor-chat-panel .hx-tutor-sheet {
        width: 100% !important;
        max-width: 100% !important;
        height: min(85%, calc(var(--hx-app-height, 100dvh) - var(--hx-safe-top))) !important;
        max-height: none !important;
        right: 0 !important;
        left: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        box-sizing: border-box;
    }
    
    /* Login Mobile Optimization */
    .duo-login-container {
        padding: 16px;
    }
    .duo-login-mascot img {
        width: 100px !important;
    }
    
    /* Tables/Lists Responsive (Leaderboard & History) */
    .duo-leaderboard-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px; /* Room for scrollbar */
    }
    .duo-leader-row {
        min-width: 0;
        width: 100%;
    }
    
    /* Shop Grid stacking is already 1fr, but pad it */
    .duo-shop-grid {
        gap: 12px;
    }
    
    /* Dashboard Map winding reduction */
    .duo-round-lessons .duo-map-node-wrapper:nth-child(8n+2) { margin-left: 45px; }
    .duo-round-lessons .duo-map-node-wrapper:nth-child(8n+3) { margin-left: 75px; }
    .duo-round-lessons .duo-map-node-wrapper:nth-child(8n+4) { margin-left: 45px; }
    .duo-round-lessons .duo-map-node-wrapper:nth-child(8n+6) { margin-left: -45px; }
    .duo-round-lessons .duo-map-node-wrapper:nth-child(8n+7) { margin-left: -75px; }
    .duo-round-lessons .duo-map-node-wrapper:nth-child(8n+8) { margin-left: -45px; }
    
    /* Mascot speech bubble adjustment */
    .duo-map-node-mascot {
        left: 75px;
        width: max-content;
        max-width: calc(100vw - 48px);
    }
    .duo-mascot-speech {
        font-size: 11px;
        padding: 5px 10px;
        white-space: nowrap;
    }
    
    /* Bottom nav chữ gọn */
    .duo-bottom-nav-item {
        font-size: 8px;
    }
    
    /* Lesson Player Fit - No vertical scroll */
    .duo-player-header {
        height: 60px;
        padding: 10px 16px;
    }
    .duo-player-overlay .duo-player-body {
        padding: 10px 16px;
        justify-content: center;
    }
    .duo-mascot-row {
        margin-bottom: 12px;
        gap: 12px;
    }
    .duo-mascot-avatar {
        width: 60px;
        height: 60px;
        font-size: 30px;
    }
    .duo-bubble {
        padding: 12px 16px;
        font-size: 15px;
    }
    .duo-choices-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns to save vertical space */
        gap: 10px;
        margin-top: 10px;
    }
    .duo-choice-card {
        padding: 12px 14px;
        font-size: 14px;
    }
    .duo-choice-key {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    .duo-player-footer {
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    }
    
    .duo-map-header {
        padding: 16px;
    }
    .duo-map-header h1 {
        font-size: 22px;
    }
    .duo-round-banner {
        padding: 14px 16px;
    }
    .duo-round-banner-icon {
        font-size: 28px;
    }
    .duo-round-banner-title {
        font-size: 14px;
    }
}

.duo-profile-avatar-wrap {
    width: 88px;
    height: 88px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

.duo-profile-avatar-wrap .duo-avatar-3d {
    filter: drop-shadow(0 6px 8px rgba(0,0,0,0.25));
}

.hx-avatar-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
}

.hx-avatar-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border-radius: 14px;
    border: 2px solid var(--duo-border-color);
    background: var(--duo-gray-light);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.hx-avatar-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.hx-avatar-option img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.15));
}

.hx-avatar-option span {
    font-size: 10px;
    font-weight: 800;
    color: var(--duo-dark-muted);
    text-align: center;
    line-height: 1.2;
}

.hx-avatar-option.selected,
.hx-avatar-option:has(input:checked) {
    border-color: var(--duo-blue);
    background: var(--duo-blue-light);
    transform: translateY(-2px);
}

.hx-avatar-option.selected span,
.hx-avatar-option:has(input:checked) span {
    color: var(--duo-blue);
}

.hx-rank-badge-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hx-rank-badge-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hx-rank-badge-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hx-rank-badge-icon img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 3px 5px rgba(0,0,0,0.18));
}

.hx-rank-badge-row.locked .hx-rank-badge-icon img {
    filter: grayscale(1) opacity(0.4);
}

.hx-rank-badge-name {
    font-size: 12px;
    font-weight: 800;
    color: var(--duo-dark);
}

.hx-rank-badge-row.unlocked .hx-rank-badge-name {
    color: var(--duo-green-border);
}

.hx-rank-badge-desc {
    font-size: 11px;
    color: var(--duo-dark-muted);
    line-height: 1.35;
}

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.text-center { text-align: center; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.hidden { display: none !important; }
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: calc(16px + var(--hx-safe-top)) calc(16px + var(--hx-safe-right)) calc(16px + var(--hx-safe-bottom)) calc(16px + var(--hx-safe-left));
    animation: fadeIn 0.15s ease-out;
    box-sizing: border-box;
}
.modal-content {
    background: white;
    border-radius: 24px;
    border: 2px solid var(--duo-border-color);
    padding: 24px;
    width: 100%;
    max-width: min(450px, 100%);
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    box-sizing: border-box;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Floating Mascot on Learning Path */
.duo-map-node-mascot {
    position: absolute;
    left: 95px;
    top: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
    pointer-events: none;
    animation: floatMascot 2.5s ease-in-out infinite alternate;
    width: max-content;
    max-width: none;
    flex-wrap: nowrap;
}
.duo-mascot-speech {
    background: white;
    border: 2px solid var(--duo-border-color);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 900;
    color: var(--duo-green-border);
    box-shadow: 0 3px 0 var(--duo-border-color);
    position: relative;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.25;
}
.duo-mascot-speech::after {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 5px 8px 5px 0;
    border-style: solid;
    border-color: transparent white transparent transparent;
    display: block;
    width: 0;
    z-index: 2;
}
.duo-mascot-speech::before {
    content: '';
    position: absolute;
    left: -11px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px 9px 6px 0;
    border-style: solid;
    border-color: transparent var(--duo-border-color) transparent transparent;
    display: block;
    width: 0;
    z-index: 1;
}
.duo-mascot-img-mini {
    font-size: 32px;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.15));
}
@keyframes floatMascot {
    0% { transform: translateY(0); }
    100% { transform: translateY(-6px); }
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    pointer-events: none;
}

.toast {
    background-color: var(--duo-dark);
    color: white;
    padding: 14px 24px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: toastSlideDown 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
    max-width: 90vw;
}

@keyframes toastSlideDown {
    from {
        transform: translateY(-20px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Capacitor native app — bàn phím không che menu/chat */
body.keyboard-open #bottom-nav,
body.keyboard-open #mobile-header {
    display: none !important;
}

body.keyboard-open .duo-content-col {
    padding-bottom: 12px !important;
}

body.keyboard-open .duo-chat-input-bar {
    position: sticky;
    bottom: 0;
    z-index: 120;
    background: white;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

body.keyboard-open .duo-chat-box {
    padding-bottom: 0;
}

html.capacitor-native body.app-shell {
    -webkit-tap-highlight-color: transparent;
}
