.study-theme-switcher {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1040;
    display: flex;
    align-items: center;
    gap: 10px;
}

.study-theme-toggle {
    border: 1px solid rgba(99, 102, 241, 0.18);
    background: #fff;
    color: #1e293b;
    border-radius: 999px;
    padding: 11px 16px;
    font-weight: 800;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.study-theme-menu {
    width: 300px;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.16);
    position: absolute !important;
    right: 0 !important;
    bottom: calc(100% + 10px) !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    display: none;
}

.study-theme-menu.show {
    display: block;
}

.study-font-control {
    display: grid;
    grid-template-columns: 52px 1fr 52px;
    gap: 8px;
    align-items: center;
    padding: 8px;
    margin-bottom: 6px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.study-theme-switcher > .study-font-control {
    grid-template-columns: 42px 52px 42px;
    margin-bottom: 0;
    padding: 6px;
    background: #fff;
    border-color: rgba(99, 102, 241, 0.18);
    border-radius: 999px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.study-theme-switcher > .study-font-control .study-font-btn {
    border-radius: 999px;
    padding: 8px 0;
    box-shadow: none;
}

.study-theme-menu .study-font-control {
    display: none !important;
}

.study-font-btn {
    border: 0;
    border-radius: 12px;
    background: #fff;
    color: #4f46e5;
    font-weight: 900;
    padding: 9px 0;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

#study-font-scale-label {
    text-align: center;
    color: #1e293b;
    font-weight: 900;
    font-size: 0.88rem;
}

.study-theme-option {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 10px;
    align-items: center;
    border-radius: 14px;
    padding: 10px;
    white-space: normal;
}

.study-theme-option i {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef2ff;
    color: #4f46e5;
}

.study-theme-option small {
    display: block;
    color: #64748b;
    line-height: 1.35;
}

.study-theme-option.active,
.study-theme-option:active {
    background: #eef2ff;
    color: #312e81;
}

.activity-progress {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 20px;
    padding: 14px 16px 16px;
    margin-bottom: 24px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.05);
}

.activity-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
}

.activity-progress-title {
    font-size: 0.78rem;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
}

.activity-progress-copy {
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 700;
}

.activity-progress-percent {
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 900;
}

.activity-progress .progress-container {
    height: 10px !important;
    background: #e2e8f0 !important;
    border-radius: 999px !important;
    margin-bottom: 0 !important;
    overflow: hidden;
}

.activity-progress .progress-bar-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 999px;
    transition: width 0.6s ease;
}

body.study-theme-focus {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%) !important;
}

body.study-theme-focus .word-card {
    background: rgba(255, 255, 255, 0.94) !important;
}

body.study-theme-dark {
    --primary-color: #38bdf8;
    --primary-gradient: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    --text-main: #e5e7eb;
    --text-muted: #94a3b8;
    --card-bg: #111827;
    background: #020617 !important;
    color: #e5e7eb !important;
}

body.study-theme-dark .navbar-custom {
    background: rgba(15, 23, 42, 0.92) !important;
    border-color: rgba(148, 163, 184, 0.18) !important;
}

body.study-theme-dark .navbar-brand span,
body.study-theme-dark .btn-action,
body.study-theme-dark .text-dark {
    color: #e5e7eb !important;
}

body.study-theme-dark .word-card,
body.study-theme-dark .stat-card,
body.study-theme-dark .meaning-box,
body.study-theme-dark .transcript-box,
body.study-theme-dark .hint-box,
body.study-theme-dark .activity-progress {
    background: #111827 !important;
    border-color: rgba(148, 163, 184, 0.22) !important;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35) !important;
}

body.study-theme-dark .activity-progress-title,
body.study-theme-dark .activity-progress-copy {
    color: #94a3b8;
}

body.study-theme-dark .btn-answer,
body.study-theme-dark .spelling-input,
body.study-theme-dark .word-mark-btn {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #e5e7eb !important;
}

body.study-theme-dark .study-theme-toggle,
body.study-theme-dark .study-theme-menu {
    background: #0f172a;
    border-color: #334155;
    color: #e5e7eb;
}

body.study-theme-dark .study-font-control {
    background: #111827;
    border-color: #334155;
}

body.study-theme-dark .study-font-btn {
    background: #0f172a;
    color: #38bdf8;
}

body.study-theme-dark #study-font-scale-label {
    color: #e5e7eb;
}

body.study-theme-compact .game-container {
    max-width: 760px !important;
    padding: 12px !important;
}

body.study-theme-compact .top-stats {
    margin-bottom: 1rem !important;
}

body.study-theme-compact .activity-progress {
    margin-bottom: 14px !important;
    padding: 10px 12px 12px !important;
    border-radius: 16px !important;
}

body.study-theme-compact .word-card {
    border-radius: 18px !important;
    padding: 28px !important;
}

body.study-theme-compact .word-en {
    font-size: 2.4rem !important;
    margin-bottom: 20px !important;
}

body.study-theme-compact .btn-answer,
body.study-theme-compact .btn-confirm,
body.study-theme-compact .btn-next {
    border-radius: 14px !important;
    padding: 13px 16px !important;
    font-size: 1rem !important;
}

body.study-theme-compact .word-mark-tools {
    margin-top: 12px !important;
}

body.study-theme-calm {
    --primary-color: #0f766e;
    --primary-gradient: linear-gradient(135deg, #14b8a6 0%, #22c55e 100%);
    background: linear-gradient(180deg, #f0fdfa 0%, #f7fee7 100%) !important;
}

body.study-theme-calm .word-card,
body.study-theme-calm .stat-card,
body.study-theme-calm .activity-progress {
    background: rgba(255, 255, 255, 0.9) !important;
    border-color: rgba(20, 184, 166, 0.18) !important;
}

body.study-theme-calm .btn-answer,
body.study-theme-calm .spelling-input,
body.study-theme-calm .meaning-box,
body.study-theme-calm .transcript-box,
body.study-theme-calm .hint-box {
    background: #f8fffc !important;
}

body[class*="study-theme-"] .word-en {
    font-size: calc(3.2rem * var(--study-font-scale, 1)) !important;
}

body[class*="study-theme-"] .word-tr,
body[class*="study-theme-"] .meaning-tr,
body[class*="study-theme-"] .meaning-reveal,
body[class*="study-theme-"] .word-reveal,
body[class*="study-theme-"] .transcript-box,
body[class*="study-theme-"] .spelling-input {
    font-size: calc(1.45rem * var(--study-font-scale, 1)) !important;
}

body[class*="study-theme-"] .btn-answer {
    font-size: calc(1.08rem * var(--study-font-scale, 1)) !important;
}

body[class*="study-theme-"] .btn-answer.correct {
    background: var(--success-color, #22c55e) !important;
    border-color: var(--success-color, #22c55e) !important;
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
}

body[class*="study-theme-"] .btn-answer.wrong {
    background: var(--error-color, #ef4444) !important;
    border-color: var(--error-color, #ef4444) !important;
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
}

body[class*="study-theme-"] .btn-answer.correct *,
body[class*="study-theme-"] .btn-answer.wrong * {
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
}

body[class*="study-theme-"] .btn-answer.option-muted {
    display: none !important;
}

body[class*="study-theme-"] .btn-answer.option-selected {
    display: flex !important;
}

body[class*="study-theme-"] .word-mark-btn,
body[class*="study-theme-"] .btn-confirm,
body[class*="study-theme-"] .btn-next,
body[class*="study-theme-"] .btn-link {
    font-size: calc(.95rem * var(--study-font-scale, 1)) !important;
}

@media (max-width: 576px) {
    body[class*="study-theme-"] .word-en {
        font-size: calc(2.45rem * var(--study-font-scale, 1)) !important;
    }

    body[class*="study-theme-"] .word-card {
        padding: 28px 20px !important;
    }

    body[class*="study-theme-"] .btn-answer,
    body[class*="study-theme-"] .spelling-input {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
}

@media (max-width: 576px) {
    .study-theme-switcher {
        right: 12px;
        bottom: 12px;
    }

    .study-theme-toggle span {
        display: none;
    }

    .study-theme-menu {
        width: min(300px, calc(100vw - 24px));
    }
}
