/* Tages Puzzle Löser – Stylesheet
   Layout: eine Spalte am Handy (Steuerung, Brett, Lösung, Schritte, Teileliste); ab 820px Brett links, Schritte rechts. */
:root {
  --bg: #E7EAEF;          /* kühle Tischplatte, damit das Holzbrett warm hervortritt */
  --surface: #F8F9FB;
  --surface-2: #EEF0F4;
  --fg: #1C2027;
  --muted: #5B6572;
  --line: #CBD1DA;
  --accent: #7A5636;      /* Nussbaum */
  --on-accent: #FFF8EF;
  --accent-soft: #EFE4D6;
  --focus: #2F6BBF;
  --wood-frame: #5B4433;
  --wood-face: #CDB48F;
  --wood-ink: #3A2A1D;
  --wood-line: #8E7657;
  --ring: #F0B429;
  --piece-ink: #1E1710;
  --pO: #4F86C6; --pP: #D9655B; --pL: #E8A33D; --pN: #68AD66;
  --pU: #3FA0A3; --pV: #9579D1; --pZ: #D97BA6; --pY: #AEB84E;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 32, .06), 0 8px 24px rgba(20, 24, 32, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181E; --surface: #1F2329; --surface-2: #272C34; --fg: #E8EBF0; --muted: #9AA4B2; --line: #343B46;
    --accent: #C9A074; --on-accent: #1C140C; --accent-soft: #3A2E22; --focus: #7FB0F0;
    --wood-frame: #4A3527; --wood-face: #BFA47E; --wood-ink: #33241A; --wood-line: #86704F; --ring: #F2B632;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15181E; --surface: #1F2329; --surface-2: #272C34; --fg: #E8EBF0; --muted: #9AA4B2; --line: #343B46;
  --accent: #C9A074; --on-accent: #1C140C; --accent-soft: #3A2E22; --focus: #7FB0F0;
  --wood-frame: #4A3527; --wood-face: #BFA47E; --wood-ink: #33241A; --wood-line: #86704F; --ring: #F2B632;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); touch-action: pan-x pan-y; }
body {
  margin: 0;
  touch-action: pan-x pan-y;   /* scrollen ja, Doppeltipp- und Spreiz-Zoom nein */
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
img { max-width: 100%; }
[hidden] { display: none !important; }

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding-block: 20px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid;
  gap: 18px;
}
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(30px, 6vw, 42px); line-height: 1.05; letter-spacing: -.01em; }
h2 { font-family: var(--font-ui); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
p { margin: 0; }
.lede { color: var(--muted); max-width: 60ch; }
header { display: grid; gap: 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 14px;
  min-width: 0;
}

/* Steuerung */
.controls { display: grid; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
select {
  font: inherit; font-weight: 700; color: var(--fg);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 36px 9px 12px; min-height: 44px; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
}
.btn {
  font: inherit; font-weight: 800; font-size: 15px; color: var(--fg);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px; min-height: 44px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.icon { width: 44px; padding: 0; font-size: 20px; line-height: 1; }
.btn[disabled] { opacity: .45; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, .step:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.quick { align-self: end; }
.toggle { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.toggle .hint { display: block; color: var(--muted); font-size: 13.5px; }

/* Datum und Lösungsnavigation */
.datehead { display: grid; gap: 4px; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; width: max-content; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 3px 10px; }
.datehead .date { font-family: var(--font-display); font-weight: 600; font-size: clamp(26px, 5.4vw, 34px); line-height: 1.1; }
.datehead .count { color: var(--muted); font-variant-numeric: tabular-nums; }

.nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.nav .pos { font-weight: 800; font-variant-numeric: tabular-nums; }
.nav .group { display: flex; align-items: center; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; border-radius: 999px; padding: 3px 10px; background: var(--surface-2); border: 1px solid var(--line); }
.badge.ok { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* Brett */
.boardwrap { display: grid; justify-items: center; }
.board { width: 100%; max-width: 460px; height: auto; display: block; }
.board text { font-family: var(--font-ui); font-weight: 800; user-select: none; }
.stepper { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line, rgba(128,128,128,.25)); }
.stepper .group { flex-wrap: wrap; }
.step.pending { opacity: .42; }
.step.pending .num { background: transparent; border: 1px dashed currentColor; }
.board .piece { transition: opacity .2s ease; }
.board .dim { opacity: .28; }
@media (prefers-reduced-motion: reduce) { .board .piece { transition: none; } }

/* Schritte */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.step {
  width: 100%; text-align: left; font: inherit; color: var(--fg); cursor: pointer;
  display: grid; grid-template-columns: 28px 56px 1fr; gap: 12px; align-items: center;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 12px; padding: 8px 10px; min-width: 0;
}
.step:hover { border-color: var(--line); }
.step.active { border-color: var(--accent); background: var(--accent-soft); }
.step .num { font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.step.active .num { color: var(--accent); }
.step .mini { width: 56px; height: 56px; display: block; }
.step .body { display: grid; gap: 2px; min-width: 0; }
.step .name { font-weight: 800; }
.step .cells { font-variant-numeric: tabular-nums; }
.step .cells b { font-weight: 800; }
.step .how { color: var(--muted); font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.step .flag { color: var(--accent); font-weight: 800; }
.stephelp { color: var(--muted); font-size: 13.5px; }

.empty { display: grid; gap: 10px; padding: 14px; border-radius: 12px; background: var(--surface-2); }
.empty strong { font-weight: 800; }

/* Teileliste */
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.legend .item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.legend .mini { width: 52px; height: 52px; flex: none; }
.legend .label { display: grid; gap: 0; min-width: 0; }
.legend .label b { font-weight: 800; }
.legend .label span { color: var(--muted); font-size: 13px; }

.about { color: var(--muted); font-size: 14px; display: grid; gap: 8px; max-width: 70ch; }
.about b { color: var(--fg); font-weight: 800; }

footer { color: var(--muted); font-size: 13px; }
footer a { color: var(--accent); }

/* Zwei Spalten ab Tablet-Breite */
@media (min-width: 820px) {
  .wrap { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
  header, footer, .span { grid-column: 1 / -1; }
  .col-left, .col-right { display: grid; gap: 18px; min-width: 0; align-content: start; }
  .col-left > .card:last-child { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 18px); }
}
