/* Lernapp – one stylesheet for all pages. Mobile first: phone layout is the default.
   Look: "lab notebook" – green, graph paper background, measurement values in a monospace font. */

:root {
  color-scheme: light;
  --bg: #f2f7f3;
  --grid: rgb(21 128 61 / 0.08);        /* lines of the graph paper */
  --surface: #ffffff;
  --text: #0f1f17;
  --muted: #5b6b62;
  --border: #d3e2d8;
  --primary: #15803d;                   /* lab green */
  --teal: #00b0c8;                      /* Physik (turquoise) */
  --blue: #2563eb;                      /* Mathe */
  --forest: #14532d;                    /* Biologie (dark green) */
  --orange: #ea580c;                    /* Erdkunde */
  --page-base: #f6f8f7;                 /* base for the tinted subject backgrounds */
  /* Main colour of the whole interface per subject (buttons, links, lines …) */
  --ui-chemie: #15803d;
  --ui-physik: #0b8193;                 /* darker turquoise, so white text on buttons stays readable */
  --ui-biologie: #14532d;
  --ui-mathe: #2563eb;
  --ui-erdkunde: #c2410c;               /* darker orange, so white text on buttons stays readable */
  --ui-start: #8b5e34;                  /* brown */
  --primary-soft: #e4f4e9;
  --primary-text: #ffffff;
  --right: #16a34a;
  --right-bg: #dcfce7;
  --wrong: #b91c1c;
  --wrong-bg: #fee2e2;
  --radius: 8px;
  --shadow: 0 1px 2px rgb(15 31 23 / 0.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, Menlo, monospace;

  /* Colours of the element categories (like a printed periodic table) */
  --cat-alkalimetall: #fecaca;
  --cat-erdalkalimetall: #fed7aa;
  --cat-uebergangsmetall: #fde68a;
  --cat-metall: #d9f99d;
  --cat-halbmetall: #bbf7d0;
  --cat-nichtmetall: #a5f3fc;
  --cat-halogen: #bfdbfe;
  --cat-edelgas: #ddd6fe;
  --cat-lanthanoid: #fbcfe8;
  --cat-actinoid: #f5d0fe;
}

/* Dark mode. Two cases, keep both blocks the same:
   1. "Automatisch": the device is set to dark (and nobody chose "Hell" on the start page)
   2. "Dunkel" was chosen on the start page (attribute data-theme="dark" on <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a1510;
    --grid: rgb(74 222 128 / 0.06);
    --surface: #11211a;
    --text: #e4f1e8;
    --muted: #8ea89a;
    --border: #23392d;
    --primary: #22c55e;
    --teal: #22d3ee;
    --forest: #4d9f6a;
    --orange: #fb923c;
    --page-base: #0b100e;
    --ui-chemie: #22c55e;
    --ui-physik: #22d3ee;
    --ui-biologie: #4d9f6a;
    --ui-mathe: #60a5fa;
    --ui-erdkunde: #fb923c;
    --ui-start: #c49a6c;
    --blue: #60a5fa;
    --primary-soft: #133524;
    --primary-text: #04210f;
    --right: #4ade80;
    --right-bg: #14532d;
    --wrong: #f87171;
    --wrong-bg: #7f1d1d;

    --cat-alkalimetall: #7f1d1d;
    --cat-erdalkalimetall: #7c2d12;
    --cat-uebergangsmetall: #713f12;
    --cat-metall: #3f6212;
    --cat-halbmetall: #14532d;
    --cat-nichtmetall: #164e63;
    --cat-halogen: #1e3a8a;
    --cat-edelgas: #4c1d95;
    --cat-lanthanoid: #831843;
    --cat-actinoid: #701a75;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1510;
  --grid: rgb(74 222 128 / 0.06);
  --surface: #11211a;
  --text: #e4f1e8;
  --muted: #8ea89a;
  --border: #23392d;
  --primary: #22c55e;
  --teal: #22d3ee;
  --forest: #4d9f6a;
  --orange: #fb923c;
  --page-base: #0b100e;
  --ui-chemie: #22c55e;
  --ui-physik: #22d3ee;
  --ui-biologie: #4d9f6a;
  --ui-mathe: #60a5fa;
  --ui-erdkunde: #fb923c;
  --ui-start: #c49a6c;
  --blue: #60a5fa;
  --primary-soft: #133524;
  --primary-text: #04210f;
  --right: #4ade80;
  --right-bg: #14532d;
  --wrong: #f87171;
  --wrong-bg: #7f1d1d;

  --cat-alkalimetall: #7f1d1d;
  --cat-erdalkalimetall: #7c2d12;
  --cat-uebergangsmetall: #713f12;
  --cat-metall: #3f6212;
  --cat-halbmetall: #14532d;
  --cat-nichtmetall: #164e63;
  --cat-halogen: #1e3a8a;
  --cat-edelgas: #4c1d95;
  --cat-lanthanoid: #831843;
  --cat-actinoid: #701a75;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  font: 17px/1.5 var(--font);
  /* Graph paper: thin horizontal and vertical lines every 20px */
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

/* Normal text links (without a class – buttons, cards, the path at the top have their own colours) */
a:not([class]) { color: var(--primary); font-weight: 600; text-underline-offset: 2px; }
a:not([class]):hover { text-decoration-thickness: 2px; }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}

h1, h2, h3 { line-height: 1.2; }
h2 { margin: 1.2em 0 0.6em; }
h3 { font-size: 1rem; margin: 1.2em 0 0.5em; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--wrong); font-weight: 600; }
[hidden] { display: none !important; }

/* Numbers and measurement values in a monospace font, like in a lab protocol */
.mono, .tile-number, .stat strong, .score-item strong, .quiz-progress, .box strong,
.solution-facts, .badge, .prompt-symbol, .prompt-number { font-family: var(--font-mono); }

/* Small uppercase labels ("01 / Was willst du lernen?") */
.setup { counter-reset: step; }
legend, .label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
}
.setup legend::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero) " / ";
  color: var(--muted);
}
/* Hidden for the eye, but still there for screen readers and the form. */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}

/* --- Icons (monochrome, take the text colour) ---------------------------- */

.icon {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  vertical-align: -0.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.accent { color: var(--primary); }
.brand .icon, .brand-icon { color: var(--primary); }

/* --- Background pattern of a subject (drawings like atoms, DNA, π …) ------ */
/* The SVG is only used as a stencil (mask), so it takes the subject colour and works in dark mode too.
   A new pattern: draw public/img/bg-NAME.svg, add a line below and set 'background' => 'NAME' in subjects.php. */

.bg-start    { --pattern: url(../img/bg-start.svg);    --pattern-color: var(--ui-start); }
.bg-chemie   { --pattern: url(../img/bg-chemie.svg);   --pattern-color: var(--primary); }
.bg-physik   { --pattern: url(../img/bg-physik.svg);   --pattern-color: var(--teal); }
.bg-biologie { --pattern: url(../img/bg-biologie.svg); --pattern-color: var(--forest); }
.bg-mathe    { --pattern: url(../img/bg-mathe.svg);    --pattern-color: var(--blue); }
.bg-erdkunde { --pattern: url(../img/bg-erdkunde.svg); --pattern-color: var(--orange); }

body[class^="bg-"]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--pattern-color);
  opacity: 0.17;
  -webkit-mask: var(--pattern) 0 0 / 600px 600px repeat;
  mask: var(--pattern) 0 0 / 600px 600px repeat;
}
/* Page background tinted in the subject colour (Chemie keeps the normal green paper) */
.bg-physik, .bg-biologie, .bg-mathe, .bg-erdkunde {
  --bg: color-mix(in srgb, var(--pattern-color) 10%, var(--page-base));
  --grid: color-mix(in srgb, var(--pattern-color) 16%, transparent);
}
/* Start page: beige paper with brown lines and drawings */
.bg-start { --bg: #f4ebdd; --grid: rgb(139 94 52 / 0.12); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bg-start { --bg: #17120d; --grid: rgb(196 154 108 / 0.08); }
}
:root[data-theme="dark"] .bg-start { --bg: #17120d; --grid: rgb(196 154 108 / 0.08); }

/* The whole interface (top bar line, buttons, links, selected boxes …) takes the colour of the page.
   Chemie keeps the normal green. */
.bg-start    { --primary: var(--ui-start); }
.bg-physik   { --primary: var(--ui-physik); }
.bg-biologie { --primary: var(--ui-biologie); }
.bg-mathe    { --primary: var(--ui-mathe); }
.bg-erdkunde { --primary: var(--ui-erdkunde); }
.bg-start, .bg-physik, .bg-biologie, .bg-mathe, .bg-erdkunde {
  --primary-soft: color-mix(in srgb, var(--primary) 14%, var(--surface));
}

/* The colours are brighter in dark mode, so a bit less is enough there */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body[class^="bg-"]::before { opacity: 0.13; } }
:root[data-theme="dark"] body[class^="bg-"]::before { opacity: 0.13; }

/* --- Slide animation between pages (see js/transitions.js) --------------- */
/* Only the content (<main>) moves – the top bar stays where it is. */

.slide-in-forward main  { animation: slide-in-from-right 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
.slide-in-back main     { animation: slide-in-from-left 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
.slide-out-forward main { animation: slide-out-to-left 0.15s ease-in forwards; }
.slide-out-back main    { animation: slide-out-to-right 0.15s ease-in forwards; }
/* no sideways scroll bar while something slides */
[class*="slide-"] body { overflow-x: hidden; }

@keyframes slide-in-from-right { from { transform: translateX(100%); } }
@keyframes slide-in-from-left  { from { transform: translateX(-35%); opacity: 0; } }
@keyframes slide-out-to-left   { to { transform: translateX(-35%); opacity: 0; } }
@keyframes slide-out-to-right  { to { transform: translateX(100%); } }

/* --- Top bar ------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 3px solid var(--primary);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.topbar nav { display: flex; align-items: center; gap: 2px; }
.topbar nav .nav-icon {
  display: grid;
  place-items: center;
  padding: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.topbar nav .nav-icon:hover { color: var(--text); background: var(--primary-soft); }
.nav-form { margin: 0; display: contents; }
/* Light mode shows the moon (→ dark), dark mode shows the sun (→ light) */
.topbar nav .theme-to-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .topbar nav .theme-to-dark { display: none; }
  :root:not([data-theme="light"]) .topbar nav .theme-to-light { display: grid; }
}
:root[data-theme="dark"] .topbar nav .theme-to-dark { display: none; }
:root[data-theme="dark"] .topbar nav .theme-to-light { display: grid; }
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 9px;
  border-radius: 6px;
  font-size: 0.95rem;
}
.topbar nav a.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.topbar nav .nav-icon.active { color: var(--primary); }

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.big { width: 100%; min-height: 56px; font-size: 1.1rem; margin-top: 10px; }
.btn.right { background: var(--right-bg); border-color: var(--right); color: var(--text); }
.btn.wrong { background: var(--wrong-bg); border-color: var(--wrong); color: var(--text); }

/* --- Login --------------------------------------------------------------- */

.login { max-width: 340px; margin: 8vh auto 0; text-align: center; }
.login h1 { margin-bottom: 0; display: flex; align-items: center; justify-content: center; gap: 10px; }
.pin-input {
  font-size: 2rem;
  letter-spacing: 0.5em;
  text-align: center;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.pin-dots { display: flex; justify-content: center; gap: 18px; margin: 14px 0 24px; }
.login-label { display: block; margin: 18px 0 6px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.login-email {
  width: 100%;
  padding: 12px;
  font-size: 1.05rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.login-email:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.login-help { margin-top: 24px; }
.pin-dots span {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--primary);
}
.pin-dots span.filled { background: var(--primary); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.keypad button {
  height: 68px;
  font-size: 1.6rem;
  border-radius: 50%;
  aspect-ratio: 1;
  justify-self: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
}
.keypad button:active { background: var(--border); }
.keypad .icon { width: 1.4rem; height: 1.4rem; vertical-align: middle; }
.keypad button:disabled { opacity: 0.4; }

/* --- Breadcrumbs (Start › Chemie › Periodensystem) ------------------------ */

/* Line with the path on the left and small buttons (e.g. "Elemente") on the right.
   If there is not enough room, the buttons move below the path – still on the right. */
.page-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.page-actions { display: flex; gap: 6px; margin-left: auto; }
.page-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  padding: 3px 10px 3px 7px;
  border: 1.5px solid var(--primary);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}
.page-action:hover { background: var(--primary-soft); }
.page-action .icon { width: 1.25rem; height: 1.25rem; stroke-width: 1.7; fill: color-mix(in srgb, var(--primary) 15%, transparent); }
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;              /* may shrink next to the button … */
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}
.breadcrumbs [aria-current] { overflow: hidden; text-overflow: ellipsis; }  /* … then "Periodensy…" */
.breadcrumbs .icon { flex-shrink: 0; }
.breadcrumbs a { color: var(--primary); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .icon { width: 0.9rem; height: 0.9rem; }
.breadcrumbs [aria-current] { color: var(--text); font-weight: 600; }

/* --- Subjects and topic folders ------------------------------------------ */

.page-title { display: flex; align-items: center; gap: 10px; font-size: 1.6rem; margin: 8px 0 16px; }
/* Start page: "Was willst du heute lernen?" underlined in the colour of the page */
.page-title.underlined {
  text-decoration: underline;
  text-decoration-color: var(--primary);
  text-decoration-thickness: 3px;
  text-underline-offset: 7px;
}
.title-icon { color: var(--accent, var(--primary)); }
.card-soon .card-text small { font-style: italic; }
.empty-state {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.card .badge { flex-shrink: 0; white-space: nowrap; }
/* Colour of a subject: .accent-green (Chemie), .accent-teal (Physik), .accent-blue (Mathe) */
.accent-green { --accent: var(--ui-chemie); }
.accent-teal { --accent: var(--teal); }
.accent-blue { --accent: var(--blue); }
.accent-forest { --accent: var(--forest); }
.accent-orange { --accent: var(--orange); }

.card {
  --accent-color: var(--accent, var(--primary));
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  min-height: 84px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-left: 5px solid var(--accent-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
}
.card:hover { border-color: var(--accent-color); }
.card:active { transform: scale(0.99); }
.card:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.card-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent-color) 18%, var(--surface));
  color: var(--accent-color);
}
.card-icon .icon { width: 28px; height: 28px; }
.card-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.card-text strong { font-size: 1.25rem; }
.card-text small { color: var(--muted); font-size: 0.85rem; }
.card-arrow { color: var(--muted); }
.card-subject { min-height: 100px; }
.card-subject .card-text strong { font-size: 1.5rem; }
.card-folder .card-icon .icon { fill: color-mix(in srgb, var(--accent-color) 20%, transparent); }

/* --- Glossary page (Begriffe) ------------------------------------------- */

.atom-intro { display: grid; gap: 14px; }
.atom-figure {
  margin: 0;
  padding: 16px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.atom-figure svg { width: 200px; max-width: 100%; height: auto; }
.atom-figure figcaption { font-size: 0.9rem; color: var(--muted); }
.atom-figure figcaption strong { color: var(--text); }
.atom-shell { fill: none; stroke: var(--border); stroke-width: 2; stroke-dasharray: 4 4; }
.atom-nucleus { fill: var(--primary-soft); stroke: var(--primary); stroke-width: 2; }
.atom-electron { fill: var(--blue); }
.atom-label { fill: var(--text); font: 600 11px var(--font-mono); text-anchor: middle; }
.rule-box {
  padding: 14px 16px;
  border: 1px dashed var(--primary);
  border-radius: var(--radius);
  background: var(--primary-soft);
}
.rule-box .label { margin: 0 0 6px; }
.rule-box ul { margin: 0; padding-left: 18px; }
.rule-box li { margin: 3px 0; }
.terms { display: grid; gap: 10px; }
.term {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
}
.term h3 { margin: 0 0 4px; font-size: 1.05rem; }
.term p { margin: 0; }
.term-example { margin-top: 6px !important; font-size: 0.9rem; color: var(--muted); }
.term-example .label { margin-right: 4px; }
/* Mathe → Parabeln → Formeln */
.formula {
  margin: 6px 0 !important;
  padding: 8px 10px;
  background: var(--primary-soft);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
}
.formula-letters { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 8px 0; font-size: 0.92rem; }
.formula-letters dt { font-family: var(--font-mono); font-weight: 700; color: var(--primary); }
.formula-letters dd { margin: 0; }
.formula-card > p:not(.formula):not(.term-example) { margin-top: 6px; }
@media (min-width: 640px) {
  .atom-intro { grid-template-columns: 240px 1fr; align-items: center; }
  .terms { grid-template-columns: 1fr 1fr; }
}

/* --- Learning streak (start page) ---------------------------------------- */

.streak {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 4px 10px 4px 7px;
  box-shadow: var(--shadow);
  border: 1.5px solid color-mix(in srgb, #f97316 45%, var(--border));
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--muted);
}
.streak strong { font-family: var(--font-mono); color: var(--text); }
.streak .icon { width: 1rem; height: 1rem; color: #f97316; }
.streak.done .icon { fill: #f97316; }  /* learned today: the flame burns */
.streak-bar { display: flex; justify-content: flex-end; gap: 8px; margin: -6px 0 0; } /* right edge, right below the top bar */
/* Easter egg on the start page: invisible button in the bottom left corner → Wiggler */
.secret-button {
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 5;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  background: transparent;
  opacity: 0;
  cursor: default;
}
.wiggler-dialog { text-align: center; }
.wiggler-image { display: block; width: 100%; max-width: 300px; height: auto; margin: 8px auto 0; }
.wiggler-text { margin: 4px 0 6px; font-size: 1.8rem; font-weight: 800; letter-spacing: 0.02em; color: #e8590c; }

/* The flame is a button (opens the explanation) */
.streak-button { font: inherit; cursor: pointer; }
.streak-button:hover { background: var(--primary-soft); }
.streak-title .icon { color: #f97316; }
.streak-title.done .icon { fill: #f97316; }
.streak-facts { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; }
.streak-facts li { display: flex; align-items: flex-start; gap: 8px; line-height: 1.4; }
.streak-facts li > .icon, .streak-mini .icon { width: 1.1rem; height: 1.1rem; flex-shrink: 0; margin-top: 2px; }
.streak-facts li > .icon { color: var(--primary); }
.streak-mini { display: inline-flex; flex-shrink: 0; }
.streak-mini .icon { color: #f97316; }
.streak-mini.done .icon { fill: #f97316; }
.streak-status { margin: 0; padding: 10px 12px; border-radius: var(--radius); background: var(--primary-soft); font-weight: 600; text-align: center; }
.streak-ranking { padding: 4px 8px; border-color: color-mix(in srgb, #eab308 50%, var(--border)); text-decoration: none; }
.streak-ranking .icon { color: #ca8a04; }
.streak-ranking:hover { background: var(--primary-soft); }

/* Rangliste (rangliste.php) */
.ranking { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.ranking th { padding: 0 10px 2px; text-align: left; font-family: var(--font-mono); font-size: 0.72rem;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.ranking td { padding: 10px; background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.ranking td:first-child { border-left: 1px solid var(--border); border-radius: var(--radius) 0 0 var(--radius); }
.ranking td:last-child { border-right: 1px solid var(--border); border-radius: 0 var(--radius) var(--radius) 0; }
.ranking .rank { width: 44px; text-align: center; font-family: var(--font-mono); font-weight: 700; }
.ranking .rank .icon { width: 1.35rem; height: 1.35rem; vertical-align: -4px; }
.ranking .rank-gold .icon { color: #ca8a04; fill: #facc15; }   /* crown */
.ranking .rank-silver .icon { color: #94a3b8; }                 /* silver medal */
.ranking .rank-bronze .icon { color: #b45309; }                 /* bronze medal */
.ranking-dialog .ranking { margin-top: 6px; }
.ranking-title { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; padding-right: 36px; }
.ranking-title .icon { color: #ca8a04; }
.ranking .name { font-weight: 600; overflow-wrap: anywhere; }
.ranking .days { white-space: nowrap; text-align: right; }
.ranking .days strong { font-family: var(--font-mono); font-size: 1.1rem; }
.ranking .days .icon { width: 1rem; height: 1rem; color: #f97316; vertical-align: -2px; margin-right: 3px; }
.ranking .days .icon.burning { fill: #f97316; }
.ranking tr.me td { background: var(--primary-soft); border-color: var(--primary); }
.ranking .badge { margin-left: 6px; font-weight: 400; }

/* --- Mathe: Parabeln ------------------------------------------------------ */

.parabola-intro { display: grid; gap: 14px; }
.parabola-figure {
  margin: 0;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.parabola-figure svg { display: block; width: 100%; max-width: 260px; height: auto; margin: 0 auto; }
.plot-grid { stroke: var(--border); stroke-width: 1; }
.plot-axis { stroke: var(--text); stroke-width: 1.5; }
.plot-label { fill: var(--muted); font: 9px var(--font-mono); text-anchor: middle; }
.plot-label.axis-name { fill: var(--text); font-weight: 700; font-size: 11px; }
.plot-curve { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
/* The three example curves: blue (Mathe colour), orange, purple */
.curve-1 { --curve: var(--primary); }
.curve-2 { --curve: #ea580c; }
.curve-3 { --curve: #9333ea; }
.plot-curve.curve-1, .plot-curve.curve-2, .plot-curve.curve-3 { stroke: var(--curve); }
.curve-legend { list-style: none; margin: 10px 0 0; padding: 0; font-size: 0.88rem; }
.curve-legend li { display: flex; align-items: baseline; gap: 8px; margin: 4px 0; }
.curve-legend strong { font-family: var(--font-mono); white-space: nowrap; }
.legend-dot { width: 12px; height: 4px; flex-shrink: 0; border-radius: 2px; background: var(--curve); transform: translateY(-3px); }
.value-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); text-align: center; margin: 4px 0 8px; }
.value-table th, .value-table td { border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); padding: 4px 2px; }
.value-table th { color: var(--primary); }
.small-note { font-size: 0.85rem; margin: 0; }
/* Exercise "Parabel → Funktionsgleichung" */
.curve-given { --curve: #ea580c; }
.plot-curve.curve-given { stroke: var(--curve); stroke-dasharray: 6 5; }
.legend-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-family: var(--font-mono); font-size: 0.85rem; }
.legend-row .legend-dot { transform: none; }
.options.equations { grid-template-columns: 1fr; }
.option.equation { font-family: var(--font-mono); font-size: 1rem; min-height: 52px; }
.helper-keys { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; margin: 6px 0 2px; }
.helper-key { min-height: 42px; padding: 4px 0; font-family: var(--font-mono); font-size: 1.05rem; }
.helper-key .icon { width: 1.1rem; height: 1.1rem; }
@media (min-width: 640px) { .options.equations { grid-template-columns: 1fr 1fr; } }
/* Exercise "Scheitelpunktform → Normalform" */
.task-equation {
  margin: 0;
  padding: 22px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 700;
  text-align: center;
}
.steps {
  margin: 10px 0 12px;
  padding: 12px 14px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
}
.steps-title { margin: 0 0 6px; font-weight: 700; }
.steps-list { margin: 0; padding-left: 1.4em; display: grid; gap: 8px; }
.steps-list strong { display: block; font-family: var(--font-mono); font-size: 0.98rem; }
.steps-list small { display: block; color: var(--muted); font-size: 0.8rem; }
/* Exercise "Brückenaufgaben": text, sketch of the bridge (drawn by js/bruecken.js) */
.bridge-story {
  margin: 4px 0 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  line-height: 1.5;
}
.bridge-figure svg { max-width: 460px; }
.bridge-figure figcaption { text-align: center; margin-top: 4px; }
.sk-water { fill: color-mix(in srgb, #38bdf8 28%, var(--surface)); }
.sk-ground { fill: color-mix(in srgb, #a16207 32%, var(--surface)); }
.sk-deck { fill: var(--muted); }
.sk-strut { stroke: var(--muted); stroke-width: 1.5; }
.sk-arch { fill: none; stroke: var(--primary); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.sk-axis { stroke: var(--text); stroke-width: 1; opacity: 0.7; }
.sk-dim { stroke: var(--text); stroke-width: 1; }
.sk-arrowhead { fill: var(--text); }
.sk-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.sk-query { stroke: #ea580c; stroke-width: 2; stroke-dasharray: 5 4; }
.sk-ship { fill: #64748b; }
.sk-cabin { fill: #e2e8f0; stroke: #64748b; stroke-width: 1; }
.sk-label {
  font: 700 11px var(--font-mono);
  fill: var(--text);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.sk-label.sk-end { text-anchor: end; }
.sk-label.sk-small { font-size: 9px; font-weight: 400; }
.sk-label.sk-axis-name { font-size: 12px; }
.sk-label.sk-ask { fill: #ea580c; font-size: 16px; }
.coming-soon { margin-top: 16px; }
@media (min-width: 640px) {
  .parabola-intro { grid-template-columns: 300px 1fr; align-items: start; }
}

/* --- Erdkunde: Länder auf der Karte (js/laender.js) ---------------------- */

.map-figure {
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.map-figure svg { display: block; width: 100%; height: auto; max-height: 52vh; }
.map-sea { fill: color-mix(in srgb, #38bdf8 20%, var(--surface)); }
.map-land {
  fill: color-mix(in srgb, var(--muted) 20%, var(--surface));
  fill-rule: evenodd;
  stroke: color-mix(in srgb, var(--muted) 60%, var(--surface));
  stroke-width: 0.8px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;   /* borders stay thin when zoomed in */
}
.map-quiz { fill: color-mix(in srgb, var(--orange) 13%, var(--surface)); }
.map-land.map-target { fill: var(--primary); stroke: var(--text); }
.map-land.map-wrong { fill: var(--wrong); stroke: var(--text); }
/* After answering: the right country turns green (your wrong answer stays red) */
.map-solved .map-land.map-target { fill: var(--right); }
.map-solved .map-marker-target { stroke: var(--right); animation: none; }
.map-marker { fill: none; stroke-width: 3px; vector-effect: non-scaling-stroke; }
.map-marker-target { stroke: var(--primary); animation: marker-pulse 1.4s ease-in-out infinite; }
.map-marker-wrong { stroke: var(--wrong); }
@keyframes marker-pulse { 50% { stroke-opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .map-marker-target { animation: none; } }
.map-legend { padding: 6px 12px 8px; border-top: 1px solid var(--border); font-size: 0.88rem; }
.legend-swatch { width: 14px; height: 14px; flex-shrink: 0; border-radius: 3px; }
.legend-swatch.map-target { background: var(--right); }
.legend-swatch.map-wrong { background: var(--wrong); }
.map-legend .legend-row { font-family: inherit; }
.options.country-options { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
/* Flags: all four in one row, so you see them at first sight (also on the phone) */
.options.flag-options { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.flag-option { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 5px; min-height: 0; }
.flag-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.15);
}
.flag-name { font-size: 0.7rem; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; hyphens: auto; }
.flag-name[hidden] { display: none; }
.country-answer { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px 0; font-weight: 600; }
.flag-small { width: 32px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.15); }
.credits { margin-top: 24px; text-align: center; }
/* Flag mode: the flag is the question */
.task-flag-figure { margin: 0 0 14px; text-align: center; }
.task-flag { width: min(260px, 70%); aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.15), var(--shadow); }
.choice-flags strong { display: inline-flex; align-items: center; gap: 6px; }
.choice-flags .icon { width: 1rem; height: 1rem; color: var(--primary); }
.choice input:disabled + span { opacity: 0.45; cursor: not-allowed; }
.boxes-label { margin: 6px 0 4px; font-size: 0.8rem; }
.choices.choices-count { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choices-count .choice span { min-height: 48px; align-items: center; }
@media (min-width: 640px) {
  .options.flag-options { gap: 10px; }
  .flag-option { padding: 8px; }
  .flag-name { font-size: 0.85rem; }
}

/* --- Erdkunde: Flaggen (flaggen.php, js/flaggen.js) ---------------------- */

.flag-section { margin-top: 18px; }
.flag-section-title { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; font-size: 1.15rem; }
.flag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.flag-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 6px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
}
.flag-tile:hover { border-color: var(--primary); }
.flag-tile:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.flag-tile:active { transform: scale(0.97); }
.flag-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.15); }
.flag-tile span { font-size: 0.78rem; font-weight: 600; line-height: 1.2; text-align: center; overflow-wrap: anywhere; hyphens: auto; }
.country-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; padding-right: 36px; }
.country-head h2 { margin: 0 0 4px; }
.country-head .label { margin: 0; }
.country-flag { width: 96px; aspect-ratio: 4 / 3; object-fit: cover; flex-shrink: 0; border-radius: 4px; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.15); }
.country-map { margin-bottom: 12px; }
.country-map svg { max-height: 220px; }

/* --- Accounts: first setup, "Mein Konto", "Konten verwalten" ------------- */

.narrow { max-width: 480px; }
.account-page.narrow { margin: 0 auto; }
.greeting { margin: 0 0 -4px; font-weight: 600; color: var(--muted); }
.flash {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--right);
  background: var(--right-bg);
  font-weight: 600;
}
.flash .icon { flex-shrink: 0; color: var(--right); }
.flash-error { border-color: var(--wrong); background: var(--wrong-bg); }
.flash-error .icon { color: var(--wrong); }
.account-form { margin: 0 0 12px; }
.account-form label:not(.check) { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 0.9rem; }
.text-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.text-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.pin-field { font-family: var(--font-mono); letter-spacing: 0.4em; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.check { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0; cursor: pointer; }
.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--primary); flex-shrink: 0; }
.account-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 16px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.account-facts dt { color: var(--muted); font-weight: 600; }
.account-facts dd { margin: 0; overflow-wrap: anywhere; }
.btn .icon { vertical-align: -3px; margin-right: 4px; }
.user-list { display: grid; gap: 10px; margin-bottom: 20px; }
.user-card { padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.user-head { display: flex; gap: 12px; align-items: flex-start; }
.user-icon { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary); }
.user-text { min-width: 0; }
.user-text strong { margin-right: 6px; }
.user-text small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.badge-me { background: var(--muted); }
.user-actions { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.user-actions summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.user-actions[open] summary { margin-bottom: 4px; }
.danger-zone { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--border); }
.btn-danger { border-color: var(--wrong); color: var(--wrong); }
/* Self-registration: waiting for approval */
.pending-title { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; }
.pending-title .badge { font-size: 0.8rem; }
.pending-card { border-color: var(--primary); }
.pending-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 10px; }
.pending-actions form { margin: 0; }
.pending-actions .btn { width: 100%; padding-left: 6px; padding-right: 6px; white-space: nowrap; }
.nav-account { position: relative; }
.nav-dot { position: absolute; top: 5px; right: 5px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--wrong); box-shadow: 0 0 0 2px var(--surface); }
/* Invisible field that only spam bots fill in (registrieren.php) */
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* --- Start page ---------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 10px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat strong { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 1.5rem; }
.stat span { display: block; line-height: 1.3; margin-top: 2px; font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-weight: 600; margin-bottom: 8px; }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.choice input { position: absolute; opacity: 0; }
.choice-group + .choice-group { margin-top: 14px; }
.choice-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 6px;
  font-size: 0.85rem;
  color: var(--muted);
  list-style: none;          /* hide the default triangle of <details> */
}
.choice-group-title::-webkit-details-marker { display: none; }
/* Foldable groups: the title looks like a button */
.foldable > summary {
  justify-content: space-between;
  padding: 12px 14px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
.foldable[open] > summary { margin-bottom: 8px; border-style: solid; }
.summary-end { display: inline-flex; align-items: center; gap: 8px; }
.boxes-overview { margin-top: 28px; }
.boxes-overview > summary { font-size: 1.05rem; }
.toggle-icon { color: var(--primary); transition: transform 0.2s; }
.choice-group[open] .toggle-icon { transform: rotate(90deg); }
/* Number blocks (1–20, 21–40 …): smaller tiles, 3 per row on the phone */
.choices.compact { grid-template-columns: repeat(3, 1fr); }
.choices.compact .choice span { min-height: 0; padding: 8px 10px; }
.choices.compact strong { font-family: var(--font-mono); }
.choices.compact small { font-size: 0.7rem; line-height: 1.25; }
.choice-wide { grid-column: 1 / -1; } /* "Alle 118" over the full width */
/* "Was wird gefragt?": all options the same – one below the other on the phone, side by side on bigger screens */
.choices.choices-row { grid-template-columns: 1fr; }
.choices-row .choice span { min-height: 48px; }
/* Boxes with a small text below the title: start at the top, so titles and small texts
   of boxes next to each other are on the same line (even if a text wraps) */
.choice span:has(small) { justify-content: flex-start; }
.choice span {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}
.choice small { color: var(--muted); font-size: 0.8rem; }
.choice input:checked + span { border-color: var(--primary); background: var(--primary-soft); }
/* Learning sets can be ticked several at once – a small check mark shows which ones */
.choice input[type="checkbox"]:checked + span::after {
  content: "✓";
  position: absolute;
  top: 3px;
  right: 7px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
}
.choice-note { margin: -4px 0 8px; }
.choice input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }

.badge {
  background: var(--primary);
  color: var(--primary-text);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
}
.boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 2px;
  text-align: center;
  box-shadow: var(--shadow);
  border-bottom: 4px solid var(--box-color, var(--border));
}
.box strong { display: block; font-size: 1.2rem; }
.box span { font-family: var(--font-mono); font-size: 0.66rem; text-transform: uppercase; color: var(--muted); }
/* Colour of each Leitner box: red (box 1) to green (box 5) */
.box-new { --box-color: var(--border); }
.box-1 { --box-color: #ef4444; }
.box-2 { --box-color: #f97316; }
.box-3 { --box-color: #eab308; }
.box-4 { --box-color: #84cc16; }
.box-5 { --box-color: #22c55e; }

/* --- Quiz ---------------------------------------------------------------- */

.quiz-head { font-size: 0.9rem; margin-bottom: 8px; }
.quiz-progress { font-size: 0.8rem; margin: 6px 0 8px; }

/* Scoreboard: right / wrong / rate */
.scoreboard { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.score-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
}
.score-item strong { font-size: 1.6rem; line-height: 1; }
.score-item span { font-size: 0.75rem; color: var(--muted); }
.score-item .icon { width: 1.3rem; height: 1.3rem; stroke-width: 2.5; }
.score-right { border-color: var(--right); background: var(--right-bg); }
.score-right .icon, .score-right strong { color: var(--right); }
.score-wrong { border-color: var(--wrong); background: var(--wrong-bg); }
.score-wrong .icon, .score-wrong strong { color: var(--wrong); }
.score-rate strong { font-size: 1.2rem; white-space: nowrap; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(.score-right, .score-wrong) :is(strong, .icon) { color: var(--text); }
}
:root[data-theme="dark"] :is(.score-right, .score-wrong) :is(strong, .icon) { color: var(--text); }

/* The counter that just changed jumps briefly */
.score-item.bump { animation: bump 0.35s ease-out; }
@keyframes bump {
  40% { transform: scale(1.12); }
}
@media (prefers-reduced-motion: reduce) {
  .score-item.bump { animation: none; }
}

/* Bar: green part = right answers, red part = wrong answers */
.score-bar {
  display: flex;
  height: 8px;
  margin-top: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border);
}
.score-bar span { flex-grow: 0; flex-basis: 0; transition: flex-grow 0.3s; }
.bar-right { background: var(--right); }
.bar-wrong { background: var(--wrong); }
.practice-banner {
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px dashed var(--primary);
  border-radius: 6px;
  background: var(--primary-soft);
  font-size: 0.9rem;
}
.next-due { font-family: var(--font-mono); font-weight: 600; color: var(--primary); }
.done-summary { font-family: var(--font-mono); font-weight: 600; }
.question-text { text-align: center; font-weight: 600; margin: 8px 0 12px; }
.tile-number { color: color-mix(in srgb, var(--text) 75%, transparent); }

/* An element tile looks like a cell of the periodic table. */
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1.5px solid color-mix(in srgb, var(--text) 25%, transparent);
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.tile-question .tile-number { top: 10px; left: 14px; font-size: 1.15rem; }
.tile-question {
  width: 220px; height: 180px; margin: 0 auto 16px;
  border: 2px solid var(--primary);
  /* corner marks like on a specimen label */
  background:
    linear-gradient(var(--primary), var(--primary)) top 8px right 8px / 14px 2px no-repeat,
    linear-gradient(var(--primary), var(--primary)) top 8px right 8px / 2px 14px no-repeat,
    linear-gradient(var(--primary), var(--primary)) bottom 8px left 8px / 14px 2px no-repeat,
    linear-gradient(var(--primary), var(--primary)) bottom 8px left 8px / 2px 14px no-repeat,
    var(--surface);
}
.tile-prompt { font-weight: 800; }
/* Symbol and atomic number: big. Names: one fixed size that fits even "Rutherfordium". */
.prompt-symbol, .prompt-number { font-size: 4.5rem; }
.prompt-name { font-size: 1.55rem; text-align: center; padding: 0 8px; white-space: nowrap; }

.tile-solution { width: 150px; height: 150px; margin: 12px auto; }
.tile-number { position: absolute; top: 6px; left: 10px; font-weight: 600; font-size: 0.95rem; }
.tile-symbol { font-size: 3rem; font-weight: 800; line-height: 1; }
.tile-name { font-size: 1rem; margin-top: 6px; }

/* Typing mode */
.typing { display: grid; gap: 4px; }
.typing-input {
  width: 100%;
  min-height: 60px;
  padding: 10px 14px;
  font: inherit;
  font-size: 1.4rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
}
.typing-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.typing-input::placeholder { color: var(--muted); font-weight: 400; font-size: 1.1rem; }
.typing-input:disabled { opacity: 1; -webkit-text-fill-color: var(--text); }
.typing-input.right { border-color: var(--right); background: var(--right-bg); }
.typing-input.wrong { border-color: var(--wrong); background: var(--wrong-bg); }
.your-answer { font-family: var(--font-mono); font-size: 0.9rem; margin: 6px 0 0; }
.answer-hint {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--primary-soft);
  font-size: 0.95rem;
}

.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.option { min-height: 64px; font-size: 1.15rem; }
.option:disabled { cursor: default; opacity: 1; }
.option:disabled:not(.right):not(.wrong) { opacity: 0.5; }

.solution { text-align: center; margin-top: 12px; }
.feedback { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 1.3rem; font-weight: 700; white-space: pre; }
.feedback.right { color: var(--right); }
.feedback.wrong { color: var(--wrong); }
.solution-facts { color: var(--muted); margin: 4px 0; font-size: 0.82rem; }
.mnemonic {
  background: var(--primary-soft);
  border: 1px dashed var(--primary);
  border-radius: 6px;
  padding: 10px 12px;
  text-align: left;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.mnemonic .icon { color: var(--primary); margin-top: 0.15em; }
.self-check { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.done { text-align: center; }
.done-icon { margin: 0; color: var(--primary); }
.done-icon .icon { width: 72px; height: 72px; stroke-width: 1.5; }

/* --- Element list -------------------------------------------------------- */

.search {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  margin-bottom: 12px;
}
.search:focus, .pin-input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.element-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.tile-small {
  min-height: 96px;
  padding: 22px 6px 8px;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}
.tile-small:hover { border-color: var(--primary); }
.tile-small:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.tile-small:active { transform: scale(0.97); }
.tile-small .tile-symbol { font-size: 1.8rem; }
.tile-small .tile-name { font-size: 0.8rem; margin-top: 2px; text-align: center; }
.tile-small .tile-number { font-size: 0.75rem; top: 4px; left: 8px; }
.tile-small .tile-name { color: var(--text); }

/* --- Element info window ------------------------------------------------- */

.element-dialog {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: 20px;
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 50px rgb(0 0 0 / 0.25);
}
.element-dialog::backdrop { background: rgb(10 21 16 / 0.55); animation: backdrop-in 0.28s ease-out; }
.element-dialog.closing::backdrop { animation: backdrop-out 0.2s ease-in forwards; }
@keyframes backdrop-in { from { opacity: 0; } }
@keyframes backdrop-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .element-dialog::backdrop, .element-dialog.closing::backdrop { animation: none; }
}
.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.dialog-close:hover { background: var(--primary-soft); color: var(--text); }
.dialog-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 0; }
.dialog-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; padding-right: 36px; }
.dialog-head h2 { margin: 0 0 4px; }
.dialog-head .label { margin: 0; }
.tile-info { width: 104px; height: 104px; flex-shrink: 0; padding-top: 14px; }
.tile-info .tile-number { font-size: 0.8rem; top: 5px; left: 8px; }
.tile-info .tile-symbol { font-size: 2.4rem; }
.tile-info .tile-name { font-size: 0.75rem; margin-top: 2px; }
.tile-mass { font-family: var(--font-mono); font-size: 0.7rem; margin-top: 2px; }

/* Facts as a two-column table (like a data sheet) */
.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  margin: 0 0 12px;
  border-top: 1px solid var(--border);
}
.facts dt, .facts dd { margin: 0; padding: 7px 0; border-bottom: 1px solid var(--border); }
.facts dt { color: var(--muted); font-size: 0.85rem; padding-right: 16px; }
.facts dd { font-family: var(--font-mono); font-size: 0.9rem; text-align: right; }

.element-dialog h3.label { margin: 16px 0 6px; }
.info-section h3.label { display: flex; align-items: center; gap: 6px; margin: 14px 0 4px; }
.info-section .icon { width: 1rem; height: 1rem; }
.info-section p { margin: 0; font-size: 0.95rem; line-height: 1.5; }
.researcher { white-space: nowrap; }  /* flag and name stay together on one line */
.flag { margin-right: 4px; font-size: 1.15em; vertical-align: -1px; cursor: help; }
.learn-status { list-style: none; margin: 0; padding: 0; }
.learn-status li { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 0.9rem; }
.box-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--box-color);
  background: color-mix(in srgb, var(--box-color) 15%, transparent);
}

/* Category colours (used by tiles) */
.cat-alkalimetall { background: var(--cat-alkalimetall); }
.cat-erdalkalimetall { background: var(--cat-erdalkalimetall); }
.cat-uebergangsmetall { background: var(--cat-uebergangsmetall); }
.cat-metall { background: var(--cat-metall); }
.cat-halbmetall { background: var(--cat-halbmetall); }
.cat-nichtmetall { background: var(--cat-nichtmetall); }
.cat-halogen { background: var(--cat-halogen); }
.cat-edelgas { background: var(--cat-edelgas); }
.cat-lanthanoid { background: var(--cat-lanthanoid); }
.cat-actinoid { background: var(--cat-actinoid); }

/* --- Bigger screens (iPad, computer) ------------------------------------- */

@media (min-width: 640px) {
  .choices { grid-template-columns: repeat(4, 1fr); }
  .choices.compact { grid-template-columns: repeat(6, 1fr); }
  .choices.choices-row { grid-template-columns: repeat(3, 1fr); }
  .tile-question { width: 260px; height: 210px; }
  .prompt-symbol, .prompt-number { font-size: 5.5rem; }
  .prompt-name { font-size: 1.85rem; }
  .boxes { gap: 10px; }
}
