@font-face {
  font-family: "Young Serif";
  src: url("../fonts/young-serif-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Figtree";
  src: url("../fonts/figtree-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Figtree";
  src: url("../fonts/figtree-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --wand: #dbe2e8;
  --wand-tief: #cdd6de;
  --fuge: #bfc9d3;
  --kachel: #f8f8f4;
  --kachel-unten: #e6e9e8;
  --kachel-kante: #fff;
  --tinte: #18264a;
  --tinte-leise: #4c5a76;
  --kobalt: #2448a6;
  --kobalt-tief: #183379;
  --glanz: #a9c1ff;
  --ocker: #c47a12;
  --ocker-flaeche: rgb(196 122 18 / 0.2);
  --scheibe: #18264a;
  --scheibe-zahl: #f8f8f4;
  --knopf-rand: #9aa7b8;
  --knopf-hover: rgb(36 72 166 / 0.08);
  --knopf-voll: #2448a6;
  --knopf-voll-text: #f8f8f4;
  --fokus: #c47a12;
  --dialog: #f4f5f2;
  --schatten: rgb(24 38 74 / 0.18);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --wand: #0e1526;
    --wand-tief: #0a101d;
    --fuge: #070b15;
    --kachel: #1c2742;
    --kachel-unten: #162036;
    --kachel-kante: #26345a;
    --tinte: #e6ebf7;
    --tinte-leise: #9eabc8;
    --kobalt: #5f88f0;
    --kobalt-tief: #3f66d0;
    --glanz: #d4e0ff;
    --ocker: #f0a640;
    --ocker-flaeche: rgb(240 166 64 / 0.22);
    --scheibe: #e6ebf7;
    --scheibe-zahl: #141d33;
    --knopf-rand: #3b4a6e;
    --knopf-hover: rgb(95 136 240 / 0.14);
    --knopf-voll: #5f88f0;
    --knopf-voll-text: #0b1222;
    --fokus: #f0a640;
    --dialog: #16203a;
    --schatten: rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template:
    "kopf leiste" auto
    "tisch tisch" minmax(0, 1fr)
    "fuss fuss" auto
    / minmax(0, 1fr) auto;
  background: radial-gradient(ellipse 80% 70% at 50% 45%, var(--wand) 0%, var(--wand-tief) 100%);
  color: var(--tinte);
  font: 500 1rem/1.45 "Figtree", system-ui, sans-serif;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.kopf {
  grid-area: kopf;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 1.25rem;
  row-gap: 0.1rem;
  min-width: 0;
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.35rem max(1rem, env(safe-area-inset-left));
}

.titel {
  margin: 0;
  font: 400 2rem/1 "Young Serif", Georgia, serif;
  letter-spacing: -0.01em;
  color: var(--kobalt-tief);
}

@media (prefers-color-scheme: dark) {
  .titel {
    color: var(--tinte);
  }
}

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.9rem;
  margin: 0;
  color: var(--tinte-leise);
  font-variant-numeric: tabular-nums;
}

.status [hidden] {
  display: none;
}

#zeit,
#bestzeit {
  color: var(--tinte);
  font-weight: 700;
}

#zeit {
  display: inline-block;
  min-width: 2.4em;
}

.leiste {
  grid-area: leiste;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
  padding: max(0.6rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.35rem 0;
}

.knopf {
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0 0.9rem;
  border: 1px solid var(--knopf-rand);
  border-radius: 0.6rem;
  background: transparent;
  color: var(--tinte);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.knopf:hover:not(:disabled) {
  background: var(--knopf-hover);
}

.knopf:disabled {
  opacity: 0.4;
  cursor: default;
}

.knopf:focus-visible,
.feld:focus-visible,
.pillen input:focus-visible + span,
.teilen:focus-visible,
.teilen-feld input:focus-visible {
  outline: 3px solid var(--fokus);
  outline-offset: 2px;
}

.knopf-symbol {
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.knopf-symbol svg {
  width: 1.4rem;
  height: 1.4rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.knopf-rund {
  border-radius: 50%;
  font: 400 1.35rem/1 "Young Serif", Georgia, serif;
}

.knopf-voll {
  background: var(--knopf-voll);
  border-color: var(--knopf-voll);
  color: var(--knopf-voll-text);
}

.knopf-voll:hover:not(:disabled) {
  background: var(--knopf-voll);
  filter: brightness(1.1);
}

.tisch {
  grid-area: tisch;
  position: relative;
  display: grid;
  grid-template: "karte" minmax(0, 1fr) "seite" auto "tipp" auto / minmax(0, 1fr);
  min-height: 0;
  padding: 0.25rem max(0.75rem, env(safe-area-inset-right)) 0 max(0.75rem, env(safe-area-inset-left));
}

.karte {
  grid-area: karte;
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
  container-type: size;
}

.feld {
  display: block;
  width: min(100cqw, 100cqh, 46rem);
  height: min(100cqw, 100cqh, 46rem);
  border-radius: 0.9rem;
  background: var(--fuge);
  box-shadow: 0 1px 0 var(--kachel-kante) inset, 0 14px 32px -12px var(--schatten);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}

.feld .kachel {
  fill: url(#glasur);
}

.feld .kachel-licht {
  fill: none;
  stroke: var(--kachel-kante);
  stroke-width: 2;
  opacity: 0.8;
}

.feld .weg {
  fill: none;
  stroke: var(--kobalt);
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.feld .weg-glanz {
  fill: none;
  stroke: var(--glanz);
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.45;
  pointer-events: none;
}

.feld .kopfteil {
  fill: var(--kobalt);
}

.feld .auge {
  fill: var(--kachel);
}

.feld .scheibe {
  fill: var(--scheibe);
}

.feld .zahl.erreicht .scheibe {
  fill: var(--kobalt-tief);
  stroke: var(--glanz);
  stroke-width: 4;
}

.feld .zahl text {
  fill: var(--scheibe-zahl);
  font-family: "Young Serif", Georgia, serif;
  font-size: 40px;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.feld .zahl text.zweistellig {
  font-size: 32px;
  letter-spacing: -1px;
}

.feld .zahl.erreicht text {
  fill: #fff;
}

.feld .hinweis-feld {
  fill: var(--ocker-flaeche);
  stroke: var(--ocker);
  stroke-width: 5;
  stroke-dasharray: 14 10;
  pointer-events: none;
  animation: hinweis 1.6s ease-out 1 forwards;
}

@keyframes hinweis {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

.feld .cursor {
  fill: none;
  stroke: var(--fokus);
  stroke-width: 5;
  opacity: 0;
}

.feld:focus-visible .cursor {
  opacity: 1;
}

.feld.gewonnen .weg-glanz {
  animation: schimmer 1.6s ease-in-out 1;
}

@keyframes schimmer {
  from { stroke-dasharray: 80 1100; stroke-dashoffset: 80; opacity: 0.9; }
  to { stroke-dasharray: 80 1100; stroke-dashoffset: -1000; opacity: 0.9; }
}

@media (prefers-reduced-motion: reduce) {
  .feld.gewonnen .weg-glanz {
    animation: none;
  }

  .feld .hinweis-feld {
    animation-duration: 2.4s;
    animation-timing-function: steps(1, end);
  }
}

.bau {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--tinte-leise);
  pointer-events: none;
}

.bau[hidden] {
  display: none;
}

.tipp {
  grid-area: tipp;
  min-height: 2.6rem;
  margin: 0;
  padding: 0.5rem 0 0.4rem;
  color: var(--tinte-leise);
  text-align: center;
}

.meldung {
  grid-area: seite;
  justify-self: center;
  align-self: center;
  width: min(22rem, 100%);
  margin: 0.6rem 0 0;
  padding: 1rem 1.4rem 1.2rem;
  border-radius: 0.9rem;
  background: var(--dialog);
  box-shadow: 0 18px 40px -10px var(--schatten), 0 0 0 1px var(--fuge);
  text-align: center;
}

.meldung[hidden] {
  display: none;
}

.meldung h2 {
  margin: 0 0 0.4rem;
  font: 400 1.7rem/1.1 "Young Serif", Georgia, serif;
  color: var(--kobalt-tief);
}

@media (prefers-color-scheme: dark) {
  .meldung h2 {
    color: var(--tinte);
  }
}

.meldung p {
  margin: 0 0 1rem;
  color: var(--tinte-leise);
}

.ansage {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.fuss {
  grid-area: fuss;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.3rem max(1rem, env(safe-area-inset-right)) max(0.5rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  color: var(--tinte-leise);
  font-size: 0.9rem;
}

.teilen {
  align-self: flex-start;
  margin: -0.3rem 0;
  padding: 0.3rem 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

.teilen-feld {
  width: min(24rem, calc(100vw - 2rem));
  padding: 0.9rem 1rem 1rem;
  border: 0;
  border-radius: 0.9rem;
  background: var(--dialog);
  color: var(--tinte);
  box-shadow: 0 18px 40px -10px var(--schatten), 0 0 0 1px var(--fuge);
}

.teilen-feld label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--tinte-leise);
}

.teilen-feld input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0 0.6rem;
  border: 1px solid var(--knopf-rand);
  border-radius: 0.6rem;
  background: var(--kachel);
  color: var(--tinte);
  font: inherit;
}

.wahl {
  width: min(30rem, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  padding: 1.1rem 1.25rem 1.25rem;
  border: 0;
  border-radius: 0.9rem;
  background: var(--dialog);
  color: var(--tinte);
  box-shadow: 0 18px 40px -10px var(--schatten);
}

.wahl::backdrop,
.anleitung::backdrop {
  background: rgb(14 21 38 / 0.45);
}

.wahl h2 {
  margin: 0 0 0.75rem;
  font: 400 1.6rem/1.1 "Young Serif", Georgia, serif;
}

.wahl h3 {
  margin: 1rem 0 0.4rem;
  font: 400 1.15rem/1.2 "Young Serif", Georgia, serif;
}

.wahl-gruppe {
  margin: 0 0 0.9rem;
  padding: 0;
  border: 0;
}

.wahl-gruppe legend {
  margin-bottom: 0.35rem;
  color: var(--tinte-leise);
}

.pillen {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
}

.pillen label {
  display: block;
}

.pillen input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pillen span {
  display: grid;
  place-items: center;
  min-height: 2.9rem;
  padding: 0.2rem;
  border: 1px solid var(--knopf-rand);
  border-radius: 0.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
}

.pillen input:checked + span {
  background: var(--knopf-voll);
  border-color: var(--knopf-voll);
  color: var(--knopf-voll-text);
}

.tasten {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 0.8rem;
  margin: 0;
}

.tasten dd {
  margin: 0;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.3em;
  border: 1px solid var(--knopf-rand);
  border-radius: 0.25rem;
  font: inherit;
  font-size: 0.9em;
  text-align: center;
}

.bestzeiten table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.bestzeiten th,
.bestzeiten td {
  padding: 0.2rem 0.3rem;
  text-align: center;
}

.bestzeiten thead th {
  color: var(--tinte-leise);
  font-weight: 500;
}

.leise {
  margin: 0.4rem 0 0;
  color: var(--tinte-leise);
  font-size: 0.9rem;
}

.anleitung {
  width: min(34rem, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  padding: 0;
  border: 0;
  border-radius: 0.9rem;
  background: var(--dialog);
  color: var(--tinte);
  box-shadow: 0 18px 40px -10px var(--schatten);
}

.anleitung[open] {
  display: flex;
}

.anleitung-form {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
}

.anleitung-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.6rem 0.5rem 1.25rem;
  border-bottom: 1px solid var(--fuge);
}

.anleitung-kopf h2 {
  margin: 0;
  font: 400 1.6rem/1.1 "Young Serif", Georgia, serif;
}

.anleitung-kopf .knopf {
  border-color: transparent;
}

.anleitung-inhalt {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 1.25rem 0.75rem;
  line-height: 1.45;
}

.anleitung h3 {
  margin: 1rem 0 0.3rem;
  font: 400 1.15rem/1.2 "Young Serif", Georgia, serif;
}

.anleitung h4 {
  margin: 0.6rem 0 0.2rem;
  color: var(--tinte-leise);
  font-size: 1rem;
}

.anleitung p {
  margin: 0 0 0.4rem;
}

.anleitung ul {
  margin: 0;
  padding-left: 1.15rem;
}

.anleitung li {
  margin-bottom: 0.25rem;
}

.beispiel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  max-width: 24rem;
  margin: 0.9rem auto 0.2rem;
}

.beispiel .feld {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 0.5rem;
  box-shadow: none;
  cursor: default;
  pointer-events: none;
}

.beispiel-pfeil {
  color: var(--tinte-leise);
  font-size: 1.4rem;
}

.beispiel figcaption {
  grid-column: 1 / -1;
  color: var(--tinte-leise);
  font-size: 0.9rem;
  text-align: center;
}

.anleitung-fuss {
  display: flex;
  justify-content: flex-end;
  padding: 0.6rem 1.25rem 0.9rem;
  border-top: 1px solid var(--fuge);
}

.wahl-aktionen {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

@media (max-width: 640px) {
  body {
    grid-template:
      "kopf" auto
      "leiste" auto
      "tisch" minmax(0, 1fr)
      "fuss" auto
      / minmax(0, 1fr);
  }

  .kopf {
    justify-content: space-between;
    padding-bottom: 0.2rem;
  }

  .titel {
    font-size: 1.65rem;
  }

  .leiste {
    justify-content: space-between;
    padding: 0.3rem max(0.75rem, env(safe-area-inset-right)) 0.3rem max(0.75rem, env(safe-area-inset-left));
  }

  .leiste #neu {
    flex: 1;
    max-width: 11rem;
    padding: 0 0.6rem;
    white-space: nowrap;
  }

  .leiste .knopf-symbol {
    min-width: 2.5rem;
  }

  .leiste .knopf-rund {
    align-self: center;
    width: 2.5rem;
    height: 2.5rem;
    min-height: 2.5rem;
  }
}

@media (orientation: landscape) {
  .tisch {
    grid-template: "karte seite" minmax(0, 1fr) "tipp tipp" auto / minmax(0, 1fr) auto;
  }

  .meldung {
    width: min(17rem, 34vw);
    margin: 0 0 0 1rem;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body {
    grid-template:
      "kopf tisch" auto
      "leiste tisch" minmax(0, 1fr)
      "fuss tisch" auto
      / minmax(12rem, 16rem) minmax(0, 1fr);
  }

  .kopf {
    flex-direction: column;
    padding-right: 0.5rem;
  }

  .leiste {
    align-content: flex-start;
    justify-content: flex-start;
    padding: 0.3rem 0.5rem 0 max(1rem, env(safe-area-inset-left));
  }

  .tisch {
    padding-top: max(0.4rem, env(safe-area-inset-top));
  }

  .fuss {
    flex-direction: column;
    gap: 0;
  }
}

.feld .glasur-oben {
  stop-color: var(--kachel);
}

.feld .glasur-unten {
  stop-color: var(--kachel-unten);
}
