/* Informatik hinter den Spielen · Stein auf Stein – styles (tokens as in the Informatik-Challenge and the model pages) */
:root {
  --bg: #ECEEEC; --surface: #F8F9F7; --fg: #1B2A34; --muted: #56636A; --line: #CBD1CF;
  --accent: #8C6420; --accent-soft: #AA7F2E; --stage: #D9DCD8; --plinth: #1B2A34; --plinth-fg: #E6E3E0;
  --ok: #237841; --bad: #B3261E; --code-bg: #FBFBF9; --code-fg: #1B2A34; --gutter: #8A969C; --sel: #E8DDC6;
  --mark: #F2D58A; --snow: #F4F7FA; --snow-line: #9FB1BF;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11181D; --surface: #18232B; --fg: #E6E3E0; --muted: #9AA6AB; --line: #2A3943;
    --accent: #D6AA55; --accent-soft: #C79A45; --stage: #0D1317; --plinth: #0A0F12; --plinth-fg: #E6E3E0;
    --ok: #6CC287; --bad: #F2867C; --code-bg: #0F161B; --code-fg: #E6E3E0; --gutter: #5F6E75; --sel: #3A3220;
    --mark: #6B5523; --snow: #1F2C35; --snow-line: #4C6272;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11181D; --surface: #18232B; --fg: #E6E3E0; --muted: #9AA6AB; --line: #2A3943;
  --accent: #D6AA55; --accent-soft: #C79A45; --stage: #0D1317; --plinth: #0A0F12; --plinth-fg: #E6E3E0;
  --ok: #6CC287; --bad: #F2867C; --code-bg: #0F161B; --code-fg: #E6E3E0; --gutter: #5F6E75; --sel: #3A3220;
  --mark: #6B5523; --snow: #1F2C35; --snow-line: #4C6272;
  color-scheme: dark;
}
/* language: every text exists twice, <x lang="de"> and <x lang="en"> */
html[data-ui="de"] [lang="en"]:not(html), html[data-ui="en"] [lang="de"]:not(html) { display: none !important; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 12px; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.55;
  padding-bottom: env(safe-area-inset-bottom, 0px); overflow-x: hidden; }
img, svg, canvas { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.wrap { max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.skip { position: absolute; left: -999px; top: 0; background: var(--fg); color: var(--bg); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 12px 0; }
.topbar a { font-size: 13.5px; text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
header.plate { padding-block: 10px 18px; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(32px, 5.6vw, 60px); line-height: 1; letter-spacing: -0.02em; margin: 6px 0 0; text-wrap: balance; }
h1 .gold, h2 .gold { color: var(--accent); }
.lede { max-width: 72ch; color: var(--muted); margin: 12px 0 0; font-size: 16px; }
section { padding-block: 36px 4px; }
section.unit { border-top: 1px solid var(--line); margin-top: 36px; padding-top: 30px; }
h2 { font-family: var(--font-display); font-weight: 700; font-size: clamp(23px, 3vw, 31px); letter-spacing: -0.01em; margin: 0 0 6px; text-wrap: balance; }
h3 { font: 600 16px var(--font-body); margin: 22px 0 6px; }
h4 { font: 600 14.5px var(--font-body); margin: 14px 0 4px; }
.sub { color: var(--muted); margin: 0 0 14px; max-width: 74ch; }
p, li { max-width: 78ch; }
code, kbd, .mono { font-family: var(--font-mono); font-size: 0.92em; }
code, kbd, pre, textarea, .mono, .log { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
p code, li code, td code, dd code, summary code { background: color-mix(in srgb, var(--line) 45%, transparent); padding: 1px 4px; border-radius: 3px; overflow-wrap: anywhere; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 0 4px; font-size: 12px; }

button.chip, a.chip { font: 500 12.5px var(--font-body); color: var(--fg); background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 11px; cursor: pointer; text-decoration: none; display: inline-block; }
button.chip:hover, a.chip:hover { border-color: var(--accent-soft); }
.btn { font: 600 14px var(--font-body); color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; min-height: 38px; }
.btn:hover { border-color: var(--accent-soft); }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.small { font-size: 13px; padding: 5px 10px; min-height: 32px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, textarea:focus-visible, summary:focus-visible,
canvas:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.pill { display: inline-block; font: 500 11.5px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.tag { display: inline-block; font: 600 11px var(--font-mono); letter-spacing: 0.04em; padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: var(--bg); white-space: nowrap; vertical-align: 1px; }
.tag.e { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); color: var(--ok); }
.tag.v { border-color: var(--accent-soft); color: var(--accent); }

/* overview */
.units { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; list-style: none; padding: 0; margin: 0; }
.units li { max-width: none; }
.units a { display: flex; flex-direction: column; gap: 4px; height: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 14px; color: var(--fg); text-decoration: none; }
.units a:hover { border-color: var(--accent-soft); }
.units .n { font: 700 14px var(--font-display); width: 26px; height: 26px; border-radius: 4px; display: inline-grid; place-items: center;
  background: var(--plinth); color: var(--accent-soft); }
.units strong { font: 700 17px var(--font-display); }
.units small { color: var(--muted); font-size: 13px; }
.units .g { font: 500 11.5px var(--font-mono); color: var(--accent); }

/* unit header */
.uhead { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 18px; align-items: end; }
.uhead .btns { justify-content: flex-end; }
.idea { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; margin-top: 14px; }
.idea > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; min-width: 0; }
.idea h3 { margin-top: 0; }
.idea p { margin: 6px 0; }
.idea ul { margin: 6px 0; padding-left: 18px; }

/* labs */
.lab { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-top: 16px; }
.lab > h3:first-child { margin-top: 0; font: 700 19px var(--font-display); }
.labgrid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 16px; align-items: start; }
.labgrid.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.ctl { display: grid; grid-template-columns: minmax(110px, auto) minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; font-size: 13.5px; margin: 8px 0; }
.ctl label { color: var(--muted); }
.ctl input[type=range] { width: 100%; accent-color: var(--accent-soft); min-width: 0; }
.ctl output { font-family: var(--font-mono); font-variant-numeric: tabular-nums; min-width: 7ch; text-align: right; font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 13.5px; margin: 8px 0; }
.row label { display: inline-flex; gap: 6px; align-items: center; }
select, input[type=number], input[type=text] { font: 14px var(--font-body); color: var(--fg); background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 4px; padding: 6px 8px; min-height: 36px; max-width: 100%; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent-soft); width: 17px; height: 17px; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { font: 600 13px var(--font-body); color: var(--fg); background: var(--surface); border: 0; border-right: 1px solid var(--line);
  padding: 7px 11px; cursor: pointer; min-height: 36px; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
canvas.view { display: block; width: 100%; height: auto; background: var(--stage); border-radius: var(--r); }
.cap { font-size: 12.5px; color: var(--muted); padding-top: 5px; }
.nums { font: 13px/1.6 var(--font-mono); background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px;
  margin: 8px 0 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.nums b { color: var(--accent); font-weight: 600; }
.status { font-size: 13.5px; min-height: 1.5em; margin: 8px 0 0; }
.status.ok { color: var(--ok); font-weight: 600; }
.status.bad { color: var(--bad); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid; margin-right: 5px; vertical-align: 3px; }
.legend i.dash { border-top-style: dashed; }
.legend i.dot { width: 9px; height: 9px; border: 0; border-radius: 50%; vertical-align: 0; }

/* robot */
.rb { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 18px; align-items: start; }
.rb-grid { position: relative; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; aspect-ratio: 1; background: #5f6b62; padding: 2px; border-radius: 6px; }
.cell { background: #7d8a80; border-radius: 2px; position: relative; }
.cell::after { content: ""; position: absolute; inset: 22%; border-radius: 50%; background: rgba(255,255,255,.12); }
.cell.t-rot { box-shadow: inset 0 0 0 3px #C91A09; } .cell.t-gelb { box-shadow: inset 0 0 0 3px #F2CD37; }
.cell.t-blau { box-shadow: inset 0 0 0 3px #0055BF; } .cell.t-gruen { box-shadow: inset 0 0 0 3px #4B9F4A; }
.cell.b-rot { background: #C91A09; } .cell.b-gelb { background: #F2CD37; } .cell.b-blau { background: #0055BF; } .cell.b-gruen { background: #4B9F4A; }
.cell[class*=" b-"]::after { background: rgba(255,255,255,.28); box-shadow: 0 1px 2px rgba(0,0,0,.35); }
.cell.wrong { outline: 3px dashed #fff; outline-offset: -5px; }
.robot { position: absolute; display: flex; align-items: center; justify-content: center; font-size: clamp(16px, 4vw, 26px); color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.8); transition: left .2s, top .2s; pointer-events: none; z-index: 2; }
.robot.fast { transition: none; }
.robot.crash { color: #FFB4A9; }
.levels { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.levels button { font: 600 13px var(--font-body); color: var(--fg); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 6px 10px; cursor: pointer; min-height: 36px; }
.levels button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* code editor with a highlight layer behind a transparent textarea */
.ed { position: relative; border: 1px solid var(--line); border-radius: 4px; background: var(--code-bg); height: 300px; overflow: hidden; }
.ed:focus-within { border-color: var(--accent-soft); }
.ed pre, .ed textarea { position: absolute; inset: 0; margin: 0; padding: 10px 12px; font: 14px/1.55 var(--font-mono); tab-size: 2;
  white-space: pre; overflow: auto; border: 0; letter-spacing: 0; word-spacing: 0; }
.ed pre { color: transparent; pointer-events: none; overflow: hidden; }
.ed pre mark { color: transparent; background: var(--mark); border-radius: 2px; box-shadow: 0 0 0 2px var(--mark); }
.ed pre mark.err { background: color-mix(in srgb, var(--bad) 35%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 35%, transparent); }
.ed textarea { background: transparent; color: var(--code-fg); resize: none; outline: 0; width: 100%; height: 100%; caret-color: var(--accent); }
.ed textarea::selection { background: var(--sel); }
.stack { font: 12.5px var(--font-mono); color: var(--muted); min-height: 1.5em; margin-top: 6px; overflow-wrap: anywhere; }
.counts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; padding: 8px 12px; border-radius: var(--r); background: var(--plinth); color: var(--plinth-fg); font-size: 13px; }
.counts strong { font: 800 20px var(--font-display); color: var(--accent-soft); font-variant-numeric: tabular-nums; margin-right: 4px; }
.ref { font-size: 13px; }
.ref table { border-collapse: collapse; width: 100%; }
.ref td, .ref th { padding: 3px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.ref td:first-child { font-family: var(--font-mono); white-space: nowrap; }

/* images and the detective */
.det { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.fp-row { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.fp-row canvas { image-rendering: pixelated; border-radius: 4px; background: var(--stage); }
ol.rank { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; }
ol.rank li { display: grid; grid-template-columns: 26px 40px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 13.5px;
  padding: 4px 6px; border-radius: 4px; background: color-mix(in srgb, var(--line) 22%, transparent); max-width: none; }
ol.rank li.hit { outline: 2px solid var(--ok); }
ol.rank li.first.miss { outline: 2px solid var(--bad); }
ol.rank li canvas { width: 40px; height: 25px; image-rendering: pixelated; border-radius: 2px; }
ol.rank li .d { font: 12.5px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
ol.rank li .k { font: 700 13px var(--font-display); color: var(--muted); text-align: center; }
.lupe { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-top: 8px; }
.lupe canvas { width: 126px; height: 126px; image-rendering: pixelated; border-radius: 4px; border: 1px solid var(--line); }
table.k3 { border-collapse: collapse; font: 12.5px var(--font-mono); }
table.k3 td { border: 1px solid var(--line); padding: 3px 6px; text-align: right; min-width: 3.4em; font-variant-numeric: tabular-nums; }
table.k3 td.c { outline: 2px solid var(--accent-soft); outline-offset: -2px; }

/* tables */
.tw { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
table.stat { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 8px; }
table.stat th, table.stat td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; vertical-align: top; }
table.stat th:first-child, table.stat td:first-child { text-align: left; }
table.stat th { font-weight: 600; color: var(--muted); font-size: 12px; }
table.stat td.hl { color: var(--accent); font-weight: 700; }
table.stat caption { text-align: left; font-size: 13px; color: var(--muted); padding-bottom: 4px; caption-side: top; }
table.plan { width: 100%; border-collapse: collapse; font-size: 14px; }
table.plan th, table.plan td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.plan th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.plan td:first-child { font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }

/* code listings */
pre.snip { font: 12.5px/1.5 var(--font-mono); background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px;
  overflow-x: auto; margin: 8px 0; max-width: 100%; }
pre.snip .cm { color: var(--muted); }

/* tasks */
.tasks { display: grid; gap: 10px; margin-top: 16px; }
.task { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; }
.task h4 { margin: 0 0 4px; font: 700 16px var(--font-display); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.task p { margin: 6px 0; }
.task ul, .task ol { margin: 6px 0; padding-left: 20px; }
details.sol { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 6px; }
details.sol summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--accent); }
details.sol[open] summary { margin-bottom: 4px; }
details.sol p { margin: 6px 0; }
.back { margin-top: 14px; font-size: 14px; }

/* charts (SVG) */
.charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.charts figure { margin: 0; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; min-width: 0; }
.charts figcaption { font-size: 13px; font-weight: 600; }
.charts figcaption small { display: block; font-weight: 400; color: var(--muted); }
.charts svg { display: block; width: 100%; height: auto; }
svg .bar { fill: var(--accent-soft); }
svg .bar.first { fill: var(--accent); }
svg .grid { stroke: var(--line); stroke-width: 1; }
svg .ideal { stroke: var(--fg); stroke-width: 1.5; stroke-dasharray: 4 3; }
svg .band { fill: color-mix(in srgb, var(--fg) 8%, transparent); }
svg text { font: 11.5px var(--font-body); fill: var(--fg); }
svg text.m { fill: var(--muted); font-family: var(--font-mono); font-size: 10.5px; }

/* teacher */
.teacher { border: 1px solid var(--line); border-left: 4px solid var(--accent-soft); background: var(--surface); border-radius: var(--r); padding: 14px 18px; }
.teacher dl { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 8px 16px; margin: 8px 0 0; }
.teacher dt { font-weight: 600; }
.teacher dd { margin: 0; color: var(--muted); }
.teacher dd ul { margin: 0; padding-left: 18px; }
.klp { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin-top: 10px; }
.klp > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; }
.klp h4 { margin-top: 0; }
.klp ul { margin: 4px 0; padding-left: 18px; font-size: 14px; }
.live { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 10px; }
.live > div { background: var(--plinth); color: var(--plinth-fg); border-radius: var(--r); padding: 10px 12px; font-size: 13.5px; }
.live strong { display: block; font: 800 22px var(--font-display); color: var(--accent-soft); }

footer { padding-block: 40px 48px; color: var(--muted); font-size: 13px; }
footer p { max-width: 95ch; }
.nameplate { display: inline-block; background: var(--plinth); color: var(--accent-soft); font: 500 12px var(--font-mono); letter-spacing: 0.3em; padding: 4px 10px; border-radius: 3px; }
.legal { display: flex; gap: 16px; flex-wrap: wrap; }
noscript p { background: var(--surface); border: 1px solid var(--bad); padding: 10px; border-radius: var(--r); }

@media (max-width: 920px) {
  .labgrid, .labgrid.even, .det, .rb { grid-template-columns: minmax(0, 1fr); }
  .rb-grid { max-width: 380px; }
  .charts { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .uhead { grid-template-columns: minmax(0, 1fr); }
  .uhead .btns { justify-content: flex-start; }
  .teacher dl { grid-template-columns: minmax(0, 1fr); }
  .teacher dt { margin-top: 6px; }
  .ctl { grid-template-columns: minmax(0, 1fr) auto; }
  .ctl input[type=range] { grid-column: 1 / -1; grid-row: 2; }
  .ed { height: 230px; }
  .ed pre, .ed textarea { font-size: 13px; }
  table.plan td:first-child { white-space: normal; }
}
@media print {
  .btns, .levels, .seg { display: none; }
  details.sol { display: block; }
}
table.stat tr.hl td { color: var(--accent); font-weight: 600; }
table.stat td.l, table.stat th.l { text-align: left; }
.charts figcaption code { font-family: var(--font-mono); font-size: 12px; background: none; padding: 0; }
@media (max-width: 560px) {
  table.plan thead { display: none; }
  table.plan tr { display: block; border-bottom: 1px solid var(--line); padding: 6px 0; }
  table.plan td { display: block; border: 0; padding: 2px 0; }
  table.plan td:first-child { font-weight: 600; }
}
