:root {
    --primary-green: #1E5631; /* Deep Forest Green */
    --accent-gold: #F1C40F;   /* Bright Gold */
    --accent-red: #D32F2F;    /* "Live" Red for Alerts */
    
    /* UI Colors */
    --bg-color: #F8F9FA;      /* Light Grey Background */
    --card-bg: #FFFFFF;
    --text-main: #2C3E50;
    --text-muted: #7F8C8D;
    --border-color: #E0E0E0;

    /* Spacing */
    --sidebar-width: 280px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* =========================================
   LOGIN SCREEN
   ========================================= */
.screen {
    display: none;
    height: 100vh;
    width: 100vw;
}

.screen.active {
    display: flex;
}

#login-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-green) 0%, #143d22 100%);
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    text-align: center;
    border-top: 6px solid var(--accent-gold);
}

.login-card h2 {
    color: var(--primary-green);
    margin-bottom: 0.5rem;
    font-weight: 800;
    text-transform: uppercase;
}

.form-group {
    margin-bottom: 1.2rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--primary-green);
    outline: none;
}

#btn-login {
    width: 100%;
    padding: 14px;
    background-color: var(--primary-green);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 1rem;
    transition: background 0.2s;
}

#btn-login:hover {
    background-color: #143d22;
}

.error-msg {
    color: var(--accent-red);
    font-size: 0.9rem;
    margin-top: 1rem;
    min-height: 1.2em;
}

/* =========================================
   EXAM LAYOUT
   ========================================= */
#exam-screen {
    flex-direction: row;
}

/* --- SIDEBAR (Left) --- */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 20;
}

.timer-box {
    background: var(--primary-green);
    color: white;
    padding: 1.5rem 1rem;
    text-align: center;
}

.timer-box .label {
    font-size: 0.75rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#timer-display {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.nav-grid-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.nav-grid-container h4 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    border-bottom: 2px solid var(--accent-gold);
    display: inline-block;
    padding-bottom: 2px;
}

/* The Question Map Grid */
.grid-map {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5 buttons per row */
    gap: 8px;
}

.map-btn {
    aspect-ratio: 1;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.1s;
}

/* Map Button States */
.map-btn.current {
    border-color: var(--primary-green);
    background-color: #e8f5e9;
    color: var(--primary-green);
    font-weight: bold;
    box-shadow: 0 0 0 2px var(--primary-green);
}

.map-btn.answered {
    background-color: var(--primary-green);
    color: white;
    border-color: var(--primary-green);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
}

.primary-btn {
    background: var(--accent-red); /* Red for Submit to encourage caution */
    border: none;
    color: white;
    padding: 12px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
}

/* --- MAIN CONTENT (Right) --- */
.content-area {
    flex: 1;
    position: relative;
    padding: 2rem;
    overflow-y: auto;
    background-color: var(--bg-color);
}

/* Watermark */
#watermark-overlay {
    position: fixed;
    top: 0; left: var(--sidebar-width); right: 0; bottom: 0;
    z-index: 10;
    pointer-events: none;
    opacity: 0.04;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
}

.watermark-text {
    font-size: 24px;
    font-weight: bold;
    color: #000;
    transform: rotate(-30deg);
    margin: 50px;
    white-space: nowrap;
}

/* Question Styling */
.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 11;
}

.question-header h3 {
    font-size: 1.5rem;
    color: var(--primary-green);
}

.required-badge {
    color: var(--accent-red);
    font-weight: bold;
    font-size: 0.9rem;
    display: none;
}

/* Image Container */
.image-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 2rem;
    position: relative;
    z-index: 11;
    text-align: center;
    border: 1px solid var(--border-color);
    cursor: zoom-in;
}

.image-container img {
    max-width: 100%;
    max-height: 600px;
    height: auto;
}

.zoom-hint {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
    gap: 12px;
    max-width: 600px;
    margin: 0 auto 3rem auto;
    position: relative;
    z-index: 11;
}

.option-btn {
    aspect-ratio: 1;
    height: 55px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 50%; /* Circle buttons */
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn.compact {
    height: 40px;
    font-size: 0.9rem;
    border-radius: 8px;
}

.option-btn:hover {
    border-color: var(--accent-gold);
    background-color: #fff9c4;
}

.option-btn.selected {
    background-color: var(--primary-green);
    color: white;
    border-color: var(--primary-green);
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(30, 86, 49, 0.3);
}

/* Nav Controls */
.nav-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    position: relative;
    z-index: 11;
}

.nav-controls button {
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    font-size: 1rem;
}

#btn-prev {
    background: #e0e0e0;
    color: var(--text-main);
}

#btn-next {
    background: var(--accent-gold);
    color: var(--primary-green); /* Contrast logic */
}

/* =========================================
   UTILITIES
   ========================================= */
#loading-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: white;
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.spinner {
    width: 40px; height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Lightbox */
.lightbox-modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.9);
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.lightbox-content {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
}

.close-btn {
    position: absolute;
    top: 20px; right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

/* =========================================
   MOBILE RESPONSIVENESS
   ========================================= */
@media (max-width: 768px) {
    #exam-screen {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        order: 2;
        border-right: none;
        border-top: 1px solid var(--border-color);
        max-height: 250px;
    }

    .content-area {
        padding: 1rem;
        order: 1;
        flex: 1;
        overflow-y: auto;
    }

    .nav-grid-container {
        display: none;
        padding: 0.5rem;
    }

    .grid-map {
        grid-template-columns: repeat(8, 1fr);
    }

    #watermark-overlay {
        left: 0;
    }

    .image-container {
        padding: 5px;
    }
    
    .option-btn {
        width: 60px;
        height: 60px;
    }

    .option-btn.compact {
        height: 35px;
        font-size: 0.8rem;
    }
}