/* 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) */
  --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;
    --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;
  --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;
}

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(--primary); }
.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); }

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;
}
/* 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; }

/* --- 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; }

/* --- 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: 24px 0; }
.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; }
.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(--primary); }
.accent-teal { --accent: var(--teal); }
.accent-blue { --accent: var(--blue); }
.accent-forest { --accent: var(--forest); }

.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; }
@media (min-width: 640px) {
  .atom-intro { grid-template-columns: 240px 1fr; align-items: center; }
  .terms { grid-template-columns: 1fr 1fr; }
}

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

.stats { display: grid; grid-template-columns: repeat(3, 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; }
.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); }
.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); }
.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; }
.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; }
}
