:root {
    --duo-green: #58cc02;
    --duo-green-dark: #46a302;
    --duo-blue: #1cb0f6;
    --duo-blue-dark: #1899d6;
    --duo-yellow: #ffc800;
    --duo-red: #ff4b4b;
    --duo-purple: #ce82ff;
    --bg-page: #ffffff;
    --bg-app: #ffffff;
    --text-main: #4b4b4b;
    --text-muted: #afafaf;
    --app-width: 430px;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: #f7f7f7;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    color: var(--text-main);
}

.app-container {
    width: 100%;
    max-width: var(--app-width);
    background-color: var(--bg-app);
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Page & Fragment System */
.page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
}

.fragment {
    background: #fff;
    border-radius: 24px;
    padding: 20px;
    border: 2px solid #e5e5e5;
    border-bottom: 5px solid #e5e5e5;
    margin-bottom: 20px;
    transition: all 0.2s ease;
}

.fragment-header {
    padding: 20px;
    border-bottom: 2px solid #e5e5e5;
}

.fragment-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 120px; /* Space for mobile nav and extra breathing room */
    -webkit-overflow-scrolling: touch;
}

.fragment-footer {
    padding: 20px;
    border-top: 2px solid #e5e5e5;
    background: #fff;
}

/* Duolingo Buttons */
.btn-duo {
    border: none;
    border-radius: 16px;
    padding: 14px 20px;
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    transition: all 0.1s;
    cursor: pointer;
    position: relative;
    border-bottom: 5px solid rgba(0,0,0,0.2);
    width: 100%;
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.btn-duo:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.btn-green { background: var(--duo-green); color: #fff; border-bottom-color: var(--duo-green-dark); }
.btn-blue { background: var(--duo-blue); color: #fff; border-bottom-color: var(--duo-blue-dark); }
.btn-gray { background: #e5e5e5; color: #afafaf; border-bottom-color: #ccc; }
.btn-red { background: var(--duo-red); color: #fff; border-bottom-color: #d32f2f; }

/* Subject Cards (Duolingo Style) */
.subject-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px 20px;
    padding: 40px 20px;
    justify-items: center;
}

.path-circle {
    width: 90px;
    height: 85px;
    background: var(--duo-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 8px solid var(--duo-green-dark);
    position: relative;
    text-decoration: none;
    color: #fff;
    font-size: 2rem;
    transition: all 0.1s;
}

.path-circle:active {
    transform: translateY(4px);
    border-bottom-width: 4px;
}

.path-circle.locked {
    background: #e5e5e5;
    border-bottom-color: #ccc;
    color: #afafaf;
}

.subject-name {
    position: absolute;
    bottom: -35px;
    background: #fff;
    border: 2px solid #e5e5e5;
    border-radius: 10px;
    padding: 2px 8px;
    color: #4b4b4b;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 3px 0 #e5e5e5;
    z-index: 10;
    left: 50%;
    transform: translateX(-50%);
}

/* Quiz UI */
.quiz-stats { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    white-space: nowrap;
}

.timer-display { 
    font-weight: 800; 
    color: #afafaf; 
    display: flex; 
    align-items: center; 
    gap: 4px; 
    font-size: 1rem; 
    min-width: 50px; 
}

.hearts-display { 
    font-weight: 800; 
    color: #ff4b4b; 
    display: flex; 
    align-items: center; 
    gap: 4px; 
    font-size: 1rem; 
}

.progress-container {
    height: 16px;
    background: #e5e5e5;
    border-radius: 20px;
    margin: 0 10px;
    flex-grow: 1;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--duo-green);
    border-radius: 20px;
    width: 0%;
    transition: width 0.4s cubic-bezier(0.65, 0, 0.35, 1);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 10%;
    right: 10%;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

.question-text {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 30px;
    padding: 0 20px;
}

.option-item {
    border: 2px solid #e5e5e5;
    border-bottom: 5px solid #e5e5e5;
    border-radius: 16px;
    padding: 15px 20px;
    margin: 0 20px 15px;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.1s;
}

.option-item:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.option-item.selected {
    background: #ddf4ff;
    border-color: #84d8ff;
    border-bottom-color: #1cb0f6;
    color: #1899d6;
}

/* Multi Select */
.option-item.multi-select {
    display: flex;
    align-items: center;
    gap: 15px;
}
.option-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid #e5e5e5;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: all 0.2s;
    flex-shrink: 0;
}
.option-item.selected .option-checkbox {
    background: #1cb0f6;
    border-color: #1cb0f6;
    color: #fff;
}


.option-marker {
    width: 35px;
    height: 35px;
    border: 2px solid #e5e5e5;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    color: #afafaf;
}

.selected .option-marker { border-color: #84d8ff; background: #fff; }

/* Bottom Check Bar */
.check-bar {
    padding: 20px;
    border-top: 2px solid #e5e5e5;
    background: #fff;
    margin-top: auto;
}

.feedback-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: var(--app-width);
    margin: 0 auto;
    padding: 30px 20px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    z-index: 1000;
}

.feedback-area.correct { background: #d7ffb8; color: #58a700; transform: translateY(0); }
.feedback-area.wrong { background: #ffdfe0; color: #ea2b2b; transform: translateY(0); }

/* Navigation */
.mobile-nav {
    background: #fff;
    border-top: 2px solid #e5e5e5;
    padding: 10px 0;
    display: flex;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: var(--app-width);
    margin: 0 auto;
    z-index: 900;
    height: 70px;
}

.nav-btn {
    text-align: center;
    color: #afafaf;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.7rem;
}

.nav-btn.active { color: var(--duo-green); }
.nav-btn i { display: block; font-size: 1.5rem; margin-bottom: 2px; }

/* Form Elements */
.form-control {
    border: 2px solid #e5e5e5 !important;
    border-bottom: 4px solid #e5e5e5 !important;
    border-radius: 16px !important;
    padding: 14px 20px !important;
    font-weight: 600 !important;
    transition: all 0.1s !important;
    background: #f7f7f7 !important;
    display: block;
    width: 100%;
}

.form-control:focus {
    border-color: #84d8ff !important;
    border-bottom-color: #1cb0f6 !important;
    background: #fff !important;
    box-shadow: none !important;
    outline: none !important;
}

.form-label {
    font-weight: 700;
    color: #4b4b4b;
    margin-bottom: 8px;
    font-size: 0.9rem;
    display: block;
}

/* Stat Cards */
.stat-card {
    background: #fff;
    border: 2px solid #e5e5e5;
    border-bottom: 4px solid #e5e5e5;
    border-radius: 16px;
    padding: 15px;
    text-align: center;
}

/* Duo Modals & Overlays */
.duo-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
    animation: fadeIn 0.3s;
}

.duo-modal {
    background: #fff;
    border: 2px solid #e5e5e5;
    border-radius: 24px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 15px 0 #e5e5e5;
    animation: slideUp 0.3s;
}

.duo-modal i.main-icon {
    font-size: 5rem;
    color: #ff4b4b;
    margin-bottom: 20px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Toast Notifications */
.duo-toast {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #4b4b4b;
    color: #fff;
    padding: 12px 24px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 0.9rem;
    z-index: 9999;
    display: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    animation: toastFade 0.3s;
}

@keyframes toastFade {
    from { transform: translate(-50%, -20px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

@media (max-width: 450px) {
    .app-container { max-width: 100%; }
    body { background-color: #fff; }
}
/* Advanced Quiz Components */
.option-item.has-image {
    flex-direction: column;
    padding: 10px;
    text-align: center;
}

.option-item.has-image img {
    max-height: 120px;
    width: auto;
    margin-right: 0 !important;
}

.matching-item {
    border: 2px solid #e5e5e5;
    border-bottom: 4px solid #e5e5e5;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.1s;
    background: #fff;
    user-select: none;
}

.matching-item.selected {
    background: #ddf4ff;
    border-color: #84d8ff;
    border-bottom-color: #1cb0f6;
    color: #1899d6;
}

.matching-item.matched {
    opacity: 0.5;
    background: #f7f7f7;
    border-color: #e5e5e5;
    border-bottom-width: 2px;
    cursor: default;
    pointer-events: none;
}

.sorting-list {
    padding: 10px;
    background: #f7f7f7;
    border-radius: 16px;
    min-height: 100px;
}

.sorting-item {
    background: #fff;
    border: 2px solid #e5e5e5;
    border-bottom: 4px solid #e5e5e5;
    border-radius: 12px;
    padding: 12px 15px;
    margin-bottom: 8px;
    cursor: grab;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.sorting-item:active { cursor: grabbing; }

.sorting-item i { color: #ccc; margin-right: 15px; }

.audio-player-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--duo-blue);
    color: #fff;
    border: none;
    border-bottom: 6px solid var(--duo-blue-dark);
    font-size: 2rem;
    transition: all 0.1s;
    margin-bottom: 15px;
}

.audio-player-btn:active {
    transform: translateY(3px);
    border-bottom-width: 3px;
}

.correct-flash {
    animation: correctFlash 0.5s;
}

.wrong-flash {
    animation: wrongFlash 0.5s;
}

@keyframes correctFlash {
    0% { background-color: #fff; }
    50% { background-color: #d7ffb8; border-color: #58a700; }
    100% { background-color: #fff; }
}

@keyframes wrongFlash {
    0% { background-color: #fff; }
    50% { background-color: #ffdfe0; border-color: #ea2b2b; }
    100% { background-color: #fff; }
}
