:root {
  color-scheme: light;
  --ink: #1c1913;
  --muted: #756c5b;
  --paper: #fffaf0;
  --paper-strong: #fff4d9;
  --blue: #284bff;
  --red: #f04d3a;
  --green: #227a4d;
  --gold: #e7ad34;
  --line: rgba(28, 25, 19, 0.14);
  --shadow: 0 30px 90px rgba(53, 39, 14, 0.18);
  --display: 'Fraunces', Georgia, serif;
  --body: 'Nunito Sans', Verdana, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  font-family: var(--body);
  background:
    linear-gradient(135deg, rgba(40, 75, 255, 0.08) 0 25%, transparent 25% 100%),
    radial-gradient(circle at 8% 10%, rgba(240, 77, 58, 0.28), transparent 28rem),
    radial-gradient(circle at 88% 12%, rgba(231, 173, 52, 0.35), transparent 24rem),
    linear-gradient(120deg, #fff4d9, #fffaf0 50%, #f7ecce);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.ambient {
  position: fixed;
  z-index: -1;
  border: 1px solid rgba(28, 25, 19, 0.12);
  opacity: 0.7;
  pointer-events: none;
}

.ambient-one {
  top: 7vh;
  left: -8rem;
  width: 18rem;
  height: 18rem;
  border-radius: 46% 54% 45% 55%;
  background: rgba(255, 250, 240, 0.42);
  transform: rotate(-18deg);
}

.ambient-two {
  right: -6rem;
  bottom: 2vh;
  width: 22rem;
  height: 22rem;
  border-radius: 2rem;
  background: repeating-linear-gradient(45deg, rgba(40, 75, 255, 0.08) 0 0.8rem, transparent 0.8rem 1.6rem);
  transform: rotate(12deg);
}

.app-shell {
  width: min(1180px, calc(100vw - 2rem));
  margin: 1rem auto;
}

.hero-card {
  min-height: calc(100vh - 2rem);
  padding: clamp(1rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 2rem;
  background: rgba(255, 250, 240, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.app-header,
.metric-row,
.control-row,
.level-ladder,
.pattern-examples,
.review-options {
  display: flex;
  gap: 1rem;
}

.app-header {
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(1.5rem, 4vw, 3rem);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 3.1rem;
  height: 3.1rem;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 1rem;
  background: var(--blue);
  color: white;
  font-family: var(--display);
  font-weight: 850;
  box-shadow: 0.35rem 0.35rem 0 var(--ink);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-weight: 800;
}

.brand small,
.eyebrow,
.metric-card span,
.level-card span,
.mode-card span,
.counter,
.card-tag,
.footer-hint {
  color: var(--muted);
}

.status-pill {
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  font-weight: 800;
}

.status-mastered {
  background: #e8f6ed;
  color: var(--green);
}

.locale-switcher {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: rgba(255, 255, 255, 0.5);
}

.locale-option-wrap {
  position: relative;
  display: inline-flex;
}

.locale-option {
  display: grid;
  gap: 0.05rem;
  min-width: 6.25rem;
  min-height: 3rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 0.85rem;
  background: transparent;
  text-align: left;
}

.locale-option strong,
.locale-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.locale-option strong {
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
}

.locale-option span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.locale-option.is-active {
  border-color: rgba(40, 75, 255, 0.72);
  background:
    linear-gradient(180deg, rgba(40, 75, 255, 0.08), rgba(255, 255, 255, 0.9)),
    white;
  color: var(--ink);
  cursor: default;
  box-shadow: inset 0 -0.22rem 0 rgba(40, 75, 255, 0.22);
}

.locale-option.is-active span {
  color: #3550c9;
}

.locale-option.is-disabled {
  color: var(--muted);
  opacity: 0.46;
  filter: grayscale(1);
  cursor: not-allowed;
}

.locale-option:focus-visible,
.locale-option-wrap:focus-visible {
  outline: 3px solid rgba(40, 75, 255, 0.36);
  outline-offset: 3px;
}

.locale-option-wrap::after {
  position: absolute;
  right: 50%;
  bottom: calc(100% + 0.55rem);
  z-index: 10;
  width: max-content;
  max-width: 15rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--ink);
  border-radius: 0.7rem;
  background: var(--ink);
  color: white;
  box-shadow: 0 0.8rem 2rem rgba(28, 25, 19, 0.18);
  content: attr(data-tooltip);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 0.25rem);
  transition: opacity 140ms ease, transform 140ms ease;
}

.locale-option-wrap::before {
  position: absolute;
  right: 50%;
  bottom: calc(100% + 0.25rem);
  z-index: 11;
  width: 0.6rem;
  height: 0.6rem;
  background: var(--ink);
  content: '';
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 0.25rem) rotate(45deg);
  transition: opacity 140ms ease, transform 140ms ease;
}

.locale-option-wrap:hover::after,
.locale-option-wrap:hover::before,
.locale-option-wrap:focus-within::after,
.locale-option-wrap:focus-within::before {
  opacity: 1;
  transform: translate(50%, 0) rotate(0);
}

.locale-option-wrap:hover::before,
.locale-option-wrap:focus-within::before {
  transform: translate(50%, 0) rotate(45deg);
}

.dashboard-grid,
.learn-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: clamp(1rem, 4vw, 2rem);
  align-items: stretch;
}

.intro-panel,
.review-panel,
.number-stage,
.pattern-panel,
.results-panel,
.review-screen,
.phase-copy {
  border: 1px solid var(--line);
  border-radius: 1.6rem;
  background: rgba(255, 255, 255, 0.46);
}

.intro-panel,
.review-panel,
.phase-copy,
.pattern-panel,
.results-panel,
.review-screen {
  padding: clamp(1.25rem, 4vw, 2rem);
}

.eyebrow {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1,
h2,
.giant-number,
.score-orb strong {
  font-family: var(--display);
  letter-spacing: -0.045em;
}

h1 {
  max-width: 12ch;
  margin-bottom: 1rem;
  font-size: clamp(3rem, 8vw, 6.7rem);
  line-height: 0.84;
}

h2 {
  margin-bottom: 1rem;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 0.94;
}

.lede,
.pattern-panel p,
.review-screen p,
.phase-copy p,
.results-panel p {
  max-width: 62ch;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.metric-row {
  flex-wrap: wrap;
  margin: 2rem 0;
}

.metric-card {
  min-width: 8rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: var(--paper);
}

.metric-card strong,
.metric-card span,
.level-card strong,
.level-card span,
.mode-card strong,
.mode-card span {
  display: block;
}

.metric-card strong {
  font-size: 1.8rem;
}

.primary-action,
.primary-small,
.secondary-action,
.mode-card,
.level-card,
.pattern-example {
  border: 1px solid var(--ink);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-action,
.primary-small {
  background: var(--ink);
  color: white;
  font-weight: 900;
}

.primary-action {
  display: inline-flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: min(100%, 24rem);
  padding: 1.15rem 1.3rem;
  border-radius: 1.1rem;
  text-align: left;
  box-shadow: 0.45rem 0.45rem 0 var(--blue);
}

.primary-action span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.9rem;
}

.compact {
  width: fit-content;
}

.primary-small,
.secondary-action {
  padding: 0.85rem 1rem;
  border-radius: 0.95rem;
}

.secondary-action {
  background: var(--paper-strong);
  color: var(--ink);
  font-weight: 800;
}

.audio-action {
  background: var(--gold);
  color: var(--ink);
}

.audio-action:hover {
  background: #f9d27a;
}

.primary-action:hover,
.primary-small:hover,
.secondary-action:hover,
.mode-card:hover,
.level-card:hover:not(:disabled),
.pattern-example:hover {
  transform: translate(-2px, -2px);
  box-shadow: 0.35rem 0.35rem 0 var(--ink);
}

.review-panel {
  display: flex;
  flex-direction: column;
}

.mode-card,
.level-card,
.pattern-example {
  padding: 1rem;
  border-radius: 1.1rem;
  background: rgba(255, 250, 240, 0.76);
  text-align: left;
}

.mode-card {
  width: 100%;
  margin-top: 0.75rem;
}

.level-groups {
  display: grid;
  gap: clamp(1rem, 2.5vw, 1.6rem);
  margin-top: 1rem;
}

.level-group {
  display: grid;
  gap: 0.85rem;
}

.level-group-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0.25rem 0;
}

.level-group-heading h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.25rem, 2.8vw, 1.8rem);
  line-height: 1;
}

.level-group-heading p:last-child {
  max-width: 32rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
}

.level-group-forming {
  position: relative;
  margin-top: 0.35rem;
  padding: clamp(0.9rem, 2.4vw, 1.15rem);
  border: 1px solid rgba(40, 75, 255, 0.2);
  border-radius: 1.35rem;
  background:
    linear-gradient(135deg, rgba(40, 75, 255, 0.1), transparent 58%),
    rgba(255, 255, 255, 0.36);
}

.level-group-forming .level-group-heading {
  padding: 0;
}

.level-group-forming .eyebrow,
.level-group-forming .level-group-heading h2 {
  color: #1f3fd4;
}

.level-ladder {
  flex-wrap: wrap;
}

.missions-section {
  margin-top: clamp(1.25rem, 4vw, 2.25rem);
  padding: clamp(1.1rem, 3vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: 1.6rem;
  background: rgba(255, 255, 255, 0.42);
}

.section-heading {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.section-heading h2,
.section-heading p {
  margin: 0;
}

.section-heading p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.5;
}

.mission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
}

.mission-card {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 0.85rem;
  min-height: 12rem;
  padding: 1.1rem;
  border: 1px solid var(--ink);
  border-radius: 1.25rem;
  background:
    radial-gradient(circle at 12% 12%, rgba(231, 173, 52, 0.22), transparent 62%),
    var(--paper);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.mission-card:not(.is-locked):hover {
  transform: translate(-2px, -2px);
  box-shadow: 0.35rem 0.35rem 0 var(--ink);
}

.mission-card.is-locked {
  opacity: 0.55;
}

.mission-card.is-cleared {
  background:
    radial-gradient(circle at 12% 12%, rgba(34, 122, 77, 0.18), transparent 62%),
    #e8f6ed;
}

.mission-main {
  display: grid;
  gap: 0.55rem;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.mission-main:disabled,
.mission-phase:disabled {
  cursor: not-allowed;
}

.mission-main strong,
.mission-main span,
.mission-phase span {
  display: block;
}

.mission-main strong {
  font-size: 1.45rem;
  line-height: 1.05;
}

.mission-badge {
  width: fit-content;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mission-stats {
  margin-top: auto;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 900;
}

.mission-phase-rail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(28, 25, 19, 0.12);
}

.mission-phase {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  min-height: 3.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(28, 25, 19, 0.18);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.58);
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.mission-phase:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--ink);
  background: white;
}

.mission-phase.is-cleared {
  border-color: rgba(34, 122, 77, 0.5);
  background: rgba(34, 122, 77, 0.1);
}

.phase-dot {
  width: 0.78rem;
  height: 0.78rem;
  flex: none;
  border: 2px solid currentColor;
  border-radius: 50%;
  color: var(--muted);
}

.mission-phase.is-hearing .phase-dot {
  box-shadow: 0 0 0 0.22rem rgba(231, 173, 52, 0.24);
}

.mission-phase.is-writing .phase-dot {
  box-shadow: 0 0 0 0.22rem rgba(40, 75, 255, 0.16);
}

.mission-phase.is-cleared .phase-dot {
  border-color: var(--green);
  background: var(--green);
  color: var(--green);
}

.mission-phase-copy {
  min-width: 0;
}

.mission-phase-copy strong {
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mission-phase-copy em {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 900;
}

.level-card {
  display: grid;
  align-content: start;
  flex: 1 1 10rem;
  min-height: 8rem;
  gap: 0.15rem;
}

.level-card:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.level-card.is-current {
  border-width: 2px;
  background:
    linear-gradient(180deg, rgba(40, 75, 255, 0.06), transparent 58%),
    rgba(255, 250, 240, 0.92);
  box-shadow: inset 0 -0.35rem 0 rgba(40, 75, 255, 0.22);
}

.level-card.is-complete {
  border-color: rgba(183, 121, 26, 0.5);
  background:
    linear-gradient(135deg, rgba(231, 173, 52, 0.16), transparent 62%),
    rgba(255, 250, 240, 0.88);
}

.level-card.is-mastered {
  border-color: var(--green);
  background:
    linear-gradient(135deg, rgba(34, 122, 77, 0.16), transparent 62%),
    #eef8f1;
}

.level-status {
  color: var(--muted);
  font-weight: 900;
}

.level-card.is-current .level-status {
  color: var(--ink);
}

.level-card.is-complete:not(.is-mastered) .level-status {
  color: #8f641d;
}

.level-card.is-mastered .level-status {
  color: var(--green);
}

.level-group-forming .level-card {
  border-color: rgba(40, 75, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(40, 75, 255, 0.05), transparent 65%),
    rgba(255, 250, 240, 0.88);
}

.level-group-forming .level-card.is-current {
  border-color: var(--blue);
  background:
    linear-gradient(180deg, rgba(40, 75, 255, 0.1), transparent 58%),
    rgba(255, 250, 240, 0.95);
}

.level-topline {
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.level-card strong {
  margin: 0.35rem 0;
  font-size: 1.55rem;
}

.level-card .level-mastery-track {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.level-card .level-mastery-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  min-height: 1.35rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.level-card .level-mastery-chip.is-passed {
  color: var(--green);
}

.level-card .level-mastery-dot {
  width: 0.5rem;
  height: 0.5rem;
  flex: none;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.level-card .level-mastery-chip.is-passed .level-mastery-dot {
  background: currentColor;
}

.level-card .level-mastery-chip strong {
  margin: 0 0 0 auto;
  color: inherit;
  font-family: var(--body);
  font-size: 0.76rem;
  line-height: 1;
}

.mini-progress,
.session-progress {
  display: block;
  height: 0.45rem;
  margin-top: 0.9rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(28, 25, 19, 0.1);
}

.mini-progress i,
.session-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.number-stage {
  display: grid;
  align-content: center;
  min-height: 31rem;
  padding: clamp(1.25rem, 5vw, 3rem);
}

.number-stage {
  position: relative;
  overflow: hidden;
  background: var(--ink);
  color: white;
}

.number-stage::before {
  position: absolute;
  inset: auto -14% -24% auto;
  width: 18rem;
  height: 18rem;
  border: 1.5rem solid rgba(231, 173, 52, 0.52);
  border-radius: 50%;
  content: '';
  pointer-events: none;
}

.counter {
  font-weight: 900;
}

.giant-number {
  position: relative;
  margin: 0.2rem 0;
  font-size: clamp(6rem, 16vw, 12rem);
  line-height: 0.85;
}

.french-word {
  position: relative;
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 900;
}

.pronunciation {
  position: relative;
  margin: 0.65rem 0 2rem;
  color: #f9d27a;
  font-size: 1.35rem;
  font-weight: 800;
}

.number-stage .control-row {
  position: relative;
  z-index: 1;
}

.pattern-panel,
.results-panel,
.review-screen {
  min-height: 34rem;
}

.pattern-examples,
.review-options {
  flex-wrap: wrap;
  margin: 1.5rem 0;
}

.pattern-example {
  flex: 1 1 13rem;
}

.pattern-example span,
.pattern-example strong,
.pattern-example em {
  display: block;
}

.pattern-example span {
  font-family: var(--display);
  font-size: 3rem;
  font-weight: 850;
}

.pattern-example em {
  color: var(--blue);
  font-style: normal;
  font-weight: 900;
}

/* ---- Duolingo-style quiz layout: card anchored left ---- */
.quiz-layout {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: clamp(1rem, 3vw, 1.5rem);
  min-height: calc(100vh - 12rem);
  --kind: var(--blue);
  --kind-soft: rgba(40, 75, 255, 0.12);
}

/* Answer-kind theming: blue = type Standard French words, gold = type a number */
.quiz-layout.want-french {
  --kind: var(--blue);
  --kind-soft: rgba(40, 75, 255, 0.12);
}

.quiz-layout.want-number {
  --kind: #b9791a;
  --kind-soft: rgba(231, 173, 52, 0.22);
}

/* ---- Direction banner: makes FROM -> TO unmistakable, re-animates per question ---- */
.direction-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 0.85rem;
  border: 1px dashed var(--kind);
  border-radius: 1rem;
  background: var(--kind-soft);
  animation: bannerPop 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes bannerPop {
  0% { opacity: 0; transform: translateY(-6px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.dir-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(28, 25, 19, 0.18);
  background: rgba(255, 255, 255, 0.7);
  font-weight: 800;
  font-size: 0.92rem;
}

.dir-chip.is-digits { font-variant-numeric: tabular-nums; }

.dir-chip.dir-target {
  border-color: var(--kind);
  background: var(--kind);
  color: white;
  box-shadow: 0 6px 16px var(--kind-soft);
}

.dir-arrow {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--kind);
}

.dir-ico {
  width: 0.95rem;
  height: 0.95rem;
  background: currentColor;
  clip-path: polygon(0 35%, 40% 35%, 70% 0, 70% 100%, 40% 65%, 0 65%);
}

.quiz-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.quiz-quit {
  display: grid;
  width: 2.6rem;
  height: 2.6rem;
  flex: none;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.6);
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.quiz-quit:hover {
  background: var(--paper-strong);
  transform: scale(1.05);
}

.session-progress {
  flex: 1;
  height: 1rem;
  margin: 0;
}

.session-progress i {
  transition: width 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.quiz-count {
  flex: none;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.quiz-board {
  display: grid;
  grid-template-columns: minmax(0, 0.62fr) minmax(0, 0.38fr);
  grid-template-rows: 1fr auto;
  gap: clamp(1rem, 3vw, 2rem);
  align-items: stretch;
}

/* The prompt card: left column, full height */
.quiz-card {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
  padding: clamp(1.5rem, 4vw, 2.75rem);
  border: 1px solid var(--line);
  border-left: 6px solid var(--kind);
  border-radius: 1.6rem;
  background:
    radial-gradient(circle at 18% 12%, var(--kind-soft), transparent 60%),
    var(--paper);
  box-shadow: 0 24px 60px rgba(53, 39, 14, 0.12);
  animation: cardSwap 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cardSwap {
  0% { opacity: 0; transform: translateX(-10px); }
  100% { opacity: 1; transform: translateX(0); }
}

.card-tag {
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--kind);
}

.written-prompt {
  margin: 0.4rem 0;
  font-family: var(--display);
  font-size: clamp(4rem, 11vw, 9rem);
  font-weight: 850;
  line-height: 0.84;
  letter-spacing: -0.04em;
}

.audio-prompt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  margin: 0.5rem 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.audio-wave {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  height: 4.5rem;
}

.audio-wave i {
  width: 0.55rem;
  border-radius: 999px;
  background: var(--kind);
  animation: wave 1.1s ease-in-out infinite;
}

.audio-wave i:nth-child(1) { height: 1.6rem; animation-delay: 0s; }
.audio-wave i:nth-child(2) { height: 3rem; animation-delay: 0.12s; }
.audio-wave i:nth-child(3) { height: 4.2rem; animation-delay: 0.24s; }
.audio-wave i:nth-child(4) { height: 2.6rem; animation-delay: 0.36s; }
.audio-wave i:nth-child(5) { height: 1.4rem; animation-delay: 0.48s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.5); opacity: 0.55; }
  50% { transform: scaleY(1); opacity: 1; }
}

.audio-hint {
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--kind);
}

.card-audio {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  align-self: flex-start;
  margin-top: 0.5rem;
  padding: 0.65rem 1.1rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.card-audio:hover {
  background: var(--paper-strong);
  transform: translateY(-1px);
}

.card-audio:disabled,
.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.card-audio .speaker {
  width: 1.1rem;
  height: 1.1rem;
  background: var(--kind);
  clip-path: polygon(0 35%, 40% 35%, 70% 0, 70% 100%, 40% 65%, 0 65%);
}

/* Answer zone: right column, top */
.answer-zone {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.65rem;
}

.answer-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 900;
  font-size: 0.95rem;
  color: var(--kind);
}

.answer-kind-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--kind);
  box-shadow: 0 0 0 0.25rem var(--kind-soft);
}

input {
  width: 100%;
  padding: 1.1rem 1.2rem;
  border: 2px solid var(--kind);
  border-radius: 1rem;
  background: white;
  font-size: 1.25rem;
  font-weight: 800;
  outline: none;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

input::placeholder {
  color: rgba(28, 25, 19, 0.32);
  font-weight: 700;
}

input:focus {
  box-shadow: 0 0 0 0.3rem var(--kind-soft);
}

/* Footer action bar: spans right column bottom on desktop, sticky bar on mobile */
.quiz-footer {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 1.2rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  transition: background 200ms ease, border-color 200ms ease;
}

.footer-hint {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.footer-action {
  padding: 0.95rem 1.8rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0.3rem 0.3rem 0 var(--blue);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.footer-action:hover {
  transform: translate(-2px, -2px);
  box-shadow: 0.45rem 0.45rem 0 var(--blue);
}

.feedback {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.feedback-icon {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  flex: none;
  place-items: center;
  border-radius: 50%;
  font-size: 1.3rem;
  font-weight: 900;
  color: white;
}

.feedback-body strong {
  display: block;
  font-size: 1.05rem;
}

.feedback-body span {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.feedback.is-correct .feedback-icon { background: var(--green); }
.feedback.is-correct .feedback-body strong { color: var(--green); }
.feedback.is-wrong .feedback-icon { background: var(--red); }
.feedback.is-wrong .feedback-body strong { color: #9e2e20; }

.quiz-layout.is-correct .quiz-footer {
  background: #e8f6ed;
  border-color: rgba(34, 122, 77, 0.4);
}

.quiz-layout.is-wrong .quiz-footer {
  background: #fff0ed;
  border-color: rgba(240, 77, 58, 0.4);
}

.score-orb {
  display: grid;
  width: 14rem;
  height: 14rem;
  margin: 1.5rem 0;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0.6rem 0.6rem 0 var(--ink);
}

.score-orb strong,
.score-orb span {
  display: block;
  text-align: center;
}

.score-orb strong {
  font-size: 4rem;
}

.completion-banner {
  display: grid;
  gap: 0.3rem;
  width: fit-content;
  padding: 1rem 1.25rem;
  border: 1px solid var(--green);
  border-radius: 1rem;
  background: #e8f6ed;
  color: var(--green);
  font-weight: 900;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 0.75rem, 48rem);
    margin: 0.375rem auto;
  }

  .hero-card {
    min-height: calc(100vh - 0.75rem);
    min-height: calc(100dvh - 0.75rem);
    padding: clamp(0.85rem, 3.5vw, 1.25rem);
    border-radius: 1.35rem;
  }

  .dashboard-grid,
  .learn-layout {
    display: block;
  }

  .app-header {
    gap: 0.85rem;
    margin-bottom: 1rem;
  }

  .header-actions {
    flex: 1 1 auto;
    flex-wrap: wrap;
  }

  .locale-switcher {
    order: 2;
    width: 100%;
    overflow-x: auto;
    padding: 0.3rem;
  }

  .locale-option {
    min-width: 5.65rem;
  }

  .brand {
    min-width: 0;
  }

  .brand-mark {
    width: 2.65rem;
    height: 2.65rem;
    border-radius: 0.85rem;
    box-shadow: 0.25rem 0.25rem 0 var(--ink);
  }

  .brand strong,
  .brand small {
    overflow-wrap: anywhere;
  }

  .status-pill {
    flex: none;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
  }

  .review-panel,
  .number-stage {
    margin-top: 1rem;
  }

  h1 {
    max-width: 9ch;
  }

  .control-row {
    flex-direction: column;
  }

  .primary-small,
  .secondary-action {
    width: 100%;
  }

  .primary-action,
  .mode-card,
  .level-card,
  .mission-card,
  .mission-phase,
  .pattern-example,
  .card-audio,
  .audio-prompt,
  .footer-action {
    touch-action: manipulation;
  }

  /* Quiz: stack card over answer, footer sticks to bottom */
  .hero-card.route-quiz,
  .hero-card.route-exam {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0.75rem;
    border: 0;
    border-radius: 0;
    background: rgba(255, 250, 240, 0.9);
    box-shadow: none;
  }

  .hero-card.route-quiz .app-header,
  .hero-card.route-exam .app-header {
    display: none;
  }

  .quiz-layout {
    min-height: calc(100vh - 1.5rem);
    min-height: calc(100dvh - 1.5rem);
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 0.75rem;
    padding-bottom: calc(6.25rem + env(safe-area-inset-bottom));
  }

  .quiz-topbar {
    gap: 0.65rem;
  }

  .quiz-quit {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 0.75rem;
  }

  .session-progress {
    height: 0.8rem;
  }

  .quiz-board {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(10rem, auto) auto;
    align-content: start;
    gap: 0.85rem;
  }

  .quiz-card {
    grid-column: 1;
    grid-row: 1;
    min-height: clamp(10rem, 32dvh, 15rem);
    padding: clamp(1rem, 4.5vw, 1.5rem);
    border-left-width: 4px;
    border-radius: 1.15rem;
  }

  .answer-zone {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .written-prompt {
    max-width: 100%;
    font-size: 4.4rem;
    line-height: 0.92;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .audio-wave {
    height: 3.4rem;
  }

  .audio-wave i:nth-child(1) { height: 1.2rem; }
  .audio-wave i:nth-child(2) { height: 2.3rem; }
  .audio-wave i:nth-child(3) { height: 3.2rem; }
  .audio-wave i:nth-child(4) { height: 2rem; }
  .audio-wave i:nth-child(5) { height: 1.1rem; }

  input {
    min-height: 3.4rem;
    padding: 0.95rem 1rem;
    border-radius: 0.9rem;
    font-size: 1.15rem;
  }

  .quiz-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    grid-column: auto;
    grid-row: auto;
    z-index: 5;
    min-height: calc(5.25rem + env(safe-area-inset-bottom));
    padding: 0.8rem 0.9rem calc(0.8rem + env(safe-area-inset-bottom));
    border-radius: 1.2rem 1.2rem 0 0;
    border-bottom: 0;
    background: var(--paper);
    box-shadow: 0 -10px 30px rgba(53, 39, 14, 0.12);
  }

  .footer-action {
    min-height: 3.2rem;
    flex: 0 0 min(13rem, 48vw);
    padding: 0.85rem 1rem;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: 100%;
    margin: 0;
  }

  .hero-card {
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
  }

  .app-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .header-actions {
    width: 100%;
  }

  .brand {
    gap: 0.7rem;
  }

  .brand strong {
    line-height: 1.1;
  }

  .brand small,
  .status-pill,
  .quiz-count,
  .footer-hint {
    font-size: 0.82rem;
  }

  .status-pill {
    max-width: 8.5rem;
    text-align: center;
  }

  .locale-switcher {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .locale-option {
    min-width: 0;
    width: 100%;
    padding: 0.45rem 0.4rem;
  }

  .locale-option strong,
  .locale-option span {
    text-align: center;
  }

  .locale-option span {
    display: none;
  }

  .locale-option-wrap::after {
    right: 0;
    max-width: min(15rem, calc(100vw - 1rem));
    transform: translate(0, 0.25rem);
  }

  .locale-option-wrap::before {
    right: 50%;
  }

  .locale-option-wrap:hover::after,
  .locale-option-wrap:focus-within::after {
    transform: translate(0, 0);
  }

  h1 {
    font-size: 2.9rem;
    line-height: 0.9;
  }

  h2 {
    font-size: 1.8rem;
  }

  .intro-panel,
  .review-panel,
  .phase-copy,
  .pattern-panel,
  .results-panel,
  .review-screen,
  .missions-section {
    padding: 1rem;
    border-radius: 1.1rem;
  }

  .metric-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
    margin: 1.1rem 0;
  }

  .metric-card {
    min-width: 0;
    padding: 0.75rem;
    border-radius: 0.85rem;
  }

  .metric-card strong {
    font-size: 1.35rem;
  }

  .metric-card span {
    font-size: 0.78rem;
    line-height: 1.15;
  }

  .primary-action {
    width: 100%;
    min-width: 0;
    border-radius: 0.95rem;
  }

  .phase-copy h1 {
    max-width: none;
    font-size: 2.45rem;
  }

  .phase-copy p {
    font-size: 1rem;
    line-height: 1.45;
  }

  .number-stage {
    min-height: 22rem;
    padding: 1.25rem;
    border-radius: 1.1rem;
  }

  .giant-number {
    font-size: 5.2rem;
  }

  .french-word {
    font-size: 2rem;
  }

  .pronunciation {
    margin-bottom: 1.2rem;
    font-size: 1.15rem;
  }

  .level-ladder,
  .pattern-examples,
  .review-options {
    gap: 0.7rem;
  }

  .level-card {
    flex-basis: calc(50% - 0.35rem);
    min-height: 7.2rem;
    padding: 0.85rem;
  }

  .mission-grid {
    grid-template-columns: 1fr;
  }

  .hero-card.route-quiz,
  .hero-card.route-exam {
    padding: 0.55rem;
  }

  .direction-banner {
    gap: 0.45rem;
    padding: 0.5rem;
    border-radius: 0.85rem;
  }

  .dir-chip {
    min-height: 2.1rem;
    padding: 0.35rem 0.6rem;
    font-size: 0.82rem;
  }

  .quiz-layout {
    min-height: calc(100vh - 1.1rem);
    min-height: calc(100dvh - 1.1rem);
    padding-bottom: calc(8.2rem + env(safe-area-inset-bottom));
  }

  .quiz-board {
    grid-template-rows: minmax(8.5rem, auto) auto;
  }

  .quiz-card {
    min-height: clamp(8.5rem, 29dvh, 12rem);
    gap: 0.55rem;
  }

  .card-tag,
  .audio-hint,
  .answer-label {
    font-size: 0.78rem;
  }

  .card-audio {
    min-height: 2.75rem;
    margin-top: 0.2rem;
    padding: 0.55rem 0.85rem;
  }

  .written-prompt {
    font-size: 3.25rem;
  }

  .quiz-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 0.65rem;
    min-height: calc(7.3rem + env(safe-area-inset-bottom));
  }

  .footer-hint {
    text-align: center;
  }

  .footer-action {
    width: 100%;
    flex-basis: auto;
  }

  .feedback {
    align-items: flex-start;
    min-width: 0;
  }

  .feedback-icon {
    width: 2rem;
    height: 2rem;
    font-size: 1.1rem;
  }

  .feedback-body {
    min-width: 0;
  }

  .feedback-body span {
    overflow-wrap: anywhere;
  }
}

@media (prefers-reduced-motion: reduce) {
  .direction-banner,
  .quiz-card,
  .audio-wave i {
    animation: none;
  }

  * {
    scroll-behavior: auto;
  }
}
