/* =============================================
   RESET & BASE
============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0f1e;
  color: #e2e8f0;
  min-height: 100vh;
  line-height: 1.5;
}

/* =============================================
   CSS VARIABLES
============================================= */
:root {
  --bg:        #0a0f1e;
  --bg2:       #0f1729;
  --card:      #111d35;
  --card2:     #162040;
  --border:    #1e3260;
  --border2:   #2a4080;
  --primary:   #3b82f6;
  --primary-d: #2563eb;
  --success:   #10b981;
  --warn:      #f59e0b;
  --danger:    #ef4444;
  --purple:    #8b5cf6;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --muted2:    #94a3b8;
  --sidebar-w: 220px;
  --header-h:  58px;
}

/* =============================================
   SCREENS
============================================= */
.screen { display: none; }
.screen.active { display: block; }

/* =============================================
   BUTTONS
============================================= */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: 8px; border: none;
  font-size: 0.9rem; font-weight: 500; cursor: pointer;
  transition: all .18s;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--primary-d); }
.btn-outline  { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover:not(:disabled)  { background: rgba(59,130,246,.12); }
.btn-ghost    { background: transparent; color: var(--muted2); border: 1.5px solid var(--border2); }
.btn-ghost:hover:not(:disabled)    { color: var(--text); border-color: var(--primary); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled)   { background: #dc2626; }
.btn-sm   { padding: 5px 12px; font-size: 0.82rem; }
.btn-lg   { padding: 12px 28px; font-size: 1rem; }

/* =============================================
   START SCREEN
============================================= */
#screen-start { min-height: 100vh; position: relative; }

.start-bg {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 20% 30%, rgba(59,130,246,.18) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 70%, rgba(139,92,246,.12) 0%, transparent 60%);
  pointer-events: none;
}

.start-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px; position: relative; z-index: 1;
}

.start-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.1rem; font-weight: 700; color: var(--muted2);
  letter-spacing: .05em; margin-bottom: 24px;
}
.start-shield { font-size: 1.5rem; }

.start-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 40px 44px;
  max-width: 560px; width: 100%; text-align: center;
  box-shadow: 0 25px 60px rgba(0,0,0,.5);
}

.start-badge {
  display: inline-block; padding: 4px 14px;
  background: rgba(59,130,246,.15); border: 1px solid rgba(59,130,246,.3);
  color: var(--primary); border-radius: 20px;
  font-size: 0.75rem; font-weight: 700; letter-spacing: .1em; margin-bottom: 14px;
}

.start-title {
  font-size: 2.4rem; font-weight: 800;
  background: linear-gradient(135deg, #e2e8f0 30%, #93c5fd);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.start-subtitle { color: var(--muted2); font-size: 0.95rem; margin-bottom: 30px; }

.start-specs {
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 28px; background: var(--bg2); border-radius: 12px;
  overflow: hidden; border: 1px solid var(--border);
}
.spec-item { flex: 1; padding: 16px 8px; }
.spec-val  { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.spec-lbl  { font-size: 0.75rem; color: var(--muted2); margin-top: 2px; text-transform: uppercase; letter-spacing: .05em; }
.spec-div  { width: 1px; background: var(--border); align-self: stretch; }

.start-domains { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 24px; }
.domain-chip {
  padding: 5px 12px; border-radius: 20px;
  background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.25);
  color: var(--primary); font-size: 0.78rem;
}

.start-notice {
  color: var(--muted); font-size: 0.82rem; background: var(--bg2);
  border-radius: 8px; padding: 12px 16px; margin-bottom: 24px; line-height: 1.6;
}

.pool-info { color: var(--muted2); font-size: 0.82rem; margin-bottom: 16px; }
.start-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }

.resume-info {
  font-size: 0.82rem; color: var(--muted2);
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.2);
  border-radius: 8px; padding: 10px 16px; margin-top: 4px;
}

.history-section { margin-top: 28px; text-align: left; }
.history-title { font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; font-size: 0.82rem;
}
.history-item .h-score { font-weight: 700; }
.history-item .h-score.pass { color: var(--success); }
.history-item .h-score.fail { color: var(--danger); }
.history-item .h-date { color: var(--muted); font-size: 0.75rem; }

/* =============================================
   EXAM HEADER
============================================= */
.exam-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h); background: rgba(10,15,30,.95);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 20px;
  backdrop-filter: blur(8px);
}
.exam-header-left  { display: flex; align-items: center; gap: 8px; min-width: 180px; }
.exam-header-center { flex: 1; }
.exam-header-right { display: flex; align-items: center; gap: 10px; }

.header-icon  { font-size: 1.3rem; }
.header-title { font-weight: 700; font-size: 0.95rem; white-space: nowrap; }

.progress-wrap { display: flex; align-items: center; gap: 10px; }
.progress-bar-outer {
  flex: 1; height: 6px; background: var(--border);
  border-radius: 99px; overflow: hidden; min-width: 120px;
}
.progress-bar-inner {
  height: 100%; background: var(--primary); border-radius: 99px;
  transition: width .4s ease; width: 0%;
}
.progress-label { font-size: 0.8rem; color: var(--muted2); white-space: nowrap; }

.timer { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 1rem; }
.timer-icon { font-size: 0.9rem; opacity: .7; }
.timer.warning #timer-text,
.timer.warning #review-timer-text { color: var(--warn); }
.timer.critical #timer-text,
.timer.critical #review-timer-text { color: var(--danger); animation: blink 1s ease infinite; }

@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:.4; } }

/* =============================================
   EXAM BODY
============================================= */
#screen-exam { padding-top: var(--header-h); min-height: 100vh; }

.exam-body { display: flex; min-height: calc(100vh - var(--header-h)); }

.exam-sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h)); overflow: hidden;
}

.sidebar-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); }
.sidebar-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 8px; }
.sidebar-legend { display: flex; gap: 10px; font-size: 0.72rem; color: var(--muted2); align-items: center; flex-wrap: wrap; }
.leg-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.leg-dot.answered { background: var(--primary); }
.leg-dot.flagged  { background: var(--warn); }

.question-nav {
  flex: 1; overflow-y: auto; padding: 12px;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px;
}

.nav-btn {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 0.75rem; font-weight: 600;
  cursor: pointer; border: 1.5px solid var(--border);
  background: transparent; color: var(--muted2); transition: all .15s;
}
.nav-btn:hover    { border-color: var(--primary); color: var(--text); }
.nav-btn.current  { border-color: var(--primary); background: rgba(59,130,246,.2); color: var(--text); }
.nav-btn.answered { background: rgba(59,130,246,.15); border-color: var(--primary); color: var(--primary); }
.nav-btn.flagged  { background: rgba(245,158,11,.15); border-color: var(--warn); color: var(--warn); }
.nav-btn.flagged.answered { background: rgba(245,158,11,.25); }

.sidebar-stats {
  padding: 12px 14px; border-top: 1px solid var(--border);
  font-size: 0.78rem; color: var(--muted2); display: flex; flex-direction: column; gap: 4px;
}
.stat-row span { font-weight: 700; color: var(--text); }

/* =============================================
   QUESTION CARD
============================================= */
.exam-main { flex: 1; padding: 28px 32px 40px; max-width: 860px; }

.question-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 30px 32px; margin-bottom: 20px;
}

.qcard-header {
  display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px;
}
.qcard-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.q-number { font-size: 0.85rem; color: var(--muted2); font-weight: 600; }

.q-cat-tag {
  padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600;
  background: rgba(59,130,246,.12); border: 1px solid rgba(59,130,246,.25); color: var(--primary);
}
.q-type-tag {
  padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600;
  background: rgba(139,92,246,.12); border: 1px solid rgba(139,92,246,.25); color: var(--purple);
}

.btn-flag {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 8px; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; border: 1.5px solid var(--border2); background: transparent;
  color: var(--muted2); transition: all .15s; white-space: nowrap;
}
.btn-flag:hover  { border-color: var(--warn); color: var(--warn); }
.btn-flag.active { border-color: var(--warn); color: var(--warn); background: rgba(245,158,11,.1); }

.multi-notice {
  background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3);
  border-radius: 8px; padding: 8px 14px;
  font-size: 0.82rem; color: var(--warn); margin-bottom: 16px;
}

.q-text { font-size: 1.05rem; line-height: 1.7; margin-bottom: 22px; }

/* =============================================
   OPTIONS
============================================= */
.q-options { display: flex; flex-direction: column; gap: 10px; }

.option-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 16px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--bg2);
  cursor: pointer; transition: all .15s;
}
.option-item:hover    { border-color: var(--border2); background: var(--card2); }
.option-item.selected { border-color: var(--primary); background: rgba(59,130,246,.1); }

.option-indicator {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border2); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px; transition: all .15s; font-size: 0.75rem; font-weight: 700;
}
.option-item.selected .option-indicator { background: var(--primary); border-color: var(--primary); color: #fff; }
.option-item.multi .option-indicator { border-radius: 5px; }

.option-text { font-size: 0.95rem; line-height: 1.5; flex: 1; }

/* =============================================
   MATCHING
============================================= */
.matching-container { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.matching-col-title {
  font-size: 0.72rem; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .08em; margin-bottom: 10px;
}

.match-term-row {
  border: 1.5px solid var(--border); border-radius: 10px;
  margin-bottom: 8px; cursor: pointer; transition: border-color .15s; overflow: hidden;
}
.match-term-row:hover { border-color: var(--border2); }
.match-term-row.active { border-color: var(--primary) !important; box-shadow: 0 0 0 2px rgba(59,130,246,.2); }
.match-term-row.matched { border-color: var(--pair-color, var(--success)); }

.match-term-label {
  padding: 9px 14px; font-size: 0.88rem; font-weight: 600;
  background: var(--card2); border-bottom: 1px solid var(--border);
}
.match-term-row.matched .match-term-label { border-bottom-color: var(--pair-color, var(--border)); }

.match-term-slot {
  padding: 7px 14px; font-size: 0.82rem; color: var(--muted);
  font-style: italic; min-height: 34px; background: var(--bg2);
}
.match-term-row.matched .match-term-slot { color: var(--text); font-style: normal; }

.match-desc-chip {
  padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 0.87rem; line-height: 1.4;
  cursor: pointer; margin-bottom: 8px; background: var(--bg2);
  transition: all .15s;
}
.match-desc-chip:hover:not(.used) { border-color: var(--border2); background: var(--card2); }
.match-desc-chip.selected { border-color: var(--primary); background: rgba(59,130,246,.15); box-shadow: 0 0 0 2px rgba(59,130,246,.2); }
.match-desc-chip.used { opacity: .55; cursor: default; border-color: var(--pair-color, var(--success)); }

.match-hint { font-size: 0.78rem; color: var(--muted); text-align: center; margin-top: 4px; font-style: italic; }

/* =============================================
   EXAM NAV ROW
============================================= */
.exam-nav { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.nav-center-info { font-size: 0.8rem; color: var(--muted2); text-align: center; }

/* =============================================
   REVIEW SCREEN
============================================= */
#screen-review { min-height: 100vh; }
.review-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; border-bottom: 1px solid var(--border);
  background: var(--bg2); position: sticky; top: 0; z-index: 10;
}
.review-title { font-size: 1.1rem; font-weight: 700; }
.review-body  { padding: 28px 40px 60px; max-width: 900px; margin: 0 auto; }

.review-summary { display: flex; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.rev-stat {
  flex: 1; min-width: 140px; padding: 16px 20px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; text-align: center;
}
.rev-stat .rs-val { font-size: 2rem; font-weight: 800; }
.rev-stat .rs-lbl { font-size: 0.78rem; color: var(--muted2); margin-top: 4px; }
.rev-stat.answered   .rs-val { color: var(--primary); }
.rev-stat.unanswered .rs-val { color: var(--warn); }
.rev-stat.flagged-s  .rs-val { color: var(--warn); }

.review-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 28px; }
.review-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 18px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; transition: border-color .15s;
}
.review-item:hover   { border-color: var(--primary); }
.review-item .ri-num { font-weight: 700; color: var(--muted2); min-width: 28px; font-size: 0.88rem; }
.review-item .ri-text { flex: 1; font-size: 0.88rem; color: var(--muted2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review-item .ri-status { font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.review-item.answered    .ri-status { color: var(--success); }
.review-item.unanswered  .ri-status { color: var(--warn); }
.review-item .ri-flag { font-size: 0.7rem; color: var(--warn); margin-left: 6px; }

.review-actions { display: flex; gap: 14px; justify-content: center; }

/* =============================================
   RESULTS SCREEN
============================================= */
#screen-results { min-height: 100vh; }
.results-body { padding: 40px 32px 60px; max-width: 960px; margin: 0 auto; }

.results-hero {
  text-align: center; padding: 40px 20px; margin-bottom: 32px;
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
}
.results-icon    { font-size: 3rem; margin-bottom: 8px; }
.results-verdict { font-size: 2rem; font-weight: 900; letter-spacing: .1em; margin-bottom: 10px; }
.results-verdict.pass { color: var(--success); }
.results-verdict.fail { color: var(--danger); }
.results-score   { font-size: 2.5rem; font-weight: 800; margin-bottom: 4px; }
.results-pct     { font-size: 1.2rem; color: var(--muted2); margin-bottom: 8px; }
.results-time-taken { font-size: 0.85rem; color: var(--muted); }

.results-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 32px;
}
.results-section {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px 26px;
}
.results-section.full-width { grid-column: 1 / -1; }
.results-section-title { font-size: 1rem; font-weight: 700; margin-bottom: 18px; }

.cat-row { margin-bottom: 14px; }
.cat-row-header { display: flex; justify-content: space-between; font-size: 0.82rem; margin-bottom: 5px; }
.cat-name  { color: var(--muted2); }
.cat-score { font-weight: 700; }
.cat-bar-bg { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 99px; transition: width .6s ease; }
.cat-bar-fill.good { background: var(--success); }
.cat-bar-fill.ok   { background: var(--warn); }
.cat-bar-fill.bad  { background: var(--danger); }

.type-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem;
}
.type-row:last-child { border-bottom: none; }
.type-name { color: var(--muted2); }
.type-val  { font-weight: 700; }

.wrong-item {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 12px; background: var(--bg2);
}
.wrong-item-header { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.wrong-qnum  { font-size: 0.78rem; color: var(--muted); font-weight: 600; min-width: 28px; }
.wrong-qtext { font-size: 0.92rem; flex: 1; }

.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.answer-box  { padding: 10px 14px; border-radius: 8px; font-size: 0.83rem; }
.answer-box.your  { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); }
.answer-box.right { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); }
.answer-box-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .7; margin-bottom: 4px; }
.answer-box-val   { line-height: 1.4; }

.wrong-note {
  margin-top: 10px; padding: 8px 12px; font-size: 0.8rem; color: var(--muted2); font-style: italic;
  background: rgba(139,92,246,.08); border: 1px solid rgba(139,92,246,.2); border-radius: 8px;
}

.results-footer-actions { display: flex; gap: 14px; justify-content: center; }

/* =============================================
   MODAL
============================================= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: 16px; padding: 32px 36px;
  max-width: 440px; width: 90%; box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.modal-title   { font-size: 1.2rem; font-weight: 700; margin-bottom: 12px; }
.modal-body    { font-size: 0.92rem; color: var(--muted2); line-height: 1.6; margin-bottom: 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* =============================================
   SCROLLBAR
============================================= */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* =============================================
   RESPONSIVE
============================================= */
@media (max-width: 768px) {
  .exam-sidebar   { display: none; }
  .exam-main      { padding: 16px 16px 40px; }
  .results-grid   { grid-template-columns: 1fr; }
  .answer-grid    { grid-template-columns: 1fr; }
  .matching-container { grid-template-columns: 1fr; }
  .start-card     { padding: 28px 20px; }
}
