:root {
  color-scheme: dark;
  --bg: #061010;
  --bg-2: #0c1c19;
  --surface: rgba(13, 31, 28, 0.9);
  --surface-strong: rgba(17, 42, 37, 0.98);
  --line: rgba(165, 230, 202, 0.25);
  --text: #f4fff8;
  --muted: #b8d2c7;
  --leaf: #9be64a;
  --mint: #35dfbd;
  --sky: #7dd7ff;
  --gold: #ffd166;
  --pink: #ff76bd;
  --shadow: 0 18px 58px rgba(0, 0, 0, 0.38);
  --radius: 8px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(155, 230, 74, 0.11), transparent 26rem),
    linear-gradient(315deg, rgba(53, 223, 189, 0.1), transparent 24rem),
    linear-gradient(180deg, #07100f 0%, #0d1916 52%, #060b0b 100%);
  color: var(--text);
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body,
button {
  font: 700 16px/1.4 "Atkinson Hyperlegible", system-ui, sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

h1,
h2,
p,
figure {
  margin: 0;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 68px;
  padding: 8px 0 12px;
  background: linear-gradient(180deg, rgba(6, 16, 16, 0.96), rgba(6, 16, 16, 0.78), transparent);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(155, 230, 74, 0.62);
  border-radius: var(--radius);
  background: rgba(155, 230, 74, 0.13);
}

.brand-mark svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: var(--leaf);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

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

.brand strong {
  overflow: hidden;
  font-family: Nunito, system-ui, sans-serif;
  font-size: 1.04rem;
  font-weight: 900;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.15;
}

.progress-card {
  display: grid;
  min-width: 84px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.24);
  text-align: right;
}

.progress-card strong {
  color: var(--leaf);
  font-family: Nunito, system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

.progress-card span {
  color: var(--muted);
  font-size: 0.72rem;
}

.hero {
  display: grid;
  gap: 16px;
  margin: 4px 0 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(24, 63, 52, 0.95), rgba(8, 21, 21, 0.96)),
    rgba(13, 31, 28, 0.92);
  box-shadow: var(--shadow);
}

h1 {
  max-width: 14ch;
  font-family: Nunito, system-ui, sans-serif;
  font-size: clamp(2.15rem, 10vw, 5rem);
  font-weight: 900;
  line-height: 0.94;
  text-wrap: balance;
}

.hero p {
  max-width: 62ch;
  margin-top: 12px;
  color: #d8eee5;
  font-size: clamp(1rem, 2.8vw, 1.16rem);
  font-weight: 700;
  line-height: 1.5;
}

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

.mode-tab,
.icon-button,
.primary-action,
.secondary-action,
.card-strip button,
.flow-track button,
.answer-list button {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(8, 22, 21, 0.84);
  cursor: pointer;
  transition: transform 160ms var(--ease), border-color 160ms var(--ease), background 160ms var(--ease), box-shadow 160ms var(--ease);
}

.mode-tab {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius);
  color: #d9eee7;
  font-size: 0.88rem;
  font-weight: 800;
}

.mode-tab svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.mode-tab.is-active {
  border-color: rgba(53, 223, 189, 0.78);
  background: linear-gradient(135deg, rgba(53, 223, 189, 0.22), rgba(155, 230, 74, 0.16));
  color: white;
  box-shadow: 0 0 26px rgba(53, 223, 189, 0.16);
}

.activity-grid {
  display: grid;
  gap: 12px;
}

.picture-panel,
.learning-panel,
.story-strip,
.flow-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(5, 14, 14, 0.7);
  box-shadow: var(--shadow);
}

.picture-panel {
  overflow: hidden;
}

.picture-toolbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid rgba(165, 230, 202, 0.18);
  background: rgba(0, 0, 0, 0.32);
}

.picture-toolbar span {
  overflow: hidden;
  color: #eefdf8;
  font-family: Nunito, system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: var(--radius);
}

.icon-button svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.main-picture {
  display: grid;
  min-height: 0;
  place-items: center;
  padding: 10px;
  background:
    linear-gradient(180deg, rgba(53, 223, 189, 0.08), rgba(0, 0, 0, 0.26)),
    #030707;
}

.main-picture img {
  display: block;
  width: min(100%, 520px);
  max-height: min(68vh, 760px);
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.42);
}

.learning-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 12px;
}

.info-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(165, 230, 202, 0.2);
  border-radius: var(--radius);
  background: var(--surface);
}

.info-card[hidden] {
  display: none;
}

.card-topline,
.quiz-footer,
.section-header,
.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.number-chip,
.system-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border-radius: 999px;
  font-family: Nunito, system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 900;
}

.number-chip {
  min-width: 42px;
  justify-content: center;
  border: 1px solid currentColor;
  color: var(--mint);
}

.system-chip {
  padding: 0 10px;
  color: #e9fff7;
  background: rgba(255, 255, 255, 0.09);
}

.info-card h2,
.story-strip h2,
.flow-section h2 {
  font-family: Nunito, system-ui, sans-serif;
  font-size: clamp(1.55rem, 7vw, 2.45rem);
  font-weight: 900;
  line-height: 0.98;
}

.info-card p {
  color: #d8eee5;
  font-size: clamp(1.04rem, 3vw, 1.22rem);
  font-weight: 700;
  line-height: 1.5;
}

.plain-facts {
  display: grid;
  gap: 10px;
}

.plain-facts div {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
}

.plain-facts span,
.score-row span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-family: Nunito, system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.plain-facts strong,
.score-row strong {
  display: block;
  color: #f8fffc;
  font-size: 1rem;
  line-height: 1.35;
}

.primary-action,
.secondary-action {
  min-height: 50px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 900;
}

.primary-action {
  border-color: rgba(155, 230, 74, 0.8);
  background: linear-gradient(135deg, var(--leaf), var(--mint));
  color: #04100c;
}

.secondary-action {
  padding: 0 14px;
  color: #ecfff8;
}

.secondary-action.compact {
  min-height: 40px;
  font-size: 0.84rem;
}

.story-strip,
.flow-section {
  margin-top: 12px;
  padding: 14px;
}

.section-header {
  margin-bottom: 12px;
}

.card-strip {
  display: grid;
  grid-auto-columns: minmax(132px, 38vw);
  grid-auto-flow: column;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
  scrollbar-color: rgba(53, 223, 189, 0.65) rgba(255, 255, 255, 0.08);
}

.card-strip button {
  display: grid;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius);
  scroll-snap-align: start;
  text-align: left;
}

.card-strip button.is-active {
  border-color: rgba(53, 223, 189, 0.9);
  box-shadow: 0 0 28px rgba(53, 223, 189, 0.2);
}

.card-strip button.is-learned {
  border-color: rgba(155, 230, 74, 0.7);
}

.thumb-frame {
  display: grid;
  aspect-ratio: 3 / 4;
  place-items: center;
  background: #040707;
}

.thumb-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-copy {
  display: grid;
  gap: 3px;
  padding: 10px;
  background: rgba(10, 26, 24, 0.96);
}

.thumb-copy span {
  color: var(--leaf);
  font-family: Nunito, system-ui, sans-serif;
  font-size: 0.76rem;
  font-weight: 900;
}

.thumb-copy strong {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.1;
}

.flow-section h2 {
  margin-bottom: 12px;
}

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

.flow-track button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  min-width: 0;
  padding: 12px;
  border-radius: var(--radius);
  text-align: left;
}

.flow-track span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: rgba(53, 223, 189, 0.14);
  color: var(--mint);
  font-family: Nunito, system-ui, sans-serif;
  font-weight: 900;
}

.flow-track strong,
.flow-track em {
  display: block;
  font-style: normal;
}

.flow-track strong {
  color: var(--text);
  font-family: Nunito, system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 900;
}

.flow-track em {
  margin-top: 2px;
  color: #c9e3da;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
}

.answer-list {
  display: grid;
  gap: 8px;
}

.answer-list button {
  min-height: 50px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: #f2fff9;
  font-size: 0.98rem;
  font-weight: 800;
  text-align: left;
}

.answer-list button.is-correct {
  border-color: rgba(155, 230, 74, 0.8);
  background: rgba(155, 230, 74, 0.18);
}

.answer-list button.is-wrong {
  border-color: rgba(255, 118, 189, 0.75);
  background: rgba(255, 118, 189, 0.14);
}

.source-note {
  padding: 18px 4px 10px;
  color: #9cb4aa;
  font-size: 0.82rem;
  line-height: 1.5;
}

.source-note code {
  color: #d9fff2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

button:hover {
  border-color: rgba(53, 223, 189, 0.65);
  transform: translateY(-1px);
}

button:focus-visible {
  outline: 3px solid rgba(53, 223, 189, 0.45);
  outline-offset: 2px;
}

@media (min-width: 680px) {
  .app-shell {
    padding: 18px;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: end;
    padding: 24px;
  }

  .plain-facts,
  .flow-track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-strip {
    grid-auto-columns: 170px;
  }
}

@media (min-width: 980px) {
  .activity-grid {
    grid-template-columns: minmax(0, 0.88fr) minmax(340px, 0.58fr);
    align-items: start;
  }

  .learning-panel {
    position: sticky;
    top: 86px;
  }

  .main-picture img {
    width: min(100%, 560px);
    max-height: min(76vh, 820px);
  }

  .card-strip {
    grid-auto-flow: initial;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: visible;
  }

  .flow-track {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .progress-card {
    min-width: 76px;
    padding: 8px;
  }

  .hero {
    padding: 15px;
  }

  .mode-tabs {
    gap: 6px;
  }

  .mode-tab {
    min-height: 46px;
    gap: 5px;
    font-size: 0.8rem;
  }

  .mode-tab svg {
    width: 16px;
    height: 16px;
  }

  .main-picture {
    padding: 8px;
  }

  .main-picture img {
    max-height: 58vh;
  }

  .learning-panel,
  .story-strip,
  .flow-section {
    padding: 10px;
  }

  .info-card {
    padding: 14px;
  }
}

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