:root {
  --primary: #0b3994;
  --primary-dark: #172554;
  --brand: #f6b511;
  --ink: #1d3557;
  --muted: #5d6b7d;
  --line: #d8e4f2;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --soft-blue: #eaf3ff;
  --ok: #147a4d;
  --bad: #c43838;
  --warn: #9a6500;
  --radius: 14px;
  --shadow: 0 14px 35px rgba(11, 57, 148, 0.12);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at 12% 12%, rgba(246, 181, 17, 0.18), transparent 18rem),
    linear-gradient(135deg, #f7fbff, #eef5ff 55%, #fff);
}

button, select { font: inherit; }

.cifp-topbar {
  width: 100%;
  margin: 0 0 18px;
  padding: 14px 20px;
  color: #fff;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-bottom: 4px solid var(--brand);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.18);
}

.cifp-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  width: min(1120px, 100%);
  margin: 0 auto;
}

.cifp-brand, .cifp-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cifp-logo-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 58px;
  padding: 8px 10px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.16);
}

.cifp-logo-box img {
  display: block;
  width: auto;
  height: 48px;
  max-width: 220px;
  object-fit: contain;
}

.cifp-logo-box.logo-missing::after {
  content: "CFPI";
  color: var(--primary);
  font-weight: 900;
}

.cifp-site-name, .cifp-author { margin: 0; }
.cifp-site-name { color: #fff; font-weight: 800; font-size: 1.1rem; }
.cifp-author { color: #bfdbfe; font-weight: 700; font-size: .9rem; }

.cifp-badge, .cifp-landing {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 999px;
  font-weight: 800;
  text-decoration: none;
}

.cifp-badge {
  padding: 7px 12px;
  border: 1px solid rgba(251, 191, 36, .35);
  color: #fde68a;
  background: rgba(246, 181, 17, .16);
  font-size: .76rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.cifp-landing {
  padding: 10px 16px;
  color: var(--primary);
  background: var(--brand);
}

.app-shell {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.hero-card, .panel, .modal-card {
  border: 1px solid rgba(11, 57, 148, .1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 430px);
  gap: 18px;
  align-items: end;
  padding: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-weight: 900;
  font-size: .82rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2.3rem, 5vw, 4rem); line-height: 1; }
h2 { font-size: 1.3rem; }
.lead { max-width: 760px; margin-bottom: 0; color: var(--muted); font-size: 1.05rem; }

.scoreboard, .result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.scoreboard div, .result-grid div {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fcff;
}

.scoreboard span, .result-grid span {
  display: block;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

.scoreboard strong, .result-grid strong { font-size: 1.45rem; }

.game-grid {
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(360px, 1fr) minmax(260px, 330px);
  gap: 18px;
  align-items: start;
}

.panel { padding: 18px; }
.setup-panel { display: grid; gap: 18px; }

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 900;
  font-size: .88rem;
  text-transform: uppercase;
}

.level-list { display: grid; gap: 9px; }

.level-btn, .pill, .primary, .secondary, .answer-btn {
  border-radius: 10px;
  border: 1px solid var(--line);
  cursor: pointer;
  touch-action: manipulation;
}

.level-btn {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 68px;
  padding: 12px;
  color: var(--ink);
  text-align: left;
  background: #fff;
}

.level-btn span { color: var(--muted); font-size: .9rem; }
.level-btn.active { border-color: var(--primary); background: var(--soft-blue); box-shadow: 0 0 0 3px rgba(11, 57, 148, .08); }

.round-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pill { min-height: 44px; background: #fff; color: var(--primary); font-weight: 900; }
.pill.active { color: #fff; border-color: var(--primary); background: var(--primary); }

select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
}

.actions, .modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.modal-actions { grid-template-columns: repeat(3, 1fr); }

.primary, .secondary {
  min-height: 48px;
  padding: 0 14px;
  font-weight: 900;
}

.primary { border-color: var(--primary); color: #fff; background: linear-gradient(135deg, var(--primary), #1976d2); }
.secondary { color: var(--primary); background: #fff; }
.next { width: 100%; margin-top: 14px; }
.next:disabled { opacity: .45; cursor: not-allowed; }

.question-panel { min-height: 520px; }
.question-meta { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 12px; color: var(--muted); font-weight: 900; }
#questionText { min-height: 76px; margin-bottom: 16px; font-size: clamp(1.45rem, 3vw, 2.25rem); line-height: 1.15; }

.answer-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.answer-btn {
  min-height: 78px;
  padding: 13px;
  color: var(--ink);
  background: #fff;
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
}

.answer-btn:hover { background: #f4f8ff; }
.answer-btn.correct { border-color: var(--ok); background: #e9f8f0; color: var(--ok); }
.answer-btn.wrong { border-color: var(--bad); background: #fff0f0; color: var(--bad); }
.answer-btn:disabled { cursor: default; }

.feedback {
  min-height: 48px;
  margin: 14px 0;
  padding: 12px;
  border-radius: 10px;
  color: var(--muted);
  background: #f7fbff;
  font-weight: 800;
}
.feedback.ok { color: var(--ok); background: #e9f8f0; }
.feedback.bad { color: var(--bad); background: #fff0f0; }

.progress-track { height: 12px; overflow: hidden; border-radius: 999px; background: #dce8f6; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), #22a6d5); transition: width .22s ease; }

.study-card { display: grid; gap: 10px; }
.study-card .med-name { margin: 0; color: var(--primary); font-size: 1.45rem; }
.study-row { padding: 10px; border-radius: 10px; background: #f8fbff; border: 1px solid var(--line); }
.study-row b { display: block; margin-bottom: 3px; color: var(--primary); }
.source-note { margin-top: 14px; padding: 12px; border-left: 4px solid var(--brand); border-radius: 10px; background: #fff8df; color: #705011; font-weight: 700; font-size: .9rem; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 37, 84, .55);
}
.modal[hidden] { display: none; }
.modal-card { width: min(620px, 100%); padding: 24px; }

@media (max-width: 1040px) {
  .hero-card, .game-grid { grid-template-columns: 1fr; }
  .question-panel { min-height: auto; }
}

@media (max-width: 640px) {
  .cifp-topbar { padding: 12px 14px; margin-bottom: 8px; }
  .cifp-brand, .cifp-actions { width: 100%; justify-content: center; text-align: center; }
  .cifp-logo-box img { height: 42px; }
  .cifp-badge, .cifp-landing { width: 100%; }
  .app-shell { padding: 10px; }
  .hero-card, .panel { padding: 14px; }
  .hero-card { gap: 12px; }
  .scoreboard, .answer-grid, .actions, .modal-actions, .result-grid { grid-template-columns: 1fr; }
  .scoreboard { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .scoreboard div { padding: 9px 7px; text-align: center; }
  .scoreboard strong { font-size: 1.1rem; }
  h1 { font-size: 2.4rem; }
  #questionText { min-height: auto; font-size: 1.55rem; }
  .answer-btn { min-height: 66px; font-size: 1rem; }
  .setup-panel { order: 2; }
  .question-panel { order: 1; }
  .study-panel { order: 3; }
}
