/* CSS Design System for Mobile-First Vocabulary App */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Color Tokens (Base HSL) */
    --h-primary: 245;
    --h-success: 142;
    --h-danger: 350;
    --h-warning: 38;
    
    /* Default Dark Mode Theme */
    --bg-gradient: linear-gradient(135deg, hsl(222, 47%, 10%) 0%, hsl(244, 49%, 13%) 100%);
    --card-bg: hsla(222, 47%, 15%, 0.7);
    --card-border: hsla(0, 0%, 100%, 0.08);
    --card-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 50px hsla(var(--h-primary), 84%, 67%, 0.04);
    
    --text-main: hsl(210, 40%, 98%);
    --text-muted: hsl(215, 25%, 72%);
    --text-inverse: hsl(222, 47%, 12%);
    
    --primary: hsl(var(--h-primary), 84%, 67%);
    --primary-glow: hsla(var(--h-primary), 84%, 67%, 0.3);
    --primary-hover: hsl(var(--h-primary), 84%, 60%);
    
    --success: hsl(var(--h-success), 76%, 45%);
    --success-glow: hsla(var(--h-success), 76%, 45%, 0.25);
    --success-bg: hsla(var(--h-success), 76%, 45%, 0.15);
    
    --danger: hsl(var(--h-danger), 89%, 60%);
    --danger-glow: hsla(var(--h-danger), 89%, 60%, 0.25);
    --danger-bg: hsla(var(--h-danger), 89%, 60%, 0.15);
    
    --warning: hsl(var(--h-warning), 95%, 55%);
    --warning-glow: hsla(var(--h-warning), 95%, 55%, 0.3);
    
    --option-bg: hsla(217, 33%, 20%, 0.55);
    --option-border: hsla(0, 0%, 100%, 0.04);
    --option-hover: hsla(217, 33%, 26%, 0.75);
    --option-text: hsl(210, 40%, 95%);
    
    --input-bg: hsla(217, 33%, 15%, 0.6);
    --input-border: hsla(0, 0%, 100%, 0.08);
    --input-focus: hsl(var(--h-primary), 84%, 67%);
    
    --switch-bg: hsla(217, 33%, 20%, 0.85);

    /* Opaque backing for the sticky dictionary header (matches the glass card tint) */
    --sticky-bg: hsl(223, 46%, 13%);
}

/* Light Mode Override */
[data-theme="vibrant-day"] {
    --bg-gradient: linear-gradient(135deg, hsl(210, 40%, 95%) 0%, hsl(220, 30%, 88%) 100%);
    --card-bg: hsla(0, 0%, 100%, 0.8);
    --card-border: hsla(222, 47%, 16%, 0.08);
    --card-shadow: 0 15px 35px rgba(15, 23, 42, 0.08), 0 0 30px hsla(var(--h-primary), 84%, 67%, 0.02);
    
    --text-main: hsl(222, 47%, 15%);
    --text-muted: hsl(215, 20%, 45%);
    --text-inverse: hsl(210, 40%, 98%);
    
    --primary: hsl(var(--h-primary), 80%, 55%);
    --primary-glow: hsla(var(--h-primary), 80%, 55%, 0.2);
    --primary-hover: hsl(var(--h-primary), 80%, 48%);
    
    --success: hsl(var(--h-success), 70%, 38%);
    --success-glow: hsla(var(--h-success), 70%, 38%, 0.2);
    --success-bg: hsla(var(--h-success), 70%, 38%, 0.1);
    
    --danger: hsl(var(--h-danger), 80%, 52%);
    --danger-glow: hsla(var(--h-danger), 80%, 52%, 0.2);
    --danger-bg: hsla(var(--h-danger), 80%, 52%, 0.1);
    
    --warning: hsl(var(--h-warning), 90%, 45%);
    --warning-glow: hsla(var(--h-warning), 90%, 45%, 0.2);
    
    --option-bg: hsla(220, 20%, 94%, 0.7);
    --option-border: hsla(222, 47%, 16%, 0.06);
    --option-hover: hsla(220, 20%, 87%, 0.85);
    --option-text: hsl(222, 47%, 15%);
    
    --input-bg: hsla(0, 0%, 100%, 0.9);
    --input-border: hsla(222, 47%, 16%, 0.12);
    --input-focus: hsl(var(--h-primary), 80%, 55%);
    
    --switch-bg: hsla(220, 20%, 92%, 0.88);

    --sticky-bg: hsl(213, 41%, 93%);
}

/* Reset and Core Layout */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    overflow-x: hidden;
    position: relative;
    transition: background 0.4s ease, color 0.4s ease;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

input, textarea, [contenteditable="true"] {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

/* Decorative background shapes */
.bg-blob {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    opacity: 0.12;
    pointer-events: none;
    animation: pulse-blob 8s infinite alternate ease-in-out;
}

.blob-primary {
    top: 5%;
    left: 5%;
    background-color: var(--primary);
}

.blob-accent {
    bottom: 5%;
    right: 5%;
    background-color: hsl(300, 80%, 60%);
    animation-delay: 4s;
}

@keyframes pulse-blob {
    0% { transform: scale(1) translate(0px, 0px); }
    100% { transform: scale(1.2) translate(30px, 40px); }
}

/* Global App Container (Native Mobile Viewport Shell) */
.app-container {
    background-color: var(--card-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--card-border);
    padding: 16px 14px 16px 14px;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    width: 100%;
    max-width: 480px;
    height: 90vh;
    max-height: 800px;
    min-height: 540px;
    position: relative;
    z-index: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Header (Static) */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.app-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--primary) 0%, hsl(var(--h-primary), 100%, 78%) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    background-color: var(--switch-bg);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    transform: scale(1.05);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Independent Scroll Zone */
.main-content-scroll {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    padding-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.main-content-scroll::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

/* Hide inactive screens */
.view-screen {
    display: none;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.view-screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

#quiz-screen.active {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    justify-content: space-between;
}

#welcome-screen.active {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    justify-content: center;
}

/* Welcome Card Styling */
.welcome-card {
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.15) 0%, rgba(0, 229, 255, 0.06) 100%);
    border: 1.5px solid rgba(124, 77, 255, 0.3);
    border-radius: 14px;
    padding: 14px 12px;
    margin-bottom: 14px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Premium Welcome Formula Card */
.hero-formula-card {
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.16) 0%, rgba(0, 229, 255, 0.06) 100%);
    border: 1.5px solid rgba(124, 77, 255, 0.35);
    border-radius: 24px;
    padding: 28px 20px;
    margin-bottom: 14px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.welcome-badge-wrapper {
    margin-bottom: 20px;
    width: 100%;
    display: flex;
    justify-content: center;
}

.welcome-badge {
    background: linear-gradient(90deg, var(--primary) 0%, #00e5ff 100%);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 4px 10px;
    border-radius: 10px;
    box-shadow: 0 0 12px rgba(124, 77, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.formula-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.formula-label {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 800;
    margin-bottom: 24px;
    text-align: center;
    opacity: 0.85;
}

.formula-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 290px;
}

.formula-step {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1.5px solid rgba(255, 255, 255, 0.05);
    padding: 14px 18px;
    border-radius: 18px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slide-in-fade 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes slide-in-fade {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.step-1 { animation-delay: 0.1s; }
.step-2 { animation-delay: 0.25s; }
.step-3 { animation-delay: 0.4s; }

.formula-step:hover {
    transform: translateY(-2px) scale(1.02);
    background: rgba(124, 77, 255, 0.08);
    border-color: rgba(124, 77, 255, 0.3);
    box-shadow: 0 10px 25px rgba(124, 77, 255, 0.2);
}

.step-bullet {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #00e5ff 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
    flex-shrink: 0;
}

.step-phrase {
    font-size: 1.35rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff 40%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.3px;
}

.step-3 .step-phrase {
    background: linear-gradient(135deg, #00f0ff 0%, #00e5ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 12px rgba(0, 229, 255, 0.2);
}

.menu-pointer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 24px;
    margin-bottom: 12px;
    width: 100%;
}

.pointer-text {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
    letter-spacing: 0.2px;
    opacity: 0.9;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    margin-bottom: 8px;
}

.pointer-arrows {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 48px;
    position: relative;
}

.pointer-chevron {
    color: var(--primary);
    animation: bounce-down 1.6s infinite ease-in-out;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.pointer-chevron.delay-1 {
    animation-delay: 0.8s;
    margin-top: -12px;
}

@keyframes bounce-down {
    0%, 100% {
        transform: translateY(-4px) scale(0.9);
        opacity: 0.3;
        color: var(--primary);
    }
    50% {
        transform: translateY(4px) scale(1.1);
        opacity: 1;
        color: #00e5ff;
    }
}

/* ============ SETUP SCREEN ============ */
.setup-group {
    margin-bottom: 12px;
}

/* Section header: title + optional right meta + marketing caption */
.group-head {
    margin-bottom: 6px;
}

.group-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: -0.1px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.group-meta {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.group-caption {
    font-size: 0.64rem;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.3;
    margin-top: 2px;
}

.units-header-actions {
    display: flex;
    gap: 12px;
}

.btn-small-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.btn-small-link:hover {
    text-decoration: underline;
}

/* Book Tab Selector Styles */
.book-tabs-container {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 2px 2px 4px 2px;
    margin-bottom: 6px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.book-tabs-container::-webkit-scrollbar {
    display: none;
}

.book-tab-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--option-bg);
    border: 1px solid var(--option-border);
    padding: 5px 10px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    user-select: none;
}

.book-tab-btn:hover {
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.12);
}

.book-tab-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, hsla(var(--h-primary), 84%, 60%, 1) 100%);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 10px var(--primary-glow);
}

.tab-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    line-height: 1;
}

.book-tab-btn.active .tab-badge {
    background: #fff;
    color: var(--primary);
}

.book-tab-btn:not(.active) .tab-badge.selected-some {
    background: var(--primary-glow);
    color: var(--primary);
    border: 1px solid rgba(var(--h-primary), 84%, 67%, 0.2);
}

.book-tab-btn:not(.active) .tab-badge.selected-all {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-glow);
}

/* Active Book Content Panel */
.active-book-panel {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.active-book-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

@media (min-width: 380px) {
    .active-book-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.book-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.book-text-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.active-book-title {
    font-size: 0.76rem;
    font-weight: 800;
    color: var(--text-main);
}

.active-book-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
}

.book-checkbox-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.book-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: #fff;
    background: rgba(0, 0, 0, 0.2);
}

.book-checkbox.checked {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

.book-checkbox svg {
    opacity: 0;
    transform: scale(0.6);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.15s ease;
}

.book-checkbox.checked svg {
    opacity: 1;
    transform: scale(1);
}

.units-grid-scroll {
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
}

.units-grid-scroll::-webkit-scrollbar {
    width: 4px;
}

.units-grid-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.units-grid-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}

.units-grid-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

.units-quick-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    padding-bottom: 2px;
}

.action-chip {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-muted);
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.action-chip:hover {
    background: var(--option-hover);
    color: var(--text-main);
    border-color: var(--primary);
}

/* Units Grid */
.units-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    padding: 2px 0;
}

.unit-chip {
    aspect-ratio: unset;
    height: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    width: 100%;
    user-select: none;
    line-height: 1.15;
}

.unit-chip span:first-child {
    font-size: 0.68rem;
    font-weight: 700;
}

.unit-chip:hover {
    border-color: var(--primary);
    color: var(--text-main);
    transform: translateY(-1px);
}

.unit-chip.selected {
    background: linear-gradient(135deg, var(--primary) 0%, hsla(var(--h-primary), 84%, 60%, 1) 100%);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 8px var(--primary-glow);
    font-weight: 700;
}

/* Tooltip/Label for unit words */
.unit-chip-meta {
    display: block;
    font-size: 0.48rem;
    font-weight: 500;
    opacity: 0.8;
}

/* Segmented chips (direction / count) */
.chip-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.chip-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.choice-chip {
    background-color: var(--option-bg);
    border: 1px solid var(--option-border);
    border-radius: 11px;
    padding: 10px 4px;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.18s ease;
}

.choice-chip:hover {
    color: var(--text-main);
    background-color: var(--option-hover);
}

.choice-chip.selected {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* Practice-mode cards — the signature element of the setup screen */
.mode-groups-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 5px;
}

.mode-group-section {
    background: hsla(222, 47%, 10%, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 6px 8px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="vibrant-day"] .mode-group-section {
    background: hsla(220, 20%, 95%, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.mode-group-section:hover {
    border-color: hsla(var(--h-primary), 80%, 60%, 0.12);
}

.mode-group-header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 3px;
    padding-bottom: 0;
    border-bottom: none;
}

[data-theme="vibrant-day"] .mode-group-header {
    border-bottom: none;
}

.mode-group-icon {
    font-size: 0.78rem;
}

.mode-group-name {
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
}

/* Category-specific color overrides via CSS variables */
.mode-group-section.group-learn {
    --h-primary: 200; /* Teal/Blue */
    --primary: hsl(var(--h-primary), 85%, 60%);
    --primary-glow: hsla(var(--h-primary), 85%, 60%, 0.3);
}

.mode-group-section.group-test {
    --h-primary: 265; /* Purple */
    --primary: hsl(var(--h-primary), 85%, 65%);
    --primary-glow: hsla(var(--h-primary), 85%, 65%, 0.3);
}

.mode-group-section.group-audio {
    --h-primary: 35;  /* Amber/Orange */
    --primary: hsl(var(--h-primary), 90%, 55%);
    --primary-glow: hsla(var(--h-primary), 90%, 55%, 0.3);
}

.mode-group-section.group-games {
    --h-primary: 325; /* Rose/Pink */
    --primary: hsl(var(--h-primary), 85%, 60%);
    --primary-glow: hsla(var(--h-primary), 85%, 60%, 0.3);
}

.mode-sub-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

@media (max-width: 360px) {
    .mode-sub-grid {
        grid-template-columns: 1fr;
    }
}

.mode-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    text-align: left;
    padding: 4px 6px;
    border-radius: 6px;
    min-width: 0;
    background: var(--option-bg);
    border: 1.5px solid var(--option-border);
    position: relative;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.mode-chip:hover {
    color: var(--text-main);
    background-color: var(--option-hover);
    border-color: var(--primary-glow);
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15), 0 0 10px var(--primary-glow);
}

.mode-chip.selected {
    background: linear-gradient(135deg, hsla(var(--h-primary), 84%, 67%, 0.12) 0%, hsla(var(--h-primary), 84%, 60%, 0.03) 100%);
    border-color: var(--primary);
    color: var(--text-main);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2), 0 0 15px var(--primary-glow);
    transform: scale(1.015) translateY(-0.5px);
}

.mode-chip.selected::before {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 3.5px;
    height: 3.5px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 4px var(--primary);
    animation: active-pulse 1.5s infinite ease-in-out;
}

@keyframes active-pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.3); }
}

.mode-chip-wide {
    grid-column: 1 / -1;
}

.mode-emoji {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    line-height: 1;
    background: none;
    border: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.mode-chip:hover .mode-emoji {
    transform: scale(1.1) rotate(3deg);
}

.mode-chip.selected .mode-emoji {
    transform: scale(1.05);
}

.mode-text {
    display: flex;
    flex-direction: column;
    gap: 0px;
    min-width: 0;
}

.mode-name {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.15;
    letter-spacing: -0.1px;
}

.mode-desc {
    font-size: 0.54rem;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.75;
}

/* Chosen-mode summary bar (shown after a type is picked) */
.mode-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    background: var(--primary-glow);
    border: 1px solid var(--primary);
    border-radius: 14px;
    padding: 10px 14px;
    margin-bottom: 20px;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.12s ease;
}

.mode-summary:hover {
    transform: translateY(-1px);
}

.mode-summary-emoji {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    line-height: 1;
    background: hsla(var(--h-primary), 84%, 67%, 0.2);
    border-radius: 10px;
}

.mode-summary-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.mode-summary-label {
    font-size: 0.66rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mode-summary-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.mode-summary-change {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
}

/* Revealed config: slightly tighter rhythm so Start stays within reach */
#config-steps .setup-group {
    margin-bottom: 16px;
}

.reveal-anim {
    animation: config-reveal 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes config-reveal {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Slogan + Start */
.start-block {
    margin-top: 4px;
}

.start-block .btn-action {
    margin-top: 0;
}

.start-slogan {
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 10px;
    padding: 0 6px;
}

.btn-action {
    background: linear-gradient(135deg, var(--primary) 0%, hsl(var(--h-primary), 84%, 60%) 100%);
    color: var(--text-inverse);
    border: none;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 10px var(--primary-glow);
    margin-top: 8px;
}

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px var(--primary-glow);
}

/* DICTIONARY SCREEN STYLING */

/* Pinned search + filters + count; only the word list scrolls beneath it */
.dict-sticky-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--sticky-bg);
    /* Bleed sideways so list rows scrolling underneath don't peek at the edges */
    margin: 0 -6px 4px -6px;
    padding: 8px 6px 4px 6px;
    border-bottom: 1px solid var(--card-border);
}

.search-box-wrapper {
    position: relative;
    margin-bottom: 12px;
}

.dict-search-input {
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 12px 40px 12px 14px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    width: 100%;
    outline: none;
    transition: all 0.2s ease;
}

.dict-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.search-icon-span {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

/* Horizontally scrolling chips wrapper */
.dict-filter-wrapper {
    overflow: hidden;
    margin-bottom: 10px;
}

.dict-filter-scroll {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: none;
}
.dict-filter-scroll::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    background-color: var(--option-bg);
    border: 1px solid var(--option-border);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.filter-chip:hover {
    color: var(--text-main);
}

.filter-chip.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
}

.dict-words-count {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dict-list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dict-word-card {
    background-color: var(--option-bg);
    border: 1px solid var(--option-border);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.15s ease;
}

.dict-word-card:hover {
    background-color: var(--option-hover);
    border-color: var(--card-border);
}

.dict-word-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

.dict-word-en {
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--text-main);
}

.dict-word-uz {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--success);
}

.dict-word-meta {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
}

.dict-unit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 4px 4px 4px;
    margin-top: 12px;
    margin-bottom: 2px;
}

.dict-unit-title {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dict-unit-title::before {
    content: '';
    display: inline-block;
    width: 3.5px;
    height: 11px;
    background-color: var(--primary);
    border-radius: 2px;
}

.dict-list-container > .dict-unit-header:first-child {
    margin-top: 2px;
    padding-top: 4px;
}

/* Infinite-scroll sentinel + loading indicator for the dictionary list */
.dict-scroll-sentinel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 6px 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.dict-scroll-sentinel:not(.dict-scroll-end)::before {
    content: '';
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--option-border);
    border-top-color: var(--primary);
    animation: dict-spin 0.7s linear infinite;
}

.dict-scroll-end {
    opacity: 0.7;
}

@keyframes dict-spin {
    to { transform: rotate(360deg); }
}

/* ACTIVE QUIZ SCREEN UI */
.quiz-meta-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.meta-streak {
    color: var(--warning);
    font-weight: 700;
    animation: streak-pulse 1.5s infinite alternate;
}

@keyframes streak-pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.06); }
}

.quiz-progress-container {
    width: 100%;
    height: 5px;
    background-color: var(--option-border);
    border-radius: 10px;
    margin-bottom: 18px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, hsl(var(--h-primary), 100%, 75%) 100%);
    width: 0%;
    border-radius: 10px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.quiz-card-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 220px;
    margin-bottom: 12px;
}

/* 3D FLASHCARD */
/* 3D FLASHCARD (Premium & Glassmorphic) */
.flashcard-3d-container {
    perspective: 1000px;
    width: 100%;
    height: 236px;
    cursor: pointer;
    margin: 8px 0;
}

.flashcard-3d {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.flashcard-3d-container.flipped .flashcard-3d {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 24px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.flashcard-face::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
    z-index: 1;
}

.flashcard-front {
    background: radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, rgba(26, 33, 49, 0.95) 70%, rgba(13, 17, 28, 0.95) 100%);
}

.flashcard-back {
    background: radial-gradient(circle at center, rgba(16, 185, 129, 0.12) 0%, rgba(16, 22, 38, 0.95) 75%, rgba(9, 11, 20, 0.97) 100%);
    transform: rotateY(180deg);
}

.flashcard-face .word-label {
    display: none !important;
}

.example-target-highlight {
    color: var(--primary);
    font-weight: 700;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.18);
    padding: 2px 6px;
    border-radius: 6px;
}

@keyframes tts-play-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.5); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(99, 102, 241, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.tts-inline-btn.playing,
.tts-front-btn.playing {
    animation: tts-play-pulse 0.4s ease;
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.word-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--primary);
    background: var(--primary-glow);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 12px;
    border: 1px solid rgba(var(--h-primary), 84%, 67%, 0.15);
    z-index: 2;
}

.word-main-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
    z-index: 2;
}

.word-main {
    font-size: 2.3rem;
    font-weight: 850;
    background: linear-gradient(135deg, #ffffff 30%, var(--primary-light, #c7d2fe) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.15;
    letter-spacing: -0.8px;
}

.tts-front-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.tts-front-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 0 8px var(--primary-glow);
}

.word-translation {
    font-size: 2.1rem;
    font-weight: 850;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
    z-index: 2;
}

/* Integrated Example Wrapper */
.word-example-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 10px 14px;
    border-radius: 16px;
    max-width: 100%;
    margin-top: 10px;
    position: relative;
    z-index: 2;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.word-example {
    flex: 1;
    font-size: 0.84rem;
    color: var(--text-main);
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    border-left: 3px solid var(--primary);
    padding-left: 10px;
}

.tts-inline-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.tts-inline-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Pulsing Flip Prompt */
@keyframes hint-pulse {
    0%, 100% { opacity: 0.6; transform: translateY(0) scale(1); }
    50% { opacity: 0.95; transform: translateY(-2px) scale(1.02); }
}

.flip-hint {
    position: absolute;
    bottom: 12px;
    font-size: 0.65rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 4px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: hint-pulse 2.2s infinite ease-in-out;
    z-index: 2;
}

.flip-hint svg {
    color: var(--primary);
}

/* Eval Action Buttons Redesign */
.flashcard-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 14px;
}

.btn-fc {
    border: 1px solid transparent;
    padding: 16px 20px;
    border-radius: 18px;
    font-weight: 800;
    font-size: 1.02rem;
    min-height: 56px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-fc-no {
    background-color: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #ef4444;
}

.btn-fc-no:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-color: #ef4444;
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.35);
    transform: translateY(-2px);
}

.btn-fc-no:active {
    transform: scale(0.96);
}

.btn-fc-yes {
    background-color: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #10b981;
}

.btn-fc-yes:hover {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: #10b981;
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
    transform: translateY(-2px);
}

.btn-fc-yes:active {
    transform: scale(0.96);
}

/* MULTIPLE CHOICE */
.question-word-card {
    background: var(--option-bg);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 20px;
    text-align: center;
    margin-bottom: 12px;
}

.tts-inline-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    vertical-align: middle;
    margin-left: 8px;
    transition: all 0.2s ease;
}

.tts-inline-btn:hover {
    background: var(--primary);
    color: var(--text-inverse);
}

.options-box {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.option-choice-btn {
    background-color: var(--option-bg);
    border: 1px solid var(--option-border);
    color: var(--option-text);
    padding: 14px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 14px;
    min-height: 52px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.option-choice-btn:hover:not(:disabled) {
    background-color: var(--option-hover);
    transform: translateX(3px);
}

.option-choice-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.option-choice-btn.correct {
    background: var(--success-bg) !important;
    border-color: var(--success) !important;
    color: var(--success) !important;
    font-weight: 700;
}

.option-choice-btn.incorrect {
    background: var(--danger-bg) !important;
    border-color: var(--danger) !important;
    color: var(--danger) !important;
    font-weight: 700;
}



/* Controls */
.quiz-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto; /* Push to bottom of the card */
    padding-top: 16px;
    min-height: 48px;
}

.btn-quit {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--option-border);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    padding: 12px 18px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.btn-quit:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

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

.btn-next-step {
    background-color: var(--option-bg);
    border: 1px solid var(--option-border);
    color: var(--text-muted);
    padding: 12px 24px;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-next-step:hover {
    background-color: var(--option-hover);
    color: var(--text-main);
}

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

.btn-next-step.answered {
    background-color: var(--primary);
    border: none;
    color: var(--text-inverse);
    box-shadow: 0 4px 10px var(--primary-glow);
}

.btn-next-step.answered:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

/* RESULTS & SCOREBOARD UI */
/* ============================================================
   RESULT SCREEN — compact game-style report card
   ============================================================ */

/* Hero rank card: grade badge + XP bar folded into one compact row */
.result-hero {
    --grade-color: var(--primary);
    --grade-glow: var(--primary-glow);
    display: flex;
    align-items: center;
    gap: 11px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 10px 12px;
    margin-bottom: 10px;
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
}
.result-hero::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -8%;
    width: 110px;
    height: 200%;
    background: radial-gradient(circle, var(--grade-glow) 0%, transparent 70%);
    opacity: 0.65;
    pointer-events: none;
}

/* Grade colour themes */
.result-hero.grade-s { --grade-color: hsl(45, 100%, 58%); --grade-glow: hsla(45, 100%, 58%, 0.35); }
.result-hero.grade-a { --grade-color: var(--success); --grade-glow: var(--success-glow); }
.result-hero.grade-b { --grade-color: var(--primary); --grade-glow: var(--primary-glow); }
.result-hero.grade-c { --grade-color: var(--warning); --grade-glow: var(--warning-glow); }
.result-hero.grade-d { --grade-color: hsl(25, 92%, 55%); --grade-glow: hsla(25, 92%, 55%, 0.3); }
.result-hero.grade-f { --grade-color: var(--danger); --grade-glow: var(--danger-glow); }

/* Grade "stamp" badge */
.grade-badge {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(150deg, var(--grade-glow), transparent 85%);
    border: 1.5px solid var(--grade-color);
    box-shadow: 0 0 14px var(--grade-glow), inset 0 0 12px var(--grade-glow);
}
.grade-letter {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1;
    color: var(--grade-color);
    text-shadow: 0 0 12px var(--grade-glow);
}
.grade-badge.reveal {
    animation: gradeStamp 0.55s cubic-bezier(0.2, 1.4, 0.5, 1) both;
}
@keyframes gradeStamp {
    0% { transform: scale(1.8) rotate(-14deg); opacity: 0; }
    60% { opacity: 1; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.hero-body {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.hero-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.hero-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
}
.hero-frac {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* XP-style score bar */
.score-bar {
    position: relative;
    height: 18px;
    border-radius: 9px;
    background: var(--option-bg);
    border: 1px solid var(--option-border);
    overflow: hidden;
}
.score-bar-fill {
    position: absolute;
    inset: 0;
    width: 0%;
    border-radius: 9px;
    background: var(--grade-color);
    box-shadow: 0 0 10px var(--grade-glow);
    transition: width 1.1s cubic-bezier(0.4, 0, 0.2, 1);
}
.score-bar-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.35) 50%, transparent 80%);
    transform: translateX(-100%);
    animation: barShimmer 1.9s ease-in-out 0.7s infinite;
}
@keyframes barShimmer {
    to { transform: translateX(100%); }
}
.score-bar-pct {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-main);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    z-index: 2;
}
.hero-msg {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--grade-color);
}

/* Compact one-line stat strip */
.stat-strip {
    display: flex;
    align-items: stretch;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 7px 2px;
    margin-bottom: 10px;
    box-shadow: var(--card-shadow);
}
.stat-cell {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    position: relative;
    padding: 0 2px;
}
.stat-cell + .stat-cell::before {
    content: "";
    position: absolute;
    left: 0;
    top: 15%;
    height: 70%;
    width: 1px;
    background: var(--option-border);
}
.stat-cell .sc-ico { font-size: 0.72rem; line-height: 1.2; opacity: 0.9; }
.stat-cell .sc-val {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.15;
}
.stat-cell .sc-lbl {
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
}
.stat-cell.correct .sc-val, .stat-cell.correct .sc-ico { color: var(--success); }
.stat-cell.incorrect .sc-val, .stat-cell.incorrect .sc-ico { color: var(--danger); }
.stat-cell.streak .sc-val, .stat-cell.streak .sc-ico { color: var(--warning); }

/* Status slot: congrats / empty state */
#res-status-slot:empty { display: none; }
.res-status-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 13px 12px;
    margin-bottom: 10px;
    text-align: center;
    box-shadow: var(--card-shadow);
}
.res-status-card.success { border-color: var(--success-glow); }
.res-status-card .rs-title {
    font-size: 0.92rem;
    font-weight: 800;
    margin-bottom: 3px;
    color: var(--text-main);
}
.res-status-card.success .rs-title { color: var(--success); }
.res-status-card .rs-sub {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
}

.mistakes-block {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 9px 10px;
    margin-bottom: 10px;
}

.mistakes-head {
    font-size: 0.78rem;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    color: var(--text-main);
}

.mistake-badge {
    background-color: var(--danger);
    color: var(--text-inverse);
    font-size: 0.62rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 7px;
}

.mistakes-list {
    max-height: 232px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 3px;
}

.mistakes-list::-webkit-scrollbar {
    width: 4px;
}
.mistakes-list::-webkit-scrollbar-track {
    background: transparent;
}
.mistakes-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
.mistakes-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mistake-card-item {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-left: 2px solid var(--danger);
    border-radius: 9px;
    padding: 7px 9px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: border-color 0.2s ease;
}

.mistake-card-item:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.mistake-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.mistake-card-en {
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
    color: var(--text-main);
}

.mistake-card-uz {
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: right;
    flex-shrink: 0;
}

.mistake-card-ex {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-style: italic;
    border-left: 2px solid var(--primary);
    padding-left: 6px;
    margin-top: 1px;
}

.mistake-comparison {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    margin-top: 1px;
}

.mistake-comparison .label {
    color: var(--text-muted);
}

.mistake-answer-user {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 1px 6px;
    border-radius: 5px;
    font-weight: 600;
    text-decoration: line-through;
}

/* Compact action buttons (scoped to results) */
.results-actions {
    display: flex;
    gap: 8px;
}
.results-actions .res-btn {
    margin-top: 0;
    padding: 10px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    border-radius: 11px;
    gap: 6px;
    width: auto;
}
.res-btn-retry {
    flex: 2;
    background: linear-gradient(135deg, var(--danger) 0%, hsl(var(--h-danger), 80%, 55%) 100%);
    box-shadow: 0 3px 12px var(--danger-glow);
}
.res-btn-ghost {
    flex: 1;
    background: var(--option-bg);
    color: var(--text-main);
    border: 1px solid var(--option-border);
    box-shadow: none;
}
.res-btn-ghost:hover {
    box-shadow: none;
    background: var(--option-hover);
}

/* Floating scroll-to-top button (dictionary) */
.scroll-top-btn {
    position: absolute;
    right: 18px;
    bottom: 80px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-inverse);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 22px var(--primary-glow), 0 3px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 40;
    opacity: 0;
    transform: translateY(12px) scale(0.85);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease;
}

.scroll-top-btn.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.scroll-top-btn:hover {
    background: var(--primary-hover);
}

.scroll-top-btn:active {
    transform: scale(0.9);
}

/* PERSISTENT BOTTOM TAB BAR */
.bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 56px;
    background: rgba(20, 24, 33, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1.5px solid var(--card-border);
    border-radius: 20px;
    margin: 12px; /* Floating dock style! */
    padding: 0 8px;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
}

.nav-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 0.62rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
    height: 100%;
    position: relative;
}

.nav-tab svg {
    width: 18px;
    height: 18px;
    stroke: var(--text-muted);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-tab:hover {
    color: var(--text-main);
}

.nav-tab.active {
    color: var(--primary);
    transform: translateY(-2px);
}

.nav-tab.active svg {
    stroke: var(--primary);
    transform: scale(1.18);
    filter: drop-shadow(0 0 5px var(--primary-glow));
}

.nav-tab::after {
    content: '';
    position: absolute;
    bottom: 2px;
    width: 0;
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.25s ease;
    box-shadow: 0 0 8px var(--primary);
}

.nav-tab.active::after {
    width: 16px;
}

/* Feedback Animations */
@keyframes element-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}
.shake-it {
    animation: element-shake 0.35s ease;
}

@keyframes element-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}
.pop-it {
    animation: element-pop 0.25s ease;
}

/* Screen Transitions */
@keyframes screen-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in {
    animation: screen-fade-in 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}



/* Matching Mode Styles */
.match-card {
    background-color: var(--option-bg);
    border: 1px solid var(--option-border);
    color: var(--text-main);
    border-radius: 12px;
    padding: 14px 10px;
    font-size: 0.88rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    user-select: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.match-card:hover:not(.disabled) {
    background-color: var(--option-hover);
    transform: translateY(-1px);
}

.match-card:active:not(.disabled) {
    transform: scale(0.95);
}

.match-card.selected {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.match-card.correct {
    background-color: var(--success-bg) !important;
    border-color: var(--success) !important;
    color: var(--success) !important;
    font-weight: 700;
    pointer-events: none;
    transform: scale(0.95);
    opacity: 0.4;
}

.match-card.incorrect {
    background-color: var(--danger-bg) !important;
    border-color: var(--danger) !important;
    color: var(--danger) !important;
    font-weight: 700;
}

.match-card.disabled {
    opacity: 0.3;
    pointer-events: none;
    cursor: default;
}

/* RESPONSIVE LAYOUT CONFIG (MOBILE-FIRST EMULATOR) */
@media (max-width: 480px) {
    body {
        padding: 0;
    }
    .app-container {
        height: 100vh;
        max-height: 100%;
        border-radius: 0;
        border: none;
        max-width: 100%;
        padding: 16px 16px 16px 16px;
    }
    .bottom-nav {
        margin: 10px !important;
        border-radius: 18px;
    }

    /* Setup screen layout adjustments for mobile */
    .app-header {
        margin-bottom: 8px !important;
    }
    .app-title {
        font-size: 1.2rem !important;
    }
    .theme-toggle {
        width: 32px !important;
        height: 32px !important;
    }
    
    #config-steps .setup-group {
        margin-bottom: 6px !important;
    }
    
    .group-head {
        margin-bottom: 3px !important;
    }
    .group-title {
        font-size: 0.76rem !important;
    }
    .group-caption {
        font-size: 0.6rem !important;
        margin-top: 1px !important;
    }
    .group-meta {
        font-size: 0.6rem !important;
    }
    
    .mode-summary {
        margin-bottom: 8px !important;
        padding: 6px 10px !important;
        gap: 8px !important;
        border-radius: 10px !important;
    }
    .mode-summary-emoji {
        width: 28px !important;
        height: 28px !important;
        font-size: 1.05rem !important;
        border-radius: 8px !important;
    }
    .mode-summary-name {
        font-size: 0.85rem !important;
    }
    
    .book-tabs-container {
        margin-bottom: 6px !important;
        padding: 2px 2px 4px 2px !important;
        gap: 6px !important;
    }
    .book-tab-btn {
        padding: 5px 10px !important;
        font-size: 0.72rem !important;
        border-radius: 8px !important;
    }
    
    .active-book-panel {
        padding: 8px !important;
        gap: 6px !important;
        border-radius: 12px !important;
    }
    .active-book-header {
        gap: 6px !important;
    }
    .book-info-row {
        gap: 6px !important;
    }
    .active-book-title {
        font-size: 0.76rem !important;
    }
    .active-book-meta {
        font-size: 0.65rem !important;
    }
    .book-checkbox {
        width: 18px !important;
        height: 18px !important;
        border-radius: 4px !important;
    }
    .action-chip {
        padding: 2px 6px !important;
        font-size: 0.6rem !important;
    }
    
    .units-grid-scroll {
        max-height: none !important;
        overflow-y: visible !important;
        padding-right: 0 !important;
    }
    .units-grid {
        grid-template-columns: repeat(10, 1fr) !important;
        gap: 4px !important;
    }
    .unit-chip {
        aspect-ratio: unset !important;
        height: 28px !important;
        min-width: 0 !important;
        width: 100% !important;
        border-radius: 5px !important;
        padding: 0 !important;
        line-height: 1.15 !important;
    }
    .unit-chip span:first-child {
        font-size: 0.68rem !important;
        font-weight: 700 !important;
    }
    .unit-chip-meta {
        display: block !important;
        font-size: 0.46rem !important;
        font-weight: 500 !important;
        opacity: 0.8 !important;
    }
    
    .practice-console-card {
        padding: 8px !important;
        gap: 8px !important;
        margin-top: 2px !important;
        margin-bottom: 6px !important;
        border-radius: 10px !important;
    }
    .segmented-control {
        height: 28px !important;
        border-radius: 6px !important;
    }
    .segmented-glider {
        height: calc(100% - 4px) !important;
        border-radius: 5px !important;
    }
    .segmented-item {
        font-size: 0.68rem !important;
    }
    
    .slider-row {
        gap: 6px !important;
        padding-top: 1px !important;
    }
    .slider-wrapper {
        gap: 3px !important;
    }
    .slider-value-pill {
        font-size: 0.68rem !important;
        padding: 1px 6px !important;
        min-width: 32px !important;
        border-radius: 6px !important;
    }
    .console-meta-row {
        padding-top: 4px !important;
        font-size: 0.64rem !important;
    }
    
    .start-block {
        margin-top: 6px !important;
        gap: 3px !important;
    }
    .start-block .btn-action {
        padding: 8px 14px !important;
        font-size: 0.8rem !important;
        border-radius: 8px !important;
        margin-top: 0 !important;
    }
    .start-slogan {
        font-size: 0.62rem !important;
    }

    /* Cover mode overrides for mobile */
    .cover-table {
        max-height: calc(100vh - 220px) !important;
    }
}

/* ============================================================
   COVER MODE (Bir tarafni yopish mashqi)
   ============================================================ */
.cover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 8px;
}

.cover-col-toggle {
    display: flex;
    gap: 6px;
}

.cover-toggle-btn {
    background: var(--option-bg);
    border: 1px solid var(--option-border);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cover-toggle-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
}

.cover-reveal-all-btn {
    background: none;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.cover-reveal-all-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.cover-table {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 2px;
}

.cover-row {
    background: var(--option-bg);
    border: 1px solid var(--option-border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* The table is a height-capped flex column; without this, rows (which have
       overflow:hidden, so their auto min-size is 0) get crushed by flex-shrink
       and clip their own content. Keep natural height and let the table scroll. */
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.cover-row-correct {
    border-color: var(--success) !important;
    background: var(--success-bg) !important;
}

.cover-row-incorrect {
    border-color: var(--danger) !important;
    background: var(--danger-bg) !important;
}

.cover-row-done .cover-eval {
    display: none !important;
}

/* Two-column cells */
.cover-cells-wrapper {
    display: flex;
    min-height: 32px;
}

.cover-cell {
    flex: 1;
    position: relative;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    min-height: 32px;
    display: flex;
    align-items: center;
}

.cover-cell-en {
    border-right: 1px solid var(--card-border);
}

.cover-cell-content {
    width: 100%;
    z-index: 1;
    position: relative;
}

.cover-word {
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.cover-uz-word {
    font-weight: 600;
    font-size: 0.74rem;
    color: var(--success);
}

.cover-meta {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 1px;
    flex-wrap: wrap;
}

.cover-tr {
    font-size: 0.62rem;
    color: var(--text-muted);
    font-weight: 500;
}

.cover-pos {
    font-size: 0.52rem;
    color: var(--primary);
    font-weight: 700;
    background: var(--primary-glow);
    padding: 1px 3px;
    border-radius: 3px;
    text-transform: uppercase;
}

/* Hidden (blurred) state */
.cover-cell.cover-hidden .cover-cell-content {
    filter: blur(7px);
    opacity: 0.2;
    pointer-events: none;
    user-select: none;
}

.cover-cell.cover-hidden .cover-reveal-btn {
    opacity: 1;
    pointer-events: auto;
}

.cover-reveal-btn {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    opacity: 0;
    pointer-events: none;
    background: transparent;
    transition: opacity 0.2s ease;
    cursor: pointer;
}

.cover-cell:not(.cover-hidden) .cover-reveal-btn {
    display: none;
}

/* Cover details (Izoh va Gap) */
.cover-details {
    display: none;
    flex-direction: column;
    gap: 3px;
    padding: 6px 10px;
    border-top: 1px dashed var(--card-border);
    font-size: 0.72rem;
    line-height: 1.3;
    background: rgba(255, 255, 255, 0.015);
    animation: screen-fade-in 0.15s ease forwards;
}

.cover-details div {
    color: var(--text-muted);
}

/* ============================================================
   LINEMATCH MODE (Chizib ulash mashqi)
   ============================================================ */
.linematch-instructions {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 10px;
}

.linematch-wrapper {
    position: relative;
    width: 100%;
    min-height: 260px;
}

.linematch-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    overflow: visible;
}

.linematch-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    position: relative;
    z-index: 3;
}

.linematch-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lm-item {
    background: var(--option-bg);
    border: 1.5px solid var(--option-border);
    border-radius: 10px;
    padding: 9px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    user-select: none;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lm-item:hover:not(.lm-matched):not(.lm-wrong) {
    background: var(--option-hover);
    transform: scale(1.02);
}

.lm-item.lm-selected {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
    box-shadow: 0 3px 12px var(--primary-glow);
    transform: scale(1.04);
}

.lm-item.lm-matched {
    background: var(--success-bg) !important;
    border-color: var(--success) !important;
    color: var(--success) !important;
    cursor: default;
    opacity: 0.65;
    transform: scale(0.97);
}

.lm-item.lm-wrong {
    background: var(--danger-bg) !important;
    border-color: var(--danger) !important;
    color: var(--danger) !important;
    animation: element-shake 0.35s ease;
}

/* Consolidated Practice Console Card */
.practice-console-card {
    background: rgba(0, 0, 0, 0.12);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 2px;
    margin-bottom: 6px;
    box-shadow: var(--card-shadow);
}

/* iOS Segmented Control */
.segmented-control {
    position: relative;
    display: flex;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 2px;
    height: 30px;
    user-select: none;
    align-items: center;
}

.segmented-glider {
    position: absolute;
    height: calc(100% - 4px);
    width: calc(33.33% - 4px);
    background: linear-gradient(135deg, var(--primary) 0%, hsla(var(--h-primary), 84%, 60%, 1) 100%);
    border-radius: 6px;
    box-shadow: 0 2px 5px var(--primary-glow);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    left: 2px;
    z-index: 1;
}

.segmented-item {
    flex: 1;
    height: 100%;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 2;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.segmented-item.selected {
    color: #ffffff;
}

/* Horizontal Slider & Badge row */
.slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 2px;
}

.slider-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.premium-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 3px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    outline: none;
}

.premium-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 6px var(--primary-glow);
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
    border: 1.5px solid var(--text-main);
}

.premium-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.premium-slider::-webkit-slider-thumb:active {
    transform: scale(0.95);
}

.slider-value-pill {
    background: var(--primary-glow);
    border: 1px solid var(--primary);
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 8px;
    min-width: 36px;
    text-align: center;
    box-shadow: 0 2px 6px var(--primary-glow);
}

/* Tiny Ticks presets */
.slider-ticks {
    display: flex;
    justify-content: space-between;
    padding: 0 2px;
}

.tick-preset {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s ease;
}

.tick-preset:hover {
    color: var(--primary);
}

.tick-preset.selected {
    color: var(--primary);
    font-weight: 700;
}

/* Console meta row */
.console-meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.66rem;
    color: var(--text-muted);
    font-weight: 600;
    border-top: 1px solid var(--option-border);
    padding-top: 4px;
}

.console-meta-row .val-highlight {
    color: var(--primary);
    font-weight: 700;
}

/* Start Block Slogan Adjustments */
.start-block {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.start-slogan {
    font-size: 0.68rem !important;
    margin: 0 !important;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.8;
}

.btn-action-pulse {
    position: relative;
    overflow: hidden;
}

.btn-action-pulse::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%) scale(0);
    border-radius: 50%;
    opacity: 0;
    transition: transform 0.5s ease, opacity 0.5s ease;
}

.btn-action-pulse:active::after {
    transform: translate(-50%, -50%) scale(2);
    opacity: 1;
    transition: 0s;
}

/* ============================================================
   WORD SEARCH MODE STYLES
   ============================================================ */
.ws-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
    margin: 10px auto;
    max-width: 320px;
    user-select: none;
}

.ws-cell {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s ease;
}

.ws-cell:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: var(--primary-glow);
}

.ws-cell.ws-selected {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 0 10px var(--primary-glow);
    transform: scale(1.05);
}

.ws-cell.ws-correct {
    background: var(--success) !important;
    border-color: var(--success) !important;
    color: #ffffff !important;
    box-shadow: 0 0 10px var(--success-glow);
}

/* ============================================================
   AUDIO SPELLING MODE STYLES
   ============================================================ */
.as-slots-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin: 20px 0;
    min-height: 42px;
}

.as-slot {
    width: 34px;
    height: 38px;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.as-slot.active {
    border-bottom: 2px solid var(--primary);
}

.as-pool-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    min-height: 80px;
}

.as-letter-chip {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.as-letter-chip:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.1);
}

.as-letter-chip.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

/* ============================================================
   AUDIO WRITE MODE STYLES
   ============================================================ */
.aw-input {
    width: 85%;
    max-width: 280px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    color: var(--text-main);
    font-size: 1.15rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: 2px;
    outline: none;
    transition: all 0.25s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.aw-input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.09);
    box-shadow: 0 0 15px var(--primary-glow), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.aw-input::placeholder {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0px;
}

.aw-input.success {
    border-color: var(--success) !important;
    color: var(--success) !important;
    box-shadow: 0 0 15px var(--success-glow);
}

.aw-input.error {
    border-color: var(--danger) !important;
    color: var(--danger) !important;
    box-shadow: 0 0 15px var(--danger-glow);
    animation: aw-input-shake 0.4s ease;
}

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

/* ============================================================
   BALLOON POP MODE STYLES
   ============================================================ */
.bp-drift-zone {
    height: 240px;
    position: relative;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.45) 0%, rgba(30, 41, 59, 0.45) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1), 0 8px 32px rgba(0, 0, 0, 0.3);
}

.bp-balloon {
    position: absolute;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 800;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.25),
        inset 0 4px 6px rgba(255, 255, 255, 0.4),
        inset 0 -4px 6px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.15);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease, border 0.2s ease;
    user-select: none;
    padding: 8px;
    word-break: normal;
    overflow-wrap: break-word;
    line-height: 1.1;
    animation: bp-float-wiggle 6s ease-in-out infinite alternate;
}

.bp-balloon:hover {
    transform: scale(1.1) translateY(-2px) !important;
    box-shadow: 
        0 12px 28px rgba(0, 0, 0, 0.35),
        inset 0 4px 6px rgba(255, 255, 255, 0.55),
        inset 0 -4px 6px rgba(0, 0, 0, 0.25),
        0 0 15px rgba(255, 255, 255, 0.25);
    z-index: 5;
}

@keyframes bp-float-wiggle {
    0% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(1px, -2px) rotate(1.5deg); }
    100% { transform: translate(-1px, 2px) rotate(-1.5deg); }
}

.bp-balloon.pop-animation {
    animation: bp-balloon-pop 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
}

@keyframes bp-balloon-pop {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.5; }
    100% { transform: scale(0); opacity: 0; }
}

/* Pop particle styling */
.bp-pop-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    animation: bp-particle-burst 0.5s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes bp-particle-burst {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0.2);
        opacity: 0;
    }
}

.fg-blank-highlight {
    color: var(--primary);
    font-weight: 700;
    border-bottom: 2px dashed var(--primary);
    padding: 0 4px;
}

/* ============================================================
   SPEECH RECOGNITION PRONUNCIATION STYLES
   ============================================================ */
.speech-mic-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    vertical-align: middle;
    margin-left: 8px;
    transition: all 0.2s ease;
}

.speech-mic-btn:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary);
}

.speech-mic-btn.listening {
    background: var(--danger-bg) !important;
    border-color: var(--danger) !important;
    color: var(--danger) !important;
    animation: mic-pulse 1.2s infinite ease-in-out;
}

.speech-mic-btn.success {
    background: var(--success-bg) !important;
    border-color: var(--success) !important;
    color: var(--success) !important;
    box-shadow: 0 0 10px var(--success-glow);
}

.speech-mic-btn.error {
    background: var(--danger-bg) !important;
    border-color: var(--danger) !important;
    color: var(--danger) !important;
    box-shadow: 0 0 10px var(--danger-glow);
}

@keyframes mic-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.speech-feedback {
    transition: all 0.2s ease;
    opacity: 0;
    transform: translateY(3px);
}

.speech-feedback.visible {
    opacity: 1;
    transform: translateY(0);
}

.speech-feedback.success {
    color: var(--success);
    background: var(--success-bg);
}

.speech-feedback.error {
    color: var(--danger);
    background: var(--danger-bg);
}

.dict-mic {
    width: 26px;
    height: 26px;
    padding: 0;
    margin-left: 6px;
}

.dict-speech-feedback {
    font-size: 0.72rem;
    font-weight: 700;
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: 4px;
    display: inline-block;
    transition: all 0.15s ease;
    opacity: 0;
    transform: scale(0.9);
}

.dict-speech-feedback.visible {
    opacity: 1;
    transform: scale(1);
}

.dict-speech-feedback.success {
    color: var(--success);
    background: var(--success-bg);
}

.dict-speech-feedback.error {
    color: var(--danger);
    background: var(--danger-bg);
}

/* ============================================================
   NEON TANK SHOOTER MODE STYLES
   ============================================================ */
.tank-battlefield {
    height: 270px;
    position: relative;
    background: 
        linear-gradient(rgba(99, 102, 241, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.08) 1px, transparent 1px),
        radial-gradient(circle at center, #111827 0%, #030010 100%);
    background-size: 24px 24px, 24px 24px, auto;
    border: 2px solid var(--primary);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: inset 0 0 35px rgba(0, 0, 0, 0.9), 0 0 15px rgba(99, 102, 241, 0.2);
}

/* Radar Scanline Overlay */
.tank-scanline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(0, 240, 255, 0.2);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
    animation: radar-sweep 4s linear infinite;
    pointer-events: none;
    z-index: 2;
}

@keyframes radar-sweep {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

/* Glassmorphic/Neon Target Saucer / Futuristic Drones */
/* Glassmorphic/Neon Target Saucer / Futuristic Drones */
.tank-target {
    position: absolute;
    padding: 8px 14px;
    background: rgba(17, 24, 39, 0.7);
    border: 1.5px solid rgba(0, 240, 255, 0.4);
    border-radius: 10px;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4), 0 0 8px rgba(0, 240, 255, 0.2);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.15s ease, border-color 0.15s ease;
    user-select: none;
    z-index: 10;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    animation: drone-bob 3s ease-in-out infinite; /* Hovering space drones! */
}

@keyframes drone-bob {
    0% { margin-top: 0px; }
    50% { margin-top: -6px; }
    100% { margin-top: 0px; }
}

.tank-target:hover {
    background: rgba(17, 24, 39, 0.9);
    border-color: #00ffff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 240, 255, 0.6);
    transform: scale(1.08);
}

.tank-target.hit-correct {
    background: rgba(16, 185, 129, 0.3) !important;
    border-color: #10b981 !important;
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.8) !important;
    transform: scale(0) rotate(180deg);
    opacity: 0;
    transition: transform 0.4s ease-in, opacity 0.4s ease-in;
    animation: none;
}

.tank-target.hit-incorrect {
    background: rgba(244, 63, 94, 0.3) !important;
    border-color: #f43f5e !important;
    box-shadow: 0 0 25px rgba(244, 63, 94, 0.8) !important;
    animation: element-shake 0.35s ease;
}

/* Tank Assembly Wrapper */
.tank-wrapper {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 55px;
    z-index: 12;
    transition: transform 0.1s ease;
}

.tank-wrapper.tank-recoil-active {
    animation: tank-recoil-anim 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes tank-recoil-anim {
    0% { transform: translateX(-50%) scale(1); }
    20% { transform: translateX(-50%) translateY(4px) scale(0.9, 0.95); }
    100% { transform: translateX(-50%) scale(1); }
}

/* Muzzle flash glow blast */
.tank-barrel-shaft {
    position: relative;
}

.tank-wrapper.muzzle-flash-active .tank-barrel-shaft::before {
    content: "";
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: radial-gradient(circle, #00ffff 0%, rgba(0, 240, 255, 0) 70%);
    box-shadow: 0 0 15px #00ffff;
    border-radius: 50%;
    z-index: 15;
    animation: flash-pulse 0.15s ease-out forwards;
}

@keyframes flash-pulse {
    0% { transform: translateX(-50%) scale(0.4); opacity: 1; }
    100% { transform: translateX(-50%) scale(1.6); opacity: 0; }
}

/* Glowing Target Pointer / Laser sight */
.tank-laser {
    position: absolute;
    bottom: 22px;
    left: calc(50% - 1px);
    width: 2px;
    height: 250px;
    background: repeating-linear-gradient(0deg, #ff0055, #ff0055 3px, transparent 3px, transparent 8px);
    transform-origin: bottom center;
    opacity: 0.25;
    pointer-events: none;
    z-index: 3;
    transition: transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Barrel assembly combining dome & barrel */
.tank-barrel-assembly {
    position: absolute;
    bottom: 12px;
    left: calc(50% - 15px);
    width: 30px;
    height: 40px;
    transform-origin: bottom center;
    transition: transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 6;
}

/* Gun barrel shaft */
.tank-barrel-shaft {
    position: absolute;
    top: -20px;
    left: calc(50% - 3px);
    width: 6px;
    height: 26px;
    background: linear-gradient(90deg, #1f2937 0%, #4b5563 50%, #1f2937 100%);
    border: 1.5px solid #00f0ff;
    border-radius: 3px 3px 0 0;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.7);
}

.barrel-glow-ring {
    position: absolute;
    left: -2px;
    width: 7px;
    height: 2px;
    background: #00ffff;
    box-shadow: 0 0 6px #00ffff;
}

/* Bullet muzzle flash circle */
.tank-barrel-shaft::after {
    content: '';
    position: absolute;
    top: -6px;
    left: calc(50% - 5px);
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, #ffffff 20%, #00f0ff 70%, transparent 100%);
    border-radius: 50%;
    opacity: 0.8;
}

/* Bullet dome turret head */
.tank-turret-dome {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 30px;
    height: 24px;
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    border: 2px solid #00f0ff;
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
    border-radius: 12px 12px 6px 6px;
}

.turret-core {
    position: absolute;
    top: 5px;
    left: calc(50% - 4px);
    width: 8px;
    height: 8px;
    background: #ff007f; /* glowing pink status dot */
    border-radius: 50%;
    box-shadow: 0 0 8px #ff007f;
    animation: turret-heartbeat 1.5s infinite ease-in-out;
}

@keyframes turret-heartbeat {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; filter: brightness(1.3); }
}

/* Tank base hull / chassis */
.tank-chassis {
    position: absolute;
    bottom: 0;
    left: calc(50% - 35px);
    width: 70px;
    height: 20px;
    z-index: 5;
}

/* Treads styling */
.tank-tread {
    position: absolute;
    bottom: 0;
    width: 14px;
    height: 20px;
    background: repeating-linear-gradient(0deg, #111827, #111827 3px, #374151 3px, #374151 6px);
    border: 1.5px solid #4b5563;
    border-radius: 4px;
}

.left-tread { left: 0; }
.right-tread { right: 0; }

.chassis-armor {
    position: absolute;
    bottom: 1px;
    left: 12px;
    width: 46px;
    height: 16px;
    background: linear-gradient(180deg, #374151 0%, #111827 100%);
    border: 1.5px solid #6366f1;
    border-radius: 6px 6px 3px 3px;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.neon-status-light {
    position: absolute;
    top: 4px;
    left: calc(50% - 6px);
    width: 12px;
    height: 3px;
    background: #00ff66; /* green power light */
    border-radius: 2px;
    box-shadow: 0 0 6px #00ff66;
}

/* Neon Plasma Bullets */
.tank-bullet {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #00ffff;
    border-radius: 50%;
    box-shadow: 0 0 15px #00ffff, 0 0 6px #ffffff;
    z-index: 4;
}

/* Explosion Sparks Particles */
.bullet-particle {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    z-index: 15;
    box-shadow: 0 0 8px currentColor;
}

/* Section header row layout */
.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--card-border);
    flex-shrink: 0;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Premium Glassmorphism Back Button */
.btn-back-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--option-bg);
    border: 1px solid var(--option-border);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 7px 12px;
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.btn-back-header:hover {
    color: var(--text-main);
    background: var(--option-hover);
    border-color: var(--primary-glow);
    transform: translateX(-2px);
}

.btn-back-header svg {
    transition: transform 0.2s ease;
}

.btn-back-header:hover svg {
    transform: translateX(-1px);
}

/* Ensure button and header work correctly on light mode */
[data-theme="vibrant-day"] .btn-back-header {
    background: var(--option-bg);
    border-color: var(--option-border);
    color: var(--text-muted);
}

/* ============================================================
   EXTRAORDINARY NEON THEMES
   ============================================================ */
/* Cyber Matrix Theme (Black + Neon Green) */
[data-theme="cyber-matrix"] {
    --h-primary: 120;
    --bg-gradient: linear-gradient(135deg, #020702 0%, #061106 100%);
    --card-bg: rgba(4, 15, 4, 0.85);
    --card-border: rgba(0, 255, 0, 0.18);
    --card-shadow: 0 20px 40px rgba(0, 0, 0, 0.9), 0 0 50px rgba(0, 255, 0, 0.1);
    
    --text-main: #00ff00;
    --text-muted: #74ff74;
    --text-inverse: #000000;
    
    --primary: #00ff00;
    --primary-glow: rgba(0, 255, 0, 0.35);
    --primary-hover: #39ff39;
    
    --option-bg: rgba(2, 8, 2, 0.7);
    --option-border: rgba(0, 255, 0, 0.12);
    --option-hover: rgba(0, 255, 0, 0.22);
    --option-text: #00ff00;
    
    --input-bg: rgba(1, 5, 1, 0.9);
    --input-border: rgba(0, 255, 0, 0.25);
    --input-focus: #00ff00;
    
    --switch-bg: rgba(3, 12, 3, 0.9);
    --sticky-bg: #030a03;
}

/* Cyber Pink Theme (Black + Neon Pink) */
[data-theme="cyber-pink"] {
    --h-primary: 320;
    --bg-gradient: linear-gradient(135deg, #090206 0%, #15020f 100%);
    --card-bg: rgba(20, 4, 14, 0.85);
    --card-border: rgba(255, 0, 128, 0.18);
    --card-shadow: 0 20px 40px rgba(0, 0, 0, 0.9), 0 0 50px rgba(255, 0, 128, 0.1);
    
    --text-main: #ff007f;
    --text-muted: #ff74b7;
    --text-inverse: #000000;
    
    --primary: #ff007f;
    --primary-glow: rgba(255, 0, 128, 0.35);
    --primary-hover: #ff3997;
    
    --option-bg: rgba(10, 2, 7, 0.7);
    --option-border: rgba(255, 0, 128, 0.12);
    --option-hover: rgba(255, 0, 128, 0.22);
    --option-text: #ff007f;
    
    --input-bg: rgba(6, 1, 4, 0.9);
    --input-border: rgba(255, 0, 128, 0.25);
    --input-focus: #ff007f;
    
    --switch-bg: rgba(12, 3, 9, 0.9);
    --sticky-bg: #0a0207;
}

/* Deep Ocean Theme (Dark Blue + Cyan) */
[data-theme="deep-ocean"] {
    --h-primary: 190;
    --bg-gradient: linear-gradient(135deg, #010810 0%, #031424 100%);
    --card-bg: rgba(3, 15, 28, 0.85);
    --card-border: rgba(0, 191, 255, 0.18);
    --card-shadow: 0 20px 40px rgba(0, 0, 0, 0.9), 0 0 50px rgba(0, 191, 255, 0.1);
    
    --text-main: #00bfff;
    --text-muted: #74dfff;
    --text-inverse: #010810;
    
    --primary: #00bfff;
    --primary-glow: rgba(0, 191, 255, 0.35);
    --primary-hover: #39cfff;
    
    --option-bg: rgba(1, 8, 16, 0.7);
    --option-border: rgba(0, 191, 255, 0.12);
    --option-hover: rgba(0, 191, 255, 0.22);
    --option-text: #00bfff;
    
    --input-bg: rgba(1, 4, 9, 0.9);
    --input-border: rgba(0, 191, 255, 0.25);
    --input-focus: #00bfff;
    
    --switch-bg: rgba(2, 10, 20, 0.9);
    --sticky-bg: #010a12;
}

/* ============================================================
   SETTINGS SCREEN — "Control Deck"
   A theme-aware instrument panel. Everything derives from the
   active theme tokens so it re-skins live with the theme picker.
   ============================================================ */
:root { --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace; }

/* Topbar identity */
.settings-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.settings-title-wrap {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}
.settings-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 500;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--primary);
    opacity: 0.9;
    margin-bottom: 3px;
}

/* Panels */
.settings-panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 13px 14px 6px;
    margin-bottom: 13px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
    backdrop-filter: blur(12px);
}
.panel-eyebrow {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 12px;
}
.panel-eyebrow > span:first-child {
    position: relative;
    padding-left: 15px;
}
.panel-eyebrow > span:first-child::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}
.panel-meta {
    color: var(--text-muted);
    font-size: 0.52rem;
    font-weight: 500;
    letter-spacing: 1.5px;
}

/* --- SIGNATURE: live theme tiles (a mini app rendered in each theme) --- */
.theme-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 4px 2px 8px;
    margin: 0 -2px;
    scrollbar-width: none;
}
.theme-strip::-webkit-scrollbar { display: none; }

.theme-tile {
    scroll-snap-align: start;
    flex: 0 0 auto;
    width: 84px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    position: relative;
}
.tile-canvas {
    position: relative;
    width: 84px;
    height: 106px;
    border-radius: 14px;
    border: 1.5px solid var(--card-border);
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
/* mini-app elements painted inside each canvas */
.tc-bar,
.tc-line,
.tc-dot { position: absolute; }
.tc-bar { top: 12px; left: 10px; width: 32px; height: 9px; border-radius: 4px; }
.tc-line { left: 10px; height: 6px; border-radius: 3px; }
.tc-line:not(.short) { top: 32px; width: 62px; }
.tc-line.short { top: 45px; width: 38px; }
.tc-dot { bottom: 11px; left: 10px; width: 34px; height: 15px; border-radius: 8px; }

.tile-name {
    font-family: var(--font-mono);
    font-size: 0.57rem;
    font-weight: 500;
    letter-spacing: 0.2px;
    color: var(--text-muted);
    white-space: nowrap;
    transition: color 0.2s ease;
}
.tile-check {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-inverse);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    box-shadow: 0 0 12px var(--primary-glow);
    border: 2px solid var(--sticky-bg);
}
.theme-tile:hover .tile-canvas {
    transform: translateY(-3px);
    border-color: var(--primary);
}
.theme-tile.selected .tile-canvas {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary), 0 0 20px var(--primary-glow);
    transform: translateY(-3px);
}
.theme-tile.selected .tile-name {
    color: var(--primary);
    font-weight: 700;
}
.theme-tile.selected .tile-check {
    display: flex;
    animation: tileCheckPop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes tileCheckPop {
    0% { transform: scale(0); }
    70% { transform: scale(1.22); }
    100% { transform: scale(1); }
}

/* Per-theme preview swatches (fixed, independent of the active theme) */
.theme-tile[data-theme="neon-night"]  .tile-canvas { background: linear-gradient(150deg, #171d2e 0%, #1e2547 100%); }
.theme-tile[data-theme="vibrant-day"] .tile-canvas { background: linear-gradient(150deg, #eef2f8 0%, #d9e2f0 100%); border-color: rgba(20, 30, 60, 0.1); }
.theme-tile[data-theme="cyber-matrix"] .tile-canvas { background: linear-gradient(150deg, #020702 0%, #061106 100%); }
.theme-tile[data-theme="cyber-pink"]  .tile-canvas { background: linear-gradient(150deg, #0b0207 0%, #160210 100%); }
.theme-tile[data-theme="deep-ocean"]  .tile-canvas { background: linear-gradient(150deg, #010810 0%, #031424 100%); }

.theme-tile[data-theme="neon-night"]  .tc-bar,
.theme-tile[data-theme="neon-night"]  .tc-dot { background: #7c83f5; box-shadow: 0 0 9px rgba(124, 131, 245, 0.65); }
.theme-tile[data-theme="neon-night"]  .tc-line { background: rgba(255, 255, 255, 0.2); }
.theme-tile[data-theme="vibrant-day"] .tc-bar,
.theme-tile[data-theme="vibrant-day"] .tc-dot { background: #4f6ef0; box-shadow: 0 0 9px rgba(79, 110, 240, 0.45); }
.theme-tile[data-theme="vibrant-day"] .tc-line { background: rgba(20, 30, 60, 0.18); }
.theme-tile[data-theme="cyber-matrix"] .tc-bar,
.theme-tile[data-theme="cyber-matrix"] .tc-dot { background: #00ff41; box-shadow: 0 0 10px rgba(0, 255, 65, 0.6); }
.theme-tile[data-theme="cyber-matrix"] .tc-line { background: rgba(0, 255, 65, 0.28); }
.theme-tile[data-theme="cyber-pink"]  .tc-bar,
.theme-tile[data-theme="cyber-pink"]  .tc-dot { background: #ff007f; box-shadow: 0 0 10px rgba(255, 0, 128, 0.6); }
.theme-tile[data-theme="cyber-pink"]  .tc-line { background: rgba(255, 0, 128, 0.28); }
.theme-tile[data-theme="deep-ocean"]  .tc-bar,
.theme-tile[data-theme="deep-ocean"]  .tc-dot { background: #00bfff; box-shadow: 0 0 10px rgba(0, 191, 255, 0.6); }
.theme-tile[data-theme="deep-ocean"]  .tc-line { background: rgba(0, 191, 255, 0.28); }

/* --- Control rows --- */
.control-row { padding: 11px 0; }
.control-row + .control-row { border-top: 1px solid var(--card-border); }

.control-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.control-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 7px;
}
.cl-emoji { font-size: 0.92rem; }
.control-sub {
    font-size: 0.66rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 3px;
}
.slider-readout {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-glow);
    padding: 2px 9px;
    border-radius: 6px;
    min-width: 42px;
    text-align: center;
}

/* Gradient-fill slider (fill driven by --pct from JS) */
.settings-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 7px;
    border-radius: 6px;
    outline: none;
    margin: 0;
    cursor: pointer;
    background: linear-gradient(to right,
        var(--primary) 0%, var(--primary) var(--pct, 50%),
        var(--option-border) var(--pct, 50%), var(--option-border) 100%);
}
.settings-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--sticky-bg);
    box-shadow: 0 0 0 1px var(--primary), 0 0 12px var(--primary-glow);
    cursor: pointer;
    transition: transform 0.12s ease;
}
.settings-slider::-webkit-slider-thumb:hover,
.settings-slider:active::-webkit-slider-thumb { transform: scale(1.18); }
.settings-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--sticky-bg);
    box-shadow: 0 0 12px var(--primary-glow);
    cursor: pointer;
}
.settings-slider::-moz-range-progress {
    height: 7px;
    border-radius: 6px;
    background: var(--primary);
}

/* Select (accent) */
.settings-select {
    width: 100%;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    padding: 11px 34px 11px 12px;
    border-radius: 11px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='3' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.settings-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.settings-select option {
    background: var(--sticky-bg);
    color: var(--text-main);
}

/* Toggle rows */
.control-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}
.control-label {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

/* Neon switch */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}
.switch-toggle input { opacity: 0; width: 0; height: 0; }
.slider-round {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: var(--option-border);
    border: 1px solid var(--card-border);
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 26px;
}
.slider-round:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    top: 2px;
    background: var(--text-muted);
    transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 50%;
}
.switch-toggle input:checked + .slider-round {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}
.switch-toggle input:checked + .slider-round:before {
    transform: translateX(20px);
    background: var(--text-inverse);
}

/* Reset — quiet destructive action */
.reset-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    margin-bottom: 10px;
    background: transparent;
    border: 1px solid var(--danger-bg);
    border-radius: 14px;
    color: var(--danger);
    cursor: pointer;
    text-align: left;
    transition: background 0.2s ease, border-color 0.2s ease;
}
.reset-row:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
}
.reset-row svg { flex-shrink: 0; }
.reset-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-weight: 800;
    font-size: 0.82rem;
}
.reset-sub {
    font-weight: 500;
    font-size: 0.64rem;
    color: var(--text-muted);
}

/* Staggered reveal when the deck opens */
@keyframes panelReveal {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}
#settings-screen.active .settings-topbar,
#settings-screen.active .settings-panel,
#settings-screen.active .reset-row {
    animation: panelReveal 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--i, 0) * 80ms + 60ms);
}

@media (prefers-reduced-motion: reduce) {
    #settings-screen.active .settings-topbar,
    #settings-screen.active .settings-panel,
    #settings-screen.active .reset-row { animation: none; }
    .tile-canvas,
    .settings-slider::-webkit-slider-thumb,
    .slider-round,
    .slider-round:before { transition: none; }
}

/* ==========================================================================
   BOOK VIEWER SCREEN STYLES (PREMIUM REVAMP)
   ========================================================================== */
/* Bottom controls flex row containing selector and switcher side-by-side */
.book-bottom-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 6px !important;
    margin-bottom: 2px !important;
    width: 100%;
    box-sizing: border-box;
}

.super-control-trigger {
    background: rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 2px 8px !important;
    border-radius: 8px;
    color: #333333 !important;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    box-shadow: none !important;
    transition: all 0.2s ease;
    height: 22px !important; /* Perfect height matching the page switcher */
    box-sizing: border-box;
    flex-shrink: 0;
}

[data-theme="neon-night"] .super-control-trigger {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff !important;
}

.super-control-trigger:hover {
    background: rgba(124, 77, 255, 0.1);
    border-color: var(--primary);
}

.sc-icon-book {
    font-size: 0.72rem;
}

.sc-book-tag {
    color: var(--primary) !important;
}

.sc-divider {
    color: rgba(0, 0, 0, 0.2);
}
[data-theme="neon-night"] .sc-divider {
    color: rgba(255, 255, 255, 0.2);
}

.sc-unit-tag {
    color: #ea580c;
}

.sc-chevron {
    width: 10px;
    height: 10px;
    color: #555555;
    transition: transform 0.2s ease;
}
[data-theme="neon-night"] .sc-chevron {
    color: #bbbbbb;
}

.super-control-trigger:hover .sc-chevron {
    transform: translateY(1px);
}

#book-screen.active {
    display: flex !important;
    flex-direction: column;
    height: 100%;
}

.book-reader-container {
    position: relative;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.book-single-page {
    flex: 1;
    width: 100%;
    max-width: 100%;
    background: #ffffff !important; /* Sof oq fon */
    border: none !important; /* Tashqi ramkalarsiz */
    border-radius: 16px;
    padding: 4px 10px 4px 10px !important;
    position: relative;
    box-shadow: none !important; /* Soyalarsiz */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    min-height: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
    color: #333333 !important;
    overflow: visible !important; /* Prevent Unit Circle clipping */
}

/* Force dark ink colors on white paper sheet */
.book-single-page .book-word-definition {
    color: #424242 !important;
}
.book-single-page .book-word-transcription,
.book-single-page .book-word-pos,
.book-single-page .book-word-example {
    color: #616161 !important;
}
.book-single-page .word-book-avatar {
    color: #616161 !important;
    border-color: #9e9e9e !important;
    background-color: #f5f5f5 !important;
}

/* Page turn chevrons positioned absolutely to allow full width */
.page-turn-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    color: #333333 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15) !important;
}

.page-turn-btn:hover:not(:disabled) {
    background: #ffffff !important;
    color: var(--primary) !important;
    transform: translateY(-50%) scale(1.08);
}

.page-turn-btn:active:not(:disabled) {
    transform: translateY(-50%) scale(0.95);
}

.page-turn-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

.page-turn-btn.prev-btn {
    left: -50px;
}

.page-turn-btn.next-btn {
    right: -50px;
}

.book-page-indicator {
    text-align: center;
    margin-top: 16px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* Light/Dark Theme Specific Variables for Book */
[data-theme="neon-night"] {
    --book-bg: #0b0c16;
    --book-border: rgba(168, 85, 247, 0.25);
    --book-text: #e2e8f0;
    --book-divider: rgba(255, 255, 255, 0.06);
}
[data-theme="vibrant-day"] {
    --book-bg: #faf8f5;
    --book-border: rgba(0, 0, 0, 0.12);
    --book-text: #1e293b;
    --book-divider: rgba(0, 0, 0, 0.06);
}
[data-theme="cyber-matrix"] {
    --book-bg: #030803;
    --book-border: rgba(0, 255, 0, 0.25);
    --book-text: #00ff00;
    --book-divider: rgba(0, 255, 0, 0.1);
}
[data-theme="cyber-pink"] {
    --book-bg: #120112;
    --book-border: rgba(255, 0, 128, 0.25);
    --book-text: #fdf2f8;
    --book-divider: rgba(255, 0, 128, 0.1);
}
[data-theme="deep-ocean"] {
    --book-bg: #030b1e;
    --book-border: rgba(0, 239, 255, 0.25);
    --book-text: #e0f2fe;
    --book-divider: rgba(0, 239, 255, 0.1);
}

.book-page {
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 50px; /* Space for page number footer */
}

/* Header skeuomorphic styling */
/* Compact Unit Badge Header */
.book-unit-badge-container {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px !important;
    height: 18px !important;
}

.book-unit-circle {
    width: 18px !important;
    height: 18px !important;
    background: radial-gradient(circle, #a855f7 0%, #7c3aed 100%);
    border: 1px solid #ffffff !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15) !important;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    flex-shrink: 0;
    z-index: 5;
}

.book-unit-circle .unit-lbl {
    display: none !important; /* Hide "UNIT" label to save vertical space */
}

.book-unit-circle .unit-num {
    font-size: 0.72rem !important;
    font-weight: 900;
    color: #facc15;
    line-height: 1;
}

.book-wordlist-ribbon {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #ffffff;
    font-size: 0.62rem !important;
    font-weight: 900;
    padding: 1px 8px !important;
    border-radius: 0 4px 4px 0 !important;
    height: 14px !important;
    display: flex;
    align-items: center;
    margin-left: -6px !important;
    z-index: 4;
}

.right-page-header-spacer {
    height: 18px !important;
    margin-bottom: 4px !important;
}

/* Glassmorphic Selector Modal Dashboard Overlay */
.super-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: flex;
    align-items: flex-end; /* Align content to bottom of screen (bottom-sheet drawer) */
    justify-content: center;
    z-index: 9999;
    animation: fadeInModal 0.22s ease-out;
}

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

.super-modal-content {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(124, 77, 255, 0.25);
    border-radius: 20px 20px 0 0; /* Bottom sheet top corners only */
    width: 100%;
    max-width: 480px; /* Matches mobile container width */
    max-height: 80%;
    padding: 16px 16px 30px 16px; /* Extra bottom padding for home indicator */
    box-shadow: 0 -10px 35px rgba(0, 0, 0, 0.5), 0 0 20px rgba(124, 77, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    animation: slideUpModal 0.28s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.super-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
}

.super-modal-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.3px;
}

.super-modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    font-weight: 300;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.super-modal-close:hover {
    color: #ffffff;
}

.super-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    padding-right: 2px;
}

/* Styled scrollbar for modal body */
.super-modal-body::-webkit-scrollbar {
    width: 3px;
}
.super-modal-body::-webkit-scrollbar-thumb {
    background: rgba(124, 77, 255, 0.4);
    border-radius: 3px;
}

.super-modal-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.super-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Books Grid */
.super-book-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.super-book-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 8px 4px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.super-book-card:hover {
    border-color: rgba(124, 77, 255, 0.4);
    background: rgba(124, 77, 255, 0.05);
}

.super-book-card.active {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.25) 0%, rgba(124, 77, 255, 0.25) 100%);
    border-color: #a855f7;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

.super-book-card .book-title {
    font-size: 0.72rem;
    font-weight: 800;
    color: #ffffff;
    display: block;
}

.super-book-card .book-subtitle {
    font-size: 0.55rem;
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
}

/* Units Grid */
.super-unit-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
    padding: 4px 2px;
}

/* Scrollbar for units grid */
.super-unit-grid::-webkit-scrollbar {
    width: 3px;
}
.super-unit-grid::-webkit-scrollbar-thumb {
    background: rgba(124, 77, 255, 0.3);
    border-radius: 3px;
}

.super-unit-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    margin: 0 auto;
    box-sizing: border-box;
}

.super-unit-btn:hover {
    border-color: rgba(234, 88, 12, 0.4);
    background: rgba(234, 88, 12, 0.08);
}

.super-unit-btn.active {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    border-color: #f97316;
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.4);
}

/* Segmented Page Controls at the bottom of sheet */
.book-page-segmented-control {
    display: flex;
    background: rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 2px !important;
    border-radius: 8px;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    width: auto;
    flex: 1;
    box-sizing: border-box;
    height: 22px !important;
    align-items: center;
}

.page-segment-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 3px 0 !important;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #555555;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.page-segment-btn:hover {
    color: #000000;
}

.page-segment-btn.active {
    background: #ffffff;
    color: var(--primary) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Words list */
.page-words-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0px !important;
}

/* Word item */
.book-word-item {
    display: flex;
    gap: 6px !important;
    align-items: flex-start;
    padding: 3px 6px !important;
    margin: 0 -6px;
    page-break-inside: avoid;
    break-inside: avoid;
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
    border-radius: 6px;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.book-word-item:hover {
    background-color: rgba(124, 77, 255, 0.04) !important;
}

.book-word-item:active {
    background-color: rgba(124, 77, 255, 0.12) !important;
    transform: scale(0.985);
}

/* Small visual avatar (Simple placeholder) */
.book-word-visual {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
    margin-top: 1px;
}

.word-book-avatar {
    width: 16px !important;
    height: 16px !important;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.6rem !important;
    font-weight: 800;
}

.word-checkbox-container {
    display: inline-block;
    vertical-align: middle;
}

.word-checkbox {
    width: 12px;
    height: 12px;
    border: 1.5px solid #22c55e;
    border-radius: 50%;
    cursor: pointer;
    display: inline-block;
    transition: all 0.2s ease;
    background: transparent;
}

.word-checkbox.checked {
    background: #22c55e;
}

/* Audio Pronunciation Button */
.word-audio-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    transition: background 0.2s, transform 0.1s, color 0.2s;
    vertical-align: middle;
}

.word-audio-btn:hover {
    color: var(--primary);
    background: rgba(124, 77, 255, 0.1);
}

.word-audio-btn svg {
    width: 12px;
    height: 12px;
}

.book-word-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px !important;
}

.book-word-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on mobile to prevent layout stretch */
    gap: 4px;
    line-height: 1.25;
    width: 100%;
}

.book-word-spelling {
    font-size: 0.76rem !important;
    font-weight: 800;
    color: #2e7d32 !important; /* Forest green always */
}

.book-word-transcription {
    font-size: 0.62rem !important;
    color: var(--text-muted);
    margin-left: 2px;
}

.book-word-pos {
    font-size: 0.56rem !important;
    color: var(--text-muted);
    font-style: italic;
}

.book-word-translation {
    font-size: 0.68rem !important;
    font-weight: 700;
    color: #c62828 !important; /* To'q qizil */
    background-color: #ffebee !important; /* Och qizil fon */
    border: 1px solid #ffcdd2 !important;
    padding: 1px 5px !important;
    border-radius: 4px !important;
    margin-left: auto; /* Push translation to the far right */
    white-space: normal; /* Allow wrap inside the sticker for long text */
    word-break: normal;
    overflow-wrap: break-word;
    text-align: right;
}

.book-word-definition {
    font-size: 0.64rem !important;
    color: var(--book-text, #1e293b);
    line-height: 1.22 !important;
    margin-top: 0px !important;
}

.book-word-example {
    display: flex;
    gap: 4px;
    font-size: 0.6rem !important;
    color: var(--text-muted);
    line-height: 1.18 !important;
}

.example-arrow {
    color: #22c55e;
    font-weight: bold;
}

/* Page Footer with tilted corner tags */
.book-page-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 2px !important;
    width: 100%;
    box-sizing: border-box;
}

.page-indicator-inner {
    font-size: 0.62rem;
    font-weight: 700;
    color: #666666 !important;
    letter-spacing: 0.2px;
}

.page-tag-corner {
    background: #a3e635; /* Lime green diagonal tag */
    color: #064e3b; /* Dark green text */
    padding: 3px 8px;
    font-weight: 900;
    font-size: 0.72rem;
    border-radius: 3px;
    display: inline-block;
    transition: transform 0.2s ease;
}

.left-footer-align {
    text-align: left;
}
.left-footer-align .page-tag-corner {
    transform: rotate(-5deg);
}

.right-footer-align {
    text-align: right;
}
.right-footer-align .page-tag-corner {
    transform: rotate(5deg);
}

/* Responsive Mobile overrides */
@media (max-width: 768px) {
    .app-container {
        padding: 10px 8px 8px 8px !important;
    }
    
    .main-content-scroll {
        padding-bottom: 0 !important;
    }
    
    .book-reader-container {
        gap: 0;
    }
    
    .book-single-page {
        padding: 4px 10px 4px 10px !important;
    }
    
    .page-turn-btn {
        display: none !important;
    }
}
