:root {
  --bg: #f5f1e8;
  --surface: #fffdf8;
  --ink: #1d1b18;
  --ink-soft: #6b645a;
  --entered: #2f5d9b;
  --line: #d4ccbf;
  --line-strong: #3a352e;
  --related: #efe9dd;
  --same: #dde6f0;
  --selected: #bcd3ee;
  --locked: #f1ede4;
  --conflict-bg: #f6d3cf;
  --conflict-ink: #b3261e;
  --button: #ebe5d8;
  --button-active: #ddd4c3;
  --accent: #3a352e;
  --accent-ink: #fffdf8;
  --seal: #b3261e;
  --overlay: rgb(255 253 248 / 0.92);
  --shadow: rgb(0 0 0 / 0.18);
  --backdrop: rgb(0 0 0 / 0.35);
  --pressed: #fffdf8;
  --ok: #2e7d4f;
  color-scheme: light;
}

/* Donker (E16): volgt het systeem, tenzij de speler zelf licht of donker kiest (data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171512;
    --surface: #221f1b;
    --ink: #ece6da;
    --ink-soft: #a89f91;
    --entered: #8db8f0;
    --line: #3b362f;
    --line-strong: #cfc6b8;
    --related: #2d2924;
    --same: #26303d;
    --selected: #2f4668;
    --locked: #1c1a17;
    --conflict-bg: #4d2320;
    --conflict-ink: #ff9a8f;
    --button: #2d2924;
    --button-active: #3a352e;
    --accent: #e6dfd1;
    --accent-ink: #171512;
    --seal: #f07a6c;
    --overlay: rgb(34 31 27 / 0.92);
    --shadow: rgb(0 0 0 / 0.5);
    --backdrop: rgb(0 0 0 / 0.6);
  --pressed: #46403a;
  --ok: #7fd4a0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171512;
  --surface: #221f1b;
  --ink: #ece6da;
  --ink-soft: #a89f91;
  --entered: #8db8f0;
  --line: #3b362f;
  --line-strong: #cfc6b8;
  --related: #2d2924;
  --same: #26303d;
  --selected: #2f4668;
  --locked: #1c1a17;
  --conflict-bg: #4d2320;
  --conflict-ink: #ff9a8f;
  --button: #2d2924;
  --button-active: #3a352e;
  --accent: #e6dfd1;
  --accent-ink: #171512;
  --seal: #f07a6c;
  --overlay: rgb(34 31 27 / 0.92);
  --shadow: rgb(0 0 0 / 0.5);
  --backdrop: rgb(0 0 0 / 0.6);
  --pressed: #46403a;
  --ok: #7fd4a0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
button:disabled { cursor: default; opacity: 0.45; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.app {
  max-width: 1180px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---- kop ------------------------------------------------------------------------------- */

.top { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { flex: none; }
h1 { margin: 0; font-size: 1.25rem; letter-spacing: 0.02em; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--button);
}
.icon-button.small { width: 34px; height: 34px; border-radius: 8px; }

.primary {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 44px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.primary.wide { width: 100%; margin-top: 8px; }

.chip {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 19px;
  background: var(--button);
  white-space: nowrap;
}

/* Spelvormen: op pc in de kop, op telefoon en tablet als balk onderaan (duimzone). */
.modes {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--button);
  margin-left: auto;
}
.modes + .top-actions { margin-left: 0; }
.modes button {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  border: 0;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 12px;
  background: transparent;
  color: var(--ink-soft);
  white-space: nowrap;
}
.modes button[aria-pressed="true"] {
  background: var(--pressed);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px var(--shadow);
}

.segmented { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--button); }
.segmented button {
  flex: 1 1 auto;
  border: 0;
  border-radius: 8px;
  min-height: 36px;
  padding: 0 10px;
  background: transparent;
  color: var(--ink-soft);
  white-space: nowrap;
}
.segmented button[aria-pressed="true"] {
  background: var(--pressed);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px var(--shadow);
}

.choices { display: flex; align-items: center; gap: 8px; }
.choices .segmented { flex: 1; max-width: 520px; }
.choices .segmented button { min-width: 0; }

@media (max-width: 959px) {
  .app { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .modes {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    margin: 0;
    padding: 6px 8px max(6px, env(safe-area-inset-bottom));
    border-radius: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 8px var(--shadow);
  }
  .modes button {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 54px;
    padding: 4px 2px;
    font-size: 0.78rem;
  }
  .modes button[aria-pressed="true"] { background: var(--related); box-shadow: none; color: var(--ink); }
  .modes button[aria-pressed="true"] svg { color: var(--seal); }
  .top-actions { margin-left: auto; }
  .top .new-game { min-height: 40px; padding: 8px 14px; }
  .top .icon-button { width: 40px; height: 40px; }
}
@media (max-width: 440px) {
  h1 { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .top-actions { gap: 6px; }
  .top .icon-button { width: 38px; height: 38px; }
  .choices { gap: 6px; }
  .choices .segmented button { padding: 0 4px; font-size: 0.85rem; }
}

/* ---- speelgebied ------------------------------------------------------------------------- */

.play { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 860px) {
  .play { grid-template-columns: minmax(0, 1fr) 300px; }
}

.stage { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.viewport-wrap { position: relative; }

.viewport {
  position: relative;
  overflow: hidden;
  width: 100%;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.viewport.square {
  aspect-ratio: 1;
  max-width: min(100%, 640px, max(280px, calc(100dvh - 190px)));
  margin: 0 auto;
}
.viewport.pannable {
  height: min(75dvh, max(320px, calc(100dvh - 230px)));
  border-radius: 12px;
  background: var(--button);
  touch-action: none;
  cursor: grab;
}
.viewport.dragging { cursor: grabbing; }
.viewport.paused .field { visibility: hidden; }

.pause-cover {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: center;
}
.pause-title { margin: 0; font-size: 1.6rem; font-weight: 700; }
.pause-text { margin: 0 0 8px; color: var(--ink-soft); }

.zoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.zoom button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--overlay);
  box-shadow: 0 1px 3px var(--shadow);
  font-size: 1.3rem;
  line-height: 1;
}
@media (hover: none) and (pointer: coarse) {
  .zoom { display: none; }
}

.parts { display: flex; flex-wrap: wrap; gap: 6px; }
.parts button {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--button);
}
@media (max-width: 719px) {
  .parts { gap: 4px; }
  .parts button { flex: 1; padding: 0 6px; font-size: 0.88rem; min-height: 38px; }
}

.toast {
  position: absolute;
  left: 50%;
  top: 10px;
  z-index: 6;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  text-align: center;
  box-shadow: 0 2px 8px var(--shadow);
  animation: toast-in 0.18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -6px); } }

/* ---- veld ------------------------------------------------------------------------------- */

.field { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.cells, .frames { position: absolute; inset: 0; }
.frames { pointer-events: none; }

.cell {
  position: absolute;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  font-size: 26px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.viewport.pannable .cell { cursor: inherit; }
.cell.given { font-weight: 700; color: var(--ink); }
.cell.entered { color: var(--entered); }
.cell.locked { background: var(--locked); }
.cell.related { background: var(--related); }
.cell.same { background: var(--same); }
.cell.conflict { background: var(--conflict-bg); }
.cell.conflict.entered { color: var(--conflict-ink); }
.cell.selected { background: var(--selected); }
.cell.selected.conflict.entered { color: var(--conflict-ink); }
.cell.wrong { background: var(--conflict-bg); color: var(--conflict-ink); }
.cell.wrong.selected { background: var(--selected); }
.cell.corner-open {
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  z-index: 1;
  box-shadow: 0 0 0 3px var(--selected);
}
.cell:focus { outline: none; }
.cell:focus-visible { box-shadow: inset 0 0 0 2px var(--entered); }

.notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 2px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-soft);
}
.notes span { display: flex; align-items: center; justify-content: center; }

.big-digits .cell { font-size: 32px; }
.big-digits .notes { font-size: 13.5px; font-weight: 600; padding: 1px; }

.frame {
  --l: var(--line-strong);
  position: absolute;
  width: 396px;
  height: 396px;
  border: 2px solid var(--l);
  background-origin: border-box;
  background-image:
    linear-gradient(to right, transparent 131px, var(--l) 131px, var(--l) 133px, transparent 133px,
      transparent 263px, var(--l) 263px, var(--l) 265px, transparent 265px),
    linear-gradient(to bottom, transparent 131px, var(--l) 131px, var(--l) 133px, transparent 133px,
      transparent 263px, var(--l) 263px, var(--l) 265px, transparent 265px);
}

/* Volgnummer van een raster op het pad (A2), midden op de bovenrand. */
.frame[data-label]::before {
  content: attr(data-label);
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 30px;
  height: 20px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--line-strong);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 700;
}

/* Gestempeld raster (A1): rood kader en een zegel rechtsboven. */
.frame.stamped { --l: var(--seal); }
.frame.stamped::after {
  content: "✓";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--seal);
  border-radius: 50%;
  color: var(--seal);
  background: var(--overlay);
  font-size: 30px;
  font-weight: 700;
  transform: rotate(-12deg);
}
.frame.celebrate { animation: grid-glow 1.1s ease-out; }
.frame.celebrate::after { animation: stamp-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes grid-glow { 0% { box-shadow: 0 0 0 0 var(--seal); } 40% { box-shadow: 0 0 0 10px transparent; } }
@keyframes stamp-in {
  0% { transform: rotate(-30deg) scale(2.2); opacity: 0; }
  100% { transform: rotate(-12deg) scale(1); opacity: 1; }
}

/* ---- paneel ------------------------------------------------------------------------------ */

.panel { display: flex; flex-direction: column; gap: 12px; }

.status { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.clock { display: flex; align-items: center; gap: 4px; }
.timer {
  border: 0;
  padding: 2px 6px;
  margin-left: -6px;
  border-radius: 8px;
  background: transparent;
  font-size: 1.4rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.timer.hidden-time { font-size: 1rem; font-weight: 500; color: var(--ink-soft); }
.info { color: var(--ink-soft); text-align: right; }

.controls { display: flex; flex-direction: column; gap: 10px; }

.pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.pad button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  border: 0;
  border-radius: 10px;
  background: var(--button);
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
}
.pad .count {
  position: absolute;
  top: 4px;
  right: 7px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.pad button.done { color: var(--ink-soft); opacity: 0.4; }
.pad button.armed { background: var(--accent); color: var(--accent-ink); }
.pad button.armed .count { color: inherit; }
.notes-mode .pad button:not(.erase) .digit { font-size: 1.15rem; color: var(--entered); }
.notes-mode .pad button.noted { box-shadow: inset 0 0 0 2px var(--entered); background: var(--same); }
.big-digits .pad button { font-size: 1.9rem; }

.tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tools button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 54px;
  padding: 4px 2px;
  border: 0;
  border-radius: 10px;
  background: var(--button);
  font-size: 0.8rem;
}
.tools button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.pad button:active, .tools button:active, .modes button:active, .segmented button:active,
.parts button:active, .zoom button:active, .chip:active, .icon-button:active { background: var(--button-active); }

/* Resultaatkaart na een winst. */
.result {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.result-head { display: flex; align-items: center; gap: 14px; }
.seal {
  flex: none;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--seal);
  border-radius: 50%;
  color: var(--seal);
  font-size: 28px;
  font-weight: 700;
  transform: rotate(-12deg);
}
.result.fresh .seal { animation: stamp-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1); }
.result-title { margin: 0; font-size: 1.35rem; font-weight: 700; }
.result-text { margin: 2px 0 0; color: var(--ink-soft); }
.result-rows { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.result-rows dt.full { grid-column: 1 / -1; color: var(--ok); font-weight: 600; }
.result-rows dt { color: var(--ink-soft); }
.result-rows dd { margin: 0; font-weight: 600; text-align: right; }
.result-rows small { display: block; margin-top: 2px; font-weight: 400; font-size: 0.82rem; color: var(--ink-soft); }
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 9px;
  background: var(--seal);
  color: var(--accent-ink);
  font-size: 0.75rem;
  font-weight: 700;
  vertical-align: 1px;
}
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.result-actions button { min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: var(--button); }
.result-actions .primary { background: var(--accent); color: var(--accent-ink); }

.help { margin: 0; font-size: 0.85rem; color: var(--ink-soft); }
@media (hover: none) { .help { display: none; } }

@media (max-width: 859px) {
  /* Telefoon: raster bovenaan, bediening onderaan in de duimzone. */
  .play { display: flex; flex-direction: column; align-items: stretch; flex: 1; }
  .panel { margin-top: auto; width: 100%; }
  .viewport.square { max-width: min(100%, max(260px, calc(100dvh - 470px))); }
  .play { gap: 10px; }
  .panel { gap: 8px; }
  .status .timer { font-size: 1.2rem; }
  .pad { gap: 6px; }
  .pad button { min-height: 48px; font-size: 1.45rem; }
  .big-digits .pad button { font-size: 1.7rem; }
  .tools { gap: 6px; }
  .tools button { min-height: 50px; }
}

/* ---- schermen (dialogen) ----------------------------------------------------------------- */

.sheet {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  border: 0;
  border-radius: 14px;
  padding: 16px;
  background: var(--surface);
  color: var(--ink);
}
.sheet::backdrop { background: var(--backdrop); }
.sheet[open] { animation: sheet-in 0.18s ease-out; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.sheet h2 { margin: 0; font-size: 1.3rem; }
.sheet-text { margin: 4px 0 12px; color: var(--ink-soft); }

.levels { display: grid; gap: 8px; }
.level {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 12px 14px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--button);
  text-align: left;
}
.level strong { font-size: 1.05rem; }
.level small { color: var(--ink-soft); }
.level.current { border-color: var(--entered); }

.intro-art { display: flex; justify-content: center; margin: 8px 0; color: var(--seal); }
.intro-art .fill { fill: currentColor; }

#archive-body h3 { margin: 14px 0 6px; font-size: 1rem; }
.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li {
  display: grid;
  grid-template-columns: minmax(6.5rem, auto) repeat(3, 1fr);
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.archive-list li:has(> :nth-child(2):last-child) { grid-template-columns: minmax(6.5rem, auto) 1fr; }
.archive-date { color: var(--ink-soft); font-size: 0.9rem; }
.archive-pick {
  min-height: 34px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  font-size: 0.85rem;
  white-space: nowrap;
}
.archive-pick.solved { border-color: var(--ok); color: var(--ok); font-weight: 600; }
.archive-pick.started { border-style: dashed; border-color: var(--entered); color: var(--entered); }
.archive-pick[aria-current="true"] { background: var(--selected); color: var(--ink); }

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.setting.stacked { flex-direction: column; align-items: stretch; gap: 10px; border-bottom: 0; }
.setting > span { display: flex; flex-direction: column; gap: 2px; }
.setting small { color: var(--ink-soft); font-size: 0.85rem; }
.backup { display: flex; flex-wrap: wrap; gap: 8px; }

.switch {
  appearance: none;
  flex: none;
  position: relative;
  width: 46px;
  height: 28px;
  margin: 0;
  border-radius: 14px;
  background: var(--button-active);
  cursor: pointer;
  transition: background 0.15s;
}
.switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px var(--shadow);
  transition: transform 0.15s;
}
.switch:checked { background: var(--entered); }
.switch:checked::before { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--entered); outline-offset: 2px; }

.stats h3 { margin: 16px 0 6px; font-size: 1.05rem; }
.stats p { margin: 0 0 6px; color: var(--ink-soft); }
.stats table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.stats abbr { text-decoration: none; }
.stats small { display: block; font-weight: 400; font-size: 0.8rem; color: var(--ink-soft); }
.stats .log th[scope="row"] { font-weight: 600; }
.stats details { margin-top: 4px; }
.stats summary { cursor: pointer; color: var(--entered); }
.stats .ranks { margin: 6px 0 0; padding-left: 20px; color: var(--ink-soft); }
.stats .ranks li { margin: 4px 0; }
.stats .ranks li.done { color: var(--ink); }
.stats th, .stats td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.stats th:first-child { text-align: left; }
.stats thead th { color: var(--ink-soft); font-weight: 500; font-size: 0.9rem; }
.progress { height: 8px; margin: 4px 0 8px; border-radius: 4px; background: var(--button); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--seal); }

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

/* Tussen 860 en 960 px: twee kolommen, maar de balk met spelvormen staat onderaan. */
@media (min-width: 860px) and (max-width: 959px) {
  .viewport.pannable { height: min(75dvh, max(320px, calc(100dvh - 300px))); }
}
@media (max-width: 859px) {
  .viewport.pannable { height: max(260px, calc(100dvh - 410px)); }
  /* Vandaag heeft een extra regel met keuzes. */
  .has-choices .viewport.pannable { height: max(240px, calc(100dvh - 466px)); }
  .has-choices .viewport.square { max-width: min(100%, max(240px, calc(100dvh - 526px))); }
}

/* ---- over, melding onderaan, privacypagina ------------------------------------------------ */

.setting.about { border-top: 1px solid var(--line); padding-top: 14px; }
.about-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; }
.about a, .doc-page a { color: var(--entered); text-underline-offset: 2px; }

.notice {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 7;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(560px, calc(100% - 24px));
  padding: 12px 12px 12px 16px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px var(--shadow);
  animation: notice-in 0.2s ease-out;
}
@keyframes notice-in { from { opacity: 0; transform: translate(-50%, 8px); } }
.notice[hidden] { display: none; }
.notice p { flex: 1; margin: 0; font-size: 0.92rem; line-height: 1.4; }
.notice-actions { display: flex; align-items: center; gap: 6px; }
.notice .primary { white-space: nowrap; }
@media (max-width: 959px) {
  .notice { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (max-width: 520px) {
  .notice { flex-direction: column; align-items: stretch; }
  .notice-actions { justify-content: flex-end; }
}

.doc-page { max-width: 720px; margin: 0 auto; padding: 24px 16px 64px; line-height: 1.55; }
.doc-page .brand { margin-bottom: 8px; }
.doc-page h2 { margin-top: 2em; }
.doc-page h3 { margin-top: 1.5em; font-size: 1.05rem; }
.doc-page ul { padding-left: 20px; }
.doc-page li { margin: 4px 0; }
.doc-page .meta { color: var(--ink-soft); font-size: 0.9rem; }
.doc-page nav { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 12px 0 0; }
