:root {
  --ink: #14304f;
  --muted: #5e748f;
  --blue: #1266d6;
  --blue-dark: #0d4faa;
  --blue-soft: #e8f2ff;
  --cyan: #20a6d2;
  --ok: #16854f;
  --bad: #c93333;
  --warn: #d58a00;
  --panel: rgba(255, 255, 255, 0.94);
  --line: #cfe0f2;
  --shadow: 0 18px 45px rgba(20, 48, 79, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #edf6ff;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at 16% 12%, rgba(32, 166, 210, 0.16), transparent 28rem),
    linear-gradient(140deg, #f7fbff 0%, #eaf4ff 52%, #ffffff 100%);
}

button {
  font: inherit;
}

.cifp-topbar {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 18px;
  padding: 14px 20px;
  color: #fff;
  background: linear-gradient(90deg, #0b3994, #172554);
  border-bottom: 4px solid #f6b511;
  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 {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 240px;
}

.cifp-logo-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  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: #0b3994;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.cifp-site-name {
  margin: 0;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.15;
}

.cifp-author {
  margin: 4px 0 0;
  color: #bfdbfe;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
}

.cifp-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.cifp-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 999px;
  color: #fde68a;
  background: rgba(246, 181, 17, 0.16);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cifp-landing {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  color: #0b3994;
  background: #f6b511;
  box-shadow: 0 4px 12px rgba(246, 181, 17, 0.22);
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.14s ease, background 0.14s ease;
}

.cifp-landing:hover {
  background: #fbbf24;
  transform: translateY(-1px);
}

.cifp-landing:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.62);
  outline-offset: 3px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.25rem;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 10px;
  min-width: min(430px, 100%);
}

.score-strip > div,
.stat-list > div,
.result-grid > div {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(20, 48, 79, 0.08);
}

.metric-label,
.stat-list span,
.result-grid span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.score-strip strong,
.stat-list strong,
.result-grid strong {
  font-size: 1.35rem;
}

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

.control-card,
.figure-card,
.side-card,
.modal-card {
  border: 1px solid rgba(207, 224, 242, 0.9);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-card,
.side-card {
  padding: 18px;
}

.control-card {
  display: flex;
  flex-direction: column;
}

.field-group + .field-group,
.challenge-panel,
.progress-wrap,
.actions {
  margin-top: 18px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.chip,
.primary,
.secondary {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease, color 0.14s ease;
  touch-action: manipulation;
}

.chip {
  color: var(--ink);
  background: #ffffff;
}

.chip.active,
.primary {
  border-color: var(--blue);
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  box-shadow: 0 12px 26px rgba(18, 102, 214, 0.24);
}

.chip:focus-visible,
.primary:focus-visible,
.secondary:focus-visible,
.anatomy-part:focus-visible {
  outline: 3px solid rgba(32, 166, 210, 0.45);
  outline-offset: 3px;
}

.chip:hover,
.primary:hover,
.secondary:hover {
  transform: translateY(-1px);
}

.challenge-panel {
  min-height: 164px;
  padding: 16px;
  border: 1px solid #b9d5f3;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fcff, var(--blue-soft));
}

#roundCounter {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--blue-dark);
  font-size: 0.86rem;
  font-weight: 800;
}

#promptText {
  margin-bottom: 9px;
  font-size: clamp(1.45rem, 2.5vw, 2.05rem);
  line-height: 1.1;
}

#feedbackText {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.4;
}

#feedbackText.ok {
  color: var(--ok);
}

#feedbackText.bad {
  color: var(--bad);
}

#feedbackText.warn {
  color: #8a5700;
}

.progress-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.progress-track {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: #d7e7f8;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  transition: width 0.25s ease;
}

#progressText {
  min-width: 42px;
  color: var(--muted);
  font-weight: 800;
  text-align: right;
}

.actions,
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.primary,
.secondary {
  padding: 0 14px;
}

.secondary {
  color: var(--blue-dark);
  background: #ffffff;
}

.secondary:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.figure-card {
  min-height: 690px;
  padding: 14px;
}

.svg-mount {
  display: grid;
  min-height: 660px;
  place-items: center;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(232,242,255,0.62)),
    repeating-linear-gradient(90deg, rgba(18,102,214,0.04) 0 1px, transparent 1px 38px);
}

.svg-mount svg {
  width: min(100%, 560px);
  height: auto;
  max-height: 78vh;
}

.anatomy-part {
  cursor: pointer;
  transition: filter 0.16s ease, opacity 0.16s ease, stroke-width 0.16s ease;
}

.anatomy-part:hover {
  filter: brightness(1.05) saturate(1.1);
}

.anatomy-part.is-inactive {
  cursor: default;
  opacity: 0.18;
  pointer-events: none;
}

.anatomy-part.is-correct {
  filter: drop-shadow(0 0 10px rgba(22, 133, 79, 0.85));
  stroke: var(--ok) !important;
  stroke-width: 4 !important;
}

.anatomy-part.is-wrong {
  filter: drop-shadow(0 0 9px rgba(201, 51, 51, 0.75));
  stroke: var(--bad) !important;
  stroke-width: 4 !important;
}

.anatomy-part.is-answer {
  filter: drop-shadow(0 0 12px rgba(213, 138, 0, 0.95));
  stroke: var(--warn) !important;
  stroke-width: 5 !important;
}

.layer-label {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-list {
  display: grid;
  gap: 10px;
}

.mini-help {
  margin-top: 16px;
  padding: 14px;
  border-left: 4px solid var(--cyan);
  border-radius: 8px;
  background: #eef8fc;
}

.mini-help p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 48, 79, 0.52);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(620px, 100%);
  padding: 24px;
}

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

@media (max-width: 1050px) {
  .topbar,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .game-layout {
    display: grid;
  }

  .control-card {
    order: 1;
  }

  .figure-card {
    order: 2;
    min-height: 580px;
  }

  .side-card {
    order: 3;
  }

  .segmented {
    grid-template-columns: repeat(3, 1fr);
  }

  .svg-mount {
    min-height: 550px;
  }
}

@media (max-width: 620px) {
  .cifp-topbar {
    margin-bottom: 10px;
    padding: 12px 14px;
  }

  .cifp-brand,
  .cifp-actions {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .cifp-logo-box img {
    height: 42px;
    max-width: 190px;
  }

  .cifp-badge,
  .cifp-landing {
    width: 100%;
    justify-content: center;
  }

  .app-shell {
    padding: 10px;
  }

  .score-strip,
  .actions,
  .modal-actions,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 12px;
  }

  h1 {
    font-size: 2rem;
  }

  .score-strip {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .score-strip > div {
    padding: 9px 8px;
    text-align: center;
  }

  .score-strip strong {
    font-size: 1.12rem;
  }

  .segmented {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .control-card .challenge-panel {
    order: -2;
    margin-top: 0;
  }

  .control-card .progress-wrap {
    order: -1;
  }

  .chip,
  .primary,
  .secondary {
    min-height: 48px;
  }

  .challenge-panel {
    min-height: 138px;
    padding: 14px;
  }

  #promptText {
    font-size: 1.55rem;
  }

  .figure-card {
    min-height: 520px;
    padding: 8px;
  }

  .svg-mount {
    min-height: 500px;
  }

  .svg-mount svg {
    width: 100%;
    max-height: none;
  }

  .control-card,
  .side-card,
  .modal-card {
    padding: 14px;
  }
}
/* Responsive vector viewer: preserve detail at every zoom level. */
.app-shell { width: min(1600px, 100%); }
.game-layout { grid-template-columns: minmax(250px, 300px) minmax(0, 1fr) minmax(190px, 230px); }
.figure-card { min-width: 0; min-height: 0; }
.figure-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.figure-tools button { min-width: 44px; min-height: 44px; padding: 8px 12px; }
.figure-tools output { min-width: 48px; text-align: center; font-weight: 700; }
.figure-tools button:focus-visible, .svg-mount:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
.figure-help { margin: 10px 0; color: var(--muted); font-size: .85rem; line-height: 1.4; }
.svg-mount { display: block; min-height: 0; height: clamp(420px, 74vh, 900px); overflow: auto; overscroll-behavior: contain; }
.svg-mount svg { display: block; max-width: none; max-height: none; margin: 0 auto; flex-shrink: 0; }
.svg-mount [hidden] { display: none !important; }
.figure-card.is-expanded { grid-column: 1 / -1; }
.figure-card.is-expanded .svg-mount { height: 85vh; }
@media (max-width: 1150px) {
  .game-layout { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); }
  .side-card { grid-column: 1 / -1; }
  .stat-list { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .segmented { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chip { padding: 6px 3px; font-size: .85rem; }
  .figure-card { padding: 8px; }
  .svg-mount { height: 65vh; min-height: 390px; }
  .challenge-panel { min-height: 0; }
}
