/* Mobile-first styles for Telegram Mini App exercises — LATAM vibes */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #ffffff;
    --text: #1a1a1a;
    --hint: #7a7a7a;
    --link: #2481cc;
    --btn: #6C3CE1;
    --btn-text: #ffffff;
    --secondary-bg: #f5f0ff;
    --accent: #FF6B35;
    --accent2: #00C9A7;
    --success: #00C9A7;
    --error: #FF4757;
    --warning: #FFBE0B;
    --gradient-1: linear-gradient(135deg, #6C3CE1, #9B59B6);
    --gradient-2: linear-gradient(135deg, #FF6B35, #FF8C61);
    --gradient-3: linear-gradient(135deg, #00C9A7, #00E5BF);
    --radius: 14px;
    --gap: 12px;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---- Header & Progress ---- */

#header {
    margin-bottom: 20px;
}

#progress-bar {
    height: 8px;
    background: #e8e0f5;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

#progress-fill {
    height: 100%;
    width: 0;
    background: var(--gradient-1);
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#topic-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--btn);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Game Container ---- */

#game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.center-text {
    text-align: center;
    color: var(--hint);
    padding: 40px 20px;
}

/* ---- Instruction line ---- */

.instruction {
    font-size: 14px;
    font-weight: 500;
    color: var(--hint);
    text-align: center;
    margin-bottom: 16px;
}

/* ---- Question Card ---- */

.question-card {
    background: var(--secondary-bg);
    border-radius: var(--radius);
    padding: 22px 18px;
    margin-bottom: 16px;
    border-left: 4px solid var(--btn);
    animation: slideIn 0.3s ease;
}

.question-card .sentence {
    font-size: 18px;
    line-height: 1.7;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

/* ---- Fill-gap: dropdown ---- */

.gap-select {
    font-size: 16px;
    font-family: inherit;
    font-weight: 600;
    padding: 6px 12px;
    border: 2px solid var(--btn);
    border-radius: 10px;
    background: #fff;
    color: var(--btn);
    cursor: pointer;
    min-width: 110px;
    appearance: auto;
}

.gap-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(108, 60, 225, 0.2);
}

.gap-select.correct {
    border-color: var(--success);
    background: #e0fff6;
    color: #00815a;
}

.gap-select.wrong {
    border-color: var(--error);
    background: #ffe8ea;
    color: #c0392b;
}

/* ---- Unscramble: word chips ---- */

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

.word-chip {
    font-size: 16px;
    font-weight: 500;
    padding: 10px 16px;
    background: #fff;
    border: 2px solid var(--accent);
    border-radius: 24px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.15);
}

.word-chip:active {
    transform: scale(0.93);
}

.word-chip.placed {
    opacity: 0.25;
    pointer-events: none;
    box-shadow: none;
}

.answer-zone {
    min-height: 56px;
    background: #fff8f4;
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    border: 2px dashed var(--accent);
    align-items: center;
}

.answer-zone .word-chip {
    border-color: var(--hint);
    background: #fff;
    box-shadow: none;
}

.answer-zone .word-chip:active {
    transform: scale(0.93);
}

.answer-zone.correct {
    border-color: var(--success);
    background: #e0fff6;
    border-style: solid;
}

.answer-zone.wrong {
    border-color: var(--error);
    background: #ffe8ea;
    border-style: solid;
}

/* ---- Error Hunt: tappable words ---- */

.hunt-sentence {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
}

.hunt-word {
    font-size: 18px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    background: var(--secondary-bg);
    border: 2px solid transparent;
}

.hunt-word:active {
    transform: scale(0.93);
}

.hunt-word.selected {
    background: var(--btn);
    color: var(--btn-text);
    border-color: var(--btn);
    box-shadow: 0 3px 12px rgba(108, 60, 225, 0.3);
}

.hunt-word.correct-word {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.hunt-word.wrong-word {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
    animation: shake 0.4s ease;
}

/* ---- Matching: pairs ---- */

.match-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.match-item {
    font-size: 15px;
    font-weight: 500;
    padding: 14px 10px;
    background: var(--secondary-bg);
    border: 2px solid transparent;
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    word-break: break-word;
}

.match-item:active {
    transform: scale(0.96);
}

.match-item.selected {
    border-color: var(--btn);
    background: #fff;
    box-shadow: 0 3px 12px rgba(108, 60, 225, 0.2);
}

.match-item.matched {
    border-color: var(--success);
    background: #e0fff6;
    opacity: 0.7;
    pointer-events: none;
}

.match-item.wrong {
    border-color: var(--error);
    background: #ffe8ea;
    animation: shake 0.4s ease;
}

/* ---- Buttons ---- */

.btn {
    display: block;
    width: 100%;
    padding: 15px;
    font-size: 17px;
    font-family: inherit;
    font-weight: 700;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    margin-top: auto;
    transition: all 0.2s ease;
    letter-spacing: 0.3px;
}

.btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.btn-primary {
    background: var(--gradient-1);
    color: var(--btn-text);
    box-shadow: 0 4px 15px rgba(108, 60, 225, 0.3);
}

.btn:disabled {
    opacity: 0.35;
    cursor: default;
    box-shadow: none;
    transform: none;
}

/* ---- Feedback banner ---- */

.feedback {
    text-align: center;
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-weight: 700;
    font-size: 16px;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback.correct {
    background: #e0fff6;
    color: #00815a;
}

.feedback.wrong {
    background: #ffe8ea;
    color: #c0392b;
}

/* ---- Result Screen ---- */

#result-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 16px;
    padding: 40px 20px;
}

#result-emoji {
    font-size: 72px;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#result-score {
    font-size: 36px;
    font-weight: 800;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#result-message {
    font-size: 18px;
    color: var(--hint);
    font-weight: 500;
}

#result-close {
    display: block;
    width: 100%;
    max-width: 300px;
    padding: 15px;
    font-size: 17px;
    font-family: inherit;
    font-weight: 700;
    border: none;
    border-radius: var(--radius);
    background: var(--gradient-1);
    color: var(--btn-text);
    cursor: pointer;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(108, 60, 225, 0.3);
    letter-spacing: 0.3px;
}

#result-close:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* ---- True/False: speed review ---- */

.tf-card {
    text-align: center;
    padding: 30px 18px;
}

.tf-sentence {
    font-size: 20px;
    line-height: 1.6;
    font-weight: 500;
}

.tf-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.tf-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 12px;
    font-size: 16px;
    font-family: inherit;
    font-weight: 700;
    border: 3px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.tf-icon {
    font-size: 28px;
}

.tf-correct {
    background: #e0fff6;
    color: #00815a;
    border-color: var(--success);
}

.tf-wrong {
    background: #ffe8ea;
    color: #c0392b;
    border-color: var(--error);
}

.tf-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.tf-btn.chosen-right {
    box-shadow: 0 0 0 4px rgba(0, 201, 167, 0.4);
    transform: scale(1.03);
}

.tf-btn.chosen-wrong {
    box-shadow: 0 0 0 4px rgba(255, 71, 87, 0.4);
    animation: shake 0.4s ease;
}

/* ---- Dialogue: chat bubbles ---- */

.dialogue-chat {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--secondary-bg);
    border-radius: var(--radius);
}

.dialogue-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    animation: slideIn 0.3s ease;
}

.bubble-left {
    align-self: flex-start;
    background: #fff;
    border-bottom-left-radius: 4px;
    border: 1px solid #e0d6f2;
}

.bubble-right {
    align-self: flex-end;
    background: var(--btn);
    color: var(--btn-text);
    border-bottom-right-radius: 4px;
}

.bubble-speaker {
    display: block;
    font-size: 11px;
    font-weight: 700;
    opacity: 0.6;
    margin-bottom: 2px;
}

.bubble-text {
    font-size: 15px;
    line-height: 1.4;
}

.bubble-blank {
    border: 2px dashed var(--accent);
    background: #fff8f4;
}

.bubble-blank .bubble-text {
    color: var(--accent);
    font-weight: 700;
}

.bubble-correct {
    border-color: var(--success);
    background: #e0fff6;
}

.bubble-correct .bubble-text {
    color: #00815a;
}

.bubble-wrong {
    border-color: var(--error);
    background: #ffe8ea;
}

.bubble-wrong .bubble-text {
    color: #c0392b;
}

.dialogue-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.dialogue-option {
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    font-family: inherit;
    font-weight: 500;
    background: #fff;
    border: 2px solid #e0d6f2;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

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

.dialogue-option:disabled {
    cursor: default;
}

.dialogue-option.option-correct {
    border-color: var(--success);
    background: #e0fff6;
    color: #00815a;
    font-weight: 700;
}

.dialogue-option.option-wrong {
    border-color: var(--error);
    background: #ffe8ea;
    color: #c0392b;
}

/* ---- Utility ---- */

.hidden {
    display: none !important;
}

/* ---- Animations ---- */

@keyframes slideIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes popIn {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}

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

.fade-in {
    animation: fadeIn 0.5s ease;
}
