:root {
    /* KAU Color Palette */
    /* Primary Colors */
    --primary: #055934;       /* Primary 01 (Dark Green) */
    --primary-hover: #208D44; /* Primary 02 (Medium Green) */
    --primary-light: #86C242; /* Primary 03 (Light Green) */
    --primary-pale: #D3E6BE;  /* Primary 04 (Pale Green) */
    --bg: #F2F7ED;            /* Primary 05 (Off-White/Tint) */
    
    /* Secondary Colors */
    --secondary-dark: #0A353E; /* Secondary 01 (Dark Teal) */
    --success: #2BB673;        /* Secondary 02 (Vibrant Green) */
    --secondary-mint: #A7E0C5; /* Secondary 03 (Mint Green) */
    --secondary-light: #EEF8F5;/* Secondary 04 (Very Light Mint) */

    /* Neutral Colors */
    --text-main: #1D2921;     /* Neutral 01 (Black/Very Dark Gray) */
    --text-sub: #5C6660;      /* Neutral 02 (Medium Gray) */
    --text-light: #8D9991;    /* Neutral 03 (Light Gray) */
    --border: #C2CCC6;        /* Neutral 04 (Very Light Gray) */

    --warning: #f59e0b;
    --danger: #ef4444;
    --card: #ffffff;
    
    --example-bg: #EEF8F5;    /* Secondary 04 */
    --example-border: #A7E0C5;/* Secondary 03 */
    --example-text: #0A353E;  /* Secondary 01 */
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Alexandria', sans-serif;
    background-color: var(--bg);
    background-image: linear-gradient(135deg, var(--bg) 0%, var(--primary-pale) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    color: var(--text-main);
    padding: 20px;
    transition: all 0.3s ease;
}

/* Arabic Font Support - Alexandria covers both Arabic and Latin */
[lang="ar"] body {
    font-family: 'Alexandria', sans-serif;
}

.logo-container {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.kau-logo {
    height: 80px; /* Adjust as needed, ensuring minimum size */
    width: auto;
    display: block;
    margin: 0 auto;
}

.container {
    background: var(--card);
    width: 100%;
    max-width: 800px;
    border-radius: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    box-sizing: border-box;
}

/* Screens */
.screen {
    display: none; /* Hidden by default */
    animation: fadeIn 0.4s ease-out;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Language Selector */
.lang-container {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 0;
}

.landing-header {
    margin-bottom: 2rem;
}

.main-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0.2rem 0;
    line-height: 1.2;
}

@media (max-width: 480px) {
    .main-title {
        font-size: 1.2rem;
    }
}

.selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    width: 100%;
    margin-top: 2rem;
}

.selection-card {
    background: white;
    border: 2px solid var(--border);
    padding: 1.5rem;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.selection-card:hover {
    border-color: var(--primary);
    background: var(--secondary-light);
    transform: translateY(-2px);
}

.icon-large { font-size: 1.6rem; margin-bottom: 0.5rem; }
.card-title { font-weight: 700; font-size: 0.8rem; }

/* Header Styling */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header h1 {
    font-size: clamp(1.2rem, 3.2vw, 2rem); /* Reduced sizing */
    margin: 0 0 0.5rem 0;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.header p {
    color: var(--text-sub);
    font-size: clamp(0.75rem, 2vw, 1rem); /* Reduced sizing */
    margin: 0;
    line-height: 1.4;
}

/* Progress Bar */
.progress-container { margin-bottom: 2rem; }
.progress-track {
    background: var(--border);
    height: 10px;
    border-radius: 99px;
    position: relative;
    overflow: hidden;
    direction: ltr; 
}
[dir="rtl"] .progress-track { direction: rtl; }
.progress-fill {
    height: 100%;
    width: 5%;
    background: var(--primary);
    border-radius: 99px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.6s ease;
}
.progress-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-sub);
    letter-spacing: 0.05em;
}

/* Question Box & Headers */
.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.phase-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    border-radius: 99px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--primary-pale);
    color: var(--primary);
}

/* NEW TRL TARGET INDICATOR */
.trl-target-badge {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: 0.05em;
    background: var(--secondary-light);
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.question-text {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

.helper-text {
    font-size: 0.75rem;
    line-height: 1.6;
    color: var(--text-sub);
    margin-bottom: 1rem;
    background: var(--bg);
    padding: 1rem;
    border-radius: 8px;
}

/* Example Box */
.example-box {
    background-color: var(--example-bg);
    border: 1px solid var(--example-border);
    color: var(--example-text);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    font-size: 0.75rem;
    line-height: 1.5;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.example-content {
    display: flex;
    flex-direction: column;
}

.example-label {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    opacity: 0.8;
}

.example-icon { font-size: 1rem; flex-shrink: 0; margin-top: 2px; }

/* Buttons */
.actions {
    display: flex;
    gap: 0.75rem;
    flex-direction: column-reverse;
    width: 100%;
}
@media (min-width: 480px) { .actions { flex-direction: row; gap: 1rem; } }

.result-actions {
    margin-top: 1.5rem;
    flex-direction: column; /* Default to column for result actions */
    width: 100%;
}
@media (min-width: 480px) {
    .result-actions {
        flex-direction: row;
        margin-top: 2rem;
    }
}

.btn {
    flex: 1;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn:active { transform: scale(0.98); }
.btn-yes { background: var(--primary); color: white; }
.btn-yes:hover { background: var(--primary-hover); }
.btn-no { background: white; border: 2px solid var(--border); color: var(--text-sub); }
.btn-no:hover { border-color: var(--text-sub); color: var(--text-main); background: var(--secondary-light); }
.btn-secondary { background: var(--bg); color: var(--text-main); }
.btn-secondary:hover { background: var(--border); }

.btn-print { background: var(--text-main); color: white; }
.btn-print:hover { background: var(--text-sub); }

/* Result Box */
.result-box { text-align: center; display: none; }
.final-score { font-size: 3.2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.score-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.15em; color: var(--text-sub); font-weight: 700; }
.result-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; color: var(--text-main); }
.result-desc { font-size: 0.8rem; line-height: 1.6; color: var(--text-sub); margin-bottom: 2.5rem; }

/* Report History */
.report-history {
    margin-top: 2rem;
    text-align: start;
    border-top: 2px solid var(--border);
    padding-top: 1rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.history-question {
    font-size: 0.75rem;
    color: var(--text-main);
    flex: 1;
    padding-inline-end: 1rem;
}

.history-answer {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.ans-yes { color: var(--success); }
.ans-no { color: var(--danger); }

/* Mobile Optimizations */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 1rem;
        border-radius: 16px;
    }

    .header h1 {
        font-size: 1rem;
    }

    .header p {
        font-size: 0.7rem;
    }

    .main-title {
        font-size: 1rem;
    }

    .question-text {
        font-size: 0.75rem;
        line-height: 1.3;
        margin-bottom: 1rem;
    }

    .helper-text {
        font-size: 0.65rem;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .example-box {
        font-size: 0.65rem;
        padding: 0.75rem;
        margin-bottom: 1.5rem;
        gap: 8px;
    }

    .final-score {
        font-size: 2.2rem;
    }

    .result-title {
        font-size: 0.85rem;
        margin-bottom: 0.75rem;
    }

    .result-desc {
        font-size: 0.7rem;
        margin-bottom: 2rem;
    }

    .card-title {
        font-size: 0.7rem;
    }

    .icon-large {
        font-size: 1.2rem;
        margin-bottom: 0.25rem;
    }

    .kau-logo {
        height: 50px;
    }
    
    .btn {
        padding: 0.75rem;
        font-size: 0.7rem;
    }

    .selection-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.75rem;
    }

    .selection-card {
        padding: 1rem;
        border-radius: 12px;
    }
    
    .progress-container {
        margin-bottom: 1.5rem;
    }

    .question-header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }
    
    .phase-badge, .trl-target-badge {
        font-size: 0.6rem;
        padding: 4px 10px;
    }

    .logo-container {
        margin-bottom: 1.5rem;
        padding-bottom: 0.75rem;
    }
    
    .history-question, .history-answer {
        font-size: 0.65rem;
    }
    
    .history-item {
        padding: 0.5rem 0;
    }
}

/* Print Styles */
@media print {
    body { background: white; }
    .container { box-shadow: none; border: 1px solid #000; max-width: 100%; }
    .btn, .actions, .progress-container, .selection-grid { display: none !important; }
    #screen-app { display: block !important; }
    .result-box { display: block !important; }
    #questionBox { display: none !important; }
    .final-score { color: black !important; }
    .report-history { display: block !important; }
    .history-item { page-break-inside: avoid; }
}

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

/* Phase Colors mapped to Growth (Light to Dark Green) */
.phase-lab { color: var(--primary); background: var(--primary-pale); }
.phase-eng { color: var(--primary); background: var(--primary-light); }
.phase-ops { color: var(--bg); background: var(--primary); }