:root {
    /* Palette */
    --hdq-bg-gradient: linear-gradient(135deg, #f3f6fc 0%, #eef2f6 100%);
    --hdq-primary: #2563eb; --hdq-success: #10b981; --hdq-danger: #ef4444; --hdq-warning: #f59e0b;       
    --hdq-text: #1e293b; --hdq-text-soft: #64748b; --hdq-border: #e2e8f0;
    --hdq-glass: rgba(255, 255, 255, 0.95); --hdq-blur: blur(12px);
    
    /* DYNAMIC FONT SIZE VARIABLE */
    --hdq-font-size: 17px; 
    
    --hdq-card-max-width: 1000px; --hdq-card-pad: 30px; --hdq-radius: 20px;
}

/* 1. LAYOUT & RESET */
body.hdq-terminal-active { 
    overflow: hidden !important; position: fixed !important; width: 100%; height: 100dvh; margin: 0 !important; 
    overscroll-behavior: none; 
}
body.hdq-terminal-active :where(.site-header, .site-footer, #wpadminbar, .hdq_timer, .hdq_quiz_start, .hdq_share, .hdq_results_title, .elementor-location-header, .elementor-location-footer) { 
    display: none !important; 
}

#hdq_terminal_root { 
    position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh; 
    z-index: 2147483647; display: flex; flex-direction: column; 
    background: var(--hdq-bg-gradient); 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    box-sizing: border-box;
}
#hdq_terminal_root * { box-sizing: border-box; }

/* PROGRESS BAR */
#fc_progress_container { position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: rgba(0,0,0,0.05); z-index: 70; pointer-events: none; }
#fc_progress_fill { height: 100%; background: var(--hdq-success); width: 0%; transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 0 10px rgba(16, 185, 129, 0.5); }

/* HEADER */
#hdq_terminal_header { 
    background: var(--hdq-glass); backdrop-filter: var(--hdq-blur); -webkit-backdrop-filter: var(--hdq-blur);
    height: 60px; padding: 0 15px; 
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.03); z-index: 60; flex-shrink: 0;
}
.hdq_head_left { justify-self: start; display: flex; gap: 10px; align-items: center; }
#hdq_home_link { 
    display: flex; align-items: center; justify-content: center; 
    width: 38px; height: 38px; background: #fff; border-radius: 10px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.08); overflow: hidden;
}
.hdq_site_logo { width: 100%; height: 100%; object-fit: cover; }

.hdq_tool_btn {
    background: transparent; border: none; font-size: 1.4rem; cursor: pointer; padding: 5px; line-height: 1; transition: 0.2s;
    color: var(--hdq-text); display: flex; align-items: center; justify-content: center;
}
.hdq_tool_btn:hover { transform: scale(1.1); }

/* Font Resize Buttons */
.fc_font_btn {
    background: transparent; border: 1px solid var(--hdq-border); border-radius: 4px;
    font-size: 12px; font-weight: bold; color: var(--hdq-text); cursor: pointer;
    padding: 2px 6px; margin-left: 2px;
}
.fc_font_btn:hover { background: var(--hdq-border); }

.hdq_head_center { justify-self: center; }
#hdq_timer_display { 
    font-family: 'Courier New', monospace; font-size: 1.1rem; font-weight: 700; 
    color: var(--hdq-primary); background: rgba(255,255,255,0.8); 
    padding: 3px 12px; border-radius: 50px; border: 1px solid rgba(37, 99, 235, 0.15);
    min-width: 100px; text-align: center;
}
.hdq_head_right { justify-self: end; display: flex; justify-content: flex-end; }
.hdq_header_btn { 
    padding: 6px 16px; border-radius: 50px; border:none; cursor:pointer; 
    font-weight:700; color:#fff; font-size: 0.8rem; text-transform:uppercase; 
    background: var(--hdq-success); box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

/* GRID BAR */
#hdq_grid_bar { 
    background: rgba(255,255,255,0.7); backdrop-filter: blur(5px);
    height: 44px; display: flex; align-items: center; 
    padding: 0 8px; gap: 6px; border-bottom: 1px solid rgba(0,0,0,0.05); flex-shrink: 0;
}
.grid_scroll_btn { 
    -webkit-appearance: none; appearance: none; padding: 0; margin: 0;
    width: 32px; height: 32px; border-radius: 8px; 
    background: rgba(29, 78, 216, 0.1); border: 1px solid rgba(29, 78, 216, 0.25); 
    color: #1d4ed8; display: flex; align-items: center; justify-content: center; 
    cursor: pointer; transition: all 0.2s ease; flex-shrink: 0;
}
.grid_scroll_btn:hover { background: #1d4ed8; color: #ffffff; border-color: #1d4ed8; }
.grid_scroll_btn svg { width: 18px; height: 18px; stroke-width: 3; }
#hdq_mini_grid_wrapper { flex-grow: 1; overflow: hidden; height: 100%; display: flex; align-items: center; }
#hdq_mini_grid { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; height: 100%; align-items: center; scroll-behavior: smooth; }
.grid_node { 
    min-width: 28px; height: 28px; display:flex; align-items:center; justify-content:center; 
    border:1px solid var(--hdq-border); border-radius: 6px; font-size:11px; font-weight:700; 
    cursor:pointer; color:var(--hdq-text-soft); background:#fff; flex-shrink: 0; transition: 0.2s;
}
.grid_node.active { 
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); color: white; border-color: #2563eb; 
    transform: scale(1.15); box-shadow: 0 4px 8px rgba(37, 99, 235, 0.4); z-index: 10;
}
.grid_node.answered { background: var(--hdq-success); color: white; border-color:var(--hdq-success); }
.grid_node.flagged_node { background: var(--hdq-warning); color: white; border-color: var(--hdq-warning); }

/* STAGE */
#hdq_terminal_stage { 
    flex-grow: 1; height: 0; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; 
    padding: 10px 0 120px 0; display: flex; flex-direction: column; align-items: center; width: 100%;
}
#hdq_terminal_root .active_q {
    background: #fff; width: 98vw !important; max-width: var(--hdq-card-max-width) !important; 
    min-height: 40vh !important; margin-bottom: 10px; padding: var(--hdq-card-pad) !important; 
    border-radius: var(--hdq-radius); box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.08); 
    border: 1px solid rgba(255,255,255,0.8); display: flex !important; flex-direction: column; flex-shrink: 0; 
}

.hdq_question_heading { 
    font-size: var(--hdq-font-size) !important; line-height: 1.4 !important; 
    font-weight: 800 !important; color: var(--hdq-text) !important; 
    margin-bottom: 20px !important; padding: 0 !important; border: none !important; 
}
.hdq_question_heading img { cursor: zoom-in; transition: 0.2s; border-radius: 8px; }
.hdq_question_heading img:hover { box-shadow: 0 5px 15px rgba(0,0,0,0.1); }

.hdq_label_answer { 
    display: flex !important; align-items: center; width: 100%;
    padding: 12px 15px 12px 50px !important; margin-bottom: 10px !important;
    border: 1px solid var(--hdq-border); border-radius: 10px; background: #fff; 
    cursor: pointer; position: relative; transition: all 0.2s ease;
    font-size: var(--hdq-font-size) !important; color: var(--hdq-text-soft) !important; 
    font-weight: 500 !important;
}
.hdq_answers { counter-reset: hdq_abcd; }
.hdq_label_answer::before {
    counter-increment: hdq_abcd; content: counter(hdq_abcd, upper-alpha);
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 26px; height: 26px; background: #f1f5f9; color: var(--hdq-text-soft);
    border-radius: 6px; font-weight: 800; font-size: 0.75em;
    display: flex; align-items: center; justify-content: center; border: 1px solid var(--hdq-border);
}
.hdq-selected-row { background: #eff6ff !important; border-color: var(--hdq-primary) !important; color: var(--hdq-primary) !important; }
.hdq-selected-row::before { background: var(--hdq-primary); color: white; border-color: var(--hdq-primary); }
input.hdq_option, .hdq_toggle, .hdq-options-check, .hdq_check_mark { display: none !important; }

/* FOOTER */
#hdq_terminal_footer { 
    position: fixed; bottom: 0; left: 0; width: 100%; padding: 10px 10px 0 10px; 
    background: var(--hdq-glass); backdrop-filter: var(--hdq-blur); -webkit-backdrop-filter: var(--hdq-blur);
    border-top: 1px solid rgba(0,0,0,0.05); display: flex; flex-direction: column; align-items: center; gap: 8px; 
    z-index: 50; flex-shrink: 0;
}
.hdq_nav_wrapper { display: flex; gap: 8px; width: 100%; justify-content: center; max-width: 800px; margin-bottom: 5px; }
.nav_btn { 
    flex: 1; min-width: 90px; padding: 8px 0; border-radius: 8px; border: none; 
    font-size: 14px; font-weight: 800; text-transform: uppercase; cursor: pointer; 
    transition: all 0.2s ease; box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
}
.nav_btn:active { transform: scale(0.97); }
#hdq_btn_prev { background: #FEEBE7; color: #000; border: 1px solid #cbd5e1; }
#hdq_btn_reset { max-width: 70px; background: #fff; color: #b45309; border: 1px solid #fcd34d; }
#hdq_btn_flag { max-width: 70px; background: #fff; color: #f59e0b; border: 1px solid #f59e0b; font-size: 1.2rem; line-height: 1; }
#hdq_btn_flag.active_flag { background: #f59e0b; color: #fff; }
#hdq_btn_next { background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%); color: #fff; box-shadow: 0 4px 12px rgba(29, 78, 216, 0.3); }
.hdq_copyright {
    width: 100vw; background: #000000; color: #555555; 
    font-size: 9px; text-transform: uppercase; text-align: center;
    padding: 3px 0; margin: 0; padding-bottom: calc(3px + env(safe-area-inset-bottom)); 
}

/* CUSTOM MODAL */
.fc-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    z-index: 2147483647; display: none; align-items: center; justify-content: center;
}
.fc-modal-box {
    background: #fff; width: 90%; max-width: 450px;
    border-radius: 16px; padding: 25px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    text-align: center; animation: fcPopIn 0.2s ease-out;
}
@keyframes fcPopIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.fc-modal-title { font-size: 18px; font-weight: 800; color: #1e293b; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.fc-modal-body { font-size: 15px; color: #64748b; margin-bottom: 25px; line-height: 1.5; }
.fc-modal-actions { display: flex; gap: 10px; justify-content: center; }
.fc-modal-btn {
    flex: 1; padding: 12px 15px; border: none; border-radius: 8px;
    font-size: 14px; font-weight: 700; cursor: pointer; transition: 0.2s;
}
.fc-btn-primary { background: #2563eb; color: #fff; }
.fc-btn-primary:hover { background: #1d4ed8; }
.fc-btn-secondary { background: #f1f5f9; color: #475569; }
.fc-btn-secondary:hover { background: #e2e8f0; }

.fly-visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

#fc_lightbox {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.9); z-index: 999999;
    display: none; align-items: center; justify-content: center;
}
#fc_lightbox img { max-width: 95vw; max-height: 95vh; object-fit: contain; box-shadow: 0 0 30px rgba(0,0,0,0.5); }
#fc_lightbox_close {
    position: absolute; top: 20px; right: 20px; color: #fff; font-size: 30px; cursor: pointer;
}

/* RESULTS DASHBOARD */
#hdq_final_summary_card { width: 98%; max-width: var(--hdq-card-max-width); margin: 0 auto; font-family: inherit; }
.v80_dashboard { background: #fff; border-radius: var(--hdq-radius); border: 1px solid #fff; text-align: center; margin-bottom: 40px; overflow: hidden; box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1); }
.v80_meta_header { background: linear-gradient(90deg, #f8fafc 0%, #f1f5f9 100%); padding: 15px 20px; border-bottom: 1px solid var(--hdq-border); display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; font-weight: 700; color: var(--hdq-text-soft); text-transform: uppercase; }
.v80_score_area { padding: 30px 15px; }
.v80_percent { font-size: 60px; font-weight: 900; line-height: 1; margin: 10px 0; background: -webkit-linear-gradient(#2563eb, #1e40af); -webkit-background-clip: text; -webkit-text-fill-color: transparent;}
.v80_grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 25px; padding-top: 25px; border-top: 1px solid #f1f5f9; }
.v80_stat { background: #fff; border: 1px solid var(--hdq-border); padding: 10px; border-radius: 10px; display: flex; flex-direction: column; cursor: pointer; transition: 0.3s; }
.v80_stat:hover { transform: translateY(-3px); border-color: var(--hdq-primary); }
.v80_batch { margin-bottom: 30px; border-radius: var(--hdq-radius); overflow: hidden; background: #fff; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.v80_batch_head { padding: 12px 20px; color: white; font-weight: 700; text-transform: uppercase; font-size: 0.8em; letter-spacing: 1px; display: flex; justify-content: space-between; }
.bg-green { background: var(--hdq-success); } .bg-red { background: var(--hdq-danger); } .bg-orange { background: var(--hdq-warning); }
.v80_list .hdq_question { display: block !important; padding: 20px !important; margin: 0 !important; border-bottom: 1px solid #f1f5f9; width: 100% !important; min-height: auto !important; height: auto !important; max-width: 100% !important; }
.v80_list .hdq_label_answer { cursor: default !important; pointer-events: none; opacity: 1; }
.hdq_correct .hdq-selected-row { background: #dcfce7 !important; border-color: var(--hdq-success) !important; color: #14532d !important; }
.hdq_correct .hdq-selected-row::before { background: var(--hdq-success); border-color: var(--hdq-success); }
.hdq_wrong .hdq-selected-row { background: #fee2e2 !important; border-color: var(--hdq-danger) !important; color: #7f1d1d !important; }
.hdq_wrong .hdq-selected-row::before { background: var(--hdq-danger); border-color: var(--hdq-danger); }
.hdq_res_time_badge { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 15px; background: #f8fafc; color: var(--hdq-text-soft); font-size: 0.75em; font-weight: 700; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--hdq-border); }
.hdq_question_after_text { display: none; margin-top: 15px; padding: 15px; border-radius: 12px; background: #eff6ff; border: 1px solid #dbeafe; color: #1e40af; font-size: 0.9em; line-height: 1.5; }
.hdq_explain_btn { display: inline-block; background: none; border: none; padding: 0; margin-top: 10px; color: var(--hdq-text-soft); font-size: 0.85em; font-weight: 600; cursor: pointer; text-decoration: none; }

/* NIGHT MODE */
body.fc-night-mode {
    --hdq-bg-gradient: linear-gradient(135deg, #0f172a 0%, #020617 100%);
    --hdq-text: #f1f5f9; --hdq-text-soft: #cbd5e1; --hdq-border: #334155; --hdq-glass: rgba(15, 23, 42, 0.98);
}
body.fc-night-mode #hdq_terminal_root .active_q { background: #1e293b !important; border-color: #334155 !important; color: #f1f5f9; }
body.fc-night-mode .hdq_label_answer { background: #0f172a !important; border-color: #334155 !important; color: #cbd5e1 !important; }
body.fc-night-mode .hdq_label_answer::before { background: #1e293b; color: #fff; border-color: #475569; }
body.fc-night-mode #hdq_grid_bar, body.fc-night-mode .grid_node { background: #1e293b; color: #94a3b8; border-color: #334155; }
body.fc-night-mode .hdq-selected-row { background: #1e3a8a !important; color: #60a5fa !important; border-color: #2563eb !important; }
body.fc-night-mode #hdq_timer_display { background: #0f172a; color: #60a5fa; border-color: #1e40af; }
body.fc-night-mode .hdq_question_heading { color: #f8fafc !important; }
body.fc-night-mode .hdq_tool_btn, body.fc-night-mode .fc_font_btn { color: #fff; border-color: #475569; }

/* RESULT DARK MODE FIXES */
body.fc-night-mode .v80_dashboard, body.fc-night-mode .v80_batch { background: #1e293b !important; border-color: #334155 !important; color: #fff !important; }
body.fc-night-mode .v80_meta_header { background: #0f172a !important; border-color: #334155 !important; color: #cbd5e1 !important; }
body.fc-night-mode .v80_stat { background: #0f172a !important; border-color: #334155 !important; color: #fff !important; }
body.fc-night-mode .v80_score_area { color: #fff !important; }
body.fc-night-mode .v80_batch_head { border-bottom: 1px solid #334155; }
body.fc-night-mode .v80_stat span { color: #94a3b8; } body.fc-night-mode .v80_stat strong { color: #fff; }

/* Modal Night Mode */
body.fc-night-mode .fc-modal-box { background: #1e293b; border: 1px solid #334155; }
body.fc-night-mode .fc-modal-title { color: #f1f5f9; }
body.fc-night-mode .fc-modal-body { color: #cbd5e1; }
body.fc-night-mode .fc-btn-secondary { background: #334155; color: #cbd5e1; }