:root {
    --bg-color: var(--tg-theme-bg-color, #1c1c1e);
    --secondary-bg-color: var(--tg-theme-secondary-bg-color, #2c2c2e);
    --text-color: var(--tg-theme-text-color, #ffffff);
    --hint-color: var(--tg-theme-hint-color, #9e9e9e);
    --button-color: var(--tg-theme-button-color, #2481cc);
    --button-text-color: var(--tg-theme-button-text-color, #ffffff);
    
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --primary-glow: rgba(36, 129, 204, 0.5);
    --success-glow: rgba(52, 199, 89, 0.5);
    --danger-glow: rgba(255, 59, 48, 0.5);
    --info-glow: rgba(90, 200, 250, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    padding: 16px;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* Loader */
.loader-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-color);
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--glass-bg);
    border-top: 4px solid var(--button-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Header */
.header {
    margin-bottom: 24px;
    padding: 16px;
    border-radius: 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}

.header-small {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.icon-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px 12px;
    color: var(--text-color);
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}
.icon-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.profile {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2481cc, #5ac8fa);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    box-shadow: 0 0 15px var(--primary-glow);
}

#user-name {
    font-size: 20px;
    font-weight: 700;
}

.subtitle {
    font-size: 14px;
    color: var(--hint-color);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 16px;
    border-radius: 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    filter: blur(20px);
    z-index: -1;
}

.stat-card.primary::before { background: var(--primary-glow); }
.stat-card.success::before { background: var(--success-glow); }
.stat-card.danger::before { background: var(--danger-glow); }
.stat-card.info::before { background: var(--info-glow); }

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

.stat-value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--hint-color);
    font-weight: 500;
}

/* Progress Section */
.progress-section {
    padding: 20px;
    border-radius: 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    margin-bottom: 24px;
}

.progress-section h2 {
    font-size: 16px;
    margin-bottom: 16px;
}

.progress-bar-container, .lesson-progress-bar-container {
    width: 100%;
    height: 12px;
    background: var(--glass-bg);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.lesson-progress-bar-container {
    flex-grow: 1;
    margin-bottom: 0;
}

.progress-bar, .lesson-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #34c759, #5ac8fa);
    border-radius: 6px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(52, 199, 89, 0.5);
}

.progress-text {
    font-size: 14px;
    color: var(--hint-color);
    text-align: right;
}

/* Button */
.main-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    background-color: var(--button-color);
    color: var(--button-text-color);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--primary-glow);
    transition: transform 0.2s ease, filter 0.2s ease;
}

.main-btn:active {
    transform: translateY(2px);
    filter: brightness(0.9);
}

.main-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Lessons View */
.lessons-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lesson-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 16px;
    border-radius: 12px;
    color: var(--text-color);
    font-size: 16px;
    font-weight: 500;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s;
    cursor: pointer;
}

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

.lesson-btn.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Exercise View */
.exercise-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.exercise-card {
    padding: 24px;
    border-radius: 16px;
    text-align: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    margin-bottom: 32px;
}

.exercise-card h2 {
    font-size: 22px;
    font-weight: 600;
}

.answer-zone {
    min-height: 60px;
    border-bottom: 2px solid var(--glass-border);
    margin-bottom: 32px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 8px;
}

.word-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 32px;
    justify-content: center;
}

.word-btn {
    background: var(--secondary-bg-color);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    user-select: none;
    -webkit-user-select: none;
}

.word-btn:active {
    transform: scale(0.95);
    background: var(--glass-bg);
}

.word-btn.selected {
    opacity: 0;
    pointer-events: none;
}

.exercise-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 16px;
    background: var(--bg-color);
    border-top: 1px solid var(--glass-border);
}

/* Results colors */
.bg-success {
    background-color: rgba(52, 199, 89, 0.2) !important;
    border-color: #34c759 !important;
}

.bg-danger {
    background-color: rgba(255, 59, 48, 0.2) !important;
    border-color: #ff3b30 !important;
}

/* Menu Options */
.menu-options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

/* Theory Cards */
.theory-container {
    margin-top: 20px;
    min-height: 200px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.theory-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--primary-color);
}

.theory-text {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-color);
    white-space: pre-wrap;
}

.theory-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

/* Flashcards */
.flashcard-container {
    width: 100%;
    height: 200px;
    perspective: 1000px;
    margin-top: 20px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard-inner.flipped {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.flashcard-back {
    transform: rotateY(180deg);
    background: rgba(74, 144, 226, 0.15);
}

.flashcard-front h2, .flashcard-back h2 {
    font-size: 1.8rem;
    margin: 0;
}

.audio-btn {
    margin-top: 15px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.2s;
}

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

.hint-text {
    text-align: center;
    margin-top: 10px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Segmented Progress Bar */
.segmented-progress {
    display: flex;
    gap: 4px;
    width: 100%;
    height: auto;
    min-height: 8px;
    background: transparent;
    border-radius: 4px;
    flex-wrap: wrap;
}

.progress-segment {
    flex: 1 1 auto;
    height: 8px;
    min-width: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    transition: background 0.3s;
}

.progress-segment.current {
    background: #007aff;
}

.progress-segment.correct {
    background: #34c759;
}

.progress-segment.wrong {
    background: #ff3b30;
}

/* Word Options Grid */
.word-options-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
    width: 100%;
}

.word-option-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 16px;
    color: var(--text-color);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

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

.word-option-btn.correct {
    background: rgba(52, 199, 89, 0.2);
    border-color: #34c759;
    color: #34c759;
}

.word-option-btn.wrong {
    background: rgba(255, 59, 48, 0.2);
    border-color: #ff3b30;
    color: #ff3b30;
}

.theory-word-clickable {
    cursor: pointer;
    color: var(--primary-color);
    transition: all 0.2s ease;
    padding: 2px 4px;
    border-radius: 4px;
    background: rgba(74, 144, 226, 0.05);
}

.theory-word-clickable:hover, .theory-word-clickable:active {
    background: rgba(74, 144, 226, 0.15);
}

.manual-input-field {
    width: 90%;
    padding: 15px;
    font-size: 1.1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    outline: none;
    transition: all 0.3s ease;
}

.manual-input-field:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.3);
}
