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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--tg-theme-bg-color, #ffffff);
    color: var(--tg-theme-text-color, #000000);
    min-height: 100vh;
    padding: 16px;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 480px;
    margin: 0 auto;
}

/* Screens */
.screen { display: none; }
.screen.active { display: block; }

/* Loading */
#screen-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    gap: 16px;
    text-align: center;
}
#screen-loading.active { display: flex; }

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(82, 136, 193, 0.3);
    border-top-color: var(--tg-theme-button-color, #5288c1);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Card */
.card {
    background: var(--tg-theme-secondary-bg-color, #f1f1f1);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
}

.tag {
    display: inline-block;
    background: var(--tg-theme-button-color, #5288c1);
    color: var(--tg-theme-button-text-color, #ffffff);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 14px;
}

h2 {
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 10px;
    line-height: 1.35;
}

.bridge-phrase {
    font-style: italic;
    color: var(--tg-theme-hint-color, #999);
    font-size: 13px;
    margin-bottom: 14px;
    line-height: 1.5;
}

.theory-content {
    font-size: 15px;
    line-height: 1.65;
    margin-bottom: 16px;
    white-space: pre-wrap;
}

.examples {
    border-left: 3px solid var(--tg-theme-button-color, #5288c1);
    padding-left: 14px;
    margin-bottom: 14px;
}

.example { margin-bottom: 10px; }
.example:last-child { margin-bottom: 0; }

.example-text {
    font-weight: 600;
    font-size: 14px;
    font-style: italic;
}

.example-note {
    font-size: 12px;
    color: var(--tg-theme-hint-color, #999);
    margin-top: 3px;
}

.pro-tip {
    background: rgba(82, 136, 193, 0.1);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    font-style: italic;
    line-height: 1.5;
}
.pro-tip:empty { display: none; }

/* Quiz */
.quiz-question {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.5;
    margin-top: 12px;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.option-btn {
    background: var(--tg-theme-bg-color, #fff);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 13px 16px;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    color: var(--tg-theme-text-color, #000);
    transition: border-color 0.15s;
    line-height: 1.4;
}
.option-btn:disabled { cursor: default; }
.option-btn.correct { background: #e8f5e9; border-color: #4caf50; color: #2e7d32; }
.option-btn.wrong { background: #ffebee; border-color: #ef5350; color: #c62828; }

.fill-blank { margin-top: 16px; }
.fill-blank input {
    width: 100%;
    padding: 13px 14px;
    border: 2px solid var(--tg-theme-hint-color, #ccc);
    border-radius: 12px;
    font-size: 16px;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color, #000);
    outline: none;
}
.fill-blank input:focus { border-color: var(--tg-theme-button-color, #5288c1); }
.fill-blank .btn-primary { margin-top: 12px; }

#word-bank, #answer-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
#answer-area {
    min-height: 48px;
    border-top: 1px solid rgba(0,0,0,0.08);
    padding-top: 12px;
}

/* Feedback */
.feedback {
    border-radius: 12px;
    padding: 13px 16px;
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.4;
}
.feedback.hidden { display: none; }
.feedback.correct { background: #e8f5e9; color: #2e7d32; }
.feedback.wrong { background: #ffebee; color: #c62828; }

/* Buttons */
.btn-primary {
    display: block;
    width: 100%;
    background: var(--tg-theme-button-color, #5288c1);
    color: var(--tg-theme-button-text-color, #ffffff);
    border: none;
    border-radius: 12px;
    padding: 15px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn-primary:active { opacity: 0.8; }

/* Complete / Done screens */
.complete-card { text-align: center; }
.trophy { font-size: 56px; margin-bottom: 14px; }

.progress-summary {
    margin-top: 14px;
    font-size: 15px;
    line-height: 2;
}

#btn-next { margin-top: 16px; }

#screen-done p {
    font-size: 15px;
    line-height: 1.6;
    color: var(--tg-theme-hint-color, #999);
    margin-top: 10px;
}

/* Learning Path */
.path-container {
    max-height: 60vh;
    overflow-y: auto;
    text-align: left;
}

.path-chapter {
    font-size: 16px;
    font-weight: bold;
    margin: 16px 0 8px;
    color: var(--tg-theme-button-color, #5288c1);
}

.path-atom {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    font-size: 14px;
}

.path-atom:last-child {
    border-bottom: none;
}

.status-icon {
    width: 24px;
    text-align: center;
    font-size: 16px;
}

.status-available { opacity: 0.3; }
.status-learning { color: #f57c00; }
.status-mastered { color: #388e3c; }
