/* ============================================================
 *  FIELD SENSE - Stylesheet
 *
 *  Design philosophy:
 *  - One screen per lesson. No long-scroll documents.
 *  - Two-column on desktop (field left, content right).
 *  - Stacked on mobile (field on top, content below).
 *  - Subtle animations. Purposeful, never gratuitous.
 *  - Google brand palette: blue=us, red=them/danger, green=opportunity.
 *  - Serif for headings, sans for body and labels.
 * ============================================================ */

/* ---------------- 1. Design tokens ---------------- */

:root {
  /* Surface */
  --paper:        #ffffff;
  --paper-shade:  #f8f9fa;
  --paper-deep:   #f1f3f4;
  --border:       #e8eaed;
  --border-soft:  #f1f3f4;

  /* Ink */
  --ink:        #202124;
  --ink-soft:   #5f6368;
  --ink-faint:  #9aa0a6;

  /* Brand */
  --our:        #1a73e8;
  --our-soft:   #8ab4f8;
  --our-tint:   #e8f0fe;
  --their:      #ea4335;
  --their-soft: #f28b82;
  --their-tint: #fce8e6;

  /* Field */
  --field:        #2d7a3e;
  --field-deep:   #1f5a2c;
  --field-line:   #ffffff;
  --field-stripe: rgba(0, 0, 0, 0.04);

  /* Semantic */
  --danger:       #ea4335;
  --opportunity:  #6abf7a;
  --opp-bright:   #34a853;
  --accent:       #fbbc04;
  --correct:      #34a853;
  --wrong:        #ea4335;
  --correct-tint: #e6f4ea;
  --wrong-tint:   #fce8e6;

  /* Elevation (Google Material-ish) */
  --shadow-sm: 0 1px 2px rgba(60, 64, 67, 0.1);
  --shadow:    0 1px 2px rgba(60, 64, 67, 0.1), 0 2px 6px 2px rgba(60, 64, 67, 0.08);
  --shadow-md: 0 1px 3px rgba(60, 64, 67, 0.12), 0 4px 12px 2px rgba(60, 64, 67, 0.1);
  --shadow-lg: 0 4px 8px rgba(60, 64, 67, 0.1), 0 12px 28px rgba(60, 64, 67, 0.15);

  /* Type */
  --font-head: 'Roboto Slab', Georgia, serif;
  --font-body: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;

  /* Layout */
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --gutter:    24px;
  --gutter-sm: 16px;
}

/* ---------------- 2. Reset & base ---------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper-shade);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 500;
  line-height: 1.2;
}
p { margin: 0; }
button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}
button:focus-visible {
  outline: 2px solid var(--our);
  outline-offset: 2px;
}
a {
  color: var(--our);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* Reduced-motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------- 3. App shell ---------------- */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.noscript-message {
  padding: 48px 24px;
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.boot-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px 24px;
  flex: 1;
  color: var(--ink-faint);
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.boot-mark {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--field);
  position: relative;
}
.boot-mark::before, .boot-mark::after {
  content: ""; position: absolute; background: white;
}
.boot-mark::before { left: 50%; top: 8px; bottom: 8px; width: 2px; transform: translateX(-50%); }
.boot-mark::after  { top: 50%; left: 8px; right: 8px; height: 2px; transform: translateY(-50%); }

/* ---------------- 4. Top bar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  /* Safe area for notched devices */
  padding-top: max(14px, env(safe-area-inset-top));
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 6px;
  transition: background 0.15s ease;
}
.brand:hover { background: var(--paper-shade); }
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: var(--field);
  position: relative;
  flex-shrink: 0;
}
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; background: white;
}
.brand-mark::before { left: 50%; top: 6px; bottom: 6px; width: 2px; transform: translateX(-50%); }
.brand-mark::after  { top: 50%; left: 6px; right: 6px; height: 2px; transform: translateY(-50%); }
.brand-text {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
}
.brand-chapter {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--ink-soft);
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--paper-shade); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

/* Hide chapter label on very small screens */
@media (max-width: 480px) {
  .brand-text { font-size: 15px; }
  .brand-chapter { display: none; }
  .topbar { padding-left: 16px; padding-right: 16px; }
}

/* ---------------- 5. Progress bar ---------------- */

.progress-bar {
  height: 3px;
  background: var(--border-soft);
  position: relative;
  overflow: hidden;
}
.progress-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--our);
  width: 0%;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------------- 6. Welcome screen ---------------- */

.welcome {
  max-width: 720px;
  margin: 0 auto;
  padding: 64px 24px 48px;
  text-align: center;
}
.welcome-eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 20px;
}
.welcome-title {
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}
.welcome-title em {
  font-style: italic;
  color: var(--field-deep);
}
.welcome-lede {
  font-size: clamp(16px, 2vw, 18px);
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 560px;
  margin: 0 auto 36px;
}
.welcome-lede em {
  font-style: italic;
  color: var(--ink);
}
.welcome-lede strong {
  color: var(--ink);
}
.welcome-art {
  max-width: 560px;
  margin: 0 auto 40px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--field);
  padding: 16px;
}
.welcome-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 48px;
}
.welcome-cta-hint {
  font-size: 13px;
  color: var(--ink-faint);
}

.chapter-list {
  margin-top: 24px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  text-align: left;
}
.chapter-list-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 16px;
  text-align: center;
}
.chapter-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 16px;
  align-items: baseline;
  width: 100%;
  padding: 14px 12px;
  border-radius: 8px;
  text-align: left;
  transition: background 0.15s ease;
}
.chapter-item:hover { background: var(--paper-shade); }
.chapter-item-num {
  font-family: var(--font-head);
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.1em;
}
.chapter-item-title {
  font-family: var(--font-head);
  font-size: 17px;
  color: var(--ink);
}
.chapter-item-meta {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.welcome-footer {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--ink-faint);
}
.welcome-footer-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------------- Welcome: what-the-app-is ---------------- */

.welcome-what {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-faint);
  max-width: 540px;
  margin: -20px auto 24px;
  padding: 0 12px;
}

/* ---------------- Welcome: continue banner ---------------- */

.continue-banner {
  display: block;
  width: 100%;
  max-width: 560px;
  margin: 8px auto 24px;
  padding: 18px 24px;
  background: var(--our-tint);
  border: 1px solid var(--our-soft);
  border-radius: var(--radius-lg);
  text-align: left;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
  cursor: pointer;
}
.continue-banner:hover {
  background: #d6e4fc;
  border-color: var(--our);
}
.continue-banner:active { transform: scale(0.99); }
.continue-banner-eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--our);
  margin-bottom: 6px;
}
.continue-banner-title {
  font-family: var(--font-head);
  font-size: 19px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}
.continue-banner-meta {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

/* ---------------- Welcome: chapter completion state ---------------- */

.chapter-item.is-complete {
  background: var(--correct-tint);
}
.chapter-item.is-complete .chapter-item-num {
  color: var(--correct);
}
.chapter-item-check {
  display: inline-block;
  vertical-align: middle;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  color: var(--correct);
}

/* ---------------- Welcome: extras row ---------------- */

.extras-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 28px;
  flex-wrap: wrap;
}
.text-link {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  background: none;
  padding: 6px 4px;
  border-radius: 4px;
  transition: color 0.15s ease;
}
.text-link:hover { color: var(--our); }

/* ---------------- Audio toggle active state ---------------- */

.icon-btn.is-active {
  color: var(--our);
  background: var(--our-tint);
}
.icon-btn.is-active:hover {
  background: #d6e4fc;
  color: var(--our);
}

/* ---------------- Recap view ---------------- */

.recap-view {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px 64px;
}
.recap-eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--correct);
  margin-bottom: 12px;
}
.recap-title {
  font-size: clamp(28px, 4vw, 36px);
  font-weight: 600;
  margin-bottom: 12px;
}
.recap-subtitle {
  font-size: 15px;
  color: var(--ink-soft);
  margin-bottom: 32px;
  line-height: 1.5;
}
.recap-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 32px;
}
.recap-row {
  display: grid;
  grid-template-columns: 32px 1fr 24px;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.recap-row:hover {
  background: var(--paper-shade);
  border-color: var(--our-soft);
}
.recap-row:active { transform: scale(0.99); }
.recap-row-num {
  font-family: var(--font-head);
  font-size: 13px;
  color: var(--ink-faint);
  text-align: center;
}
.recap-row-title {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 2px;
}
.recap-row-concept {
  font-family: var(--font-head);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.4;
}
.recap-row-jump {
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  justify-content: center;
}
.recap-row:hover .recap-row-jump {
  color: var(--our);
}
.recap-actions {
  display: flex;
  justify-content: center;
}

/* ---------------- Reference view ---------------- */

.reference-view {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 64px;
}
.reference-eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}
.reference-title {
  font-size: clamp(26px, 4vw, 32px);
  font-weight: 600;
  margin-bottom: 12px;
}
.reference-subtitle {
  font-size: 15px;
  color: var(--ink-soft);
  margin-bottom: 28px;
  line-height: 1.55;
}
.reference-subtitle em { font-style: italic; }
.reference-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}
.reference-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.reference-row:last-child { border-bottom: none; }
.reference-name {
  font-family: var(--font-head);
  font-size: 15px;
  color: var(--ink);
  text-align: right;
}
.reference-abbr {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.1em;
  margin-left: 6px;
}
.reference-arrow {
  color: var(--ink-faint);
}
.reference-family {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.reference-family.family-defender   { color: var(--our); }
.reference-family.family-midfielder { color: var(--ink); }
.reference-family.family-forward    { color: var(--their); }
.reference-family.family-goalkeeper { color: #b8860b; }
.reference-footnote {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.55;
  padding: 16px 20px;
  background: var(--paper-shade);
  border-left: 3px solid var(--our);
  border-radius: 4px;
}
.reference-footnote strong { color: var(--ink); }

/* ---------------- 7. Lesson layout ---------------- */

.lesson {
  flex: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}

.lesson-stage {
  flex: 1;
  display: grid;
  /* Desktop: two columns. Mobile media query collapses below. */
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 32px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  align-items: start;
  min-height: 0;
}

.lesson-visual {
  position: sticky;
  top: 70px; /* clear of topbar */
  align-self: start;
}

.lesson-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lesson-eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.lesson-title {
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.lesson-explain {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
}
.lesson-explain strong { color: var(--ink); font-weight: 700; }
.lesson-explain em { font-style: italic; color: var(--ink-soft); }
.lesson-explain p { margin-bottom: 12px; }
.lesson-explain p:last-child { margin-bottom: 0; }

.concept-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 18px 20px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.concept-card-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.concept-card-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.concept-card-body {
  font-family: var(--font-head);
  font-style: italic;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.4;
}

/* ---------------- 8. Field ---------------- */

.field {
  background: var(--field);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.field svg {
  display: block;
  width: 100%;
  height: auto;
}

.field-banner {
  position: absolute;
  top: 16px;
  left: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--paper);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  z-index: 2;
}
.field-banner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.field-banner-dot.ours { background: var(--our); }
.field-banner-dot.theirs { background: var(--their); }

.field-legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  justify-content: center;
}
.field-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}
.field-legend-swatch.danger { background: var(--danger); }
.field-legend-swatch.score { background: var(--opportunity); }

/* SVG field elements */
.zone-funnel-danger {
  fill: var(--danger);
  fill-opacity: 0.25;
  pointer-events: none;
}
.zone-funnel-opportunity {
  fill: var(--opportunity);
  fill-opacity: 0.55;
  pointer-events: none;
}
.zone-box-danger {
  fill: var(--danger);
  fill-opacity: 0.45;
  stroke: var(--danger);
  stroke-width: 3;
  stroke-opacity: 1;
  animation: pulse-danger 2.6s ease-in-out infinite;
  pointer-events: none;
}
.zone-box-opportunity {
  fill: var(--opportunity);
  fill-opacity: 0.7;
  stroke: var(--opportunity);
  stroke-width: 3;
  stroke-opacity: 1;
  animation: pulse-opp 2.6s ease-in-out infinite;
  animation-delay: 1.3s;
  pointer-events: none;
}
@keyframes pulse-danger {
  0%, 100% { fill-opacity: 0.35; }
  50%      { fill-opacity: 0.55; }
}
@keyframes pulse-opp {
  0%, 100% { fill-opacity: 0.55; }
  50%      { fill-opacity: 0.75; }
}

.field-line { stroke: var(--field-line); stroke-width: 2; fill: none; }
.field-stripe { fill: var(--field-stripe); }

.player-circle {
  stroke: white;
  stroke-width: 2;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}
.player-circle.us { fill: var(--our); }
.player-circle.them { fill: var(--their); }
.player-label {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11px;
  fill: white;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.player-you-highlight {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  filter: drop-shadow(0 0 4px var(--accent));
  pointer-events: none;
}
.you-pointer {
  fill: var(--paper);
  stroke: var(--accent);
  stroke-width: 1.5;
}
.you-pointer-text {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 10px;
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: 0.05em;
}

.ball {
  fill: white;
  stroke: #333;
  stroke-width: 1.5;
}
.arrow-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 6 4;
}
.arrow-path.good { stroke: var(--correct); }
.arrow-path.bad { stroke: var(--wrong); }
.arrow-label {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 10px;
  fill: white;
  text-anchor: middle;
  letter-spacing: 0.04em;
}
.arrow-label-bg { fill: rgba(0,0,0,0.5); }

.wall-line {
  stroke: var(--our);
  stroke-width: 4;
  stroke-linecap: round;
  fill: none;
  opacity: 0.75;
  stroke-dasharray: 8 4;
}
.line-band {
  fill: rgba(255,255,255,0.08);
  stroke: rgba(255,255,255,0.4);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}
.line-band-label {
  font-family: var(--font-body);
  font-size: 10px;
  fill: white;
  text-anchor: middle;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
}

.goal-label {
  font-family: var(--font-body);
  font-size: 10px;
  fill: white;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.8;
}

/* Outcome banner inside the SVG */
.outcome-banner-bg {
  fill: var(--paper);
  stroke: var(--border);
  stroke-width: 1;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.25));
}
.outcome-banner-text {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: 0.04em;
}

/* Legacy "Here's what should have happened" interrupt - kept for backward
   compat but no longer actively used. See .focus-overlay below. */
.replay-interrupt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.replay-interrupt.is-visible { opacity: 1; }
.replay-interrupt::before {
  content: "";
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
  border-radius: var(--radius);
}
.replay-card {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 24px 32px;
  text-align: center;
  max-width: 80%;
  box-shadow: var(--shadow-lg);
  border-top: 4px solid var(--correct);
  transform: scale(0.92);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.replay-interrupt.is-visible .replay-card { transform: scale(1); }
.replay-card-eyebrow {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--correct);
  margin-bottom: 8px;
}
.replay-card-text {
  font-family: var(--font-head);
  font-size: clamp(18px, 2.2vw, 22px);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

/* ---------------- Focused-field overlay ----------------
   When the kid taps an answer, the page dims and the field lifts
   into the center of the screen with an outcome badge above it.
   The animation plays there so the kid never has to scroll.
   Auto-releases back to the normal page when done.
*/
.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 20, 25, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.35s ease;
  overflow-y: auto;
}
.focus-overlay.is-visible { opacity: 1; }
.focus-overlay.is-leaving { opacity: 0; }

.focus-stage {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  width: 100%;
  max-width: 640px;
  transform: scale(0.96);
  transition: transform 0.35s cubic-bezier(0.34, 1.35, 0.65, 1);
}
.focus-overlay.is-visible .focus-stage { transform: scale(1); }

.focus-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  align-self: center;
  padding: 10px 20px;
  border-radius: 999px;
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--paper);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  animation: focus-badge-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.focus-badge-icon {
  display: inline-flex;
  width: 22px; height: 22px;
  align-items: center;
  justify-content: center;
}
.focus-badge-icon svg { width: 22px; height: 22px; }
.focus-badge-correct {
  background: var(--correct-tint);
  color: var(--correct);
}
.focus-badge-wrong {
  background: var(--wrong-tint);
  color: var(--wrong);
}
.focus-badge-correction {
  background: var(--our-tint);
  color: var(--our);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 18px;
}
@keyframes focus-badge-in {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.focus-field-wrap {
  width: 100%;
}
.focus-content-wrap {
  width: 100%;
}
.focus-field {
  /* Larger, more prominent than the inline field, but still readable */
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.focus-field svg {
  max-height: 55vh;
}

.focus-decoder {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  max-height: 60vh;
  overflow-y: auto;
}
.focus-decoder .decoder-card {
  border: none;
  box-shadow: none;
  padding: 0;
  background: transparent;
  max-height: none;
  overflow: visible;
}

.focus-custom {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  max-height: 60vh;
  overflow-y: auto;
}
.focus-custom .custom-visual {
  background: transparent;
  padding: 0;
  border: none;
}

/* Caption text below the stage - for lessons where we want to reinforce
   the answer's key phrase alongside the visual highlight */
.focus-caption {
  align-self: center;
  color: white;
  font-family: 'Roboto Slab', Georgia, serif;
  font-size: clamp(16px, 2.2vw, 20px);
  font-weight: 500;
  text-align: center;
  line-height: 1.4;
  max-width: 480px;
  padding: 0 8px;
  animation: focus-caption-in 0.5s ease;
}
@keyframes focus-caption-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.focus-caption em {
  font-style: italic;
  color: #fbbc04;
}

/* Highlighted state for demo elements (decoder rows, level cards, etc.) */
.demo-active {
  background: rgba(251, 188, 4, 0.18) !important;
  outline: 3px solid #fbbc04;
  outline-offset: -2px;
  border-radius: 6px;
  animation: demo-pulse-el 1.4s ease-in-out infinite;
  transition: background 0.3s ease;
}
@keyframes demo-pulse-el {
  0%, 100% { outline-color: rgba(251, 188, 4, 1); }
  50%      { outline-color: rgba(251, 188, 4, 0.4); }
}

/* SVG-level pulses used by zone/lane/spot highlights */
@keyframes demo-pulse {
  0%, 100% { fill-opacity: 0.35; }
  50%      { fill-opacity: 0.6; }
}
@keyframes demo-ring {
  0%   { r: 22; opacity: 1; }
  100% { r: 40; opacity: 0; }
}

/* Action buttons that appear once the demo has finished playing.
   The overlay stays open until the kid taps one - no auto-close. */
.focus-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  animation: focus-actions-in 0.4s ease;
}
@keyframes focus-actions-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.focus-close-btn, .focus-replay-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.15s ease, transform 0.1s ease, color 0.15s ease;
  min-height: 44px;
  white-space: nowrap;
}
.focus-close-btn {
  background: white;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.focus-close-btn:hover { background: #f5f5f5; }
.focus-close-btn:active { transform: scale(0.97); }
.focus-replay-btn {
  background: rgba(255, 255, 255, 0.14);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.focus-replay-btn:hover { background: rgba(255, 255, 255, 0.22); }
.focus-replay-btn:active { transform: scale(0.97); }
.focus-replay-btn svg, .focus-close-btn svg {
  width: 14px; height: 14px;
}

/* Feedback highlight: when it first appears, it pulses softly so the kid's
   eye lands on it when the overlay releases. */
.feedback.just-revealed {
  animation: feedback-pulse 1.2s ease;
}
@keyframes feedback-pulse {
  0%   { background-color: var(--paper); }
  30%  { background-color: rgba(26, 115, 232, 0.12); }
  100% { background-color: inherit; }
}

/* Reduced-motion: no scale animations, faster transitions */
@media (prefers-reduced-motion: reduce) {
  .focus-overlay { transition: opacity 0.15s ease; }
  .focus-stage { transform: none; transition: none; }
  .focus-badge { animation: none; }
  .feedback.just-revealed { animation: none; }
  .demo-active { animation: none; }
  .focus-caption { animation: none; }
}

/* Small phones: tighter padding, smaller field, smaller badge */
@media (max-width: 560px) {
  .focus-overlay { padding: 16px; }
  .focus-stage { gap: 12px; }
  .focus-badge { font-size: 14px; padding: 8px 16px; }
  .focus-badge-correction { font-size: 12px; }
  .focus-field { padding: 12px; }
  .focus-field svg { max-height: 50vh; }
  .focus-decoder, .focus-custom { padding: 16px; max-height: 55vh; }
  .focus-caption { font-size: 15px; }
}

/* ---------------- 9. Custom-visual lessons (Chapter 5) ---------------- */

.custom-visual {
  background: var(--paper-shade);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
}

.big-quote {
  font-family: var(--font-head);
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
  text-align: center;
  padding: 16px 0;
}
.big-quote em {
  color: var(--our);
  font-style: italic;
}

.level-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.level-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 18px;
  align-items: flex-start;
  padding: 16px;
  background: var(--paper);
  border-radius: 8px;
  border-left: 4px solid var(--border);
}
.level-row.level-active {
  border-left-color: var(--our);
  background: var(--our-tint);
}
.level-num {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 600;
  color: var(--ink-faint);
  line-height: 1;
}
.level-row.level-active .level-num { color: var(--our); }
.level-name {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}
.level-desc {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.5;
}
.level-quote {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 13px;
  margin-top: 6px;
}

.ladder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ladder-step {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  padding: 14px 16px;
  background: var(--paper);
  border-radius: 8px;
  border-left: 4px solid var(--border);
  align-items: center;
}
.ladder-step.is-current {
  border-left-color: var(--accent);
  background: rgba(251, 188, 4, 0.08);
}
.ladder-title {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 500;
}
.ladder-meta {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.practice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.practice-item {
  background: var(--paper);
  border-radius: 8px;
  padding: 14px 16px;
  border-left: 4px solid var(--our);
}
.practice-title {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}
.practice-desc {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* ---------------- 10. Decoder (position-name chart) ---------------- */

.decoder-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.decoder-head {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 14px;
  text-align: center;
}
.decoder-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.decoder-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.decoder-row:last-child { border-bottom: none; }
.decoder-name {
  font-family: var(--font-head);
  font-size: 14px;
  color: var(--ink);
  text-align: right;
}
.decoder-abbr {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.1em;
}
.decoder-arrow {
  color: var(--ink-faint);
  font-size: 14px;
}
.decoder-family {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.decoder-family.family-defender   { color: var(--our); }
.decoder-family.family-midfielder { color: var(--ink); }
.decoder-family.family-forward    { color: var(--their); }
.decoder-family.family-goalkeeper { color: var(--accent); }

/* ---------------- 11. Question + answers ---------------- */

.question-block {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.question-prompt {
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
}

.options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.option {
  display: grid;
  grid-template-columns: 28px 1fr 22px;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: left;
  transition: all 0.15s ease;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.4;
}
.option:not(:disabled):hover {
  border-color: var(--our-soft);
  background: var(--our-tint);
}
.option:not(:disabled):active {
  transform: scale(0.98);
  background: var(--our-tint);
}
.option:disabled { cursor: default; }
.option-marker {
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  text-align: center;
}
.option-text { min-width: 0; }
.option-check {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.option-check svg { width: 18px; height: 18px; opacity: 0; transition: opacity 0.2s ease; }

.option.correct {
  border-color: var(--correct);
  background: var(--correct-tint);
}
.option.correct .option-marker { color: var(--correct); }
.option.correct .option-check svg { opacity: 1; color: var(--correct); }

.option.wrong {
  border-color: var(--wrong);
  background: var(--wrong-tint);
}
.option.wrong .option-marker { color: var(--wrong); }
.option.wrong .option-check svg { opacity: 1; color: var(--wrong); }

.feedback {
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  display: none;
}
.feedback.is-visible { display: block; }
.feedback.correct {
  background: var(--correct-tint);
  border-left: 4px solid var(--correct);
}
.feedback.wrong {
  background: var(--wrong-tint);
  border-left: 4px solid var(--wrong);
}
.feedback-head {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.feedback.correct .feedback-head { color: var(--correct); }
.feedback.wrong .feedback-head { color: var(--wrong); }
.feedback-body { color: var(--ink); }

/* ---------------- 12. Lesson navigation footer ---------------- */

.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--paper);
  border-top: 1px solid var(--border);
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.lesson-nav-progress {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------------- 13. Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  min-height: 40px;
  white-space: nowrap;
}
.btn-primary {
  background: var(--our);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: #1557b0;
}
.btn-primary:active:not(:disabled) {
  background: #174ea6;
  transform: scale(0.97);
}
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--paper-shade);
  color: var(--ink);
}
.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--paper-shade); }
.btn-large {
  padding: 14px 28px;
  font-size: 15px;
  min-height: 48px;
  letter-spacing: 0.04em;
}

.btn-stripe {
  background: #635bff;
  color: white;
}
.btn-stripe:hover { background: #5048e6; }
.btn-kofi {
  background: #ff5e5b;
  color: white;
}
.btn-kofi:hover { background: #e84c49; }

/* ---------------- 14. Lesson transitions ---------------- */

.lesson-stage {
  animation: lesson-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes lesson-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------------- 15. Index (All Concepts) view ---------------- */

.concepts-view {
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 24px;
}
.concepts-title {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 8px;
}
.concepts-subtitle {
  font-size: 15px;
  color: var(--ink-soft);
  margin-bottom: 32px;
}
.concepts-chapter {
  margin-bottom: 32px;
}
.concepts-chapter-head {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.concepts-chapter-name {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}
.concepts-row {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  width: 100%;
  border-radius: 6px;
  transition: background 0.15s ease;
}
.concepts-row:hover { background: var(--paper-shade); }
.concepts-row:last-child { border-bottom: none; }
.concepts-row-num {
  font-family: var(--font-head);
  font-size: 13px;
  color: var(--ink-faint);
}
.concepts-row-title {
  font-family: var(--font-head);
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 2px;
}
.concepts-row-concept {
  font-family: var(--font-head);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------------- 16. Finish view ---------------- */

.finish-view {
  max-width: 640px;
  margin: 0 auto;
  padding: 80px 24px;
  text-align: center;
}
.finish-eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--correct);
  margin-bottom: 16px;
}
.finish-title {
  font-size: clamp(32px, 5vw, 44px);
  font-weight: 600;
  margin-bottom: 16px;
}
.finish-message {
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin-bottom: 32px;
}
.finish-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ============================================================
 *  RESPONSIVE: Mobile layout
 * ============================================================ */

@media (max-width: 900px) {
  .lesson-stage {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px 16px;
  }
  .lesson-visual {
    position: static;
  }
  .lesson-content {
    gap: 16px;
  }
  .lesson-title {
    font-size: 22px;
  }
  .lesson-explain {
    font-size: 15px;
  }
}

@media (max-width: 560px) {
  .welcome {
    padding: 40px 20px 32px;
  }
  .welcome-title {
    font-size: 32px;
  }
  .welcome-lede {
    font-size: 15px;
  }
  .topbar {
    padding: 12px 16px;
  }
  .field {
    padding: 12px;
  }
  .field-banner {
    top: 12px; left: 12px;
    font-size: 9px;
    padding: 4px 8px;
  }
  .field-legend {
    font-size: 10px;
    gap: 12px;
  }
  .lesson-stage {
    padding: 16px 12px;
    gap: 16px;
  }
  .question-block {
    padding: 16px;
  }
  .question-prompt {
    font-size: 15px;
  }
  .option {
    padding: 12px;
    font-size: 14px;
  }
  .lesson-nav {
    padding: 12px 16px;
  }
  .btn-large {
    padding: 12px 22px;
    font-size: 14px;
  }
  .concepts-view {
    padding: 32px 16px;
  }
  .finish-view {
    padding: 56px 20px;
  }
  .recap-view {
    padding: 36px 16px 48px;
  }
  .reference-view {
    padding: 32px 16px 48px;
  }
  .continue-banner {
    padding: 16px 18px;
  }
  .continue-banner-title {
    font-size: 17px;
  }
  .recap-row {
    padding: 12px 14px;
    grid-template-columns: 28px 1fr 20px;
    gap: 10px;
  }
  .recap-row-title { font-size: 14px; }
  .recap-row-concept { font-size: 12px; }
  .reference-card { padding: 12px 14px; }
  .reference-row {
    grid-template-columns: 1fr auto 1fr;
    gap: 10px;
    padding: 8px 2px;
  }
  .reference-name { font-size: 13px; }
  .reference-abbr { font-size: 10px; }
  .reference-family { font-size: 10px; }
  .reference-footnote { font-size: 13px; padding: 12px 14px; }
  .welcome-what { font-size: 13px; margin: -16px auto 20px; }
}

/* Landscape phone: short screens, the field shouldn't dominate. Constrain its height. */
@media (max-height: 500px) and (orientation: landscape) {
  .lesson-stage {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding: 12px 16px;
    gap: 16px;
  }
  .lesson-visual {
    position: sticky;
    top: 60px;
  }
  .field svg {
    max-height: 50vh;
    width: auto;
    margin: 0 auto;
    display: block;
  }
  .field {
    padding: 12px;
  }
  .lesson-title {
    font-size: 20px;
  }
  .lesson-explain {
    font-size: 14px;
  }
}
