:root {
  --orange: #FF9900;
  --dark-bg: #1A1A1A;
  --card-bg: #2D2D2D;
  --nav-bg: #232F3E;
  --footer-bg: #0F0F0F;
  --green: #4CAF50;
  --red: #F44336;
  --text: #FFFFFF;
  --text-muted: #888;
  --border: #333;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #111;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  font-family: 'Segoe UI', Arial, sans-serif;
  padding: 0;
}

/* ─── APP SHELL (mobile-first) ─── */
.app {
  width: 100%;
  min-height: 100vh;
  background: var(--dark-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ─── HEADER ─── */
.header {
  background: var(--orange);
  padding: 22px 20px 14px;
  text-align: center;
  flex-shrink: 0;
}
.header h1 { color: white; font-size: 22px; font-weight: 800; letter-spacing: 0.5px; }
.header .subtitle { color: #1A1A1A; font-size: 11px; font-weight: 600; margin: 4px 0 10px; }
.badge {
  display: inline-block;
  background: #232F3E;
  color: var(--orange);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 14px;
  border-radius: 20px;
  letter-spacing: 1px;
}

/* ─── TOTAL TIMER BAR ─── */
.total-timer-bar {
  background: var(--nav-bg);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.total-timer-label { color: var(--text-muted); font-size: 10px; font-weight: 600; letter-spacing: 1px; }
.total-timer-value { color: var(--orange); font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.total-timer-value.warning { color: #FF5722; }
.total-progress { flex: 1; margin: 0 12px; height: 4px; background: #333; border-radius: 2px; }
.total-progress-fill { height: 4px; background: var(--orange); border-radius: 2px; transition: width 1s linear; }
.total-progress-fill.warning { background: #FF5722; }

/* ─── SCROLLABLE CONTENT ─── */
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.content::-webkit-scrollbar { width: 3px; }
.content::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

/* ─── SCREEN VISIBILITY ─── */
.screen { display: none; width: 100%; }
.screen.active { display: flex; flex-direction: column; gap: 10px; }

/* ─── LEVEL SELECT ─── */
.welcome-card {
  background: var(--card-bg);
  border-radius: 12px;
  border-left: 5px solid var(--orange);
  padding: 16px;
}
.welcome-card h2 { color: var(--orange); font-size: 14px; font-weight: 700; letter-spacing: 1px; margin-bottom: 8px; }
.welcome-card p { color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.welcome-card p strong { color: var(--text); }

.level-card {
  background: var(--card-bg);
  border-radius: 12px;
  border-left: 5px solid var(--orange);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 12px;
}
.level-card:active { transform: scale(0.98); background: #363636; }
.level-icon { font-size: 28px; flex-shrink: 0; }
.level-info { flex: 1; }
.level-name { color: var(--text); font-size: 14px; font-weight: 700; }
.level-meta { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.level-badge {
  background: var(--nav-bg);
  color: var(--orange);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.divider { color: var(--text-muted); font-size: 10px; font-weight: 600; letter-spacing: 2px; text-align: center; padding: 4px 0; }
.provider-group { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.provider-header { color: var(--orange); font-size: 11px; font-weight: 700; letter-spacing: 2px; padding: 4px 2px 0; }

/* ─── QUESTION CARD ─── */
.question-card {
  background: var(--card-bg);
  border-radius: 12px;
  border-left: 5px solid var(--orange);
  padding: 16px;
  position: relative;
}
.question-label { color: var(--orange); font-size: 10px; font-weight: 700; letter-spacing: 1.5px; margin-bottom: 10px; }
.question-text { color: var(--text); font-size: 15px; line-height: 1.55; }
.multi-hint { color: var(--orange); font-size: 11px; font-weight: 700; letter-spacing: 0.5px; margin-top: 8px; }
.question-source { color: var(--text-muted); font-size: 10px; font-style: italic; margin-top: 10px; }
.question-id-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px;
  padding: 2px 7px;
  user-select: none;
}

/* ─── OPTIONS ─── */
.options { display: flex; flex-direction: column; gap: 8px; }

.option {
  background: var(--nav-bg);
  border-radius: 10px;
  border-left: 5px solid var(--orange);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 3px;
  -webkit-tap-highlight-color: transparent;
}
.option:active { transform: scale(0.99); }
.option.selected { background: #2A2410; border-left-color: var(--orange); box-shadow: 0 0 0 1px rgba(255,152,0,0.35); }
.option.correct { background: #1E3A1E; border-left-color: var(--green); box-shadow: 0 0 0 1px rgba(76,175,80,0.3); }
.option.wrong { background: #3A1E1E; border-left-color: var(--red); box-shadow: 0 0 0 1px rgba(244,67,54,0.3); }
.option.disabled { cursor: default; }

.option-header { display: flex; align-items: center; gap: 10px; }
.option-letter { color: var(--orange); font-weight: 800; font-size: 14px; min-width: 20px; }
.option.correct .option-letter { color: var(--green); }
.option.wrong .option-letter { color: var(--red); }
.option-title { color: var(--text); font-size: 14px; font-weight: 600; }
.option-desc { color: var(--text-muted); font-size: 11px; padding-left: 30px; }
.option.correct .option-desc, .option.wrong .option-desc { color: #aaa; }

/* ─── EXPLANATION ─── */
.explanation-card {
  background: #1A2A1A;
  border-radius: 12px;
  border-left: 5px solid var(--green);
  padding: 14px 16px;
  display: none;
}
.explanation-card.show { display: block; }
.explanation-label { color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: 1.5px; margin-bottom: 8px; }
.explanation-text { color: #ccc; font-size: 13px; line-height: 1.55; }

/* ─── QUESTION TIMER ─── */
.q-timer-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.q-timer-secs { color: var(--orange); font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.q-timer-secs.urgent { color: var(--red); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.5; } }

.timer-bar-bg { background: #333; height: 6px; border-radius: 3px; margin-top: 6px; }
.timer-bar-fill { background: var(--orange); height: 6px; border-radius: 3px; transition: width 1s linear, background 0.3s; }
.timer-bar-fill.urgent { background: var(--red); }

/* ─── SCORE CARD ─── */
.score-card {
  background: var(--card-bg);
  border-radius: 12px;
  border-left: 5px solid var(--orange);
  padding: 20px 16px;
  text-align: center;
}
.score-title { color: var(--orange); font-size: 12px; font-weight: 700; letter-spacing: 1.5px; margin-bottom: 12px; }
.score-number { color: var(--text); font-size: 52px; font-weight: 900; line-height: 1; }
.score-sub { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.score-pass { color: var(--green); font-size: 20px; font-weight: 800; margin-top: 8px; }
.score-fail { color: var(--red); font-size: 20px; font-weight: 800; margin-top: 8px; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.stat-value { color: var(--text); font-size: 24px; font-weight: 800; }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-label { color: var(--text-muted); font-size: 10px; font-weight: 600; letter-spacing: 1px; margin-top: 4px; }

/* ─── BUTTONS ─── */
.btn-primary {
  background: var(--orange);
  color: #1A1A1A;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  letter-spacing: 0.5px;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary:disabled:active { background: transparent; color: var(--orange); }

.btn-secondary {
  background: transparent;
  color: var(--orange);
  border: 1.5px solid var(--orange);
  border-radius: 12px;
  padding: 13px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:active { background: var(--orange); color: #1A1A1A; }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn-secondary { flex: 1; }

/* ─── FOOTER NAV ─── */
.footer {
  background: var(--footer-bg);
  padding: 10px 16px 14px;
  flex-shrink: 0;
  border-top: 1px solid #1f1f1f;
}

.pause-btn {
  background: var(--nav-bg);
  color: var(--orange);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.pause-btn:active { background: var(--orange); color: #1A1A1A; }
.pause-btn.paused { background: #2a1a00; border-color: var(--orange); color: var(--orange); }

.footer-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.footer-info { color: var(--text-muted); font-size: 11px; }
.footer-nav { display: flex; gap: 8px; }
.nav-btn {
  background: var(--nav-bg);
  color: var(--text);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn:disabled { opacity: 0.3; cursor: default; }
.nav-btn:not(:disabled):active { background: var(--orange); color: #1A1A1A; }

/* ─── SITE FOOTER (signature) ─── */
.site-footer {
  flex-shrink: 0;
  background: var(--footer-bg);
  border-top: 1px solid #1f1f1f;
  padding: 10px 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.site-footer-text { color: var(--text-muted); font-size: 11px; letter-spacing: 0.3px; }
.site-footer-text strong { color: var(--orange); }
.site-footer-links { display: flex; align-items: center; gap: 16px; }
.site-footer-disclaimer {
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
  max-width: 560px;
}
.social-link {
  color: var(--text-muted);
  display: inline-flex;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.social-link:hover, .social-link:active { color: var(--orange); }
.social-link svg { width: 18px; height: 18px; display: block; }

/* ─── PAUSED OVERLAY ─── */
.paused-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
}
.paused-overlay.show { display: flex; }
.paused-icon { font-size: 56px; }
.paused-text { color: var(--orange); font-size: 24px; font-weight: 800; letter-spacing: 2px; }
.paused-sub { color: var(--text-muted); font-size: 13px; }
.paused-overlay .btn-primary { width: 200px; }

/* ─── MODE SELECT ─── */
.mode-card {
  background: var(--card-bg);
  border-radius: 12px;
  border-left: 5px solid var(--orange);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 14px;
}
.mode-card:active { transform: scale(0.98); background: #363636; }
.mode-icon { font-size: 36px; flex-shrink: 0; }
.mode-info { flex: 1; }
.mode-name { color: var(--text); font-size: 15px; font-weight: 700; }
.mode-desc { color: var(--text-muted); font-size: 12px; margin-top: 4px; line-height: 1.4; }

/* ─── QUESTION LIST ─── */
.q-list-item {
  background: var(--card-bg);
  border-radius: 10px;
  border-left: 5px solid var(--border);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.q-list-item:active { transform: scale(0.99); }
.q-list-item.q-correct { border-left-color: var(--green); }
.q-list-item.q-wrong   { border-left-color: var(--red); }
.q-list-num  { color: var(--orange); font-size: 13px; font-weight: 800; min-width: 30px; flex-shrink: 0; }
.q-list-text { flex: 1; color: var(--text); font-size: 13px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.q-list-status { font-size: 16px; flex-shrink: 0; }
.q-list-progress { color: var(--text-muted); font-size: 11px; margin-top: 4px; }

/* ─── TIMEOUT BANNER ─── */
.timeout-banner {
  background: #3A1E1E;
  border: 1px solid var(--red);
  border-radius: 10px;
  padding: 12px 14px;
  display: none;
  align-items: center;
  gap: 10px;
}
.timeout-banner.show { display: flex; }
.timeout-icon { font-size: 22px; }
.timeout-text { color: var(--red); font-size: 13px; font-weight: 700; }

/* ─── RESPONSIVE ─── */

/* Tablet: 600px+ */
@media (min-width: 600px) {
  body {
    padding: 0 24px;
    background: #0d0d0d;
    align-items: center;
  }
  .app {
    max-width: 680px;
    min-height: 100vh;
  }
  .header { padding: 26px 24px 16px; }
  .header h1 { font-size: 26px; }
  .header .subtitle { font-size: 12px; }
  .badge { font-size: 12px; padding: 4px 16px; }
  .content { padding: 16px 20px; gap: 12px; }
  .question-text { font-size: 16px; }
  .option { padding: 14px 16px; }
  .option-title { font-size: 15px; }
  .option-desc { font-size: 12px; }
  .score-number { font-size: 60px; }
  .welcome-card p { font-size: 13px; }
  .mode-desc { font-size: 13px; }
  .explanation-text { font-size: 14px; }
}

/* Desktop: 900px+ */
@media (min-width: 900px) {
  body {
    padding: 32px;
    background: #080808;
  }
  .app {
    max-width: 820px;
    min-height: calc(100vh - 64px);
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
  }
  .header { padding: 32px 32px 20px; }
  .header h1 { font-size: 30px; letter-spacing: 1px; }
  .header .subtitle { font-size: 13px; margin-bottom: 12px; }
  .badge { font-size: 13px; }
  .total-timer-bar { padding: 10px 24px; }
  .total-timer-label { font-size: 11px; }
  .total-timer-value { font-size: 16px; }
  .content { padding: 20px 28px; gap: 14px; }
  .welcome-card { padding: 20px 22px; }
  .welcome-card h2 { font-size: 16px; }
  .welcome-card p { font-size: 13px; }
  .level-card { padding: 16px 20px; gap: 16px; }
  .level-name { font-size: 16px; }
  .level-meta { font-size: 12px; }
  .level-icon { font-size: 34px; }
  .question-card { padding: 20px 22px; }
  .question-text { font-size: 17px; line-height: 1.6; }
  .question-label { font-size: 11px; margin-bottom: 12px; }
  .option { padding: 14px 18px; gap: 6px; }
  .option-title { font-size: 15px; }
  .option-desc { font-size: 12px; }
  .option-letter { font-size: 15px; }
  .explanation-card { padding: 18px 20px; }
  .explanation-text { font-size: 14px; }
  .score-card { padding: 28px 22px; }
  .score-number { font-size: 72px; }
  .score-sub { font-size: 14px; }
  .score-pass, .score-fail { font-size: 22px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .stat-value { font-size: 28px; }
  .stat-label { font-size: 11px; }
  .mode-card { padding: 20px 22px; gap: 18px; }
  .mode-icon { font-size: 42px; }
  .mode-name { font-size: 17px; }
  .mode-desc { font-size: 13px; }
  .btn-primary { font-size: 15px; padding: 16px; border-radius: 14px; }
  .btn-secondary { font-size: 14px; padding: 15px; border-radius: 14px; }
  .footer { padding: 12px 24px 18px; }
  .footer-info { font-size: 12px; }
  .site-footer { padding: 12px 24px 18px; }
  .site-footer-text { font-size: 12px; }
  .site-footer-disclaimer { font-size: 11px; }
  .social-link svg { width: 20px; height: 20px; }
  .nav-btn { padding: 10px 18px; font-size: 13px; }
  .pause-btn { padding: 10px 20px; font-size: 13px; }
  .paused-text { font-size: 28px; }
  .paused-sub { font-size: 14px; }
  .paused-overlay .btn-primary { width: 240px; }
  .q-list-item { padding: 14px 18px; }
  .q-list-text { font-size: 14px; }
  .q-list-num { font-size: 14px; }
  .q-timer-secs { font-size: 22px; }
}

/* Large desktop: 1200px+ */
@media (min-width: 1200px) {
  .app { max-width: 960px; }
  .header h1 { font-size: 34px; }
  .question-text { font-size: 18px; }
  .option-title { font-size: 16px; }
  .score-number { font-size: 80px; }
}
