:root {
  --primary: #465818;
  --turtle-light: #a6b46a;
  --ink: #121611;
  --muted: #657062;
  --panel: #ffffff;
  --panel-soft: #f6f7f1;
  --accent: #0f6b72;
  --accent-soft: #dff1f2;
  --warm: #b65f39;
  --warm-soft: #f5e5db;
  --bg-color: #f7f8f3;
  --text-main: #2a3129;
  --border: #dce3d4;
  --hairline: rgba(70, 88, 24, 0.12);
  --wrong: #c74242;
  --correct: #258457;
  --shadow-soft: 0 24px 80px rgba(27, 37, 23, 0.13);
  --shadow-card: 0 14px 40px rgba(22, 30, 20, 0.12);
  --shadow-lift: 0 18px 50px rgba(22, 30, 20, 0.16);
}

* { box-sizing: border-box; }

*:focus-visible {
  outline: 3px solid rgba(15,107,114,0.28);
  outline-offset: 3px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at 16% 10%, rgba(15, 107, 114, 0.18), transparent 28rem),
    radial-gradient(circle at 85% 0%, rgba(166, 180, 106, 0.28), transparent 26rem),
    linear-gradient(180deg, #fbfcf8 0%, #eef3e6 54%, #e2ead8 100%);
  background-attachment: fixed;
  color: var(--text-main);
  margin: 0;
  min-height: 100vh;
}

.app-shell {
  width: min(1160px, calc(100% - 28px));
  margin: 0 auto;
  padding: 14px 0 38px;
}

.pre-game-shell {
  position: relative;
  display: flow-root;
  margin-bottom: 12px;
}

.topbar {
  position: sticky;
  top: 10px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding: 7px;
  color: var(--ink);
  border: 1px solid rgba(70, 88, 24, 0.1);
  border-radius: 22px;
  background: rgba(251,252,248,0.78);
  box-shadow: 0 10px 34px rgba(22, 30, 20, 0.08);
  backdrop-filter: blur(16px);
}

.brand-lockup,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-lockup {
  order: 1;
}

.topbar-actions {
  order: 2;
  margin-left: auto;
}

.topbar-play {
  order: 3;
  flex: 0 0 auto;
}

.brand-lockup {
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}

.topbar-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 800;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255,255,255,0.72);
  border-color: rgba(70, 88, 24, 0.14);
}

.play-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 16px;
  color: #fff;
  text-decoration: none;
  border: 1px solid rgba(15, 107, 114, 0.18);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #258457);
  box-shadow: 0 10px 24px rgba(15, 107, 114, 0.18);
  font-size: 0.88rem;
  font-weight: 900;
  cursor: pointer;
}

.play-nav-link:hover,
.play-nav-link:focus-visible {
  color: #fff;
  background: linear-gradient(135deg, #0b5960, #1f764d);
  border-color: rgba(15, 107, 114, 0.28);
  transform: translateY(-1px);
}

.nav-link:active,
.ghost-btn:active,
.play-nav-link:active,
.secondary-btn:active {
  transform: translateY(1px);
}

.status-pill {
  border: 1px solid rgba(83, 102, 26, 0.22);
  color: var(--primary);
  background: rgba(255,255,255,0.72);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 700;
}

.hero-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  width: min(1020px, 100%);
  gap: 12px;
  align-items: stretch;
  margin: 0 auto 10px;
}

.hero-copy {
  position: relative;
  overflow: hidden;
  padding: clamp(18px, 2.6vw, 26px);
  border: 1px solid rgba(70, 88, 24, 0.12);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.92), rgba(255,255,255,0.72)),
    linear-gradient(135deg, rgba(15, 107, 114, 0.14), rgba(166, 180, 106, 0.18));
  box-shadow: var(--shadow-soft);
}

.hero-copy::after {
  content: "";
  position: absolute;
  inset: auto -12% -48% 54%;
  height: 190px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(15,107,114,0.14), rgba(182,95,57,0.12));
  transform: rotate(-8deg);
}

.eyebrow,
.metric-label {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-copy h1 {
  position: relative;
  z-index: 1;
  margin: 7px 0 8px;
  color: var(--ink);
  font-size: clamp(2.45rem, 5vw, 3.9rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.hero-copy p {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0;
  color: #4e5a4c;
  font-size: clamp(0.95rem, 1.35vw, 1.02rem);
  line-height: 1.48;
}

.hero-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.hero-actions button {
  min-height: 44px;
}

.hero-card {
  display: grid;
  align-content: space-between;
  gap: 10px;
  min-height: 100%;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(70, 88, 24, 0.14);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.86), rgba(246,248,242,0.82)),
    radial-gradient(circle at 100% 0%, rgba(182,95,57,0.12), transparent 16rem);
  box-shadow: var(--shadow-card);
}

.hero-card-header {
  display: grid;
  gap: 8px;
}

.hero-card strong {
  display: block;
  color: var(--ink);
  font-size: 1.22rem;
  line-height: 1.18;
  letter-spacing: -0.035em;
}

.hero-card small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.35;
}

.hero-sync-note {
  display: none;
  padding: 9px 10px;
  color: #455044;
  border: 1px solid rgba(15,107,114,0.12);
  border-radius: 14px;
  background: rgba(223,241,242,0.52);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.35;
}

.hero-flow {
  display: grid;
  gap: 8px;
}

.hero-flow span {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 9px 11px;
  color: #324131;
  border: 1px solid rgba(70, 88, 24, 0.1);
  border-radius: 14px;
  background: rgba(255,255,255,0.7);
  font-size: 0.92rem;
  font-weight: 850;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
}

.hero-flow span::before {
  content: "";
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(15,107,114,0.12);
}

.hero-flow span.active {
  color: #064b52;
  border-color: rgba(15,107,114,0.28);
  background: var(--accent-soft);
}

.hero-flow span.complete {
  color: #1f6845;
  border-color: rgba(37,132,87,0.24);
  background: #edf8f2;
}

.hero-flow span.complete::before {
  background: var(--correct);
  box-shadow: 0 0 0 4px rgba(37,132,87,0.12);
}

.completion-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  width: min(1020px, 100%);
  margin: 0 auto 18px;
  padding: 20px;
  border: 1px solid rgba(37, 132, 87, 0.18);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(240,255,244,0.92), rgba(255,255,255,0.78)),
    radial-gradient(circle at 100% 0%, rgba(37,132,87,0.16), transparent 18rem);
  box-shadow: var(--shadow-card);
}

.completion-banner span,
.content-kicker {
  display: block;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.completion-banner h2 {
  margin: 6px 0;
  color: var(--ink);
  font-size: clamp(1.4rem, 3vw, 2rem);
  letter-spacing: -0.035em;
}

.completion-banner p {
  margin: 0;
  max-width: 660px;
  color: var(--muted);
  line-height: 1.5;
}

.completion-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.learner-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0;
}

.learner-summary div {
  padding: 10px 12px;
  border: 1px solid rgba(70, 88, 24, 0.12);
  border-radius: 18px;
  background: rgba(255,255,255,0.74);
  box-shadow: 0 10px 30px rgba(22, 30, 20, 0.08);
}

.learner-summary span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.learner-summary strong {
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
}

.login-nudge {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(15,107,114,0.14);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(223,241,242,0.72), rgba(255,255,255,0.78)),
    radial-gradient(circle at 100% 0%, rgba(166,180,106,0.18), transparent 18rem);
  box-shadow: 0 10px 30px rgba(22,30,20,0.08);
}

.login-nudge span {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-nudge strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.2;
}

.login-nudge p {
  margin: 0;
  color: #455044;
  font-size: 0.88rem;
  line-height: 1.42;
}

.progress-strip {
  display: none;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  gap: 10px;
  margin-bottom: 12px;
}

.pre-game-shell {
  position: relative;
}

.archive-panel {
  position: absolute;
  z-index: 35;
  top: 138px;
  right: max(0px, calc((100% - 1020px) / 2));
  display: grid;
  grid-template-columns: minmax(280px, 420px);
  justify-content: center;
  gap: 20px;
  width: min(420px, calc(100% - 24px));
  margin: 0;
  padding: 22px;
  border-radius: 24px;
  border: 1px solid rgba(70, 88, 24, 0.14);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 24px 80px rgba(22,30,20,0.22);
  animation: archivePopoverIn 180ms ease-out;
}

@keyframes archivePopoverIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.archive-panel h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 1.25rem;
}

.archive-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.archive-heading h2 {
  margin-bottom: 8px;
}

.archive-close-btn {
  min-height: 34px;
  padding: 7px 10px;
  color: #943434;
  border-color: rgba(199, 66, 66, 0.22);
  background: rgba(255, 245, 245, 0.86);
  font-size: 0.78rem;
}

.archive-close-btn:hover {
  color: #fff;
  border-color: var(--wrong);
  background: var(--wrong);
}

.archive-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.archive-controls {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.archive-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.archive-controls select {
  min-height: 42px;
  width: 100%;
  padding: 8px 10px;
  color: var(--ink);
  border: 1px solid rgba(70, 88, 24, 0.16);
  border-radius: 12px;
  background: rgba(255,255,255,0.86);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  outline: none;
}

.archive-controls select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 107, 114, 0.12);
}

.archive-calendar {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding: 12px;
  border: 1px solid rgba(70, 88, 24, 0.12);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.88), rgba(246,248,242,0.84)),
    radial-gradient(circle at 100% 0%, rgba(15,107,114,0.08), transparent 12rem);
}

.archive-calendar-header,
.archive-calendar-weekdays,
.archive-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  align-items: center;
}

.archive-calendar-header {
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  margin-bottom: 2px;
}

.archive-calendar-header strong {
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 900;
  text-align: center;
}

.archive-calendar-header button {
  min-height: 34px;
  width: 34px;
  padding: 0;
  border-radius: 12px;
  font-size: 1.15rem;
}

.archive-calendar-header button:disabled {
  opacity: 0.35;
}

.archive-calendar-weekdays span {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.archive-calendar-day,
.archive-calendar-blank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  aspect-ratio: 1;
  padding: 0;
  color: #9aa394;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  font-size: 0.84rem;
  font-weight: 850;
}

.archive-calendar-day.empty {
  background: rgba(70, 88, 24, 0.035);
}

.archive-calendar-day.has-case {
  color: var(--ink);
  border-color: rgba(70, 88, 24, 0.12);
  background: rgba(255,255,255,0.86);
  box-shadow: 0 6px 14px rgba(22,30,20,0.06);
}

.archive-calendar-day.has-case:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.archive-calendar-day.completed {
  color: #1f6845;
  background: #edf8f2;
  border-color: rgba(37,132,87,0.22);
}

.archive-calendar-day.started {
  color: #064b52;
  background: var(--accent-soft);
  border-color: rgba(15,107,114,0.22);
}

.archive-calendar-day.active,
.archive-calendar-day.active:hover {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--correct));
  border-color: rgba(15,107,114,0.28);
  box-shadow: 0 10px 22px rgba(15,107,114,0.18);
}

.archive-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.archive-case-btn {
  position: relative;
  display: grid;
  gap: 5px;
  min-height: 86px;
  padding: 14px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: none;
}

.archive-case-btn::before {
  content: "";
  position: absolute;
  top: 12px;
  right: 12px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c4cab9;
}

.archive-case-btn:hover,
.archive-case-btn.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.archive-case-btn span {
  font-size: 0.76rem;
  font-weight: 800;
  opacity: 0.72;
}

.archive-case-btn strong {
  font-size: 0.95rem;
  line-height: 1.2;
}

.archive-case-btn em {
  width: fit-content;
  margin-top: 2px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 800;
  border-radius: 999px;
  background: rgba(70, 88, 24, 0.08);
}

.archive-case-btn:hover em,
.archive-case-btn.active em {
  color: rgba(255,255,255,0.78);
  background: rgba(255,255,255,0.14);
}

.archive-case-btn.completed:not(.active) {
  border-color: rgba(37, 132, 87, 0.28);
  background: #f3fbf6;
}

.archive-case-btn.completed::before {
  background: var(--correct);
}

.archive-case-btn.completed:not(.active) em {
  color: var(--correct);
  background: rgba(37, 132, 87, 0.1);
}

.archive-case-btn.started:not(.active) {
  border-color: rgba(15,107,114,0.22);
  background: #f0fafb;
}

.archive-case-btn.started::before {
  background: var(--accent);
}

.archive-case-btn.started:not(.active) em {
  color: var(--accent);
  background: rgba(15,107,114,0.1);
}

.archive-case-btn.started:not(.active):hover {
  color: var(--ink);
  background: #e6f5f6;
  border-color: rgba(15,107,114,0.34);
}

.archive-case-btn.started:not(.active):hover em {
  color: var(--accent);
  background: rgba(15,107,114,0.12);
}

.archive-case-btn.not-started:not(.active) {
  background: rgba(255,255,255,0.78);
}

.archive-case-btn.not-started.active,
.archive-case-btn.not-started.active:hover {
  color: var(--ink);
  background: #f7f8f2;
  border-color: rgba(70, 88, 24, 0.34);
  box-shadow: inset 0 0 0 2px rgba(70, 88, 24, 0.1);
}

.archive-case-btn.not-started.active em,
.archive-case-btn.not-started.active:hover em {
  color: var(--muted);
  background: rgba(70, 88, 24, 0.1);
}

.archive-case-btn.not-started:not(.active):hover {
  color: var(--ink);
  background: #f7f8f2;
  border-color: rgba(70, 88, 24, 0.22);
}

.archive-case-btn.not-started:not(.active):hover em {
  color: var(--muted);
  background: rgba(70, 88, 24, 0.1);
}

.archive-case-btn.completed:not(.active):hover {
  color: var(--ink);
  background: #e8f6ee;
  border-color: rgba(37, 132, 87, 0.42);
}

.archive-case-btn.completed:not(.active):hover em {
  color: var(--correct);
}

.archive-case-btn.completed.active,
.archive-case-btn.completed.active:hover {
  color: var(--ink);
  background: #e8f6ee;
  border-color: rgba(37, 132, 87, 0.46);
  box-shadow: inset 0 0 0 2px rgba(37, 132, 87, 0.16);
}

.archive-case-btn.completed.active em,
.archive-case-btn.completed.active:hover em {
  color: var(--correct);
  background: rgba(37,132,87,0.1);
}

.content-page {
  display: grid;
  gap: 18px;
}

.content-hero {
  border: 1px solid rgba(70, 88, 24, 0.14);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,255,255,0.74)),
    radial-gradient(circle at 100% 0%, rgba(15,107,114,0.13), transparent 22rem);
  box-shadow: var(--shadow-card);
}

.content-hero {
  padding: clamp(26px, 5vw, 54px);
  border-radius: 28px;
}

.content-hero h1 {
  margin: 10px 0 12px;
  color: var(--ink);
  font-size: clamp(2.8rem, 8vw, 6.2rem);
  line-height: 0.9;
  letter-spacing: -0.06em;
}

.content-hero p {
  max-width: 760px;
  margin: 0;
  color: #4e5a4c;
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  line-height: 1.6;
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: clamp(22px, 4vw, 42px);
  align-items: start;
}

.content-story {
  display: grid;
  gap: 14px;
  max-width: 760px;
}

.content-story h2,
.play-step h2,
.content-aside h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  letter-spacing: -0.035em;
}

.content-story p,
.content-aside p,
.content-aside li,
.play-step p {
  margin: 0;
  color: #455044;
  font-size: 1.02rem;
  line-height: 1.68;
}

.content-story.compact {
  max-width: none;
}

.content-aside {
  position: sticky;
  top: 18px;
  padding: 18px;
  border-left: 3px solid rgba(15, 107, 114, 0.3);
  background: rgba(255,255,255,0.56);
  border-radius: 0 18px 18px 0;
}

.content-aside ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.play-guide {
  display: grid;
  gap: 0;
  max-width: 880px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.play-step {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 18px;
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}

.play-step:last-child {
  border-bottom: 0;
}

.play-step > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  font-weight: 900;
}

.play-step div {
  display: grid;
  gap: 8px;
}

.page-cta {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.page-cta a {
  text-decoration: none;
}

.game-wrapper {
  max-width: 1020px;
  width: 100%;
  margin: 0 auto;
  background: rgba(255,255,255,0.9);
  padding: clamp(16px, 2.6vw, 28px);
  border: 1px solid rgba(83, 102, 26, 0.14);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  align-self: flex-start; 
  transition: opacity 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.game-wrapper.case-transitioning {
  opacity: 0.42;
  transform: translateY(6px);
}

.game-wrapper.case-transitioned {
  animation: caseRefresh 280ms ease-out;
}

@keyframes caseRefresh {
  from {
    opacity: 0.68;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.case-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 18px;
  align-items: end;
  text-align: left;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.case-header > div:first-child {
  min-width: 0;
}

.case-header h2 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: clamp(1.35rem, 2.25vw, 1.9rem);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.case-stats {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.stat-card {
  min-width: 116px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(248,250,244,0.86));
  box-shadow: 0 8px 24px rgba(22,30,20,0.055);
}

.stat-card span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-utility-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: 7px;
  margin-top: 2px;
}

.case-utility-row span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  color: #4d5a4b;
  border: 1px solid rgba(70, 88, 24, 0.11);
  border-radius: 999px;
  background: rgba(255,255,255,0.66);
  font-size: 0.76rem;
  font-weight: 800;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s;
}

#save-indicator,
#guesses-chip {
  display: none;
}

.case-utility-row span::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.case-utility-row span.is-saved,
.case-utility-row span.is-complete {
  color: #1f6845;
  background: #edf8f2;
  border-color: rgba(37,132,87,0.2);
  box-shadow: 0 8px 22px rgba(37,132,87,0.08);
}

.case-utility-row span.is-saved::before,
.case-utility-row span.is-complete::before {
  background: var(--correct);
}

.case-utility-row span.is-active {
  color: #064b52;
  background: var(--accent-soft);
  border-color: rgba(15,107,114,0.24);
}

.case-utility-row span.is-active::before {
  background: var(--accent);
}

.case-utility-row span.is-warning {
  color: #6d391f;
  background: var(--warm-soft);
  border-color: rgba(182,95,57,0.22);
}

.case-utility-row span.is-warning::before {
  background: var(--warm);
}

.case-utility-row span.pulse,
.hero-flow span.pulse {
  animation: progressPulse 520ms ease-out;
}

.attempt-meter {
  grid-column: 1 / -1;
  overflow: hidden;
  height: 5px;
  border-radius: 999px;
  background: rgba(70, 88, 24, 0.1);
}

.attempt-meter span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--correct));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 220ms ease;
}

.phase-tracker {
  display: none;
  grid-template-columns: auto minmax(20px, 1fr) auto minmax(20px, 1fr) auto minmax(20px, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(70, 88, 24, 0.1);
  border-radius: 16px;
  background: rgba(255,255,255,0.58);
}

.phase-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.phase-step span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.phase-step strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phase-step.active,
.phase-step.complete {
  color: var(--ink);
}

.phase-step.active span {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 5px rgba(15, 107, 114, 0.12);
}

.phase-step.complete span {
  color: #fff;
  background: var(--correct);
  border-color: var(--correct);
}

.phase-line {
  height: 2px;
  background: var(--border);
  border-radius: 999px;
}

.phase-line.complete {
  background: linear-gradient(90deg, var(--correct), var(--accent));
}

header p { margin: 4px 0 0 0; color: #718096; font-size: 0.9rem; }

.brand-logo {
  max-width: 240px; 
  height: auto;
  display: block;
  margin: 0 auto 12px auto;
}

/* --- Header Instructions Styling --- */
.header-instructions { margin-top: 8px; }
header .subtitle { font-weight: 850; color: var(--primary); margin: 0 0 5px 0; font-size: 0.92rem; }
header .instruction-text { font-size: 0.92rem; color: var(--muted); max-width: 560px; margin: 0; line-height: 1.42; }

/* --- THE IMAGE LAYOUT FIX --- */
.clinical-focus {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: -4px 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 107, 114, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(223, 241, 242, 0.74), rgba(255,255,255,0.76)),
    radial-gradient(circle at 100% 0%, rgba(166,180,106,0.16), transparent 16rem);
}

.clinical-focus > span {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.clinical-focus strong {
  color: #3d493b;
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.35;
}

.image-gallery { 
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px; 
  margin-bottom: 18px; 
  justify-content: center; 
}

#image-gallery:has(#comparison-box.hidden) {
  grid-template-columns: minmax(280px, 540px);
  justify-content: start;
}

.image-box {
  width: 100%;
  max-width: none;
  aspect-ratio: 4 / 3; 
  position: relative; 
  border: 1px solid rgba(255,255,255,0.76);
  border-radius: 18px; 
  overflow: hidden; 
  box-shadow: var(--shadow-card);
  background: #000; 
}

.image-box::after {
  content: "Click to zoom";
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 8;
  padding: 6px 9px;
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 999px;
  background: rgba(4,7,5,0.42);
  backdrop-filter: blur(10px);
  font-size: 0.72rem;
  font-weight: 850;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
}

.image-box:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.image-box img { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
  display: block; 
  cursor: pointer; 
  transition: transform 0.2s; 
  -webkit-user-drag: none;
  user-select: none;
}
.image-box img:hover { transform: scale(1.02); }

.image-label { position: absolute; top: 10px; left: 10px; background: rgba(83,102,26,0.92); color: white; padding: 6px 10px; font-size: 0.75rem; border-radius: 999px; font-weight: bold; z-index: 10; pointer-events: none; }

.clues-container {
  background:
    linear-gradient(180deg, rgba(246,247,241,0.92), rgba(255,255,255,0.72));
  padding: 16px;
  border-radius: 18px;
  margin-bottom: 18px;
  border: 1px solid var(--hairline);
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.section-heading h3,
.clues-container h3 { margin: 0; font-size: 1rem; color: var(--ink); }
.section-heading span {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 850;
}
#clues-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 0;
  font-size: 0.98rem;
  color: #455044;
  line-height: 1.55;
  list-style: none;
}

#clues-list li:not(.placeholder-text) {
  position: relative;
  padding: 11px 12px 11px 38px;
  border: 1px solid rgba(70,88,24,0.1);
  border-radius: 14px;
  background: rgba(255,255,255,0.72);
  animation: clueReveal 180ms ease-out;
}

#clues-list li:not(.placeholder-text)::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(15,107,114,0.1);
}

.placeholder-text { list-style-type: none; font-style: italic; color: #8d998a; margin-left: 0; }

/* Grid & Inputs */
.guess-grid { display: grid; gap: 7px; margin-bottom: 18px; }
.guess-row {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 11px 14px 11px 112px;
  color: #344132;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: rgba(255,255,255,0.78);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
  font-weight: 800;
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
}

.guess-row::before {
  content: attr(data-attempt);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 82px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.guess-row:empty::after {
  content: "Awaiting guess";
  color: #9ba597;
  font-weight: 750;
}

.guess-row.wrong {
  border-color: rgba(199,66,66,0.34);
  background: linear-gradient(135deg, #fff5f5, rgba(255,255,255,0.84));
  color: var(--wrong);
}

.guess-row.correct {
  border-color: rgba(37,132,87,0.34);
  background: linear-gradient(135deg, #f0fff4, rgba(255,255,255,0.84));
  color: var(--correct);
}

.guess-row.wrong::after,
.guess-row.correct::after {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 900;
}

.guess-row.wrong::after { content: "Review"; }
.guess-row.correct::after { content: "Correct"; }

.guess-feedback {
  margin: -8px 0 16px;
  padding: 12px 14px;
  border-radius: 14px;
  color: #4f382d;
  background: var(--warm-soft);
  border: 1px solid rgba(182, 95, 57, 0.22);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.45;
}

.guess-feedback.success {
  color: #184d36;
  background: #edf8f2;
  border-color: rgba(37, 132, 87, 0.24);
}

/* --- Custom Autocomplete Search Bar --- */
.autocomplete-container {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  width: 100%;
}

input[type="text"] {
  min-width: 0;
  padding: 15px 16px;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  font-size: 1rem;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 8px 24px rgba(22,30,20,0.055);
}
input[type="text"]:focus {
  outline: none;
  border-color: rgba(15,107,114,0.5);
  box-shadow: 0 0 0 4px rgba(15,107,114,0.1), 0 8px 24px rgba(22,30,20,0.055);
}

.autocomplete-list {
  position: absolute;
  /* FIX: Pops the menu upwards instead of downwards */
  bottom: 100%; 
  left: 0;
  right: 176px; 
  background-color: #fff;
  border: 1px solid rgba(83, 102, 26, 0.34);
  border-radius: 12px;
  max-height: 220px; 
  overflow-y: auto; 
  /* FIX: Shadow pushes upward now */
  box-shadow: 0 -12px 28px rgba(24,33,26,0.18); 
  z-index: 100;
  /* FIX: Margin creates space between the list and the top of the search bar */
  margin: 0 0 8px 0; 
  padding: 0;
  list-style: none;
}

.autocomplete-item {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-main);
  border-bottom: 1px solid #edf2f7;
  transition: background-color 0.2s, color 0.2s;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background-color: var(--turtle-light);
  color: white;
}

.autocomplete-item:last-child { border-bottom: none; }

.input-helper {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

button { background: var(--primary); color: white; border: none; padding: 13px 20px; border-radius: 14px; font-weight: 800; cursor: pointer; transition: background 0.2s, transform 0.2s, border-color 0.2s; font-size: 0.98rem; }
button:hover { background: #667b25; }
button:active { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
.ghost-btn {
  background: rgba(255,255,255,0.68);
  color: var(--ink);
  border: 1px solid var(--border);
}

.reset-progress-btn {
  color: #8f3434;
  border-color: rgba(199, 66, 66, 0.22);
  padding-inline: 10px;
  min-height: 30px;
  font-size: 0.8rem;
  opacity: 0.72;
}

.reset-progress-btn:hover {
  opacity: 1;
  color: #fff;
  background: var(--wrong);
  border-color: var(--wrong);
}
.review-btn {
  margin: 0 auto 20px auto;
  display: block;
  width: fit-content;
}
.secondary-btn { background: #fff; color: var(--text-main); border: 1px solid var(--border); }
.secondary-btn:hover { background: #e2e8f0; }

.secondary-btn.archive-toggle-open {
  color: #fff;
  background: var(--wrong);
  border-color: var(--wrong);
}

.secondary-btn.archive-toggle-open:hover {
  background: #a93535;
}

.clear-guess-btn {
  min-width: 76px;
  color: var(--muted);
  background: rgba(255,255,255,0.68);
}

#submit-btn.is-ready {
  background: linear-gradient(135deg, var(--primary), #6f842d);
  box-shadow: 0 12px 28px rgba(70,88,24,0.18);
}

#phase-divider { border: 0; height: 2px; background: var(--border); margin: 32px 0; }

/* Phase 2: Match Styling */
.target-section {
  text-align: center;
  margin-bottom: 24px;
  padding-top: 4px;
}
.phase-eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.target-section h3 {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  letter-spacing: -0.04em;
}
.highlight-text { color: var(--primary); }
.instruction {
  max-width: 760px;
  margin: 0 auto 16px;
  padding: 15px 16px;
  color: #24474a;
  border: 1px solid rgba(15,107,114,0.12);
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-soft), rgba(255,255,255,0.74));
  font-weight: 700;
}

.options-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; align-items: start; }

.option-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(70,88,24,0.12);
  border-radius: 20px;
  cursor: pointer;
  background: rgba(255,255,255,0.86);
  box-shadow: var(--shadow-card);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.option-card:hover:not(.eliminated) {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
  border-color: rgba(15,107,114,0.28);
}

.card-img-wrapper { position: relative; }
.option-card img { width: 100%; aspect-ratio: 4 / 3; height: auto; object-fit: cover; display: block; transition: opacity 0.3s, filter 0.3s; }

.option-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  color: #24474a;
  border-top: 1px solid rgba(70,88,24,0.08);
  background: rgba(255,255,255,0.84);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.option-status::after {
  content: "Tap to choose";
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0;
  text-transform: none;
}

.card-reveal {
  display: none;
  background: linear-gradient(180deg, #fff, #f7fafc);
  font-size: 0.85rem;
  color: #2d3748;
  text-align: left;
}
.option-card.expanded .card-reveal {
  display: block;
  max-height: none;
  padding: 12px;
  border-top: 1px solid var(--border);
  overflow: visible;
}
.review-title { font-weight: 700; color: var(--primary); display: block; margin-bottom: 6px; font-size: 0.95rem; }
.review-text { line-height: 1.4; }

.zoom-btn { position: absolute; top: 8px; right: 8px; background: rgba(255, 255, 255, 0.9); color: var(--ink); border-radius: 50%; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 20px; z-index: 10; box-shadow: 0 2px 10px rgba(0,0,0,0.18); transition: all 0.2s; padding: 0; }
.zoom-btn:hover { transform: scale(1.08); background: white; }

.option-card.correct { border-color: var(--correct); }
.option-card.disabled { pointer-events: none; }

.option-card.eliminated { border-color: rgba(199,66,66,0.36); pointer-events: none; }
.option-card.eliminated img { opacity: 0.4; filter: grayscale(80%); }
.option-card.eliminated .zoom-btn { display: none; }
.option-card.eliminated .option-status {
  color: #8f3434;
  background: rgba(199,66,66,0.86);
}
.option-card.eliminated .option-status::before { content: "Ruled out"; }
.option-card.eliminated .option-status { font-size: 0; }
.option-card.eliminated .option-status::before,
.option-card.eliminated .option-status::after { font-size: 0.78rem; color: #fff; }
.option-card.eliminated .option-status::after { content: "Review the feedback"; opacity: 0.78; }

.option-card.correct .option-status {
  color: #fff;
  background: rgba(37,132,87,0.9);
}
.option-card.correct .option-status { font-size: 0; }
.option-card.correct .option-status::before { content: "Matched"; font-size: 0.78rem; }
.option-card.correct .option-status::after { content: "Review below"; color: rgba(255,255,255,0.82); font-size: 0.72rem; }

.feedback-container {
  position: relative;
  overflow: hidden;
  padding: clamp(20px, 3vw, 28px);
  border-radius: 24px;
  margin-top: 22px;
  text-align: left;
  box-shadow: var(--shadow-card);
}

.feedback-container::after {
  content: "";
  position: absolute;
  inset: auto -14% -46% 36%;
  height: 190px;
  border-radius: 999px;
  background: rgba(255,255,255,0.42);
  transform: rotate(-8deg);
  pointer-events: none;
}

.feedback-container.success {
  background:
    linear-gradient(135deg, rgba(237,248,242,0.98), rgba(255,255,255,0.9)),
    radial-gradient(circle at 100% 0%, rgba(37,132,87,0.22), transparent 20rem);
  border: 1px solid rgba(37, 132, 87, 0.24);
  box-shadow: 0 20px 70px rgba(37,132,87,0.12);
}

.feedback-container.success::before {
  content: "Case complete";
  position: relative;
  z-index: 1;
  display: inline-flex;
  margin-bottom: 12px;
  padding: 7px 11px;
  color: #1f6845;
  border: 1px solid rgba(37,132,87,0.2);
  border-radius: 999px;
  background: rgba(255,255,255,0.72);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.feedback-container.error {
  background:
    linear-gradient(135deg, rgba(255,245,245,0.96), rgba(255,255,255,0.84)),
    radial-gradient(circle at 0% 0%, rgba(199,66,66,0.16), transparent 18rem);
  border: 1px solid rgba(199, 66, 66, 0.24);
}

.feedback-header {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.feedback-header span {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.feedback-container.error .feedback-header span {
  color: var(--wrong);
}

.feedback-container h3 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: -0.035em;
}

.feedback-container.success h3 {
  font-size: clamp(1.7rem, 3.4vw, 2.45rem);
}

.feedback-container > p {
  position: relative;
  z-index: 1;
  margin: 0 0 16px 0;
  max-width: 780px;
  font-size: 1rem;
  line-height: 1.6;
  color: #334033;
}

.educational-deep-dive {
  position: relative;
  z-index: 1;
  background: rgba(255,255,255,0.88);
  padding: 18px;
  border-radius: 18px;
  margin-top: 18px;
  border: 1px solid rgba(37, 132, 87, 0.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9);
}

.feedback-container.success .educational-deep-dive {
  border-color: rgba(37,132,87,0.2);
  box-shadow: 0 12px 34px rgba(22,30,20,0.07);
}

.educational-deep-dive h4 {
  margin: 0 0 8px 0;
  color: var(--primary);
  font-size: 0.95rem;
}

.educational-deep-dive p {
  font-size: 0.95rem;
  color: #455044;
  line-height: 1.55;
  text-align: left !important;
  margin: 0;
}

#next-case-btn {
  position: relative;
  z-index: 1;
  width: 100%;
  margin-top: 18px;
  background: var(--correct);
}

.hidden { display: none !important; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 50% 8%, rgba(223,241,242,0.18), transparent 22rem),
    rgba(8,12,9,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal:not(.hidden) {
  animation: modalBackdropIn 140ms ease-out;
}

.modal-content {
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(255,255,255,0.72);
  padding: 0;
  border-radius: 24px;
  max-width: 700px;
  width: 100%;
  max-height: min(820px, 88vh);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.32);
}

.modal:not(.hidden) .modal-content {
  animation: modalCardIn 180ms cubic-bezier(.2, .9, .25, 1);
}

.diagnosis-modal {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.diagnosis-modal-hero {
  position: relative;
  overflow: visible;
  padding: clamp(20px, 3vw, 28px);
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.96), rgba(246,248,242,0.9)),
    radial-gradient(circle at 100% 0%, rgba(15,107,114,0.1), transparent 18rem);
  border-bottom: 1px solid var(--border);
}

.diagnosis-modal-hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -44% 42%;
  height: 130px;
  border-radius: 999px;
  background: rgba(15,107,114,0.07);
  transform: rotate(-8deg);
}

.diagnosis-modal-hero span {
  position: relative;
  z-index: 1;
  display: block;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.diagnosis-modal-hero h2 {
  position: relative;
  z-index: 1;
  margin: 7px 0 6px;
  font-size: clamp(1.8rem, 4.8vw, 3rem);
  line-height: 0.96;
  letter-spacing: -0.045em;
}

.diagnosis-modal-hero p {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.45;
}

#modal-body {
  overflow-y: auto;
  padding: clamp(16px, 3vw, 22px);
}

.diagnosis-banner {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(37,132,87,0.18);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(240,255,244,0.94), rgba(255,255,255,0.9)),
    radial-gradient(circle at 100% 0%, rgba(37,132,87,0.16), transparent 14rem);
}

.diagnosis-banner span,
.teaching-card span {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.diagnosis-highlight {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.35rem, 3vw, 2.05rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.teaching-points {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.76fr);
  gap: 12px;
}

.teaching-card {
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(22,30,20,0.06);
}

.teaching-card h4 {
  color: var(--ink);
  margin: 7px 0 8px;
  font-size: 1rem;
}

.teaching-card p,
.teaching-card ul {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.48;
  color: #455044;
}

.teaching-card ul {
  display: grid;
  gap: 7px;
  padding-left: 20px;
}

.modal-buttons {
  display: flex;
  flex-shrink: 0;
  padding: 0 clamp(16px, 3vw, 22px) clamp(16px, 3vw, 22px);
  background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(255,255,255,0.98) 38%);
  border-top: 1px solid rgba(220,227,212,0.72);
  padding-top: 14px;
}

.modal-buttons button {
  width: 100%;
  min-height: 50px;
  border-radius: 16px;
  font-size: 1rem;
}

@keyframes modalBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalCardIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes clueReveal {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes progressPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(37,132,87,0.22);
  }
  50% {
    transform: scale(1.025);
    box-shadow: 0 0 0 8px rgba(37,132,87,0.08);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(37,132,87,0);
  }
}

.lightbox-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  align-items: stretch;
  justify-content: stretch;
  justify-items: stretch;
  width: 100vw;
  height: 100dvh;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(15,107,114,0.22), transparent 26rem),
    rgba(4, 7, 5, 0.92);
}

.lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  margin-bottom: 14px;
  padding: 10px 12px;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(14px);
}

.lightbox-toolbar span,
.lightbox-toolbar small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-toolbar span {
  font-weight: 900;
}

.lightbox-toolbar small {
  margin-top: 3px;
  color: rgba(255,255,255,0.62);
  font-size: 0.78rem;
}

.lightbox-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lightbox-controls button {
  width: auto;
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  color: #fff;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
}

.lightbox-controls button:hover {
  background: rgba(255,255,255,0.2);
}

.lightbox-stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 0;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.025) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.025) 25%, transparent 25%),
    #050705;
  background-size: 28px 28px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 24px 80px rgba(0,0,0,0.35);
  cursor: grab;
  touch-action: none;
}

.lightbox-stage:active {
  cursor: grabbing;
}

.lightbox-content {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: none;
  max-height: none;
  width: min(92vw, 1100px);
  height: auto;
  user-select: none;
  pointer-events: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  will-change: transform;
}

.close-lightbox {
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
}

@media (max-width: 760px) {
  body {
    padding-bottom: 96px;
  }

  .app-shell {
    width: min(100% - 16px, 680px);
    padding-top: 8px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    top: 8px;
    border-radius: 18px;
  }

  .topbar-actions {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 6px;
    padding-bottom: 2px;
  }

  .status-pill,
  .ghost-btn,
  .nav-link,
  .play-nav-link {
    padding: 7px 9px;
    font-size: 0.76rem;
  }

  .topbar-actions .status-pill,
  .topbar-actions .ghost-btn,
  .topbar-actions .nav-link,
  .topbar-actions .play-nav-link {
    width: auto;
    flex: 0 0 auto;
    min-height: 38px;
  }

  .brand-logo {
    max-width: 160px;
  }

  .image-gallery,
  .options-grid,
  .case-stats,
  .clinical-focus,
  .progress-strip,
  .completion-banner,
  .content-layout {
    grid-template-columns: 1fr;
  }

  .learner-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .learner-summary div {
    min-height: 70px;
    padding: 10px;
    border-radius: 16px;
  }

  .learner-summary span {
    font-size: 0.68rem;
  }

  .learner-summary strong {
    font-size: 1.25rem;
  }

  .login-nudge {
    display: none;
  }

  .content-aside {
    position: static;
  }

  .play-step {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
  }

  .completion-actions {
    flex-direction: column;
  }

  .phase-tracker {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px;
  }

  .phase-line {
    display: none;
  }

  .image-box {
    aspect-ratio: 4 / 3;
  }

  .autocomplete-container {
    grid-template-columns: 1fr;
  }

  #input-section {
    position: static;
    z-index: 35;
    padding: 10px;
    border: 1px solid rgba(70, 88, 24, 0.14);
    border-radius: 18px;
    background: rgba(255,255,255,0.92);
    box-shadow: 0 14px 42px rgba(22,30,20,0.18);
    backdrop-filter: blur(14px);
  }

  .autocomplete-list {
    right: 0;
    bottom: calc(100% + 8px);
  }

  button,
  input[type="text"] {
    width: 100%;
    min-height: 48px;
  }

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

  .hero-actions button {
    min-width: 0;
    padding-inline: 10px;
    font-size: 0.86rem;
  }

  .modal {
    align-items: flex-end;
    padding: 12px;
  }

  .modal-content {
    max-height: 86vh;
  }

  .teaching-points {
    grid-template-columns: 1fr;
  }

  .diagnosis-modal-hero h2 {
    font-size: clamp(2rem, 12vw, 3.2rem);
  }

  .lightbox-modal {
    align-items: stretch;
    padding: 10px;
  }

  .lightbox-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .lightbox-controls {
    width: 100%;
  }

  .lightbox-controls button {
    flex: 1;
  }

  .hero-panel,
  .archive-panel {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .hero-card {
    display: grid;
    gap: 10px;
    padding: 14px;
  }

  .hero-card-header {
    grid-template-columns: 1fr;
  }

  .hero-card small,
  .hero-sync-note {
    display: none;
  }

  .hero-copy {
    padding: 18px;
    border-radius: 20px;
  }

  .hero-copy h1 {
    font-size: clamp(2.25rem, 11vw, 2.9rem);
  }

  .hero-copy p {
    font-size: 0.94rem;
    line-height: 1.46;
  }

  .hero-flow {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .hero-flow span {
    justify-content: center;
    min-height: 38px;
    padding: 8px 6px;
    font-size: 0.78rem;
  }

  .hero-flow span::before {
    display: none;
  }

  .archive-list {
    grid-template-columns: 1fr;
  }

  .game-wrapper {
    border-radius: 20px;
    padding: 14px;
  }

  .case-header {
    gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 14px;
  }

  .case-utility-row span {
    width: 100%;
  }

  .clinical-focus p span {
    flex: 1 1 auto;
    justify-content: center;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
    align-items: center;
    padding: 6px;
  }

  .brand-lockup {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    font-size: 0.95rem;
    gap: 6px;
  }

  .brand-lockup span {
    flex: 0 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-lockup .reset-progress-btn {
    width: auto;
    min-height: 28px;
    padding: 4px 7px;
    font-size: 0.68rem;
  }

  .topbar-logo {
    width: 34px;
    height: 34px;
  }

  .topbar-play {
    grid-column: 2;
    grid-row: 1;
    min-height: 34px;
    padding: 7px 14px;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-left: 0;
    padding-bottom: 0;
    scrollbar-width: none;
  }

  .topbar-actions::-webkit-scrollbar {
    display: none;
  }

  .topbar-actions .status-pill,
  .topbar-actions .ghost-btn,
  .topbar-actions .nav-link {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 0.74rem;
  }

  .pre-game-shell {
    margin-bottom: 8px;
  }

  .hero-panel {
    margin-bottom: 8px;
  }

  .hero-copy {
    padding: 14px;
  }

  .hero-copy h1 {
    margin: 5px 0 6px;
  }

  .hero-copy p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 0.88rem;
    line-height: 1.38;
  }

  .hero-actions {
    margin-top: 10px;
  }

  .progress-strip {
    margin-bottom: 8px;
  }

  .learner-summary div {
    min-height: 58px;
    padding: 8px;
  }

  .learner-summary span {
    line-height: 1.1;
  }

  .archive-panel {
    position: static;
    width: 100%;
    margin: 0 0 10px;
    padding: 8px;
    border-radius: 20px;
  }

  .archive-heading {
    align-items: center;
  }

  .archive-close-btn {
    width: auto;
    min-height: 38px;
    padding-inline: 12px;
  }

  .archive-controls {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .archive-calendar {
    grid-column: 1 / -1;
  }

  .archive-controls select {
    min-height: 42px;
    padding: 8px;
    font-size: 0.86rem;
  }

  .archive-calendar {
    padding: 2px;
    border-radius: 16px;
  }

  .archive-calendar-header,
  .archive-calendar-weekdays,
  .archive-calendar-grid {
    gap: 2px;
  }

  .archive-calendar-header button {
    width: 38px;
    min-height: 38px;
  }

  .archive-calendar-weekdays span {
    font-size: 0.58rem;
  }

  .archive-calendar-day,
  .archive-calendar-blank {
    min-height: 44px;
    border-radius: 11px;
  }

  .archive-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .archive-case-btn {
    min-height: 72px;
    padding: 10px;
    border-radius: 14px;
  }

  .archive-case-btn strong {
    font-size: 0.82rem;
  }

  .archive-case-btn span,
  .archive-case-btn em {
    font-size: 0.7rem;
  }

  .game-wrapper {
    padding: 12px;
  }

  .case-header h2 {
    font-size: clamp(1.35rem, 7vw, 1.8rem);
  }

  .case-header {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 8px;
  }

  header .instruction-text {
    font-size: 0.86rem;
    line-height: 1.38;
  }

  .case-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .stat-card {
    min-width: 0;
    padding: 9px 8px;
    border-radius: 12px;
  }

  .stat-card span {
    margin-bottom: 4px;
    font-size: 0.62rem;
    letter-spacing: 0.045em;
  }

  .stat-card strong {
    font-size: 0.82rem;
  }

  .case-utility-row {
    gap: 6px;
  }

  .case-utility-row span {
    min-height: 26px;
    padding: 4px 8px;
    font-size: 0.72rem;
  }

  #guesses-chip {
    display: none;
  }

  .phase-step {
    min-height: 34px;
    padding: 4px 6px;
    border-radius: 12px;
    background: rgba(255,255,255,0.58);
  }

  .phase-step span {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  .clinical-focus {
    padding: 12px;
    border-radius: 16px;
  }

  .clinical-focus strong {
    font-size: 0.92rem;
  }

  .clinical-focus p {
    gap: 5px;
  }

  .clinical-focus p span {
    min-height: 28px;
    padding: 5px 7px;
    font-size: 0.76rem;
  }

  #image-gallery:has(#comparison-box.hidden),
  .image-gallery {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .image-box {
    border-radius: 16px;
  }

  .image-label {
    max-width: calc(100% - 72px);
    font-size: 0.68rem;
  }

  .image-box::after {
    opacity: 1;
    transform: none;
    padding: 5px 8px;
    font-size: 0.66rem;
  }

  #input-section {
    gap: 8px;
    padding: 8px;
  }

  #input-section input,
  #input-section button {
    min-height: 44px;
  }

  .autocomplete-list {
    max-height: 42vh;
  }

  .options-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .option-card {
    border-radius: 16px;
  }

  .option-status {
    min-height: 42px;
    padding: 8px;
    font-size: 0.68rem;
    letter-spacing: 0.025em;
  }

  .option-status::after {
    font-size: 0.66rem;
  }

  .zoom-btn {
    width: 32px;
    height: 32px;
    min-height: 32px;
  }

  .option-card.expanded {
    grid-column: 1 / -1;
  }

  .option-card.expanded .card-reveal {
    max-height: none;
    padding: 10px;
    overflow: visible;
  }

  .feedback-container {
    padding: 18px;
    border-radius: 20px;
  }

  .feedback-container.success h3 {
    font-size: clamp(1.45rem, 8vw, 2rem);
  }

  .feedback-container > p,
  .educational-deep-dive p {
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .educational-deep-dive {
    padding: 14px;
    border-radius: 16px;
  }

  .modal-content {
    width: 100%;
    max-height: 82dvh;
    padding: 18px;
    border-radius: 24px 24px 18px 18px;
  }

  .diagnosis-modal-hero {
    padding: 14px 16px;
    border-radius: 20px;
  }

  .diagnosis-modal-hero h2 {
    margin-bottom: 4px;
    line-height: 1.04;
  }

  .diagnosis-modal-hero p {
    font-size: 0.86rem;
    line-height: 1.35;
  }

  .diagnosis-banner {
    padding: 14px;
    border-radius: 18px;
  }

  .diagnosis-banner h3 {
    font-size: clamp(1.55rem, 8vw, 2.25rem);
  }

  .teaching-card {
    padding: 14px;
    border-radius: 18px;
  }

  .modal-buttons {
    position: sticky;
    bottom: -18px;
    padding-top: 10px;
    background: linear-gradient(180deg, rgba(255,255,255,0), #fff 28%);
  }

  .lightbox-modal {
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    padding: 8px;
  }

  .lightbox-toolbar {
    width: 100%;
    min-width: 0;
    min-height: 0;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px;
    border-radius: 16px;
  }

  .lightbox-toolbar > div:first-child {
    width: 100%;
    min-width: 0;
  }

  .lightbox-toolbar span,
  .lightbox-toolbar small {
    white-space: normal;
  }

  .lightbox-toolbar small {
    display: none;
  }

  .lightbox-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    gap: 6px;
  }

  .lightbox-controls button {
    width: auto;
    min-width: 0;
    min-height: 40px;
    height: 40px;
    padding: 0 8px;
    font-size: 0.86rem;
  }

  .close-lightbox {
    font-size: 22px !important;
  }

  .lightbox-stage {
    width: 100%;
    min-width: 0;
    border-radius: 18px;
  }

  .lightbox-content {
    width: calc(100% - 12px);
    height: calc(100% - 12px);
    max-width: none;
    object-fit: contain;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
