:root {
    --green: #58cc02;
    --green-dark: #4aa302;
    --blue: #1cb0f6;
    --blue-dark: #1899d6;
    --red: #ff4b4b;
    --red-dark: #cc3a3a;
    --orange: #ff9800;
    --orange-dark: #e68a00;
    --purple: #9069fe;
    --purple-dark: #7b58e6;
    --light-grey: #e5e5e5;
    --mid-grey: #9da3b1;
    --dark-grey: #2a2d3a;
    --dark-bg: #1e2029;
    --white: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--dark-bg);
    color: var(--light-grey);
    margin: 0;
    padding: 15px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    box-sizing: border-box;
}

.container {
    background: var(--dark-grey);
    border-radius: 15px;
    padding: 25px;
    border: 2px solid #3a3d4a;
    margin-bottom: 10px;
}

.header {
    text-align: center;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    color: var(--white);
    margin: 0;
    font-size: 1.8rem;
    flex-grow: 1;
}

.btn {
    padding: 12px 20px;
    color: var(--white);
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.logout-btn {
    background-color: var(--red);
    padding: 8px 12px;
    font-size: 0.9rem;
    border-bottom: 2px solid var(--red-dark);
}

.ai-connect-btn {
    background-color: var(--orange);
    border-bottom: 3px solid var(--orange-dark);
    padding: 8px 12px;
    font-size: 0.9rem;
}

#sync-btn, #start-vocab-btn, #grammar-btn {
    background-color: var(--purple);
    border-bottom: 3px solid var(--purple-dark);
    width: 100%;
    margin: 10px 0;
}

.lesson-btn {
    background-color: var(--orange);
    border-bottom: 3px solid var(--orange-dark);
    width: 100%;
    margin-top: 10px;
}

.admin-toggle-btn {
    background-color: transparent;
    border: 2px dashed var(--mid-grey);
    color: var(--mid-grey);
    width: 100%;
    margin-top: 20px;
    font-size: 0.9rem;
}

.stats-container {
    background: var(--dark-bg);
    padding: 15px;
    border-radius: 10px;
    margin: 20px 0;
}

.stats-container h3 {
    margin: 0 0 10px 0;
    color: var(--mid-grey);
}

.xp-text {
    font-size: 1.5rem;
    margin: 5px 0;
    color: var(--orange);
    font-weight: bold;
}

#loading-message {
    text-align: center;
    font-weight: bold;
    color: var(--blue);
    display: none;
    margin-top: 15px;
}

.exercise-container, #round-summary-screen, #error-container, #menu-screen, #grammar-container, #auth-screen {
    display: none;
}

.prompt-label {
    font-size: 1.1rem;
    color: var(--mid-grey);
    margin-bottom: 7px;
}

.prompt-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 10px;
}

.prompt-text {
    font-size: 1.2rem;
    font-weight: bold;
    line-height: 1.5;
}

.center-text { text-align: center; margin-bottom: 20px; }

.prompt-text .clickable-word {
    cursor: pointer;
    transition: color 0.2s;
}

.prompt-text .clickable-word:hover {
    color: var(--blue);
}

.learning-word {
    color: var(--purple);
    text-decoration: underline;
    text-decoration-style: wavy;
    text-underline-offset: 3px;
}

.replay-btn {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--blue);
    padding: 5px;
}

.large-replay { font-size: 2.5rem; }

.answer-area {
    min-height: 120px;
    border-bottom: 2px solid var(--mid-grey);
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding-bottom: 10px;
    align-content: flex-start;
}

.word-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: center;
    padding: 20px 0;
}

.word-chip {
    padding: 10px 18px;
    background-color: var(--dark-bg);
    border: 2px solid #4b4f5f;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1rem;
}

.word-chip.invisible { visibility: hidden; cursor: default; }
.word-chip.selected { border-color: var(--blue); background-color: #2a3a4a; }

.exercise-textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 150px;
    padding: 12px;
    font-size: 1.1rem;
    border-radius: 10px;
    background-color: var(--dark-bg);
    color: var(--white);
    resize: vertical;
    border: 2px solid #4b4f5f;
}

.mt-15 { margin-top: 15px; }

.listen-options {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.listen-btn {
    width: 120px;
    height: 90px;
    font-size: 2.5rem;
    border-radius: 15px;
    background-color: var(--dark-bg);
    color: var(--blue);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #4b4f5f;
    flex-shrink: 0;
}

.listen-btn.selected { border-color: var(--blue); background-color: #2a3a4a; }

.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background-color: var(--dark-bg);
    border-top: 2px solid #3a3d4a;
    z-index: 10;
}

#check-btn, #next-btn, #continue-btn {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    box-sizing: border-box;
}

#check-btn { background-color: var(--green); border-bottom: 4px solid var(--green-dark); }
#next-btn, #continue-btn { background-color: var(--blue); border-bottom: 4px solid var(--blue-dark); }

.feedback {
    padding: 20px;
    border-radius: 10px;
    font-weight: bold;
    color: white;
    margin-bottom: 15px;
}

.feedback p { margin: 8px 0 0 0; font-weight: normal; opacity: 0.9; }
.feedback.correct { background-color: var(--green); }
.feedback.incorrect { background-color: var(--red); }

.gamification-header {
    display: none;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.progress-bar-container {
    flex-grow: 1;
    height: 16px;
    background-color: #4b4f5f;
    border-radius: 8px;
    overflow: hidden;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--green);
    transition: width 0.3s ease;
}

#xp-display { font-weight: bold; font-size: 1.1rem; color: var(--orange); }
.voice-flag { font-size: 1.5rem; margin-left: 10px; }
.target-word { font-weight: bold; color: var(--white); }

#translation-tooltip {
    position: fixed;
    display: none;
    background-color: var(--dark-bg);
    color: var(--light-grey);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--mid-grey);
    font-size: 0.9rem;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s, transform 0.2s;
}

#translation-tooltip.visible { opacity: 1; transform: translateY(0); }

/* Auth Forms */
.auth-form-container { max-width: 400px; margin: auto; text-align: center; }
.auth-form-container h1 { margin-bottom: 10px; }
.auth-form-container p { color: var(--mid-grey); margin-bottom: 25px; }
.auth-form-container input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    font-size: 1rem;
    border-radius: 8px;
    background-color: var(--dark-bg);
    color: var(--white);
    border: 2px solid #4b4f5f;
    margin-bottom: 15px;
}
.auth-form-container .btn { width: 100%; background-color: var(--blue); border-bottom: 3px solid var(--blue-dark); }
.auth-toggle-link { color: var(--blue); cursor: pointer; text-decoration: underline; }
#auth-status, #signup-status { margin-top: 15px; color: var(--red); min-height: 20px; font-weight: bold; }
#signup-form { display: none; }

/* Match Columns Styles */
.match-columns { display: flex; justify-content: space-between; gap: 15px; margin-top: 20px; }
.match-col { display: flex; flex-direction: column; gap: 10px; width: 48%; }
.match-btn { 
    padding: 15px 10px; 
    background: var(--dark-bg); 
    border: 2px solid #4b4f5f; 
    border-radius: 10px; 
    cursor: pointer; 
    color: white; 
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    transition: all 0.2s;
}
.match-btn.selected { border-color: var(--blue); background-color: #2a3a4a; }
.match-btn.matched { border-color: var(--green); background-color: rgba(88, 204, 2, 0.1); opacity: 0.5; cursor: default; }
.match-btn.error { border-color: var(--red); background-color: rgba(255, 75, 75, 0.1); animation: shake 0.4s; }

.fill-blank-input {
    width: 100%;
    padding: 15px;
    font-size: 1.5rem;
    text-align: center;
    border-radius: 10px;
    border: 2px solid #4b4f5f;
    background-color: var(--dark-bg);
    color: var(--white);
    margin-top: 20px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
    font-weight: bold;
}
.fill-blank-input:focus {
    border-color: var(--blue);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}