/* History & Facts: visual system.
   Calm and editorial: neutral surfaces, fine borders, one accent colour, and topic/group colours
   (passed in as --g) used only as small accents. Light and dark themes share every rule; only the
   tokens change. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../assets/fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../assets/fonts/schibsted-grotesk-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens: light ---------- */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --sunken: #eceef2;
  --tree-sky-1: #f4fbf2;
  --tree-sky-2: #e3f0f7;
  --tree-bark: #8a6a4f;
  --tree-wood: #a98b6c;
  --tree-alive: #6d7f3a;
  --tree-leaf: #2f9e44;
  --tree-bud: #c9b49a;
  --tree-ground: #cfe3c0;
  --text: #15171c;
  --text-muted: #5b6170;
  --line: #e2e5eb;
  --line-strong: #cfd4dc;

  --accent: #3346d3;
  --accent-hover: #2838b5;
  --accent-soft: #eef0fd;
  --accent-text: #2a3bb8;
  --on-accent: #ffffff;

  --success: #127a52;
  --success-soft: #e7f5ee;
  --success-text: #0f6a47;
  --warn-soft: #fdf3e2;
  --warn-text: #8a4b00;
  --warn-line: #f0d4a3;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --danger-text: #a8201a;

  --shadow: 0 1px 2px rgb(16 24 40 / 0.04), 0 2px 8px rgb(16 24 40 / 0.04);
  --tile-mix: 12%;

  --radius: 12px;
  --radius-sm: 8px;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Schibsted Grotesk", "Inter", ui-sans-serif, system-ui, sans-serif;
}

/* ---------- Tokens: dark (device setting, unless the reader picked light) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #16191f;
    --surface-2: #1b1f26;
    --sunken: #12151a;
    --tree-sky-1: #18231c;
    --tree-sky-2: #121a22;
    --tree-bark: #6f5641;
    --tree-wood: #5d4a39;
    --tree-alive: #8aa04a;
    --tree-leaf: #4cc25f;
    --tree-bud: #6d6152;
    --tree-ground: #22311f;
    --text: #e8eaee;
    --text-muted: #9aa1ad;
    --line: #262b33;
    --line-strong: #353b45;
    --accent: #8c9bff;
    --accent-hover: #a3afff;
    --accent-soft: #1d2344;
    --accent-text: #b3bcff;
    --on-accent: #0f1115;
    --success: #4cc38a;
    --success-soft: #13291f;
    --success-text: #6fd6a4;
    --warn-soft: #2c2210;
    --warn-text: #f3c26b;
    --warn-line: #5a4519;
    --danger: #f97066;
    --danger-soft: #331715;
    --danger-text: #ff8b82;
    --shadow: none;
    --tile-mix: 18%;
  }
}

/* ---------- Tokens: dark (picked with the toggle) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #16191f;
  --surface-2: #1b1f26;
  --sunken: #12151a;
  --tree-sky-1: #18231c;
  --tree-sky-2: #121a22;
  --tree-bark: #6f5641;
  --tree-wood: #5d4a39;
  --tree-alive: #8aa04a;
  --tree-leaf: #4cc25f;
  --tree-bud: #6d6152;
  --tree-ground: #22311f;
  --text: #e8eaee;
  --text-muted: #9aa1ad;
  --line: #262b33;
  --line-strong: #353b45;
  --accent: #8c9bff;
  --accent-hover: #a3afff;
  --accent-soft: #1d2344;
  --accent-text: #b3bcff;
  --on-accent: #0f1115;
  --success: #4cc38a;
  --success-soft: #13291f;
  --success-text: #6fd6a4;
  --warn-soft: #2c2210;
  --warn-text: #f3c26b;
  --warn-line: #5a4519;
  --danger: #f97066;
  --danger-soft: #331715;
  --danger-text: #ff8b82;
  --shadow: none;
  --tile-mix: 18%;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}

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

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

a {
  color: var(--accent-text);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon {
  flex: none;
  display: block;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 20;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 600;
}

.skip-link:focus {
  top: 10px;
}

.dev-banner {
  margin: 0;
  padding: 6px 16px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--warn-soft);
  color: var(--warn-text);
}

/* ---------- Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--line);
}

@supports (backdrop-filter: blur(1px)) {
  @media (min-width: 761px) {
    .topbar {
      backdrop-filter: saturate(1.4) blur(10px);
    }
  }
}

.topbar__inner,
.footer__inner,
.page {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

.topbar__inner {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 60px;
}

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

.brand__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
}

.brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand__amp {
  margin: 0 3px;
  color: var(--text-muted);
  font-weight: 500;
}

.topbar__tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.daily,
.profile-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  white-space: nowrap;
}

.daily:empty,
.daily[hidden],
.profile-button[hidden] {
  display: none;
}

.daily .icon {
  color: var(--text-muted);
}

.daily strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.daily__label {
  color: var(--text-muted);
}

.daily--full {
  background: var(--warn-soft);
  border-color: var(--warn-line);
}

.streak .icon {
  color: #e8590c;
}

.streak--pending .icon {
  color: var(--text-muted);
}

.profile-button {
  cursor: pointer;
  font-weight: 500;
}

.profile-button .icon {
  color: var(--text-muted);
}

.profile-button:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  align-self: stretch;
  gap: 4px;
}

.tabs:empty {
  display: none;
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
}

.tab::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: transparent;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-current="page"] {
  color: var(--text);
}

.tab[aria-current="page"]::after {
  background: var(--text);
}

.tab__icon {
  display: grid;
}

.tab__badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.tab__badge[hidden] {
  display: none;
}

/* ---------- Page & footer ---------- */
.page {
  flex: 1;
  padding-top: 32px;
  padding-bottom: 64px;
}

.page:focus {
  outline: none;
}

.footer {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: 18px;
  padding-bottom: 24px;
  border-top: 1px solid var(--line);
}

.link-button {
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-button:hover {
  color: var(--danger-text);
}

.loading {
  padding: 40px 0;
  color: var(--text-muted);
}

.note {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

code {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--sunken);
  font-size: 0.9em;
}

/* ---------- Buttons, badges, meters ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.button:hover {
  background: var(--accent-hover);
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.button--small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.button--success {
  background: var(--success);
  color: #fff;
}

.button--quiet {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
}

.button--quiet:hover {
  background: var(--surface-2);
  border-color: var(--text-muted);
}

.button--danger {
  color: var(--danger-text);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--sunken);
  color: var(--text-muted);
}

.badge--complete,
.badge--included {
  background: var(--success-soft);
  color: var(--success-text);
}

.badge--open,
.badge--in-progress,
.badge--downloaded {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.badge--waiting,
.badge--update,
.badge--downloading {
  background: var(--warn-soft);
  color: var(--warn-text);
}

.meter {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: var(--sunken);
  overflow: hidden;
}

.meter__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.4s ease;
}

.meter--group .meter__fill {
  background: var(--g, var(--accent));
}

.meter--large {
  height: 6px;
}

.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 40px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-muted);
  list-style: none;
}

.empty__title {
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
}

.empty .button {
  margin-top: 10px;
}

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger-text);
  font-weight: 500;
}

/* ---------- Shared headings ---------- */
.page-head {
  display: grid;
  gap: 6px;
  margin-bottom: 24px;
}

.page-head h1 {
  font-size: clamp(1.8rem, 4vw, 2.3rem);
}

.page-head p {
  max-width: 60ch;
  color: var(--text-muted);
}

.page-head--topic {
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 16px;
}

.page-head__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--g, var(--accent)) var(--tile-mix), var(--surface));
  border: 1px solid color-mix(in srgb, var(--g, var(--accent)) 25%, var(--line));
  color: var(--g, var(--accent));
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 32px 0 12px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 0.8rem;
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section-head .section-title {
  margin: 0;
}

.section-title--icon {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title__icon {
  display: grid;
  color: var(--g, var(--accent));
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}

.back:hover {
  color: var(--text);
}

.group-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.group-tag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--g, var(--accent));
}

/* ---------- Home ---------- */
.intro {
  display: grid;
  gap: 10px;
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.intro__title {
  max-width: 18ch;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -0.025em;
  line-height: 1.05;
}

.intro__lead {
  max-width: 62ch;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.intro__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 36px;
  margin: 10px 0 0;
}

.intro__stats dt {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.intro__stats dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.home-section {
  margin-bottom: 32px;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.topic-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  height: 100%;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease;
}

.topic-card:hover {
  border-color: var(--line-strong);
}

.topic-card__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--g) var(--tile-mix), var(--surface));
  color: var(--g);
}

.topic-card__icon .icon {
  width: 24px;
  height: 24px;
}

.topic-card__body {
  display: grid;
  align-content: start;
  gap: 2px;
}

.topic-card__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1.2;
}

.topic-card__tagline {
  color: var(--text-muted);
}

.topic-card__stats {
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: 500;
}

.topic-card__starter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--success-text);
  font-size: 0.82rem;
}

.topic-card__foot {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.topic-card__count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.recent {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recent__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.recent__item:hover {
  border-color: var(--line-strong);
}

.recent__item > .icon {
  color: var(--text-muted);
}

.recent__body {
  flex: 1;
  display: grid;
  min-width: 0;
}

.recent__meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ---------- Topic screen ---------- */
.starter {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.starter:hover {
  border-color: var(--line-strong);
}

.starter__emoji {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 10px;
  background: color-mix(in srgb, var(--g, var(--accent)) var(--tile-mix), var(--surface));
  font-size: 1.5rem;
}

.starter__text {
  flex: 1;
  display: grid;
}

.starter__title {
  font-weight: 600;
}

.starter__sub {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.starter > .icon {
  color: var(--text-muted);
}

/* Course card (topics with a syllabus, e.g. Cars) */
.course {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.course__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.course__label {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.course__count {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.course__count small {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
}

.course .starter {
  margin: 0;
  background: var(--surface-2);
}

.course__note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.search {
  position: relative;
  margin-bottom: 14px;
}

.search .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search__input {
  width: 100%;
  height: 46px;
  padding: 0 16px 0 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.search__input::placeholder {
  color: var(--text-muted);
}

.search__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.chips {
  display: flex;
  gap: 6px;
  margin: 0 -20px 16px;
  padding: 2px 20px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--line-strong);
}

.chip__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--g, var(--accent));
}

.chip__count {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.chip[aria-pressed="true"] {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.chip[aria-pressed="true"] .chip__count {
  color: inherit;
  opacity: 0.7;
}

.result-count {
  margin-bottom: 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Card grid (Animals) */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--line-strong);
}

.card__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card__emoji {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--g, var(--accent)) var(--tile-mix), var(--surface));
  font-size: 1.65rem;
}

.card__emoji--small {
  width: 40px;
  height: 40px;
  font-size: 1.35rem;
}

.card__titles {
  display: grid;
  min-width: 0;
  flex: 1;
}

.card__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.25;
}

.card__sci {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: italic;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.card__head .badge {
  align-self: flex-start;
}

.card__foot {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card__count {
  font-variant-numeric: tabular-nums;
}

.card--done .card__count {
  color: var(--success-text);
}

/* System menu (Cars) */
.results {
  display: grid;
  gap: 16px;
}

.system {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.system__head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  box-shadow: inset 3px 0 0 var(--g, var(--accent));
}

.system__emoji {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 9px;
  background: color-mix(in srgb, var(--g, var(--accent)) var(--tile-mix), var(--surface));
  font-size: 1.2rem;
}

.system__titles {
  flex: 1;
  min-width: 0;
}

.system__name {
  font-size: 1.1rem;
}

.system__desc {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.system__count {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.menu {
  margin: 0;
  padding: 0;
  list-style: none;
}

.menu li + li {
  border-top: 1px solid var(--line);
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  color: inherit;
  text-decoration: none;
}

.menu-row:hover {
  background: var(--surface-2);
}

.menu-row__emoji {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 8px;
  background: var(--sunken);
  font-size: 1.05rem;
}

.menu-row__lesson {
  width: 22px;
  flex: none;
  text-align: right;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.menu-row--done .menu-row__lesson {
  color: var(--success-text);
}

.menu-row__body {
  flex: 1;
  display: grid;
  min-width: 0;
}

.menu-row__name {
  font-weight: 600;
}

.menu-row__summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.menu-row__side {
  display: grid;
  justify-items: end;
  gap: 3px;
}

.menu-row__count {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.menu-row--done .menu-row__count {
  color: var(--success-text);
}

/* ---------- Item page ---------- */
.animal {
  display: grid;
  gap: 20px;
  max-width: 760px;
}

.animal-hero {
  display: grid;
  gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.animal-hero__top {
  display: flex;
  align-items: center;
  gap: 18px;
}

.animal-hero__emoji {
  flex: none;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--g, var(--accent)) var(--tile-mix), var(--surface));
  border: 1px solid color-mix(in srgb, var(--g, var(--accent)) 22%, var(--line));
  font-size: 2.5rem;
}

.animal-hero .group-tag {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.animal-hero__name {
  margin-top: 2px;
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  letter-spacing: -0.02em;
}

.animal-hero__sci {
  margin-top: 2px;
  font-style: italic;
  color: var(--text-muted);
}

.animal-hero__summary {
  max-width: 62ch;
  font-size: 1.08rem;
  color: var(--text-muted);
}

.facts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

/* Hairlines between cells that never leave an empty grey cell behind. */
.facts-grid__item {
  padding: 12px 16px;
  box-shadow: 1px 1px 0 var(--line);
}

.facts-grid dt {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.facts-grid dd {
  margin: 2px 0 0;
  font-weight: 500;
  font-size: 0.92rem;
  line-height: 1.45;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--success-soft);
  color: var(--success-text);
  font-size: 0.88rem;
}

.status-strip--downloaded {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.status-strip--update {
  background: var(--warn-soft);
  color: var(--warn-text);
}

.status-strip__text {
  flex: 1;
  min-width: 170px;
  font-weight: 500;
}

.status-strip__actions {
  display: flex;
  gap: 8px;
}

.progress-card {
  display: grid;
  gap: 10px;
}

.progress-card__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.progress-card__count {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.progress-card__count small {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--text-muted);
}

.celebrate {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 18px 20px;
  border: 1px solid color-mix(in srgb, var(--success) 30%, var(--line));
  border-radius: var(--radius);
  background: var(--success-soft);
}

.celebrate__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--success-text);
}

.celebrate__sub {
  color: var(--text);
}

.celebrate__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.celebrate__actions:empty {
  display: none;
}

.celebrate__note {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Levels */
.level {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.level--locked {
  background: transparent;
  border-style: dashed;
  box-shadow: none;
}

.level__header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.level__num {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--text);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
}

.level--complete .level__num {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.level--locked .level__num {
  border-color: var(--line-strong);
  color: var(--text-muted);
}

.level__titles {
  flex: 1;
  min-width: 0;
}

.level__title {
  font-size: 1.15rem;
}

.level__desc {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.level__side {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.level__count {
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.level__more {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.facts {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fact {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
}

.fact--learned + .fact--learned {
  border-top: 1px solid var(--line);
}

.fact__mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
}

.fact__body {
  display: grid;
  gap: 2px;
}

.fact__title {
  font-weight: 600;
}

.fact__formula {
  justify-self: start;
  max-width: 100%;
  margin: 4px 0 0;
  padding: 6px 10px;
  overflow-x: auto;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--sunken);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  font-size: 0.88rem;
  white-space: nowrap;
}

.fact--next .fact__formula {
  font-size: 0.95rem;
  background: var(--surface);
}

.fact--next {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  animation: reveal 0.3s ease;
}

.fact__label {
  justify-self: start;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.fact__title--next {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.fact--next .fact__text {
  font-size: 1.06rem;
  line-height: 1.6;
}

.fact--next .button {
  justify-self: start;
  margin-top: 4px;
}

/* In depth (adults) */
.depth {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.depth__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.depth__text {
  font-size: 0.95rem;
  line-height: 1.65;
}

/* Quiz */
.quiz {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.quiz__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.quiz__title .icon {
  color: var(--accent);
}

.quiz__intro {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.questions {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.question {
  display: grid;
  gap: 10px;
}

.question__text {
  font-weight: 500;
}

.question__num {
  display: inline-block;
  margin-right: 8px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.question__choices {
  display: grid;
  gap: 8px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.choice:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice:disabled {
  cursor: default;
}

.choice--answer {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success-text);
  font-weight: 500;
}

.choice--picked {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger-text);
}

.choice--dim {
  opacity: 0.55;
}

.question__result {
  font-size: 0.88rem;
  font-weight: 500;
}

.question--right .question__result {
  color: var(--success-text);
}

.question--wrong .question__result {
  color: var(--danger-text);
}

/* Notices */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--sunken);
}

.notice__icon {
  display: grid;
  place-items: center;
  flex: none;
  padding-top: 2px;
  color: var(--text-muted);
}

.notice--wait,
.notice--daily-limit {
  background: var(--warn-soft);
}

.notice--wait .notice__icon,
.notice--daily-limit .notice__icon {
  color: var(--warn-text);
}

.notice__title {
  font-weight: 600;
}

.notice__text {
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ---------- Reference: tabs, parts, handbook, sources ---------- */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sunken);
}

.segmented__tab {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.segmented__tab:hover {
  color: var(--text);
}

.segmented__tab[aria-selected="true"],
.segmented__tab[aria-pressed="true"],
.segmented__tab[aria-current="page"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.segmented__count {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.panel-intro {
  margin: 0 0 14px;
  color: var(--text-muted);
}

.parts__list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.part {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.part__name {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 1.05rem;
}

.part__num {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.part__rows {
  display: grid;
  gap: 10px;
  margin: 0;
}

.part__row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
}

.part__row dt {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.part__row dd {
  margin: 0;
  line-height: 1.55;
}

.part__row--fails dd {
  color: var(--text);
}

.handbook {
  display: grid;
  gap: 22px;
}

.handbook__toc {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.handbook__toc ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.handbook__jump {
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.handbook__jump:hover {
  text-decoration: underline;
}

.handbook__section {
  display: grid;
  gap: 10px;
  scroll-margin-top: 90px;
}

.handbook__section p {
  line-height: 1.65;
}

.handbook__heading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
}

.handbook__num {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--sunken);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.handbook__section--safety {
  padding: 16px 18px;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  background: var(--warn-soft);
}

.handbook__list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 1.3em;
  line-height: 1.55;
}

.sources {
  display: grid;
  gap: 18px;
}

.sources__group {
  display: grid;
  gap: 8px;
}

.sources__kind {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sources__list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.source {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.source__title {
  font-weight: 600;
}

.source__title a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-text);
}

.source__by,
.source__note {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

@media (max-width: 560px) {
  .part__row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .segmented__tab {
    padding: 0 8px;
    font-size: 0.86rem;
  }
}

/* Models catalogue (Car Makers) */
.model__picture {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 10px 12px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
}

.model__picture figcaption {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.model__picture--photo {
  padding: 0;
  overflow: hidden;
}

.model__picture--photo img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-width: 100%;
  object-fit: cover;
}

.model__picture--photo figcaption {
  padding: 4px 10px 6px;
}

.body-shape {
  width: 100%;
  max-width: 260px;
  height: auto;
  justify-self: center;
}

.body-shape__body {
  fill: currentColor;
  opacity: 0.55;
}

.body-shape__wheel {
  fill: var(--surface-2);
  stroke: currentColor;
  stroke-width: 3;
}

.models {
  display: grid;
  gap: 14px;
}

.models .chips {
  margin-bottom: 0;
}

.models__family {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.models__family-name {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.models__list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.model {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.model__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.model__name {
  font-size: 1.05rem;
  margin: 0;
}

.model__years {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.model__status {
  margin-left: auto;
}

.model__status--current {
  background: var(--success-soft);
  color: var(--success-text);
}

.model__status--announced {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.model__bodies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.body-tag {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.8rem;
}

.model__engineering {
  line-height: 1.55;
}

.model__built {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.model__built span {
  font-weight: 600;
}

.model__gens {
  display: grid;
  gap: 4px;
  margin: 2px 0 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--sunken);
  list-style: none;
  font-size: 0.88rem;
}

.model__gens li {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.model__gen-code {
  min-width: 5.5em;
  font-weight: 600;
}

.model__gen-years {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.model__gen-note {
  color: var(--text-muted);
}

/* Flagship backdrop (Car Makers) */
.animal-hero--flagship {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 22px 22px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--g, var(--accent)) 8%, var(--surface));
}

.animal-hero--flagship > *:not(.flagship, .photo-bg) {
  position: relative;
  z-index: 1;
}

.flagship {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: end end;
  pointer-events: none;
}

.flagship__drawing {
  width: min(78%, 560px);
  max-width: none;
  margin: 0 -4% -6% 0;
  color: var(--g, var(--accent));
  opacity: 0.22;
}

.flagship__drawing .body-shape__wheel {
  fill: color-mix(in srgb, var(--g, var(--accent)) 8%, var(--surface));
}

.flagship__label {
  margin-top: 6px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.flagship__tag {
  margin-right: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.flagship__label strong {
  color: var(--text);
}

.flagship__credit {
  display: block;
  margin-top: 2px;
  font-size: 0.75rem;
}

/* A car photo as the whole background of a card (maker header and model cards). Always dark, in both themes,
   so white text stays readable over any photo. */
.photo-stage {
  --text: #ffffff;
  --text-muted: rgb(255 255 255 / 0.82);
  --line: rgb(255 255 255 / 0.22);
  --line-strong: rgb(255 255 255 / 0.32);
  --surface: rgb(255 255 255 / 0.14);
  --surface-2: rgb(255 255 255 / 0.12);
  --sunken: rgb(0 0 0 / 0.34);
  --success-soft: rgb(18 122 82 / 0.88);
  --success-text: #ffffff;
  --accent-soft: rgb(51 70 211 / 0.88);
  --accent-text: #ffffff;
  --stage-pad-x: 16px;
  --stage-pad-top: 14px;
  --stage-overlap: 56px;
  color-scheme: dark;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-color: transparent;
  background: #15171c;
  color: var(--text);
}

.photo-stage > :not(.photo-bg) {
  position: relative;
  z-index: 1;
}

.photo-stage :is(h1, h4, strong, .model__years, .animal-hero__summary, .model__engineering, .model__built) {
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.55);
}

.photo-stage a {
  color: inherit;
}

.photo-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.photo-bg__fill {
  position: absolute;
  inset: -32px;
  width: calc(100% + 64px);
  height: calc(100% + 64px);
  max-width: none;
  object-fit: cover;
  filter: blur(24px) brightness(0.42) saturate(1.15);
}

.photo-bg__car {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  max-width: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent);
  mask-image: linear-gradient(to bottom, #000 62%, transparent);
}

.photo-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgb(0 0 0 / 0) 25%, rgb(0 0 0 / 0.3));
}

/* Holds the car's space at the top; the card's text starts just above the bottom of the car. */
.photo-bg__spacer {
  aspect-ratio: 16 / 9;
  margin: calc(-1 * var(--stage-pad-top)) calc(-1 * var(--stage-pad-x)) calc(-1 * var(--stage-overlap));
}

.photo-credit {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.model.photo-stage {
  gap: 10px;
}

@media (max-width: 560px) {
  .photo-stage {
    --stage-overlap: 36px;
  }
}

/* The badge (Car Makers) */
.logo-mark {
  background-color: var(--surface);
}

.logo-mark::before {
  content: "";
  display: block;
  width: 62%;
  height: 62%;
  background-color: var(--text);
  -webkit-mask: var(--logo) center / contain no-repeat;
  mask: var(--logo) center / contain no-repeat;
}

.badge-card__credit {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.badge-card {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.badge-card__title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.badge-card__shows {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}

.badge-card__history {
  color: var(--text-muted);
}

/* Where it's found (Animals) */
.chips__label {
  align-self: center;
  margin-right: 2px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
  font-size: 0.88rem;
  white-space: nowrap;
  cursor: pointer;
}

.card__regions {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.region-section {
  display: grid;
  gap: 12px;
}

.region-section__count {
  margin-left: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ---------- Trouble codes ---------- */
.code-tag {
  display: inline-block;
  flex: none;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--sunken);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.code-tag--large {
  padding: 6px 10px;
  font-size: 1rem;
}

.code-tag--hero {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: clamp(1.5rem, 5vw, 2rem);
}

.severity {
  --sev: var(--text-muted);
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.severity__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sev);
}

.severity--low { --sev: #2f9e6e; }
.severity--medium { --sev: #e08a00; }
.severity--high { --sev: #d9342b; }

.notice--severity-low { background: var(--success-soft); }
.notice--severity-low .notice__icon { color: var(--success-text); }
.notice--severity-medium { background: var(--warn-soft); }
.notice--severity-medium .notice__icon { color: var(--warn-text); }
.notice--severity-high { background: var(--danger-soft); }
.notice--severity-high .notice__icon { color: var(--danger-text); }

.code-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 18px;
  color: inherit;
  text-decoration: none;
}

.code-row:hover {
  background: var(--surface-2);
}

.code-row__body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px 14px;
  flex: 1;
  min-width: 0;
}

@media (max-width: 560px) {
  .code-row {
    padding: 11px 14px;
  }

  .code-row__body {
    flex-direction: column;
    align-items: flex-start;
  }
}

.tool-link {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.tool-link:hover,
.starter--code:hover {
  border-color: var(--line-strong);
}

.tool-link__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.tool-link > .icon:last-child {
  color: var(--text-muted);
}

.code-lookup-slot:empty,
.code-hint-slot:empty {
  display: none;
}

.code-hint-slot .starter,
.code-lookup-slot .starter {
  margin-bottom: 14px;
}

.how-to-read {
  margin-bottom: 18px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.how-to-read summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}

.how-to-read > p {
  margin: 12px 0;
  color: var(--text-muted);
}

.decoder {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.decoder__part {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.decoder__chars {
  min-width: 2.6em;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  font-weight: 700;
  text-align: center;
}

.decoder__body {
  display: grid;
  gap: 1px;
}

.decoder__label {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.code-page {
  display: grid;
  gap: 20px;
  max-width: 760px;
}

.code-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.code-hero__body {
  display: grid;
  gap: 6px;
  flex: 1;
  min-width: 220px;
}

.code-hero__title {
  font-size: clamp(1.35rem, 3.6vw, 1.8rem);
  line-height: 1.2;
}

.code-page__meaning {
  font-size: 1.06rem;
  line-height: 1.6;
}

.code-page__range {
  color: var(--text-muted);
}

.code-section {
  display: grid;
  gap: 10px;
}

.code-section__title {
  font-size: 1.05rem;
}

.code-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 1.3em;
}

.menu--boxed {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

/* Codes explained under a fact */
.code-notes {
  display: grid;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.code-note {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: inherit;
  font-size: 0.9rem;
  text-decoration: none;
}

.code-note:hover {
  border-color: var(--line-strong);
}

.code-note__title {
  flex: 1;
  min-width: 0;
}

.code-note > .icon {
  flex: none;
  color: var(--text-muted);
}

/* Download prompt */
.download-card {
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.download-card__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.download-card__icon .icon {
  width: 22px;
  height: 22px;
}

.download-card__title {
  font-size: 1.3rem;
}

.download-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.download-card p {
  color: var(--text-muted);
}

.download-card .download-card__note {
  color: var(--success-text);
  font-weight: 500;
}

/* ---------- Downloads ---------- */
.storage {
  margin-bottom: 4px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.storage__row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.storage__row strong {
  font-weight: 600;
}

.storage__row span {
  color: var(--text-muted);
}

.shelf {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.shelf__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.shelf__item + .shelf__item {
  border-top: 1px solid var(--line);
}

.shelf__link {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.shelf__link:hover .card__name {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.shelf__body {
  display: grid;
  min-width: 0;
}

.shelf__detail {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.shelf__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Age group picker ---------- */
.profile-picker {
  max-width: 720px;
}

.audiences {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.audience {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 18px 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.audience:hover {
  border-color: var(--accent);
}

.audience--current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.audience__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.audience__label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
}

.audience__ages {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.audience__desc {
  color: var(--text-muted);
}

.audience__current {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  color: var(--accent-text);
  font-size: 0.82rem;
  font-weight: 600;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Narrower desktop ---------- */
@media (max-width: 980px) {
  .daily__label,
  .tab__label {
    display: none;
  }

  .topbar__inner {
    gap: 16px;
  }
}

/* ---------- Small phones: make room in the header for the streak ---------- */
@media (max-width: 430px) {
  .topbar__inner:has(.streak:not([hidden])) .brand__name {
    display: none;
  }
}

@media (max-width: 360px) {
  .brand__name {
    display: none;
  }
}

/* ---------- Phone layout: bottom tab bar ---------- */
@media (max-width: 760px) {
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }

  .topbar__inner,
  .footer__inner,
  .page {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar__inner {
    min-height: 54px;
    gap: 10px;
  }

  .topbar__tools {
    gap: 6px;
  }

  .daily,
  .profile-button {
    padding: 0 9px;
    gap: 5px;
  }

  .page {
    padding-top: 22px;
  }

  .chips {
    margin: 0 -16px 14px;
    padding: 2px 16px 6px;
  }

  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 12;
    gap: 0;
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
  }

  .tab {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    height: 54px;
    padding: 0 4px;
    font-size: 0.7rem;
  }

  .tab__label {
    display: inline;
  }

  .tab::after {
    display: none;
  }

  .tab[aria-current="page"] {
    color: var(--accent-text);
  }

  .tab__badge {
    position: absolute;
    top: 5px;
    left: calc(50% + 6px);
  }

  .profile-button span {
    display: none;
  }

  .profile-button {
    padding: 0 9px;
  }

  .shelf__item {
    flex-wrap: wrap;
  }

  .shelf__actions {
    width: 100%;
  }

  .shelf__actions .button {
    flex: 1;
  }

  .menu-row {
    padding: 12px 14px;
  }

  .menu-row__summary {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .level {
    padding: 16px;
  }

  .fact--next {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .brand__name {
    font-size: 0.98rem;
  }

  .system__head {
    padding: 12px 14px;
  }

  .system__count {
    display: none;
  }

  .download-card {
    padding: 18px;
  }

  .animal-hero__emoji {
    width: 60px;
    height: 60px;
    font-size: 2rem;
  }
}

/* Inside the phone apps, keep clear of the status bar / notch. */
.is-native .topbar {
  padding-top: env(safe-area-inset-top);
}

/* A car photo as the background of the whole page (Car Makers, see page-photo.js). The photo is fixed behind the
   page; the page turns dark, with see-through panels, so the car shows around the content in both themes. */
:root.has-page-photo {
  color-scheme: dark;
  --bg: #0e1015;
  --surface: rgb(18 20 26 / 0.74);
  --surface-2: rgb(255 255 255 / 0.08);
  --sunken: rgb(0 0 0 / 0.34);
  --text: #ffffff;
  --text-muted: rgb(255 255 255 / 0.8);
  --line: rgb(255 255 255 / 0.16);
  --line-strong: rgb(255 255 255 / 0.28);
  --accent: #8b9bff;
  --accent-hover: #a5b2ff;
  --accent-soft: rgb(139 155 255 / 0.2);
  --accent-text: #c3ccff;
  --on-accent: #0e1015;
  --success: #3fcf8e;
  --success-soft: rgb(63 207 142 / 0.2);
  --success-text: #8ff0c2;
  --warn-soft: rgb(240 180 80 / 0.18);
  --warn-text: #ffd28a;
  --warn-line: rgb(240 180 80 / 0.4);
  --danger: #ff7a6e;
  --danger-soft: rgb(255 122 110 / 0.18);
  --danger-text: #ffb1a8;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
}

.has-page-photo body {
  background: var(--bg);
}

.has-page-photo :is(.topbar, .page, .footer) {
  position: relative;
  z-index: 1;
}

.has-page-photo .topbar {
  position: sticky;
  z-index: 10;
  background: rgb(14 16 21 / 0.86);
}

.page-photo {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg);
}

.page-photo__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}

/* Tall screens: turn the photo 90° so the whole car fills the screen. */
@media (orientation: portrait) {
  .page-photo__img {
    inset: auto;
    top: 50%;
    left: 50%;
    width: 100vh;
    height: 100vw;
    transform: translate(-50%, -50%) rotate(90deg);
  }
}

.page-photo__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgb(8 10 14 / 0.25), rgb(8 10 14 / 0.55) 45%, rgb(8 10 14 / 0.72));
}

/* The header sits straight on the photo, below an open space where the car shows. */
.has-page-photo .animal-hero--page-photo {
  padding-top: clamp(160px, 34vh, 340px);
  border-color: transparent;
  background: none;
}

.has-page-photo .animal-hero--page-photo .flagship {
  display: none;
}

.has-page-photo .animal-hero--page-photo :is(h1, strong, .animal-hero__summary, .group-tag, .flagship__why) {
  text-shadow: 0 1px 4px rgb(0 0 0 / 0.7);
}

.has-page-photo .animal-hero__summary,
.has-page-photo .flagship__label {
  color: rgb(255 255 255 / 0.88);
}

.has-page-photo .flagship__credit a {
  color: inherit;
}

.has-page-photo :is(.panel-intro, .models__family-name, .empty) {
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.6);
}

/* Choosing a model's photo as the page background (Models tab). */
.model__bg-button {
  margin-left: auto;
}

.model--chosen {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.background-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.background-note .flagship__tag {
  margin-right: 0;
}

.background-note .flagship__credit {
  display: inline;
  margin-top: 0;
}

.background-note__reset {
  margin-left: auto;
}

/* Model pages (Car Makers): year by year, ratings, and the best-to-worst list. */
.model__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.model__links .button {
  margin-left: auto;
}

.rating-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--sunken);
  color: var(--text);
}

.rating-chip--best { background: #1f7a4d; color: #fff; }
.rating-chip--great { background: #2f6f9f; color: #fff; }
.rating-chip--good { background: #56606f; color: #fff; }
.rating-chip--mixed { background: #8a6a1c; color: #fff; }
.rating-chip--worst { background: #a3362b; color: #fff; }

.stars {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.stars__on { color: #f2b632; }
.stars__off { color: var(--line-strong); }

.stars__num {
  margin-left: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0;
}

.ranking {
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.ranking summary {
  cursor: pointer;
  font-weight: 600;
}

.ranking__list {
  display: grid;
  gap: 8px;
  margin: 10px 0 2px;
  padding-left: 1.4em;
}

.ranking__list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.ranking__list a {
  color: var(--text);
  font-weight: 600;
}

.ranking__why {
  flex-basis: 100%;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.model-page__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}

.model-page .animal-hero__name {
  font-size: clamp(1.6rem, 4.4vw, 2.3rem);
}

.years__list {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.year {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.year__picture {
  display: grid;
  align-content: start;
  gap: 4px;
  margin: 0;
}

.year__picture img {
  display: block;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.year__picture--drawing {
  padding: 12px 12px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
}

.year__picture figcaption,
.year__credit {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.year__credit a {
  color: inherit;
}

.year__when {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.year__gap {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.year__title {
  margin: 4px 0 8px;
  font-size: 1.05rem;
}

.year__label {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.year__changes {
  display: grid;
  gap: 4px;
  margin: 4px 0 0;
  padding-left: 1.2em;
}

.rating {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.rating__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.rating__head .stars {
  font-size: 1.5rem;
}

.rating__why-title {
  font-size: 1rem;
  margin: 4px 0 0;
}

.rating__why {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 1.2em;
}

.rating__basis {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.model-overview {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

@media (max-width: 640px) {
  .year {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The main tabs of a section of the app (Cars: About cars, Car history), above the topic page. */
.section-tabs {
  margin-bottom: 18px;
}

.section-tabs .segmented__tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-size: 0.98rem;
}

.section-tabs__icon {
  display: inline-flex;
}

/* ---------- Discover: the home page, one fact at a time ---------- */
.discover {
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 0 1.5rem;
}

/* The card sits on a "deck": two cards peeking out underneath, like a physical stack. */
.discover__deck {
  position: relative;
  isolation: isolate;
}

.discover__deck::before,
.discover__deck::after,
.discover--static .fact-card::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 4%;
  right: 4%;
  bottom: -10px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.discover__deck::after {
  left: 8%;
  right: 8%;
  bottom: -20px;
  z-index: -2;
  opacity: 0.7;
}

.fact-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 28px 28px 22px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--c, var(--accent));
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(16 24 40 / 0.05), 0 10px 30px rgb(16 24 40 / 0.08);
  touch-action: pan-y;
}

.fact-card--enter {
  animation: fact-in 0.28s ease-out;
}

@keyframes fact-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .fact-card--enter { animation: none; }
}

.fact-card__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.fact-pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--surface));
  color: color-mix(in srgb, var(--c, var(--accent)) 82%, var(--text));
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.fact-card__save {
  margin-left: auto;
}

.fact-card__save[aria-pressed="true"] {
  color: var(--c, var(--accent));
}

.fact-card__hook {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 4.6vw, 2.15rem);
  line-height: 1.18;
  letter-spacing: -0.015em;
}

.fact-card__body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.04rem;
  line-height: 1.62;
  color: var(--text);
}

.fact-card__why {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.fact-card__why summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent-text);
  list-style-position: inside;
}

.fact-card__why p {
  margin: 8px 0 0;
  line-height: 1.6;
  color: var(--text-muted);
}

.fact-card__source {
  justify-self: start;
  margin: 2px 0 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--sunken);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.fact-card__really {
  font-weight: 700;
  color: var(--text);
}

.discover__actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 36px;
}

.discover__actions > :only-child {
  grid-column: 1 / -1;
}

.discover__next {
  min-height: 52px;
  font-size: 1.02rem;
}

.discover__key {
  padding: 1px 6px;
  border: 1px solid rgb(255 255 255 / 0.45);
  border-radius: 5px;
  font: 600 0.7rem var(--font-body);
  opacity: 0.85;
}

.discover__connected {
  min-height: 52px;
  justify-content: space-between;
  text-align: left;
}

.discover__connected > span {
  display: grid;
  line-height: 1.25;
}

.discover__connected-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.discover__connected-why {
  font-size: 0.9rem;
  white-space: normal;
}

.discover__share {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 10px;
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.discover__status {
  min-height: 1.4em;
  margin: 8px 0 0;
  text-align: center;
  font-size: 0.86rem;
  color: var(--success-text);
}

.discover__explore {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  margin-top: 28px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

@media (max-width: 560px) {
  .discover { padding-top: 1.25rem; }
  .fact-card { padding: 22px 18px 18px; }
  .discover__actions { grid-template-columns: minmax(0, 1fr); }
  .discover__key { display: none; }
}

/* ---------- Drawer: saved facts, progress, offline packs and storage ---------- */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.drawer__scrim {
  position: absolute;
  inset: 0;
  background: rgb(10 12 16 / 0.42);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(380px, 92vw);
  padding: 18px 20px 24px;
  overflow-y: auto;
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgb(0 0 0 / 0.18);
  transform: translateX(100%);
  transition: transform 0.18s ease;
}

.drawer--open .drawer__scrim { opacity: 1; }
.drawer--open .drawer__panel { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .drawer__scrim, .drawer__panel { transition: none; }
}

.drawer__panel:focus { outline: none; }

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer__head h2 { margin: 0; font-size: 1.15rem; }

.drawer__section h3 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.drawer__list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.drawer__list a {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  line-height: 1.35;
}

.drawer__empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.drawer__storage {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.drawer__storage p { margin: 0 0 6px; }

html.drawer-open { overflow: hidden; }

/* ---------- Account and admin ---------- */
.account-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: 600 0.86rem var(--font-body);
  cursor: pointer;
}

.account-button--signed-in {
  padding: 0;
  width: 38px;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.account {
  display: grid;
  gap: 14px;
  max-width: 460px;
  margin: 0 auto;
  padding: 2.5rem 0;
}

.account h1 { margin: 0; }

.account__lead { margin: 0; color: var(--text-muted); line-height: 1.6; }

.account__admin {
  margin-left: 8px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.account__form { display: grid; gap: 8px; }
.account__form label { font-weight: 600; }

.account__input,
.admin-form input,
.admin-form select,
.admin-form textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.admin-form textarea { min-height: 0; resize: vertical; }

.account__or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.account__or::before,
.account__or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.account__message {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--success-soft);
  color: var(--success-text);
}

.account__message--error {
  background: var(--danger-soft);
  color: var(--danger-text);
}

.admin { display: grid; gap: 16px; }

.admin-panel { display: grid; gap: 14px; }

.admin-callout {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 14px 16px;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: var(--warn-text);
}

.admin-callout p { margin: 0; }

.admin-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.admin-form h3 { margin: 0; }

.admin-form__row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.admin-form__field { display: grid; gap: 4px; font-size: 0.88rem; font-weight: 600; }
.admin-form__field small { font-weight: 400; color: var(--text-muted); }
.admin-form__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.admin-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }

.admin-list__item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.admin-list__id { margin-left: 8px; font-size: 0.8rem; color: var(--text-muted); }
.admin-list__hook { margin: 6px 0 0; font-weight: 600; }
.admin-list__actions { display: flex; gap: 12px; align-items: center; }

.link-button--danger { color: var(--danger-text); }

.admin-table-wrap { overflow-x: auto; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.admin-table th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.admin-you { color: var(--text-muted); }

.account-button[hidden] { display: none; }

/* The card's own action bar (Next fact, Bookmark, Copy) and the rabbit-hole link in "Why is this true?". */
.card-actions {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.card-actions__next { min-height: 48px; font-size: 1rem; }
.card-actions__secondary { min-height: 48px; gap: 6px; }
.card-actions__secondary[aria-pressed="true"] { color: var(--c, var(--accent)); border-color: var(--c, var(--accent)); }

.fact-card__rabbit {
  margin: 10px 0 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.fact-card__rabbit a { font-weight: 600; }

@media (max-width: 560px) {
  .card-actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .card-actions__next { grid-column: 1 / -1; }
}

/* ---------- Site search and page requests ---------- */
.site-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
}

.site-search--compact { margin-top: 26px; }

.site-search__input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.site-search__input:focus { outline: none; }
.site-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.search-page { display: grid; gap: 14px; max-width: 720px; margin: 0 auto; padding: 2rem 0; }
.search-page h1 { margin: 0; }
.search-page__count { margin: 0; color: var(--text-muted); }

.search-results { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }

.search-result {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.search-result:hover { border-color: var(--line-strong); }
.search-result__emoji { font-size: 1.4rem; line-height: 1; }
.search-result__name { display: block; font-weight: 600; }
.search-result__meta { display: block; font-size: 0.86rem; color: var(--text-muted); }

.request {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.request h2, .request p { margin: 0; }
.request--sent { border-style: solid; border-color: var(--success); background: var(--success-soft); color: var(--success-text); }

.request-ready {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--success-soft);
  color: var(--success-text);
  font-weight: 600;
}

.account-button { gap: 6px; }

@media (max-width: 430px) {
  .account-button__label { display: none; }
  .account-button { width: 38px; padding: 0; }
}

/* ---------- Daily 5: Real Fact or Nerd Trap ---------- */
.game-pips {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}
.game-pips[hidden] { display: none; }
.game-pips:hover { border-color: var(--line-strong); }

.game-intro {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}
.game-intro strong { color: var(--text); }

.game-choices {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.game-choice {
  min-height: 56px;
  font-size: 1.02rem;
  font-weight: 700;
  gap: 8px;
}
.game-choice--real { background: var(--success); border-color: var(--success); color: #fff; }
.game-choice--real:hover { background: color-mix(in srgb, var(--success) 86%, #000); }
.game-choice--trap { background: var(--danger); border-color: var(--danger); color: #fff; }
.game-choice--trap:hover { background: color-mix(in srgb, var(--danger) 86%, #000); }
.game-choice .discover__key { background: rgb(255 255 255 / 0.18); color: inherit; border-color: rgb(255 255 255 / 0.35); }

.game-card__claim--trap {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: color-mix(in srgb, var(--danger) 70%, transparent);
  color: var(--text-muted);
}

.game-verdict {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 1.02rem;
  animation: verdict-pop 0.22s ease-out;
}
.game-verdict strong { font-size: 1.1rem; }
.game-verdict--right { background: var(--success-soft); color: var(--success-text); }
.game-verdict--wrong { background: var(--danger-soft); color: var(--danger-text); }

@keyframes verdict-pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* The truth slides open below the verdict. */
.game-reveal {
  display: grid;
  grid-template-rows: 1fr;
  animation: reveal-open 0.42s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.game-reveal__inner {
  display: grid;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}
@keyframes reveal-open {
  from { grid-template-rows: 0fr; opacity: 0; }
  to { grid-template-rows: 1fr; opacity: 1; }
}

.game-truth {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
}
.game-truth span { color: var(--success-text); }

.source-badge {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--sunken);
  font-size: 0.8rem;
  color: var(--text-muted);
}
.source-badge__label {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--c, var(--accent));
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.game-summary { border-top-color: var(--accent); text-align: left; }
.game-summary__score {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 8vw, 3rem);
  line-height: 1;
}
.game-summary__verdict { margin: 0; color: var(--text-muted); }
.game-summary__receipt {
  margin: 0;
  padding: 14px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.game-summary .card-actions { grid-template-columns: 1fr; }
.game-summary__review summary { cursor: pointer; font-weight: 600; color: var(--accent-text); }
.game-summary__review ol { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 8px; line-height: 1.45; }
.game-summary__kind { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }
.game-summary__unlock {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.92rem;
  line-height: 1.5;
}
.discover__roam {
  margin: 28px 0 12px;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

@media (max-width: 420px) {
  .game-choice { min-height: 60px; font-size: 0.98rem; padding-inline: 10px; }
  .game-choice .discover__key { display: none; }
  .game-pips { padding: 0 8px; letter-spacing: 0.02em; font-size: 0.74rem; }
}

@media (prefers-reduced-motion: reduce) {
  .game-reveal, .game-verdict { animation: none; }
}

/* Phones: make room in the header for the Daily 5 pips. */
@media (max-width: 480px) {
  .topbar:has(.game-pips:not([hidden])) .brand__name { display: none; }
  .topbar__tools { gap: 6px; }
}

/* ---------- Quests: every item is a game of stages ---------- */
.stars { display: inline-flex; gap: 1px; font-size: 1rem; line-height: 1; vertical-align: middle; }
.star { color: var(--line-strong); }
.star--on { color: #f5a524; }

.quest-card { display: grid; gap: 14px; }
.quest-card .progress-card__row { flex-wrap: wrap; gap: 8px 14px; }
.quest-card__stars { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 0.92rem; color: var(--text-muted); margin-right: auto; }
.quest-card__hint { margin: 0; font-size: 0.9rem; color: var(--text-muted); }

.stage-map {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  position: relative;
}
.stage-map__node { position: relative; }
.stage-map__node:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 17px;
  left: calc(50% + 20px);
  right: calc(-50% + 20px);
  height: 3px;
  border-radius: 2px;
  background: var(--line);
}
.stage-map__node--cleared:not(:last-child)::after { background: var(--success); }
.stage-map__node a {
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
}
.stage-map__dot {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  font-weight: 800;
  font-size: 0.92rem;
}
.stage-map__node--cleared .stage-map__dot { background: var(--success); border-color: var(--success); color: #fff; }
.stage-map__node--current .stage-map__dot { border-color: var(--accent); color: var(--accent-text); box-shadow: 0 0 0 4px var(--accent-soft); animation: stage-pulse 1.8s ease-in-out infinite; }
.stage-map__node--locked { opacity: 0.6; }
.stage-map__name { font-size: 0.74rem; line-height: 1.25; color: var(--text-muted); overflow-wrap: anywhere; }
.stage-map .stars { font-size: 0.78rem; }
@keyframes stage-pulse { 50% { box-shadow: 0 0 0 8px var(--accent-soft); } }

.level__stage { color: var(--text-muted); font-weight: 600; }
.level__again { margin: 4px 0 0; }
.level__again summary { cursor: pointer; font-weight: 600; color: var(--accent-text); font-size: 0.92rem; }
.level__again .facts { margin-top: 10px; }

.knowledge {
  display: grid;
  gap: 8px;
  margin: 4px 0 10px;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--success) 35%, var(--line));
  background: var(--success-soft);
  animation: verdict-pop 0.3s ease-out;
}
.knowledge:focus { outline: 2px solid var(--success); outline-offset: 2px; }
.knowledge__title { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 800; color: var(--success-text); }
.knowledge__lead { margin: 0; font-weight: 600; }
.knowledge__list { margin: 0; padding-left: 20px; display: grid; gap: 6px; line-height: 1.5; }

.challenge { border-color: color-mix(in srgb, #f5a524 45%, var(--line)); }
.challenge .quiz__title { color: color-mix(in srgb, #f5a524 60%, var(--text)); }
.challenge--cleared { border-color: var(--line); }

.quest-stars { color: #b7791f; font-weight: 700; white-space: nowrap; }
[data-theme="dark"] .quest-stars { color: #f5c46b; }

.quest-intro {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
}
.quest-intro svg { flex: none; margin-top: 2px; color: var(--accent-text); }

.quest-launch {
  display: grid;
  gap: 10px;
  margin-top: 22px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.quest-launch h2 { margin: 0; font-family: var(--font-display); font-size: 1.2rem; }
.quest-launch p { margin: 0; color: var(--text-muted); line-height: 1.5; }
.quest-launch__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.quest-launch__rank { font-size: 0.88rem; }
.quest-launch__rank strong { color: var(--accent-text); }
.quest-launch__choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.quest-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.quest-choice:hover { border-color: var(--accent); }
.quest-choice__emoji { font-size: 1.6rem; }
.quest-choice span { display: grid; }
.quest-choice small { color: var(--text-muted); font-size: 0.8rem; }

@media (prefers-reduced-motion: reduce) {
  .stage-map__node--current .stage-map__dot, .knowledge { animation: none; }
}

/* ---------- Store and paywall ---------- */
.store { display: grid; gap: 16px; }
.store h1 { margin: 0; font-family: var(--font-display); }
.store__lead { margin: 0; color: var(--text-muted); line-height: 1.55; max-width: 62ch; }
.store__heading { margin: 12px 0 0; font-family: var(--font-display); font-size: 1.2rem; }
.store__notice {
  display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 14px;
  border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn-text); border: 1px solid var(--warn-line);
  font-size: 0.92rem; line-height: 1.45;
}
.store__notice--ok { background: var(--success-soft); color: var(--success-text); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.store-card {
  display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; align-items: start;
  padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.store-card > .button, .store-card > .badge { grid-column: 1 / -1; justify-self: stretch; text-align: center; justify-content: center; }
.store-card--best { border: 2px solid var(--accent); }
.store-card--owned { border-color: var(--success); }
.store-card__emoji { font-size: 2rem; line-height: 1; }
.store-card__body { display: grid; gap: 6px; }
.store-card__body h2, .store-card__body h3 { margin: 0; font-family: var(--font-display); }
.store-card__body p { margin: 0; color: var(--text-muted); line-height: 1.5; }
.store-card__tag { color: var(--accent-text) !important; font-weight: 800; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.store-card__meta { font-size: 0.86rem; }
.store-card__items { margin: 4px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 0.86rem; }
.store-card__items a { color: var(--text); text-decoration: none; }
.store-card__items a:hover { text-decoration: underline; }
.store-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.store-table th, .store-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.store-table td:last-child, .store-table th:last-child { text-align: right; white-space: nowrap; font-weight: 700; }
.store-table tr:last-child td { border-bottom: 0; }

.level--paywall { border-style: dashed; }
.paywall { display: grid; gap: 12px; padding: 4px 0 2px; }
.paywall__title { margin: 0; font-weight: 700; }
.paywall__offers { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.paywall__offer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
}
.paywall__offer > span { display: grid; }
.paywall__offer small { color: var(--text-muted); }
.level__price { margin: 4px 0 0; font-size: 0.8rem; color: var(--text-muted); }
.quest-intro__price a { font-weight: 700; color: var(--accent-text); }

/* ======================= The game ======================= */
.play-home { display: grid; gap: 14px; }
.play-home h1 { margin: 0; font-family: var(--font-display); }
.play-home__lead { margin: 0; color: var(--text-muted); max-width: 60ch; line-height: 1.55; }
.play-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.play-game {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; padding: 18px;
  border: 1px solid var(--line); border-top: 4px solid var(--g); border-radius: var(--radius); background: var(--surface);
  color: var(--text); text-decoration: none; transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.play-game:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgb(16 24 40 / 0.1); }
.play-game__icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: color-mix(in srgb, var(--g) 14%, var(--surface)); color: var(--g); }
.play-game__body { display: grid; gap: 2px; }
.play-game__body strong { font-family: var(--font-display); font-size: 1.15rem; }
.play-game__body span { color: var(--text-muted); font-size: 0.88rem; }
.play-game__stars { color: #b7791f !important; font-weight: 700; }
.play-game__go { grid-column: 1 / -1; display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; font-weight: 700; color: var(--accent-text); }

/* ---- The map ---- */
.play-map { display: grid; gap: 18px; }
.play-map__head { display: grid; gap: 8px; justify-items: start; }
.play-map__head h1 { margin: 0; font-family: var(--font-display); }
.play-map__stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.play-map__stats span { padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 0.88rem; }
.world { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.world--locked { opacity: 0.75; }
.world__banner {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 16px 18px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--g) 18%, var(--surface)), var(--surface));
  border-bottom: 1px solid var(--line);
}
.world__banner h2 { margin: 0; font-family: var(--font-display); font-size: 1.1rem; }
.world__banner p { margin: 2px 0 0; color: var(--text-muted); font-size: 0.88rem; }
.world__emoji { font-size: 2rem; }
.world__stars { font-weight: 800; color: #b7791f; white-space: nowrap; }
.path { list-style: none; margin: 0; padding: 18px 14px 22px; display: grid; gap: 10px; position: relative; }
.path::before { content: ""; position: absolute; left: 50%; top: 18px; bottom: 22px; width: 4px; margin-left: -2px; border-radius: 2px; background: repeating-linear-gradient(var(--line-strong) 0 10px, transparent 10px 18px); }
.node { position: relative; display: flex; justify-content: center; transform: translateX(calc((var(--i) - 1.5) * 34px)); }
.node > a, .node > span {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: min(100%, 340px); padding: 8px 12px 8px 8px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); text-decoration: none; box-shadow: 0 2px 6px rgb(16 24 40 / 0.06);
}
.node > a:hover { border-color: var(--g); }
.node__dot { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-size: 1.15rem; font-weight: 800; background: var(--sunken); border: 3px solid var(--line-strong); }
.node__label { display: grid; min-width: 0; line-height: 1.25; }
.node__label strong { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node__label small { color: var(--text-muted); font-size: 0.74rem; }
.node__stars { color: #f5a524; letter-spacing: 1px; font-size: 0.85rem; }
.node--done .node__dot { background: var(--success); border-color: var(--success); color: #fff; }
.node--current > a { border: 2px solid var(--g); box-shadow: 0 0 0 5px color-mix(in srgb, var(--g) 20%, transparent); }
.node--current .node__dot { background: var(--g); border-color: var(--g); color: #fff; animation: node-bounce 1.4s ease-in-out infinite; }
.node__go { padding: 4px 10px; border-radius: 999px; background: var(--g); color: #fff; font-weight: 800; font-size: 0.8rem; }
.node--locked > span { opacity: 0.55; }
.node--boss .node__dot { width: 54px; height: 54px; font-size: 1.5rem; border-color: #f5a524; background: color-mix(in srgb, #f5a524 18%, var(--surface)); }
.node--boss.node--done .node__dot { background: #f5a524; }
@keyframes node-bounce { 50% { transform: translateY(-4px) scale(1.06); } }
@media (max-width: 520px) { .node { transform: translateX(calc((var(--i) - 1.5) * 10px)); } }

/* ---- Playing ---- */
.game-shell { display: grid; gap: 16px; max-width: 720px; margin: 0 auto; }
.game-bar {
  position: sticky; top: 62px; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
}
.game-bar__progress { flex: 1; height: 12px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.game-bar__progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--success), color-mix(in srgb, var(--success) 60%, #9be15d)); transition: width 0.35s ease; }
.game-bar__hearts, .game-bar__combo, .game-bar__xp { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; font-size: 0.9rem; white-space: nowrap; }
.game-bar__combo--hot { color: #c2410c; animation: verdict-pop 0.25s ease-out; }
.game-bar__xp { color: var(--accent-text); }
.game-bar .icon-button { width: 34px; height: 34px; }

.game-card {
  display: grid; gap: 14px; padding: 24px; border-radius: 18px; background: var(--surface);
  border: 1px solid var(--line); border-top: 5px solid var(--g); box-shadow: 0 10px 30px rgb(16 24 40 / 0.08);
  animation: fact-in 0.28s ease-out;
}
.game-card h1, .game-card h2 { margin: 0; font-family: var(--font-display); line-height: 1.2; }
.game-card h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.game-card__eyebrow { margin: 0; color: var(--text-muted); font-size: 0.82rem; font-weight: 600; }
.game-card__sub { margin: 0; color: var(--text-muted); }
.game-go { justify-self: start; min-height: 50px; padding-inline: 22px; font-size: 1.02rem; gap: 10px; }
.game-rules { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.game-rules li { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.unlock-banner { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius); background: linear-gradient(120deg, #fff4d6, #ffe7b3); color: #6b4500; animation: unlock-glow 1.6s ease-in-out 2; }
.unlock-banner span { display: grid; }
.unlock-banner__emoji { font-size: 1.8rem; }
@keyframes unlock-glow { 50% { box-shadow: 0 0 0 6px rgb(245 165 36 / 0.35); } }

.learn-card { text-align: center; justify-items: center; }
.learn-card__emoji { font-size: 3.4rem; line-height: 1; animation: verdict-pop 0.4s ease-out; }
.learn-card__text { margin: 0; font-size: 1.15rem; line-height: 1.6; max-width: 52ch; }
.learn-card .game-go { justify-self: center; }
.learn-dots { display: flex; gap: 6px; }
.learn-dots span { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.learn-dots span.on { background: var(--g); }
.briefing { margin: 0; padding-left: 22px; display: grid; gap: 10px; line-height: 1.55; }

.challenge-card__prompt { font-size: clamp(1.25rem, 3.8vw, 1.6rem); }
.game-options { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.game-options--2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .game-options { grid-template-columns: 1fr; } .game-options--2 { grid-template-columns: 1fr 1fr; } }
.game-option {
  display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 10px 14px; text-align: left;
  border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 14px; background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}
.game-option:hover:not([disabled]) { border-color: var(--g); transform: translateY(-1px); }
.game-option:active:not([disabled]) { transform: translateY(2px); border-bottom-width: 2px; }
.game-option__key { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--sunken); font-size: 0.8rem; color: var(--text-muted); font-family: inherit; }
.game-option.is-right { border-color: var(--success); background: var(--success-soft); color: var(--success-text); animation: verdict-pop 0.25s ease-out; }
.game-option.is-wrong { border-color: var(--danger); background: var(--danger-soft); color: var(--danger-text); }
.game-option.is-dim { opacity: 0.5; }
.game-option.is-out { opacity: 0.35; text-decoration: line-through; }
.game-quote { margin: 0; padding: 16px 18px; border-left: 4px solid var(--g); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 1.08rem; line-height: 1.6; }
.game-quote--trap { border-left-color: #f5a524; }
.game-blank { margin: 0; font-size: 1.12rem; line-height: 1.8; }
.game-blank__gap { display: inline-block; min-width: 4.5em; margin: 0 4px; padding: 0 8px; border-bottom: 3px dashed var(--g); text-align: center; font-weight: 800; color: var(--g); }
.game-blank__gap.is-right { border-bottom-style: solid; color: var(--success-text); border-color: var(--success); }
.game-blank__gap.is-wrong { color: var(--danger-text); border-color: var(--danger); }
.clues { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.clue { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); line-height: 1.5; }
.clue--new { animation: fact-in 0.3s ease-out; border: 1px solid color-mix(in srgb, var(--g) 40%, var(--line)); }
.clue__n { display: block; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--g); }
.match { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 10px; }
.match__col { display: grid; gap: 8px; align-content: start; }
.match__tile { min-height: 52px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; text-align: left; cursor: pointer; line-height: 1.35; }
.match__tile--right { font-weight: 500; font-size: 0.92rem; }
.match__tile.is-picked { border-color: var(--g); background: color-mix(in srgb, var(--g) 12%, var(--surface)); }
.match__tile.is-right { border-color: var(--success); background: var(--success-soft); color: var(--success-text); }
.match__tile.is-wrong { border-color: var(--danger); background: var(--danger-soft); animation: shake 0.35s; }
.match__tile[disabled] { cursor: default; }
.match__help { margin: 0; color: var(--text-muted); font-size: 0.88rem; }
.game-timer { height: 6px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.game-timer span { display: block; height: 100%; background: linear-gradient(90deg, #f5a524, var(--danger)); transform-origin: left; animation: timer-run var(--secs) linear forwards; }
@keyframes timer-run { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.game-hint { margin: 0; padding: 10px 14px; border-radius: var(--radius-sm); background: #fff8e1; color: #6b4500; line-height: 1.5; animation: fact-in 0.25s ease-out; }
.game-hint-btn { justify-self: start; gap: 6px; }
.game-hint-btn__count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 999px; background: #f5a524; color: #fff; font-size: 0.75rem; }
.game-feedback { display: grid; gap: 8px; padding: 14px 16px; border-radius: 14px; animation: fact-in 0.22s ease-out; }
.game-feedback p { margin: 0; line-height: 1.5; }
.game-feedback--right { background: var(--success-soft); color: var(--success-text); }
.game-feedback--wrong { background: var(--danger-soft); color: var(--danger-text); }
.game-feedback__title { font-weight: 800; font-size: 1.1rem; }
.game-feedback__xp { font-weight: 700; }
.game-feedback__explain { color: var(--text) !important; }
.is-shaking { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.result-card { text-align: center; justify-items: center; }
.result-card .game-go, .result-card__actions { justify-self: center; }
.result-card__stars { margin: 0; display: flex; gap: 6px; font-size: 3.4rem; line-height: 1; }
.result-card__stars span { color: var(--line-strong); }
.result-card__stars span.on { color: #f5a524; animation: star-in 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; animation-delay: var(--d); }
@keyframes star-in { from { transform: scale(0) rotate(-40deg); opacity: 0; } to { transform: none; opacity: 1; } }
.result-card__xp { margin: 0; font-weight: 700; color: var(--accent-text); }
.result-card__big { margin: 0; font-size: 3.4rem; }
.result-card__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.result-card .knowledge { text-align: left; width: 100%; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

[data-theme="dark"] .unlock-banner { background: linear-gradient(120deg, #3a2a05, #4a3306); color: #ffd98a; }
[data-theme="dark"] .game-hint { background: #3a2a05; color: #ffd98a; }
@media (prefers-reduced-motion: reduce) {
  .game-card, .node--current .node__dot, .unlock-banner, .result-card__stars span.on, .is-shaking, .clue--new, .game-option.is-right, .match__tile.is-wrong { animation: none !important; }
  .game-timer span { animation: none; }
}

/* ---------- Uncertain figures: a link that opens the estimates ---------- */
.estimate-link {
  display: inline; padding: 0 1px; margin: 0; border: 0; background: none; font: inherit; color: var(--accent-text); text-align: left;
  text-decoration: underline dotted 2px; text-underline-offset: 3px; cursor: help; border-radius: 3px;
}
.estimate-link:hover { background: var(--accent-soft); }
.estimate-link[aria-expanded="true"] { background: var(--accent-soft); text-decoration-style: solid; }
.estimate-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.estimate-link__mark { margin-left: 2px; font-size: 0.62em; font-weight: 800; letter-spacing: 0.02em; color: #b7791f; text-decoration: none; vertical-align: super; }
.estimates {
  display: grid; gap: 8px; margin: 8px 0 4px; padding: 12px 14px; border: 1px solid var(--line-strong);
  border-left: 4px solid #f5a524; border-radius: var(--radius-sm); background: var(--surface);
  box-shadow: 0 6px 18px rgb(16 24 40 / 0.1); font-size: 0.92rem; line-height: 1.45; text-align: left;
  animation: fact-in 0.18s ease-out;
}
.estimates[hidden] { display: none; }
.estimates__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.estimates__title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0; font-weight: 700; }
.estimates__badge { padding: 2px 8px; border-radius: 999px; background: #fff1d6; color: #7a4a00; font-size: 0.74rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.estimates__close { flex: none; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-2); color: var(--text-muted); font-size: 1.1rem; line-height: 1; cursor: pointer; }
.estimates__list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.estimates__list li { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: baseline; padding: 6px 8px; border-radius: 6px; background: var(--surface-2); }
.estimates__tag { grid-row: span 2; align-self: start; padding: 1px 6px; border-radius: 4px; border: 1px solid #f5c46b; color: #7a4a00; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.estimates__value { font-weight: 700; color: var(--text); }
.estimates__by { color: var(--text-muted); font-size: 0.86rem; }
.estimates__note { margin: 0; color: var(--text); }
.estimates__foot { margin: 0; color: var(--text-muted); font-size: 0.8rem; font-style: italic; }
[data-theme="dark"] .estimates__badge, [data-theme="dark"] .estimates__tag { background: #3a2a05; color: #ffd98a; border-color: #6b4a0a; }
@media (prefers-reduced-motion: reduce) { .estimates { animation: none; } }

/* ======================= New challenge types ======================= */
.cbody { display: grid; gap: 12px; }
.cbody__note { margin: 0; color: var(--warn-text); background: var(--warn-soft); padding: 8px 12px; border-radius: var(--radius-sm); }
.challenge-badge { display: inline-block; margin-right: 8px; padding: 2px 8px; border-radius: 999px; background: #fff1d6; color: #7a4a00; font-weight: 800; font-size: 0.74rem; }
[data-theme="dark"] .challenge-badge { background: #3a2a05; color: #ffd98a; }
.challenge-card__tools { display: flex; flex-wrap: wrap; gap: 8px; }

/* Crossword */
.cw { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 40px)); gap: 3px; justify-content: start; max-width: 100%; overflow-x: auto; }
.cw__block { aspect-ratio: 1; }
.cw__cell { position: relative; aspect-ratio: 1; border: 2px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.cw__cell:focus-within { border-color: var(--g, var(--accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--g, var(--accent)) 25%, transparent); }
.cw__num { position: absolute; top: 1px; left: 3px; font-size: 0.6rem; font-weight: 800; color: var(--text-muted); pointer-events: none; }
.cw__input { width: 100%; height: 100%; border: 0; background: transparent; text-align: center; text-transform: uppercase; font: 800 1.1rem var(--font-display); color: var(--text); padding: 6px 0 0; caret-color: transparent; }
.cw__input:focus { outline: none; }
.cw__cell.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.cw__cell.is-given { background: #fff1d6; }
.cw__cell.is-right { border-color: var(--success); background: var(--success-soft); }
.cw__cell.is-shown { border-color: var(--danger); }
.cw__clues { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.cw__clues ol { margin: 4px 0 0; padding-left: 22px; display: grid; gap: 6px; }
.cw__dir { margin: 0; font-weight: 800; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.cw__clue { text-align: left; font-size: 0.92rem; line-height: 1.4; color: var(--text); text-decoration: none; }

/* Unscramble */
.scramble__slots, .scramble__tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.scramble__slot, .scramble__tile { width: 44px; height: 50px; border-radius: 10px; font: 800 1.25rem var(--font-display); cursor: pointer; }
.scramble__slot { border: 2px dashed var(--line-strong); background: var(--surface-2); color: var(--text); }
.scramble__slot.is-given { border-style: solid; background: #fff1d6; }
.scramble__slot.is-right { border: 2px solid var(--success); background: var(--success-soft); color: var(--success-text); }
.scramble__slot.is-shown { border: 2px solid var(--danger); }
.scramble__tile { border: 2px solid var(--line); border-bottom-width: 4px; background: var(--surface); color: var(--text); }
.scramble__tile:active { transform: translateY(2px); border-bottom-width: 2px; }

/* Timeline */
.order { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.order__item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); }
.order__item.is-given { background: #fff1d6; }
.order__item.is-right { border-color: var(--success); background: var(--success-soft); }
.order__item.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.order__n { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--sunken); font-weight: 800; }
.order__text { line-height: 1.4; }
.order__moves { display: flex; gap: 4px; }
.order__moves .icon-button { width: 34px; height: 34px; }

/* Closest guess */
.estimate__row { display: flex; flex-wrap: wrap; gap: 8px; }
.estimate__input, .team-answer, .ask__name { flex: 1 1 180px; min-height: 48px; padding: 0 14px; border: 2px solid var(--line-strong); border-radius: 12px; background: var(--surface); color: var(--text); font: 600 1.05rem var(--font-body); }
.estimate__range { margin: 0; font-weight: 700; color: var(--accent-text); }
.estimate__result { margin: 0; font-weight: 600; }

/* ======================= Facts & quiz ======================= */
.lab { display: grid; gap: 14px; max-width: 760px; margin: 0 auto; }
.lab-head { display: grid; gap: 8px; }
.lab-head h1 { margin: 0; font-family: var(--font-display); }
.lab-tabs { max-width: 320px; }
.lab-stats, .lab-run { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.lab-stats span, .lab-run span { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 0.86rem; }
.lab-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lab-badge { padding: 2px 8px; border-radius: 999px; font-size: 0.74rem; font-weight: 800; }
.lab-badge--new { background: var(--accent-soft); color: var(--accent-text); }
.lab-badge--ready { background: var(--sunken); color: var(--text-muted); }
.lab-badge--mastered { background: var(--success-soft); color: var(--success-text); }
.lab-badge--missed { background: var(--danger-soft); color: var(--danger-text); }
.lab-inline-quiz { display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--line-strong); }
.lab-links, .play-extras { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.lab-links .tool-link { margin: 0; }
.tool-link__icon { font-size: 1.3rem; }

/* ======================= Party & teams ======================= */
.party { display: grid; gap: 14px; max-width: 760px; margin: 0 auto; }
.party h1 { margin: 0; font-family: var(--font-display); }
.party-players { display: grid; gap: 8px; }
.party-player { display: flex; align-items: center; gap: 10px; }
.party-player input { flex: 1; min-height: 44px; padding: 0 12px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; }
.party-player__dot { width: 14px; height: 14px; border-radius: 50%; background: var(--p); flex: none; }
.party-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.party-mode { display: grid; gap: 4px; padding: 14px; text-align: left; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.party-mode.is-picked { border-color: var(--accent); background: var(--accent-soft); }
.party-mode__emoji { font-size: 1.6rem; }
.party-mode small { color: var(--text-muted); line-height: 1.4; }
.party-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.party-row select { min-height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; }
.party-top { display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--text-muted); }
.party-scores { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.party-scores li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 2px solid var(--p); }
.party-turn { margin: 0; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--p) 14%, var(--surface)); border-left: 5px solid var(--p); font-weight: 800; font-size: 1.1rem; }
.buzzers { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.buzzer { display: grid; gap: 4px; justify-items: center; min-height: 96px; border: 0; border-radius: 18px; background: var(--p); color: #fff; font: inherit; font-size: 1.1rem; cursor: pointer; box-shadow: 0 6px 0 color-mix(in srgb, var(--p) 60%, #000); touch-action: manipulation; }
.buzzer:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--p) 60%, #000); }
.buzzer[disabled] { opacity: 0.35; }
.buzzer kbd { background: rgb(255 255 255 / 0.2); border-radius: 6px; padding: 0 8px; }
.party-guesses { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.team-clue { min-height: 140px; padding: 18px; border: 2px dashed var(--line-strong); border-radius: 14px; background: var(--surface-2); color: var(--text-muted); font: inherit; font-size: 1.05rem; line-height: 1.5; cursor: pointer; user-select: none; touch-action: none; }
.team-clue.is-shown { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--text); font-weight: 600; }
.team-status { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; font-weight: 800; }

/* ======================= Ask a friend & questions board ======================= */
.together { display: grid; gap: 14px; max-width: 720px; margin: 0 auto; }
.together h1 { margin: 0; font-family: var(--font-display); }
.ask__label { display: grid; gap: 6px; font-weight: 700; }
.ask__tip { min-height: 80px; padding: 10px 12px; border: 2px solid var(--line-strong); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; resize: vertical; }
.game-option.is-picked { border-color: var(--accent); background: var(--accent-soft); }
.board-replies { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.board-tip { color: var(--text-muted); font-style: italic; }

/* ======================= Welcome ======================= */
.welcome { display: grid; gap: 14px; max-width: 720px; margin: 0 auto; }
.welcome__head { display: flex; align-items: center; gap: 14px; }
.welcome__head h1 { margin: 0; font-family: var(--font-display); }
.welcome__head p { margin: 2px 0 0; color: var(--text-muted); }
.welcome__owl { font-size: 3rem; animation: owl-bob 2.6s ease-in-out infinite; }
@keyframes owl-bob { 50% { transform: translateY(-5px) rotate(-4deg); } }
.welcome-chat { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 18px; line-height: 1.5; animation: fact-in 0.25s ease-out; }
.bubble--nerdy { justify-self: start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble--me { justify-self: end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; }
.bubble--typing { display: flex; gap: 4px; }
.bubble--typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: typing 1s infinite; }
.bubble--typing span:nth-child(2) { animation-delay: 0.15s; }
.bubble--typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 50% { opacity: 0.25; transform: translateY(-3px); } }
.welcome-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.welcome-choices--grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); max-height: 360px; overflow-y: auto; padding: 2px; }
.welcome-choice { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 10px 12px; text-align: left; border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.welcome-choice:hover { border-color: var(--accent); }
.welcome-choice span { display: grid; }
.welcome-choice small { color: var(--text-muted); font-weight: 500; font-size: 0.8rem; }
.welcome-choice__emoji { font-size: 1.5rem; }
.welcome-card { display: grid; gap: 12px; }
.welcome-about { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.welcome-about summary { cursor: pointer; font-weight: 700; }
.welcome-about ul { margin: 8px 0; padding-left: 20px; display: grid; gap: 4px; }

/* ======================= Tour ======================= */
.tour { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.tour-spot { position: fixed; border-radius: 12px; box-shadow: 0 0 0 9999px rgb(10 12 20 / 0.55); transition: all 0.25s ease; }
.tour-bubble { position: fixed; width: min(340px, calc(100vw - 24px)); padding: 14px 16px; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgb(0 0 0 / 0.3); pointer-events: auto; display: grid; gap: 6px; }
.tour-bubble p { margin: 0; }
.tour-bubble__who { font-weight: 800; color: var(--accent-text); font-size: 0.85rem; }
.tour-bubble__title { font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; }
.tour-bubble__text { line-height: 1.5; color: var(--text-muted); }
.tour-bubble__actions { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.tour-bubble__count { margin-right: auto; font-size: 0.8rem; color: var(--text-muted); }
@media (prefers-reduced-motion: reduce) { .welcome__owl, .bubble, .bubble--typing span, .tour-spot { animation: none; transition: none; } }
.lab-tabs .segmented__tab { text-decoration: none; }

/* ======================= Top bar without tabs, and the main menu ======================= */
/* The bar holds: For Nerds (home) · Daily 5 · Learning as · Sign in · Saved & offline · Light/dark, spread out. */
.topbar__tools { flex: 1; justify-content: space-evenly; margin-left: 0; }
.profile-button__label small { color: var(--text-muted); font-weight: 500; margin-right: 2px; }
@media (max-width: 760px) {
  body { padding-bottom: env(safe-area-inset-bottom); } /* no bottom tab bar any more */
  .topbar__tools { justify-content: space-between; }
  .profile-button__label small { display: none; }
  .topbar:has(.game-pips:not([hidden])) .brand__name { display: none; }
}

.menu { display: grid; gap: 16px; max-width: 860px; margin: 0 auto; }
.menu__head h1 { margin: 0; font-family: var(--font-display); font-size: clamp(1.8rem, 5vw, 2.4rem); }
.menu__head p { margin: 4px 0 0; color: var(--text-muted); }
.menu-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.menu-stats li { padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 0.9rem; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.menu-card {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; min-height: 96px; padding: 16px 18px;
  border: 1px solid var(--line); border-left: 5px solid var(--g, var(--accent)); border-radius: var(--radius); background: var(--surface);
  color: var(--text); text-decoration: none; transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.menu-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgb(16 24 40 / 0.1); }
.menu-card__icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; font-size: 1.7rem; background: color-mix(in srgb, var(--g, var(--accent)) 14%, var(--surface)); color: var(--g, var(--accent)); }
.menu-card__body { display: grid; gap: 3px; min-width: 0; }
.menu-card__body strong { font-family: var(--font-display); font-size: 1.2rem; }
.menu-card__body small { color: var(--text-muted); line-height: 1.4; }
.menu-card__meter { display: block; height: 5px; margin-top: 6px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.menu-card__meter span { display: block; height: 100%; background: var(--g, var(--accent)); }
.menu-more { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0; padding: 0; list-style: none; }
.menu-more a { font-weight: 600; color: var(--accent-text); text-decoration: none; }
.menu-more a:hover { text-decoration: underline; }
.menu-grid > li, .menu-more > li, .menu-stats > li + li { border-top: 0; margin-top: 0; }
.menu-grid > li { padding: 0; border: 0; }

/* ---------- Trees: kingdom → … → species, area → system → subsystem, country → owner → make ---------- */
.view-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 12px 0 4px;
}

.view-switch {
  flex: 0 0 auto;
}

.view-bar__link {
  font-weight: 600;
}

.tree {
  display: grid;
  gap: 20px;
  margin-top: 8px;
}

.tree__title {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.tree details {
  margin: 0;
}

.tree__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  list-style: none;
}

.tree__summary::-webkit-details-marker {
  display: none;
}

.tree__summary::before {
  content: '▸';
  display: inline-block;
  width: 1em;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.tree details[open] > .tree__summary::before {
  transform: rotate(90deg);
}

.tree__summary:hover {
  background: var(--sunken);
}

.tree__node--focus > .tree__summary {
  background: var(--sunken);
  outline: 2px solid var(--accent, currentColor);
}

.tree__rank {
  min-width: 4.5em;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tree__name {
  font-weight: 700;
}

.tree__common {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.tree__count {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tree__children {
  margin: 0 0 0 14px;
  padding: 0 0 0 10px;
  border-left: 2px solid var(--line);
  list-style: none;
}

.tree__leaf-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.tree__leaf-link:hover {
  border-color: currentColor;
}

.tree__leaf-text {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  min-width: 0;
}

.tree__emoji {
  font-size: 1.2rem;
}

.tree__done {
  color: var(--good, #17a356);
}

.tree-page__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.classification {
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.classification__title {
  margin: 0 0 8px;
  font-size: 1rem;
}

.classification__path {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.classification__path li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
}

.classification__path li + li {
  padding-left: calc(var(--depth, 0) * 10px);
}

@media (max-width: 560px) {
  .tree__children {
    margin-left: 6px;
    padding-left: 6px;
  }

  .tree__rank {
    min-width: 0;
  }
}

/* ---------- The upside-down tree: a node-and-line diagram, root at the top ---------- */
.explorer {
  margin: 12px 0 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.explorer__trail {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px;
  min-height: 1.4em;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.explorer__info {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--tree-alive);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.explorer__info p { margin: 0 0 4px; }
.explorer__info-title { font-size: 1.05rem; }
.explorer__info-count { color: var(--text-muted); font-size: 0.88rem; }

.explorer__rank {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.explorer__key,
.explorer__hint {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
}

/* The diagram scrolls sideways inside its box when a level is wider than the screen; the page itself never does. */
.diagram {
  overflow-x: auto;
  padding-bottom: 4px;
  text-align: center;
  -webkit-overflow-scrolling: touch;
}

.diagram__svg {
  display: inline-block;
  max-width: none;
  vertical-align: top;
}

.diagram__edge {
  stroke: var(--text-muted);
  stroke-width: 1.4;
}

.diagram__edge--on {
  stroke: var(--text);
  stroke-width: 1.8;
}

.diagram__node,
.diagram__leaf {
  cursor: pointer;
}

.diagram__node:focus,
.diagram__leaf:focus { outline: none; }

.diagram__circle {
  fill: var(--surface);
  stroke: var(--text);
  stroke-width: 1.6;
  transition: fill 0.15s ease;
}

.diagram__node:hover .diagram__circle,
.diagram__node:focus-visible .diagram__circle,
.diagram__leaf:hover .diagram__circle,
.diagram__leaf:focus-visible .diagram__circle {
  fill: var(--sunken);
  stroke-width: 2.4;
}

.diagram__node--open .diagram__circle {
  fill: color-mix(in srgb, var(--tree-leaf) 22%, var(--surface));
  stroke: var(--tree-alive);
  stroke-width: 2.4;
}

.diagram__leaf .diagram__circle { stroke: color-mix(in srgb, var(--tree-leaf) 70%, var(--text)); }
.diagram__leaf--started .diagram__circle { fill: color-mix(in srgb, var(--tree-leaf) 18%, var(--surface)); }

.diagram__letter {
  fill: var(--text);
  font-size: 19px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.diagram__emoji {
  font-size: 20px;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.diagram__side {
  fill: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}

.diagram__side--done { fill: var(--tree-alive); }

.diagram__name {
  fill: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
}

.diagram__name--latin { font-style: italic; }

.diagram__common {
  fill: var(--text-muted);
  font-size: 11px;
  text-anchor: middle;
}

.diagram__more-stem {
  stroke: var(--text-muted);
  stroke-width: 1.6;
  stroke-dasharray: 3 4;
}

.diagram__more {
  fill: var(--text-muted);
  font-size: 11px;
  text-anchor: middle;
}

.diagram__hidden {
  fill: var(--text-muted);
  font-size: 10.5px;
  font-style: italic;
}

.diagram__row {
  fill: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.account__code {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3em;
}

/* ---------- The Account menu (#/account) ---------- */
.account-menu {
  max-width: 600px;
  gap: 18px;
}

.account-menu__section {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.account-menu__section h2 {
  margin: 0;
  font-size: 1.05rem;
}

.account-menu__section p { margin: 0; }

.account-menu__list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.account-menu__row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.account-menu__row:hover { background: var(--sunken); }
.account-menu__emoji { font-size: 1.3rem; }

.account-menu__text {
  display: grid;
  flex: 1;
  gap: 1px;
}

.account-menu__text small { color: var(--text-muted); }

.account-menu__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.account-menu__code {
  overflow-x: auto;
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--sunken);
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre;
}

.account-menu__danger { justify-self: start; color: #d13438; }
