@font-face {
  font-family: 'Zilla Slab';
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/zilla-slab-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Zilla Slab';
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/zilla-slab-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Chivo';
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/chivo-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Chivo';
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/chivo-latin-600-normal.woff2') format('woff2');
}

:root {
  color-scheme: light dark;
  --seite: #d6ddd3;
  --text: #1c2420;
  --text-leise: #4d5a53;
  --linie: #9aa79e;
  --karte: #e6ebe3;
  --rahmen: #21322b;
  --mulde: #15211c;
  --stein: #e3a63a;
  --stein-hell: #f0bd5c;
  --stein-dunkel: #c98a24;
  --ziffer: #3a2312;
  --akzent: #8c2b2b;
  --akzent-text: #fff4ec;
  --fokus: #8c2b2b;
  --schrift-titel: 'Zilla Slab', Georgia, serif;
  --schrift: 'Chivo', system-ui, sans-serif;
  --zeit: 110ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --seite: #121815;
    --text: #dbe3dc;
    --text-leise: #9aa89f;
    --linie: #3c4c44;
    --karte: #1b2420;
    --rahmen: #2a3c34;
    --mulde: #0b110e;
    --stein: #cf9433;
    --stein-hell: #dda64a;
    --stein-dunkel: #b47a20;
    --ziffer: #2e1b0d;
    --akzent: #d0605a;
    --akzent-text: #1a0d0b;
    --fokus: #e88a84;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root { --zeit: 0ms; }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-height: 100dvh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--seite);
  color: var(--text);
  font: 400 1rem/1.4 var(--schrift);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--fokus); outline-offset: 2px; }

.kopf {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: 'titel wahl' 'status status';
  align-items: center;
  gap: 4px 12px;
  padding: 12px 16px 6px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

.titel {
  grid-area: titel;
  margin: 0;
  font: 700 1.75rem/1 var(--schrift-titel);
  letter-spacing: -0.01em;
}

.knopf-wahl { grid-area: wahl; }

.status {
  grid-area: status;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 18px;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.wert-name { color: var(--text-leise); font-size: 0.85rem; }
.wert > span:last-child { font-weight: 600; }

.leiste {
  display: flex;
  gap: 6px;
  padding: 6px 16px 4px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

.knopf {
  min-height: 42px;
  padding: 6px 12px;
  border: 1.5px solid var(--linie);
  border-radius: 10px;
  background: var(--karte);
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}
.knopf:hover:not(:disabled) { border-color: var(--text-leise); }
.knopf:disabled { opacity: 0.45; cursor: default; }
.knopf-voll { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.knopf-voll:hover:not(:disabled) { border-color: var(--text); }
.leiste .knopf { flex: 1 1 auto; padding: 6px 4px; font-size: 0.86rem; }
.knopf[aria-pressed='true'] { background: var(--text); color: var(--seite); border-color: var(--text); }

.tisch {
  position: relative;
  container-type: size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 0;
  padding: 8px 16px;
}

.rahmen {
  --kante: clamp(10px, 3.2cqmin, 20px);
  width: min(100cqw, 100cqh - 36px, 640px);
  aspect-ratio: 1;
  padding: var(--kante);
  border-radius: calc(var(--kante) * 0.75);
  background:
    radial-gradient(circle at calc(var(--kante) * 0.55) calc(var(--kante) * 0.55), #6f7f76 0 2.5px, #1a2621 3px 3.8px, transparent 4.2px),
    radial-gradient(circle at calc(100% - var(--kante) * 0.55) calc(var(--kante) * 0.55), #6f7f76 0 2.5px, #1a2621 3px 3.8px, transparent 4.2px),
    radial-gradient(circle at calc(var(--kante) * 0.55) calc(100% - var(--kante) * 0.55), #6f7f76 0 2.5px, #1a2621 3px 3.8px, transparent 4.2px),
    radial-gradient(circle at calc(100% - var(--kante) * 0.55) calc(100% - var(--kante) * 0.55), #6f7f76 0 2.5px, #1a2621 3px 3.8px, transparent 4.2px),
    linear-gradient(170deg, color-mix(in srgb, var(--rahmen), white 8%), var(--rahmen) 40%, color-mix(in srgb, var(--rahmen), black 18%));
  box-shadow:
    inset 0 2px 0 rgb(255 255 255 / 0.1),
    inset 0 -3px 0 rgb(0 0 0 / 0.3),
    0 14px 28px -16px rgb(0 0 0 / 0.55);
}

.brett {
  --fuge: calc(100cqw / var(--n) * 0.035);
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  container-type: inline-size;
  border-radius: 8px;
  background: var(--mulde);
  box-shadow: inset 0 3px 8px rgb(0 0 0 / 0.55);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
.brett:focus-visible { outline-offset: calc(var(--kante, 12px) / 2 - 1px); }

.stein {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(100% / var(--n));
  height: calc(100% / var(--n));
  padding: var(--fuge);
  border: 0;
  background: none;
  transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%));
  transition: transform var(--zeit) cubic-bezier(0.25, 0.75, 0.35, 1), padding 400ms ease;
  cursor: pointer;
  touch-action: none;
}

.flaeche {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 13%;
  background: linear-gradient(165deg, var(--stein-hell), var(--stein) 45%, var(--stein-dunkel));
  box-shadow:
    inset 0 calc(100cqw / var(--n) * 0.03) 0 rgb(255 255 255 / 0.32),
    inset 0 calc(100cqw / var(--n) * -0.045) 0 rgb(80 40 5 / 0.32),
    0 2px 3px rgb(0 0 0 / 0.35);
  color: var(--ziffer);
  font: 700 calc(100cqw / var(--n) * 0.46) / 1 var(--schrift-titel);
  font-variant-numeric: lining-nums;
  text-shadow: 0 1px 0 rgb(255 255 255 / 0.35);
  transition: border-radius 400ms ease, box-shadow 400ms ease, background-position 400ms ease;
}

.bildmodus .flaeche {
  background-image: var(--bild);
  background-size: 100cqw 100cqw;
  background-position:
    calc(-1 * (var(--gc) * 100cqw / var(--n) + var(--fuge)))
    calc(-1 * (var(--gr) * 100cqw / var(--n) + var(--fuge)));
  border-radius: 6%;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.3),
    inset 0 -2px 0 rgb(0 0 0 / 0.25),
    0 2px 3px rgb(0 0 0 / 0.35);
}

.ziffer {
  position: absolute;
  left: 6%;
  top: 6%;
  min-width: 1.7em;
  padding: 0.1em 0.3em;
  border-radius: 0.5em;
  background: rgb(20 24 22 / 0.62);
  color: #fdf3df;
  font: 600 max(11px, calc(100cqw / var(--n) * 0.16)) / 1.1 var(--schrift);
  text-shadow: none;
  text-align: center;
}

.stein.hinweis .flaeche {
  outline: 4px solid var(--akzent);
  outline-offset: -4px;
  animation: puls 0.9s ease-in-out 3;
}

@keyframes puls {
  50% { transform: scale(0.92); }
}

.stein.letztes { opacity: 0; pointer-events: none; transition: opacity 500ms ease; }

.gewonnen.bildmodus { --fuge: 0px; }
.gewonnen .stein { cursor: default; }
.gewonnen.bildmodus .flaeche { border-radius: 0; box-shadow: none; }
.gewonnen.bildmodus .ziffer { opacity: 0; }
.gewonnen .stein.letztes { opacity: 1; }
.gewonnen:not(.bildmodus) .stein.letztes { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .stein, .flaeche, .stein.letztes { transition: none; }
  .stein.hinweis .flaeche { animation: none; }
}

.tipp {
  min-height: 1.4em;
  margin: 0;
  color: var(--text-leise);
  font-size: 0.9rem;
  text-align: center;
}

.meldung {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(340px, calc(100% - 48px));
  padding: 20px 22px 18px;
  border-radius: 14px;
  background: var(--karte);
  border: 1.5px solid var(--linie);
  box-shadow: 0 18px 40px -12px rgb(0 0 0 / 0.55);
  text-align: center;
}
.meldung h2 { margin: 0 0 6px; font: 700 1.6rem/1.1 var(--schrift-titel); }
.meldung p { margin: 0 0 14px; }
.meldung-aktionen { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.meldung-aktionen .knopf { flex: 1 1 120px; }

.wahl {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 18px 18px 16px;
  border: 1.5px solid var(--linie);
  border-radius: 16px;
  background: var(--karte);
  color: var(--text);
}
.wahl::backdrop { background: rgb(10 16 13 / 0.55); }
.wahl h2 { margin: 0 0 10px; font: 700 1.5rem/1.1 var(--schrift-titel); }

.gruppe { border: 0; margin: 0 0 12px; padding: 0; min-width: 0; }
.gruppe legend { padding: 0; margin-bottom: 6px; font-weight: 600; font-size: 0.9rem; color: var(--text-leise); }
.gruppe[hidden] { display: none; }

.pillen { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 6px; }
.pille { position: relative; display: block; }
.pille input, .motiv input { position: absolute; opacity: 0; pointer-events: none; }
.pille span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1.5px solid var(--linie);
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
.pille input:checked + span { background: var(--text); color: var(--seite); border-color: var(--text); }
.pille input:focus-visible + span, .motiv input:focus-visible + span { outline: 3px solid var(--fokus); outline-offset: 2px; }

.motive { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.motiv { position: relative; display: block; }
.motiv span {
  display: block;
  aspect-ratio: 1;
  border-radius: 8px;
  background-size: cover;
  border: 3px solid transparent;
  cursor: pointer;
}
.motiv input:checked + span { border-color: var(--akzent); }

.schalter { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 42px; cursor: pointer; }
.schalter input {
  appearance: none;
  flex: none;
  width: 46px;
  height: 26px;
  border-radius: 13px;
  background: var(--linie);
  position: relative;
  cursor: pointer;
  transition: background 150ms;
}
.schalter input::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--karte);
  transition: transform 150ms;
}
.schalter input:checked { background: var(--akzent); }
.schalter input:checked::after { transform: translateX(20px); }

.tasten { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0; font-size: 0.85rem; }
.tasten dt { white-space: nowrap; }
.tasten dd { margin: 0; color: var(--text-leise); }
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.3em;
  border: 1px solid var(--linie);
  border-bottom-width: 2px;
  border-radius: 4px;
  font: 600 0.8rem/1.4 var(--schrift);
  text-align: center;
}
/* Anleitung */
.anleitung { padding: 0; overflow: hidden; }
.anleitung-rahmen { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.anleitung-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 10px 18px;
  border-bottom: 1.5px solid var(--linie);
}
.wahl .anleitung-kopf h2 { margin: 0; }
.anleitung-zu { flex: none; width: 42px; padding: 0; font-size: 1.4rem; line-height: 1; }
.anleitung-text { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 2px 18px 14px; font-size: 0.95rem; }
.anleitung-text:focus { outline: none; }
.anleitung-text h3 { margin: 14px 0 4px; font: 700 1.15rem/1.2 var(--schrift-titel); }
.anleitung-text h4 { margin: 8px 0 2px; font-size: 0.85rem; color: var(--text-leise); }
.anleitung-text p, .anleitung-text ul { margin: 0; }
.anleitung-text ul { padding-left: 1.2em; }
.anleitung-text li + li { margin-top: 4px; }
.anleitung-text .tasten { display: grid; margin: 0; }
.beispiel { margin: 0; }
.beispiel-bild { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: 6px 0; }
.beispiel-bild svg { width: 84px; height: auto; }
.beispiel-bild .beispiel-pfeil { width: 24px; fill: none; stroke: var(--text-leise); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.bsp-ziel { position: relative; display: flex; margin-left: 12px; }
.bsp-ziel span { position: absolute; top: 100%; left: 0; right: 0; font-size: 0.8rem; text-align: center; color: var(--text-leise); }
.beispiel-bild:has(.bsp-ziel) { margin-bottom: 22px; }
.bsp-rahmen { fill: var(--rahmen); }
.bsp-mulde { fill: var(--mulde); }
.bsp-stein { fill: var(--stein); }
.bsp-ziffer { fill: var(--ziffer); font: 700 17px var(--schrift-titel); text-anchor: middle; }
.bsp-ring { fill: none; stroke: var(--akzent); stroke-width: 3; }
.bsp-pfeil { fill: none; stroke: var(--akzent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.beispiel figcaption { font-size: 0.85rem; color: var(--text-leise); }
.anleitung-fuss { display: flex; justify-content: flex-end; padding: 10px 18px 14px; border-top: 1.5px solid var(--linie); }
.anleitung-fuss .knopf { min-width: 140px; }
.knopf-zurueck { display: inline-flex; align-items: center; justify-content: center; }
.knopf-zurueck svg { display: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.leiste .knopf-hilfe { flex: none; width: 42px; padding: 0; border-radius: 50%; font: 700 1.15rem/1 var(--schrift-titel); }

.hilfe-hinweis { margin: 4px 0 12px; font-size: 0.85rem; color: var(--text-leise); }
.wahl-aktionen { display: flex; gap: 8px; justify-content: flex-end; }

@media (max-width: 440px) {
  .leiste .knopf-zurueck { flex: none; width: 44px; padding: 0; }
  .knopf-zurueck svg { display: block; }
  .knopf-zurueck .text { display: none; }
}

.fuss {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 16px 10px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  font-size: 0.82rem;
  color: var(--text-leise);
}
.teilen-ort { position: relative; }
.teilen {
  min-height: 28px;
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}
.teilen-pop {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 6;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 8px;
  align-items: center;
  width: min(380px, calc(100vw - 32px));
  padding: 10px 12px;
  border: 1.5px solid var(--linie);
  border-radius: 12px;
  background: var(--karte);
  color: var(--text);
  box-shadow: 0 18px 40px -12px rgb(0 0 0 / 0.55);
}
.teilen-pop[hidden] { display: none; }
.teilen-pop label { grid-column: 1 / -1; font-weight: 600; }
.teilen-pop input {
  min-width: 0;
  min-height: 40px;
  padding: 0 8px;
  border: 1.5px solid var(--linie);
  border-radius: 8px;
  background: var(--seite);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(44px + env(safe-area-inset-bottom));
  z-index: 20;
  width: max-content;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--rahmen);
  color: #f3efe4;
  font-size: 0.88rem;
  text-align: center;
  box-shadow: 0 18px 40px -12px rgb(0 0 0 / 0.55);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast[hidden] { display: none; }

@media (min-width: 700px) {
  .kopf {
    grid-template-columns: auto auto 1fr;
    grid-template-areas: 'titel wahl status';
    padding-top: 18px;
  }
  .status { justify-content: flex-end; }
  .titel { font-size: 2.1rem; }
  .leiste { gap: 8px; }
  .leiste .knopf { flex: 1 1 0; padding: 6px 12px; font-size: 0.92rem; }
  .leiste .knopf-hilfe { flex: none; padding: 0; font-size: 1.15rem; }
}

@media (max-height: 520px) and (min-width: 600px) {
  body {
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }
  .kopf {
    grid-column: 1;
    grid-row: 1;
    grid-template-columns: 1fr;
    grid-template-areas: 'titel' 'wahl' 'status';
    padding: 10px 12px 4px;
  }
  .knopf-wahl { justify-self: start; }
  .status { justify-content: flex-start; }
  .titel { font-size: 1.5rem; }
  .leiste { grid-column: 1; grid-row: 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) 42px; padding: 4px 12px; }
  .leiste .knopf-hilfe { grid-column: 3; grid-row: 1; }
  .tisch { grid-column: 2; grid-row: 1 / 5; padding: 8px; }
  .rahmen { width: min(100cqw, 100cqh - 32px, 640px); }
  .fuss { grid-column: 1; grid-row: 4; padding: 4px 12px 8px; }
  .teilen { min-height: 0; }
}
