:root {
    color-scheme: light;
    --bg: #f0f5f3;
    --bg-warm: #fff8f0;
    --surface: #ffffff;
    --ink: #152033;
    --muted: #5f6f85;
    --line: #d5e0ea;
    --brand: #166a5b;
    --brand-dark: #0f4f44;
    --brand-soft: #e4f4f0;
    --accent: #e86a2f;
    --accent-soft: #fff1e8;
    --uzbek-col: #e8f2ff;
    --english-col: #e8f7ef;
    --danger: #d64545;
    --success: #2f9e44;
    --star: #f2b705;
    --shadow: 0 14px 32px rgba(21, 32, 51, 0.08);
    --radius: 14px;
    --radius-sm: 10px;
    --font: 'Nunito', Arial, Helvetica, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(180deg, var(--bg) 0%, #f8fafc 100%);
    color: var(--ink);
    font-family: var(--font);
    line-height: 1.45;
}

a {
    color: inherit;
}

img {
    max-width: 100%;
}

.app-shell {
    flex: 1;
    width: min(1040px, 100%);
    margin: 0 auto;
    padding: 20px 16px 32px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

/* Site chrome */
.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(10px);
}

.site-header-inner,
.site-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: min(1040px, 100%);
    margin: 0 auto;
    padding: 12px 16px;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 800;
    text-decoration: none;
}

.site-brand img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
}

.site-header .container-fluid {
    width: 66.666667%;  
    margin: 0 auto;
    padding: 0;
}

.navbar-collapse {
    justify-content: flex-end;
}

.navbar-nav {
    margin-left: auto;
    gap: 8px;
}

.site-nav,
.footer-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.site-nav a,
.footer-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 999px;
    color: var(--brand-dark);
    font-weight: 700;
    text-decoration: none;
}

.site-nav a:hover,
.footer-nav a:hover {
    background: var(--brand-soft);
}

.site-footer {
    margin-top: auto;
    border-top: 1px solid var(--line);
    background: var(--surface);
}

.footer-brand {
    margin: 0;
    font-weight: 800;
}

.footer-copy {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

/* Typography */
.eyebrow {
    margin: 0 0 6px;
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

h1, h2, h3 {
    margin: 0;
    line-height: 1.15;
}

h1 {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
}

h2 {
    font-size: clamp(1.25rem, 3vw, 1.7rem);
}

.section-sub,
.empty-state-uz,
.hero-lead-uz,
.intro-copy-uz,
.about-headline-uz {
    color: var(--muted);
}

.empty-state-uz,
.hero-lead-uz,
.intro-copy-uz,
.about-headline-uz {
    font-size: 0.92rem;
}

/* Hero */
.hero {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 24px;
    align-items: center;
    margin-bottom: 24px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 4px);
    background: linear-gradient(135deg, var(--surface), var(--brand-soft));
    box-shadow: var(--shadow);
}

.hero-lead {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 1.02rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.hero-photo {
    width: min(260px, 100%);
    aspect-ratio: 1;
    margin-inline: auto;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow);
}

/* Continue card */
.continue-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    align-items: center;
    margin-bottom: 24px;
    padding: 16px 18px;
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}

.continue-card strong {
    grid-column: 1;
    font-size: 1.1rem;
}

.continue-arrow {
    grid-row: span 2;
    font-size: 1.4rem;
}

/* How it works */
.how-it-works,
.teacher-teaser,
.page-section {
    margin-bottom: 28px;
}

.steps-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.steps-list li {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.steps-list strong {
    display: block;
    margin-bottom: 4px;
}

.steps-list span {
    color: var(--muted);
    font-size: 0.9rem;
}

.teacher-teaser {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.text-link {
    display: inline-block;
    margin-top: 10px;
    color: var(--brand-dark);
    font-weight: 800;
    text-decoration: none;
}

/* Level grid */
.section-heading {
    margin-bottom: 14px;
}

.level-grid,
.unit-path {
    display: grid;
    gap: 12px;
}

.level-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.level-card,
.unit-card {
    display: grid;
    gap: 6px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
    transition: transform 140ms ease, border-color 140ms ease;
}

.level-card:hover,
.unit-card:hover {
    border-color: var(--brand);
    transform: translateY(-2px);
}

.level-card-meta,
.unit-best {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.unit-path {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.unit-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.unit-number {
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.unit-card.is-completed {
    border-color: var(--success);
    background: linear-gradient(180deg, #fff, #f3fbf5);
}

.star {
    color: #d0d7e2;
    font-size: 0.95rem;
}

.star.is-earned {
    color: var(--star);
}

.victory-stars .star,
.unit-stars .star {
    margin-right: 2px;
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 16px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.breadcrumbs a {
    color: var(--brand-dark);
    text-decoration: none;
}

/* About */
.about-page {
    display: grid;
    gap: 24px;
}

.about-hero {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 20px;
    align-items: center;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.about-photo {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
}

.about-headline {
    margin-top: 10px;
    font-size: 1.05rem;
}

.about-body,
.about-credentials,
.about-contact {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.about-text {
    color: var(--muted);
}

.about-credentials ul {
    margin: 0;
    padding-left: 18px;
}

.contact-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Unit intro */
.unit-intro-card {
    max-width: 560px;
    margin-inline: auto;
    padding: 28px 24px;
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 2px);
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
}

.intro-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.intro-stats div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.intro-stats dt {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.intro-stats dd {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 800;
}

.intro-copy {
    margin: 0 0 8px;
    color: var(--muted);
}

.intro-start {
    margin-top: 18px;
    width: 100%;
}

/* Buttons */
.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

nav.study-actions .secondary-button {
    padding: 6px 14px;
    font-size: 0.9rem;
    line-height: 1.2;
}

.primary-button {
    border: 0;
    background: var(--brand);
    color: #fff;
}

.primary-button:hover {
    background: var(--brand-dark);
    color: #ffffff;
}

.secondary-button {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
}

.secondary-button:hover {
    border-color: var(--brand);
}

.secondary-button:disabled,
.primary-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.empty-state {
    padding: 20px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    color: var(--muted);
    text-align: center;
}

/* Game page */
body.game-page {
    height: 100dvh;
    overflow: hidden;
    background: var(--bg);
}

body.game-page.modal-open {
    overflow: hidden;
    touch-action: none;
}

.game-page .app-shell {
    display: flex;
    width: 100%;
    max-width: none;
    height: 100dvh;
    min-height: 100dvh;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

.game-page .game {
    flex: 1;
    min-height: 0;
    height: 100%;
}

.game {
    position: relative;
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    gap: 4px;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.topbar-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    min-width: 48px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--brand-dark);
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.topbar-icon {
    width: 22px;
    height: 22px;
    display: block;
}

.topbar-icon[hidden],
.mute-toggle-btn .icon-sound-on[hidden],
.mute-toggle-btn .icon-sound-off[hidden] {
    display: none;
}

.mute-toggle-btn .fa-solid {
    font-size: 1.05rem;
    line-height: 1;
    width: 1.25rem;
    text-align: center;
}

.shooter-mute-btn .fa-solid {
    font-size: 1rem;
}

.game-topbar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
    max-width: 920px;
    margin-inline: auto;
    width: 100%;
}

.game-hud-stats {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin-left: auto;
}

.stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-weight: 800;
    font-size: 0.95rem;
    white-space: nowrap;
}
.stat-icon {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1;
    display: none;
}

.stat-label {
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
}

.stat-lives {
    justify-content: center;
}

.lives-display {
    display: inline-flex;
    gap: 3px;
}

.life-icon {
    font-size: 1rem;
    line-height: 1;
    transition: color 0.2s ease
}

.life-icon.is-full {
    color: var(--danger);
}

.life-icon.is-empty {
    color: #707172;
}

.game-status {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
    gap: 8px;
    align-items: end;

    width: 66.666667%;
    margin-inline: auto;
}

.game-title h1 {
    overflow: hidden;
    font-size: clamp(1.1rem, 3.5vw, 1.6rem);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-page .game-title .eyebrow {
    margin-bottom: 0;
    font-size: 0.68rem;
}

.unit-progress {
    display: grid;
    gap: 4px;
}

.progress-copy {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.progress-track {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #dfe7f3;
    margin: 0px 0px;
}

.progress-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), #2f9e7d);
    transition: width 260ms ease;
}

.message {
    min-height: 0;
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.game-page .message:empty {
    display: none;
}

.game-board-zone {
    display: grid;
    grid-template-rows: 10dvh minmax(0, 1fr);
    gap: 6px;
    width: calc(100% * 8 / 12);
    max-width: 100%;
    height: 100%;
    min-height: 0;
    margin-inline: auto;
}

.event-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 10dvh;
    max-height: 10dvh;
    min-height: 10dvh;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #f8fbff;
    color: var(--muted);
    font-size: clamp(0.78rem, 1.8dvh, 0.95rem);
    font-weight: 800;
    text-align: center;
    overflow: hidden;
}

.event-banner.is-empty {
    background: transparent;
    border-color: transparent;
}

.event-banner strong {
    color: var(--ink);
    font-size: clamp(0.85rem, 2dvh, 1.05rem);
}

.event-banner strong:not(:empty) + span:not(:empty)::before {
    content: ' — ';
}

.match-board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.word-column h2 {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    text-align: center;
}

.word-column--uzbek .word-list {
    background: var(--uzbek-col);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.word-column--english .word-list {
    background: var(--english-col);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.word-list {
    display: grid;
    grid-template-rows: repeat(var(--round-count, 10), minmax(0, 1fr));
    gap: 8px;
    min-height: 0;
    height: 100%;
}

.word-button {
    min-height: 48px;
    width: 100%;
    height: 100%;
    padding: 10px 12px;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 4px 12px rgba(21, 32, 51, 0.06);
    cursor: pointer;
    font: inherit;
    font-size: clamp(1rem, 2.6vw, 1.35rem);
    font-weight: 800;
    line-height: 1.2;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    transition: border-color 140ms ease, transform 140ms ease, opacity 220ms ease;
}

.word-button:hover {
    border-color: var(--brand);
    transform: translateY(-1px);
}

.word-button.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: scale(1.02);
}

.word-button.matched {
    opacity: 0;
    transform: scale(0.92);
    pointer-events: none;
}

.word-button.shake {
    animation: shake 240ms ease-in-out;
}

.word-button.correct {
    border-color: var(--success);
    background: #ebfbee;
}

/* Loading */
.game-loading {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: grid;
    place-items: center;
    background: rgba(240, 245, 243, 0.82);
}

.game-loading[hidden] {
    display: none;
}

.game-loading-card {
    display: grid;
    gap: 10px;
    justify-items: center;
    padding: 20px 24px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    font-weight: 800;
}

.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--line);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Modals */
.game-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    background: rgba(21, 32, 51, 0.48);
}

.game-modal[hidden] {
    display: none;
}

.game-modal-card {
    width: min(480px, 100%);
    max-height: min(90dvh, 720px);
    overflow: auto;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.game-modal-title {
    margin: 0 0 8px;
    font-size: clamp(1.35rem, 4vw, 1.9rem);
}

.game-modal-message {
    margin: 0 0 14px;
    color: var(--muted);
}

.modal-score-big {
    margin: 0 0 12px;
    font-size: clamp(2rem, 8vw, 2.8rem);
    font-weight: 800;
    text-align: center;
    color: var(--brand-dark);
}

.victory-stars {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 1.6rem;
}

.event-gif {
    display: block;
    width: min(220px, 100%);
    max-height: 180px;
    margin: 0 auto 14px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.event-gif[hidden] {
    display: none;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0 0 18px;
}

.stats-grid--compact {
    margin-bottom: 12px;
}

.stats-grid div {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #f8fbff;
}

.stats-grid dt {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.stats-grid dd {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.modal-actions--three {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.modal-actions--three > :last-child {
    grid-column: 1 / -1;
}

.modal-actions--two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.modal-actions--five {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.modal-actions--five > :first-child {
    grid-column: 1 / -1;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes cardSlideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.game-modal:not([hidden]),
.shooter-overlay:not([hidden]),
.shooter-pause-menu:not([hidden]) {
    animation: modalFadeIn 0.3s ease-out forwards;
}

.game-modal:not([hidden]) .game-modal-card,
.shooter-overlay:not([hidden]) .shooter-overlay-card,
.shooter-pause-menu:not([hidden]) .shooter-pause-card {
    animation: cardSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.continue-hint {
    margin: 12px 0 0;
    color: var(--danger);
    font-size: 0.88rem;
    font-weight: 800;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile */
@media (max-width: 640px) {
    .site-header-inner,
    .site-footer-inner {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .site-header .container-fluid {
        width: 90%;  
        margin: 0 auto;
        padding: 0;
    }

    .site-nav,
    .footer-nav {
        justify-content: center;
    }

    .hero {
        grid-template-columns: 1fr;
        padding: 18px;
        text-align: center;
    }

    .hero-actions {
        justify-content: center;
    }

    .steps-list {
        grid-template-columns: 1fr;
    }

    .about-hero {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .about-photo {
        margin-inline: auto;
    }

    .game-page .app-shell {
        padding: 8px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    .game-topbar {
        gap: 4px;
        margin-bottom: 10px;
        padding: 0;
    }

    .stat {
        padding: 5px 8px;
        min-height: 36px;
        font-size: 0.88rem;
        gap: 4px;
    }

    .stat-label { display: none; }
    .stat-icon  { display: inline-block; }

    .topbar-button {
        min-height: 36px;
        min-width: 36px;
        padding: 7px;
    }

    .topbar-icon {
        width: 18px;
        height: 18px;
    }

    .game-board-zone {
        width: calc(100% * 11 / 12);
        gap: 4px;
    }

    .game-status {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .game-modal {
        padding: 6px;
        overflow: hidden;
    }

    .game-modal-card {
        max-height: 96dvh;
        overflow: hidden;
        padding: 12px 14px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .game-modal-title {
        font-size: 1.15rem;
        margin-bottom: 4px;
    }

    .game-modal-message {
        font-size: 0.78rem;
        margin-bottom: 8px;
    }

    .event-gif {
        max-height: 72px;
        margin-bottom: 6px;
    }

    .stats-grid {
        gap: 6px;
        margin-bottom: 10px;
    }

    .stats-grid div {
        padding: 6px 8px;
    }

    .stats-grid dt {
        font-size: 0.62rem;
    }

    .stats-grid dd {
        font-size: 0.95rem;
    }

    .modal-actions {
        flex-direction: column;
        gap: 6px;
    }

    .modal-actions .primary-button,
    .modal-actions .secondary-button {
        width: 100%;
        min-height: 42px;
        padding: 8px 12px;
        font-size: 0.84rem;
    }

    .modal-score-big {
        font-size: 2rem;
    }

    .word-button {
        font-size: clamp(0.92rem, 2.4vw, 1.15rem);
    }
}

/* Unit mode hub */
/* .unit-hub .mode-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 20px;
    text-align: left;
}

.mode-card--study {
    grid-column: auto;
} */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.mode-card--study {
    grid-column: 1 / -1; /* span the entire row */
}

.mode-card {
    display: grid;
    gap: 8px;
    padding: 20px;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--ink);
    text-decoration: none;
    transition: transform 140ms ease, border-color 140ms ease;
}

.mode-card:hover {
    transform: translateY(-2px);
    border-color: var(--brand);
}

.mode-card strong {
    font-size: 1.1rem;
}

.mode-card span:not(.mode-icon):not(.mode-tag) {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.mode-icon {
    font-size: 1.6rem;
}

.mode-tag {
    justify-self: start;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.mode-card--spell .mode-tag {
    background: var(--accent-soft);
    color: var(--accent);
}

.mode-card--study .mode-tag {
    background: #e0f2fe;
    color: #0369a1;
}

/* ═══════════════════════════════════════════
   Vocabulary study page
   ═══════════════════════════════════════════ */
.study-page {
    display: grid;
    gap: 18px;
    max-width: 920px;
    margin: 0 auto;
}

/* ── Header ── */
.study-header {
    display: grid;
    gap: 4px;
}

.study-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--muted);
    text-decoration: none;
    margin-bottom: 4px;
    width: fit-content;
}

.study-back-btn:hover { color: var(--brand); }

.study-header__titles h1 { margin-bottom: 0; }

.study-header__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.study-info {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.study-count {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 800;
}

.study-page-label {
    margin: 0;
    color: var(--brand-dark);
    font-size: 0.88rem;
    font-weight: 800;
    background: var(--brand-soft);
    padding: 2px 10px;
    border-radius: 999px;
}

/* ── Toolbar: mode toggle on top, search below ── */
.study-toolbar {
    display: grid;
    gap: 10px;
}

.study-mode-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.study-mode-btn {
    min-height: 44px;
    padding: 10px 12px;
    border: none;
    border-radius: calc(var(--radius) - 4px);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.study-mode-btn.is-active {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.study-search {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 1rem;
}

.study-search:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ── Panel (shared) ── */
.study-panel {
    display: grid;
    gap: 14px;
}

/* ── Vocabulary list ── */
.study-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.vocab-card {
    display: grid;
    gap: 8px;
    padding: 16px;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.vocab-card__uzbek  { font-size: 1.15rem; font-weight: 800; color: var(--ink); }
.vocab-card__english { font-size: 1rem; font-weight: 700; color: var(--brand-dark); }
.vocab-card__extra  { font-size: 0.88rem; color: var(--muted); }

.vocab-card__speak {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--brand-soft);
    color: var(--brand-dark);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
}

.vocab-card__speak:hover { border-color: var(--brand); }

/* ── Pagination ── */
.study-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 4px 0;
}

.study-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: 0.9rem;
    cursor: pointer;
}

.study-page-btn:disabled { opacity: 0.35; cursor: default; }
.study-page-btn:not(:disabled):hover { border-color: var(--brand); color: var(--brand); }

.study-page-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.page-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: var(--line);
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, transform 0.15s;
}

.page-dot.is-active {
    background: var(--brand);
    transform: scale(1.3);
}

/* ── Flash: progress bar ── */
.flash-progress-wrap { display: grid; gap: 8px; }

.flash-progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--muted);
}

.flash-progress-track {
    height: 8px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}

.flash-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), #2f9e7d);
    transition: width 0.3s ease;
}

.flash-stats {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 0.9rem;
    font-weight: 800;
}

.flash-stat { display: inline-flex; align-items: center; gap: 6px; }
.flash-stat--known  { color: var(--success); }
.flash-stat--review { color: var(--danger); }

/* ── 3-D flip card ── */
.flashcard-scene {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    perspective: 1200px;
    /* Taller card */
    height: 360px;
    position: relative;
}

/* Swipe hint overlays (sit inside the scene, behind the card) */
.swipe-hint {
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 0;
}

.swipe-hint--left {
    background: linear-gradient(135deg, rgba(220,38,38,0.18) 0%, rgba(220,38,38,0.05) 100%);
    color: #dc2626;
    border: 2px solid rgba(220,38,38,0.3);
    border-radius: var(--radius);
}

.swipe-hint--right {
    background: linear-gradient(135deg, rgba(22,163,74,0.18) 0%, rgba(22,163,74,0.05) 100%);
    color: #16a34a;
    border: 2px solid rgba(22,163,74,0.3);
    border-radius: var(--radius);
}

.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    user-select: none;
    z-index: 1;
}

.flashcard.flipped { transform: rotateY(180deg); }

.flashcard__face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: var(--radius);
    border: 2px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 14px;
    padding: 32px 28px;
    text-align: center;
}

.flashcard__face--back {
    transform: rotateY(180deg);
    background: linear-gradient(160deg, var(--surface) 0%, var(--brand-soft) 100%);
    border-color: var(--brand);
}

.flashcard__hint-label {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.flashcard__word {
    margin: 0;
    font-size: clamp(2rem, 7vw, 2.8rem);
    font-weight: 800;
    line-height: 1.1;
    color: var(--ink);
}

.flashcard__word--english { color: var(--brand-dark); }

.flashcard__tap-hint {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 999px;
    padding: 6px 18px;
}

/* Swipe-off exit animations */
.flashcard.swipe-right {
    transform: translate3d(160%, 0, 0) rotate(18deg) !important;
    opacity: 0;
    transition: transform 0.38s ease-out, opacity 0.38s ease-out !important;
}

.flashcard.swipe-left {
    transform: translate3d(-160%, 0, 0) rotate(-18deg) !important;
    opacity: 0;
    transition: transform 0.38s ease-out, opacity 0.38s ease-out !important;
}

/* ── Know / Need Practice buttons — always side by side ── */
.flash-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;   /* always 2 columns, no exceptions */
    gap: 12px;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

.flash-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 54px;
    padding: 12px 10px;
    border-radius: var(--radius);
    border: 2px solid transparent;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.flash-action-btn:active { transform: scale(0.97); }

.flash-action-btn--know {
    background: var(--success, #16a34a);
    border-color: var(--success, #16a34a);
    color: #fff;
}

.flash-action-btn--know:hover { background: #15803d; border-color: #15803d; }

.flash-action-btn--review {
    background: var(--surface);
    border-color: var(--danger, #dc2626);
    color: var(--danger, #dc2626);
}

.flash-action-btn--review:hover { background: #fef2f2; }

/* ── Shared flash utils ── */
.study-flash-actions {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

.study-flash-actions .secondary-button {
    width: 100%;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button#studyFlashShuffle {
    margin: 10px 0px;
}

/* ── Summary card ── */
.summary-card {
    max-width: 480px;
    margin: 0 auto;
    padding: 36px 28px;
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 2px);
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
    display: grid;
    gap: 16px;
}

.summary-icon   { font-size: 2.8rem; margin: 0; }
.summary-title  { margin: 0; font-size: clamp(1.4rem, 4vw, 1.9rem); }
.summary-subtitle { margin: 0; color: var(--muted); font-size: 0.95rem; }

.summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.summary-stat {
    display: grid;
    gap: 4px;
    padding: 14px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.summary-stat__num {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--brand-dark);
}

.summary-stat__lbl {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.summary-actions { display: grid; gap: 10px; }

.summary-actions .primary-button {
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ── Game links ── */
.study-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.study-actions .primary-button,
.study-actions .secondary-button {
    min-height: 48px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.study-empty-filter,
.study-empty-state { text-align: center; }

/* ── Flashcard mode: everything fits in one viewport ── */
body.flashcard-mode {
    overflow: hidden;
}

/* Reclaim the large bottom padding in flashcard mode */
body.flashcard-mode .app-shell {
    padding-bottom: 8px;
}

/* study-page becomes a 3-row grid that fills the viewport:
   row 1 = study-header, row 2 = toolbar (mode toggle), row 3 = flash panel */
body.flashcard-mode .study-page {
    height: calc(100dvh - 62px - 20px - 8px);
    gap: 0;
    grid-template-rows: auto auto 1fr;
}

body.flashcard-mode .study-header  { padding-bottom: 6px; }
body.flashcard-mode .study-toolbar { padding-bottom: 6px; }

/* The flash panel fills row 3 and lays itself out as a flex column */
body.flashcard-mode #studyFlashPanel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    overflow: hidden;
}

/* Progress section: compact, fixed size */
body.flashcard-mode .flash-progress-wrap {
    flex-shrink: 0;
    gap: 4px;
}

body.flashcard-mode .flash-progress-header {
    font-size: 0.78rem;
}

body.flashcard-mode .flash-stats {
    padding: 5px 12px;
    font-size: 0.8rem;
}

/* The card scene grows to fill all leftover space */
body.flashcard-mode .flashcard-scene {
    flex: 1 1 0;
    height: auto;        /* override the fixed 360px */
    min-height: 180px;
    max-height: none;
}

/* Action buttons: compact but still comfortably tappable */
body.flashcard-mode .flash-actions {
    flex-shrink: 0;
    gap: 8px;
}

body.flashcard-mode .flash-action-btn {
    min-height: 42px;
    padding: 8px 10px;
    font-size: 0.86rem;
}

/* Shuffle: smallest of all — just text + icon, no tall box */
body.flashcard-mode .study-flash-actions {
    flex-shrink: 0;
}

body.flashcard-mode .study-flash-actions .secondary-button {
    min-height: 34px;
    padding: 5px 14px;
    font-size: 0.8rem;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .study-list-grid {
        grid-template-columns: 1fr;
    }

    .study-actions {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .flashcard-scene {
        height: 300px;
    }

    /* flash-actions always side by side, even on mobile */
    .flash-actions {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .flash-action-btn {
        min-height: 46px;
        padding: 10px 8px;
        font-size: 0.82rem;
    }
}

/* Spelling shooter */
body.shooter-page {
    background: #0b1220;
    color: #e8eef7;
}

.shooter-page .app-shell {
    width: 100%;
    max-width: none;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

.shooter-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-height: calc(100dvh - 24px);
}

.shooter-shell > .shooter-topbar,
.shooter-shell > .shooter-hint,
.shooter-shell > .shooter-stats-bar {
    width: calc(100% * 8 / 12);
}

.shooter-stats-bar {
    display: none;
}

.shooter-keyboard {
    display: none;
}

.shooter-topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.shooter-topbar-copy {
    flex: 1;
    min-width: 0;
}

.shooter-topbar-copy strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shooter-topbar .eyebrow {
    margin-bottom: 0;
    color: #6b8cae;
}

.shooter-topbar .topbar-button {
    background: #152033;
    border-color: #2a3f5f;
    color: #e8eef7;
}

.shooter-hint {
    margin: 0;
    color: #8fa3be;
    font-size: 0.86rem;
    font-weight: 700;
    text-align: center;
}

.shooter-stage {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 420px;
    border: 1px solid #2a3f5f;
    border-radius: var(--radius);
    overflow: hidden;
    background: linear-gradient(180deg, #0f172a 0%, #0f1a2e 55%, #020617 100%);
    outline: none;
}

.shooter-stage:focus-visible {
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.45);
}

.shooter-canvas-host {
    width: 100%;
    height: 100%;
    min-height: 420px;
}

@media (min-width: 641px) {
    .shooter-stats-bar {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px 18px;
        width: calc(100% * 8 / 12);
        padding: 10px 14px;
        border: 1px solid #2a3f5f;
        border-radius: var(--radius);
        background: rgba(21, 32, 51, 0.92);
        color: #cbd5e1;
        font-size: 0.92rem;
        font-weight: 800;
    }

    .shooter-stats-bar span {
        white-space: nowrap;
    }

    #shooterStatScore {
        color: #ffffff;
    }

    .shooter-stage {
        width: calc(100% * 8 / 12);
        min-height: min(680px, calc(100dvh - 180px));
    }

    .shooter-canvas-host {
        min-height: min(680px, calc(100dvh - 180px));
    }

    .shooter-ship svg {
        width: 60px;
        height: 45px;
    }
}

.shooter-ship {
    position: fixed;
    z-index: 5;
    pointer-events: none;
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 4px 10px rgba(96, 165, 250, 0.45));
    transition: left 0.25s ease-out, top 0.25s ease-out;
}

.shooter-laser {
    position: fixed;
    height: 3px;
    margin-top: -1px;
    border-radius: 999px;
    background: linear-gradient(90deg, #60a5fa, #fef08a, #ffffff);
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.85);
    transform-origin: left center;
    transition: width 0.28s linear;
    pointer-events: none;
    z-index: 4;
}

.shooter-explosion {
    position: fixed;
    width: 120px;
    height: 120px;
    margin-left: -60px;
    margin-top: -60px;
    border-radius: 50%;
    background: radial-gradient(circle, #fef08a 0%, #f97316 35%, #ef4444 55%, transparent 72%);
    animation: shooter-boom 0.65s ease-out forwards;
    pointer-events: none;
    z-index: 6;
}

@keyframes shooter-boom {
    0% {
        opacity: 1;
        transform: scale(0.35);
    }

    100% {
        opacity: 0;
        transform: scale(1.35);
    }
}

.shooter-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(8, 12, 22, 0.72);
}

.shooter-overlay[hidden] {
    display: none;
}

.shooter-overlay-card {
    width: min(420px, 100%);
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
}

.shooter-overlay-card h2 {
    margin-bottom: 8px;
}

.shooter-overlay-score {
    margin: 12px 0;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--brand-dark);
}

.shooter-pause-btn {
    display: none;
}

#shooterPauseBtnDesktop {
    display: grid;
    place-items: center;
}

.shooter-mute-btn {
    display: none;
}

.shooter-mobile-toast {
    display: none;
}

.shooter-pause-menu {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(8, 12, 22, 0.72);
}

.shooter-pause-menu[hidden] {
    display: none;
}

.shooter-pause-card {
    width: min(360px, 100%);
    padding: 20px;
    border: 1px solid #2a3f5f;
    border-radius: var(--radius);
    background: #152033;
    color: #e8eef7;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

.shooter-pause-card h2 {
    margin-bottom: 4px;
}

.shooter-pause-unit {
    margin: 0 0 16px;
    color: #8fa3be;
    font-size: 0.9rem;
    font-weight: 700;
}

@media (max-width: 640px) {
    .unit-hub .mode-grid {
        grid-template-columns: 1fr;
    }

    html:has(body.shooter-page),
    body.shooter-page {
        overflow: hidden;
        height: 100dvh;
        overscroll-behavior: none;
    }

    .shooter-page .app-shell {
        padding: 0;
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
    }

    .shooter-shell {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100dvh;
        min-height: 100dvh;
        gap: 0;
        align-items: stretch;
        flex-direction: column;
    }

    .shooter-topbar,
    .shooter-hint,
    .shooter-stats-bar {
        display: none;
    }

    .shooter-pause-btn,
    .shooter-mute-btn {
        display: grid;
        place-items: center;
        position: fixed;
        top: calc(24px + var(--tg-safe-area-inset-top, env(safe-area-inset-top, 10px)));
        z-index: 12;
        width: 40px;
        height: 40px;
        padding: 0;
        border: 1px solid rgba(148, 163, 184, 0.28);
        border-radius: 10px;
        background: rgba(15, 23, 42, 0.55);
        color: #e8eef7;
        cursor: pointer;
    }

    #shooterPauseBtnDesktop {
        display: none;
    }

    .shooter-pause-btn {
        right: max(10px, env(safe-area-inset-right));
    }

    .shooter-mute-btn {
        left: max(10px, env(safe-area-inset-left));
    }

    .shooter-stage {
        position: relative;
        flex: 1;
        width: 100%;
        min-height: 0;
        border: none;
        border-radius: 0;
    }

    .shooter-stage:focus-visible {
        box-shadow: none;
    }

    .shooter-canvas-host {
        min-height: 0;
        height: 100%;
    }

    .shooter-keyboard {
        display: block;
        flex-shrink: 0;
        width: 100%;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        border-top: 1px solid #1e293b;
        background: linear-gradient(180deg, #0b1220 0%, #020617 100%);
        touch-action: manipulation;
        user-select: none;
    }

    .shooter-keyboard[hidden] {
        display: none;
    }

    .shooter-keyboard-row {
        display: flex;
        justify-content: center;
        gap: 4px;
        margin-bottom: 4px;
    }

    .shooter-keyboard-row:last-child {
        margin-bottom: 0;
    }

    .shooter-key {
        min-width: 0;
        flex: 1 1 0;
        max-width: 34px;
        height: 40px;
        padding: 0;
        border: 1px solid #334155;
        border-radius: 8px;
        background: linear-gradient(180deg, #1e293b 0%, #172033 100%);
        color: #e2e8f0;
        font-family: Consolas, monospace;
        font-size: 0.95rem;
        font-weight: 800;
        line-height: 1;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .shooter-key.is-pressed,
    .shooter-key:active {
        background: #334155;
        border-color: #60a5fa;
        color: #ffffff;
        transform: scale(0.96);
    }

    .shooter-mobile-toast {
        display: block;
        position: fixed;
        left: 50%;
        bottom: calc(148px + env(safe-area-inset-bottom));
        z-index: 11;
        width: min(92vw, 360px);
        margin: 0;
        padding: 8px 12px;
        border-radius: 999px;
        background: rgba(15, 23, 42, 0.72);
        color: #cbd5e1;
        font-size: 0.78rem;
        font-weight: 700;
        text-align: center;
        transform: translateX(-50%);
        pointer-events: none;
        opacity: 0;
        transition: opacity 180ms ease;
    }

    .shooter-mobile-toast.is-visible {
        opacity: 1;
    }

    .shooter-ship svg {
        width: 30px;
        height: 22px;
    }

    .shooter-overlay {
        padding-top: calc(36px + var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)));
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ═══════════════════════════════════════════
   Word Order game
   ═══════════════════════════════════════════ */
body.word-order-page {
    height: 100dvh;
    overflow: hidden;
    background: linear-gradient(180deg, #f0f9ff 0%, var(--bg) 40%);
}

body.word-order-page.modal-open {
    overflow: hidden;
    touch-action: none;
}

.word-order-page .app-shell {
    display: flex;
    width: 100%;
    max-width: none;
    height: 100dvh;
    min-height: 100dvh;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

.wo-shell {
    display: grid;
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas:
        "topbar"
        "status"
        "message"
        "main";
    gap: 8px;
    width: 100%;
    max-width: 920px;
    margin-inline: auto;
    min-height: 0;
    height: 100%;
}

.wo-topbar,
.wo-status {
    width: 100%;
}

.wo-topbar { 
    grid-area: topbar; 
}
.wo-status { 
    grid-area: status; 
}
.wo-message { 
    grid-area: message; 
}

#woLoading,
#woEmptyState,
#woDifficultyScreen,
#woGameScreen { 
    grid-area: main; 
    min-height: 0; 
}

.wo-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
}

.wo-hud .stat-mastery {
    min-width: 72px;
}

.wo-hud {
    visibility: hidden;
}

body.wo-playing .wo-hud {
    visibility: visible;
}

.wo-message:empty {
    display: none;
}

.wo-empty {
    display: grid;
    gap: 14px;
    place-items: center;
    padding: 28px 16px;
    text-align: center;
}

.wo-difficulty {
    display: grid;
    gap: 16px;
    align-content: start;
    overflow: auto;
    padding-bottom: 12px;
}

.wo-difficulty h2 {
    margin: 0;
    font-size: 1.35rem;
}

.wo-difficulty-copy {
    margin: 0;
    color: var(--muted);
    font-weight: 600;
}

.wo-difficulty-grid {
    display: grid;
    gap: 12px;
}

.wo-difficulty-card {
    display: grid;
    gap: 6px;
    padding: 18px;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: left;
    cursor: pointer;
    transition: transform 140ms ease, border-color 140ms ease;
}

.wo-difficulty-card:hover,
.wo-difficulty-card:focus-visible {
    transform: translateY(-2px);
    border-color: var(--brand);
    outline: none;
}

.wo-difficulty-card strong {
    font-size: 1.08rem;
}

.wo-difficulty-card span:last-child {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
}

.wo-difficulty-icon {
    font-size: 1.5rem;
}

.wo-difficulty-card--challenge {
    border-color: #fecaca;
    background: linear-gradient(180deg, #fff 0%, #fff7ed 100%);
}

.wo-game {
    display: grid;
    grid-template-rows: minmax(180px, 1fr) minmax(174px, auto);
    height: 100%;
    min-height: 0;
    gap: 8px;
}

.word-order-page .flashcard-scene {
    height: 100%;
    max-width: 100%;
    min-height: 0;
}

.word-order-page .flashcard {
    height: 100%;
}

.word-order-page .flashcard__face--front.wo-card-front {
    justify-content: center;
}

/* Word order: left swipe = next (green), right swipe = review (red) */
.word-order-page .swipe-hint--left {
    background: linear-gradient(135deg, rgba(22,163,74,0.18) 0%, rgba(22,163,74,0.05) 100%);
    color: #16a34a;
    border-color: rgba(22,163,74,0.3);
}

.word-order-page .swipe-hint--right {
    background: linear-gradient(135deg, rgba(220,38,38,0.18) 0%, rgba(220,38,38,0.05) 100%);
    color: #dc2626;
    border-color: rgba(220,38,38,0.3);
}

.word-order-page .wo-game {
    height: 100%;
    min-height: 0;
}

.word-order-page .flashcard-scene {
    height: 100%;
    max-width: 100%;
}

.word-order-page .flashcard {
    height: 100%;
}

.word-order-page .flashcard__face--front.wo-card-front {
    justify-content: center;
    gap: 12px;
    cursor: default;
}

.word-order-page .flashcard__face--back {
    gap: 12px;
}

.word-order-page .flashcard__face--back .flashcard__word {
    font-size: clamp(1.1rem, 4.5vw, 1.65rem);
    line-height: 1.35;
}

.wo-completed-uzbek {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.45;
    max-width: 100%;
}

.wo-next-btn {
    width: 100%;
    max-width: 280px;
    min-height: 48px;
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.word-order-page .flashcard.is-timed-out .flashcard__face--front {
    background: #fef2f2;
    border-color: #fecaca;
}

.word-order-page .flashcard.is-success-pulse {
    animation: woSuccessPulse 520ms ease;
}

.word-order-page .flashcard.is-challenge-flash {
    animation: woChallengeFlash 700ms ease;
}

.wo-sentence-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    line-height: 1.7;
    font-size: clamp(1rem, 3.8vw, 1.2rem);
    font-weight: 800;
}

.wo-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    min-height: 44px;
    padding: 6px 10px;
    border-radius: 12px;
    transition: background 0.5s ease, color 0.5s ease, min-width 0.55s ease, transform 0.55s ease;
}

.wo-slot.is-empty {
    background: #e2e8f0;
    color: #64748b;
    letter-spacing: 0.08em;
}

.wo-slot.is-filled {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.wo-translation-hint {
    margin: 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fef9c3;
    color: #854d0e;
    font-weight: 700;
}

.wo-word-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-content: start;
    padding: 4px 0;
    max-height: 174px;  /* 3 rows worth */
    overflow: visible;
    transition: gap 0.55s ease;
}


.wo-word-block {
    min-height: 52px;
    min-width: 56px;
    padding: 12px 16px;
    border: 2px solid var(--brand);
    border-radius: 14px;
    background: #ffffff;
    color: var(--brand-dark);
    font: inherit;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.15s ease, background 0.15s ease,
        opacity 0.3s ease, width 0.4s ease, min-width 0.4s ease,
        min-height 0.4s ease, padding 0.4s ease, margin 0.4s ease;
    -webkit-tap-highlight-color: transparent;
}

.wo-word-block.is-removing {
    opacity: 0;
    width: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border-width: 0 !important;
    pointer-events: none;
}

.wo-word-block:active {
    transform: scale(0.96);
}

.wo-word-block.is-wrong {
    animation: woShake 420ms ease;
    background: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
}

.wo-word-block.is-hinted {
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.45);
    border-color: #f59e0b;
    animation: woHintPulse 1.2s ease-in-out infinite;
}

.wo-word-flyer {
    position: fixed;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-weight: 800;
    pointer-events: none;
    transition: transform 620ms cubic-bezier(0.22, 1, 0.36, 1), width 380ms ease;
}

/* ── Hint dropdown ──────────────────────────────────────────────────── */
.wo-hint-wrap { position: relative; }

.wo-hint-trigger[aria-expanded="true"] {
    color: var(--accent);
    background: var(--accent-soft, #ede9fe);
    border-radius: var(--radius-sm);
}

.wo-hint-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 200;
    min-width: 248px;
    padding: 8px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 8px 32px rgba(0,0,0,0.13), 0 2px 8px rgba(0,0,0,0.07);
    display: grid;
    gap: 2px;
    animation: woHintOpen 0.17s cubic-bezier(0.4,0,0.2,1);
    transform-origin: top right;
}

@keyframes woHintOpen {
    from { opacity: 0; transform: scale(0.93) translateY(-6px); }
    to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

.wo-hint-dropdown__header {
    margin: 0;
    padding: 4px 10px 8px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.wo-hint-dropdown__divider {
    height: 1px;
    border: none;
    background: var(--line);
    margin: 4px 2px;
}

.wo-hint-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    padding: 8px 10px;
    border: none;
    border-radius: calc(var(--radius) - 4px);
    background: transparent;
    color: var(--ink);
    font: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
}
.wo-hint-row:hover  { background: var(--brand-soft); }
.wo-hint-row:active { background: var(--line); }

.wo-hint-row--danger .wo-hint-row__label { color: #dc2626; }
.wo-hint-row--danger .wo-hint-row__cost  { color: #dc2626; background: #fef2f2; border-color: #fecaca; }
.wo-hint-row--danger:hover { background: #fef2f2; }

/* Icon badge */
.wo-hint-badge {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}
.wo-hint-badge--next   { background: #fef9c3; color: #ca8a04; }
.wo-hint-badge--trans  { background: #dbeafe; color: #2563eb; }
.wo-hint-badge--reveal { background: #fce7f3; color: #db2777; }

/* Text block */
.wo-hint-row__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.wo-hint-row__label {
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.2;
}
.wo-hint-row__desc {
    font-size: 0.73rem;
    font-weight: 500;
    color: var(--muted);
    line-height: 1.2;
}

/* Cost pill */
.wo-hint-row__cost {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 800;
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
}

@keyframes woShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@keyframes woHintPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35); }
    50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.15); }
}

@keyframes woSuccessPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); box-shadow: 0 0 0 4px rgba(22, 106, 91, 0.18); }
}

@keyframes woChallengeFlash {
    0%, 100% { filter: brightness(1); }
    40% { filter: brightness(1.15); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.35); }
}

.lives-display.is-shake {
    animation: woShake 420ms ease;
}

#woTimerWrap.is-low {
    color: #d97706;
}

#woTimerWrap.is-critical {
    color: #dc2626;
    animation: woHintPulse 1s ease-in-out infinite;
}

.mode-card--wordorder .mode-tag {
    background: #ede9fe;
    color: #6d28d9;
}

.mode-card--wordorder {
    grid-column: 1 / -1;
}

@media (min-width: 720px) {
    .wo-difficulty-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .wo-shell {
        height: 100%;
        max-width: 920px;
    }

    .wo-game {
        grid-template-rows: 1fr auto;
    }
}

@media (max-width: 480px) {
    .wo-hint-btn {
        flex: 1 1 100%;
    }

    .wo-hud .stat-mastery {
        display: none;
    }
}


/* ==========================================================================
   TELEGRAM MINI APP CUSTOM OVERRIDES
   ========================================================================== */
html.telegram-mini-app,
body.telegram-mini-app {
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    -webkit-text-size-adjust: 100%;
    background: var(--bg) !important;
    color: var(--ink) !important;
}

/* Hide standard website navigation and footer for a clean native app shell */
body.telegram-mini-app .site-header,
body.telegram-mini-app .site-footer {
    display: none !important;
}

/* Configure the app shell as the main scrollable viewport container */
body.telegram-mini-app .app-shell {
    height: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: flex;
    flex-direction: column;
    padding: calc(36px + var(--tg-safe-area-inset-top, 0px)) 16px calc(16px + var(--tg-safe-area-inset-bottom, 0px)) !important;
    margin: 0 !important;
}

/* Word Order page overrides inside Telegram Mini App */
body.telegram-mini-app.word-order-page .app-shell {
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    padding: 8px 12px !important;
    padding-top: calc(8px + var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px))) !important;
    padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
}

/* Hide unit title during active gameplay to maximize vertical height on compact/landscape screens */
body.wo-playing .game-title {
    display: none;
}



/* Ensure centering and beautiful presentation of loading/auth screens */
.tg-auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    text-align: center;
    padding: 24px;
    background: radial-gradient(circle at top, var(--surface) 0%, var(--bg) 100%);
    color: var(--ink);
}

.tg-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px 24px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 440px;
    border: 1px solid var(--line);
    animation: tgCardFadeIn 0.4s ease-out;
}

@keyframes tgCardFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tg-logo {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 3px solid var(--brand);
}

.tg-title {
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--ink);
}

.tg-desc {
    color: var(--muted);
    font-size: 0.95rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

.tg-desc-uz {
    color: var(--muted);
    font-size: 0.88rem;
    margin-top: -12px;
    margin-bottom: 24px;
    font-style: italic;
}

.tg-btn-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.tg-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--line);
    border-top: 4px solid var(--brand);
    border-radius: 50%;
    animation: tgSpinner 1s linear infinite;
    margin: 20px auto;
}

@keyframes tgSpinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.tg-error-icon {
    font-size: 3.5rem;
    color: var(--danger);
    margin-bottom: 16px;
}