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

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

:root {
  --grund: #dde3ec;
  --grund-licht: #eef1f6;
  --tinte: #18203a;
  --tinte-leise: #4c5774;
  --brett: #26396a;
  --brett-tief: #1a2a52;
  --linie: rgb(214 225 255 / 0.2);
  --rahmen: #14204a;
  --safran: #e3a72a;
  --safran-tief: #a86f08;
  --fokus: #e3a72a;
  --knopf-rand: rgb(24 32 58 / 0.32);
  --knopf-hover: rgb(255 255 255 / 0.45);
  --knopf-voll: #26396a;
  --knopf-voll-text: #f4f6fb;
  --karte: #f5f7fb;
  --punkt: rgb(238 242 255 / 0.72);
  --schatten: 0 1px 2px rgb(10 16 40 / 0.35), 0 10px 30px rgb(10 16 40 / 0.25);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #0e1426;
    --grund-licht: #18223c;
    --tinte: #e8ecf6;
    --tinte-leise: #a3adc6;
    --brett: #22355f;
    --brett-tief: #15234a;
    --linie: rgb(190 205 255 / 0.17);
    --rahmen: #070c1c;
    --safran: #f0b542;
    --fokus: #f0b542;
    --knopf-rand: rgb(232 236 246 / 0.28);
    --knopf-hover: rgb(232 236 246 / 0.08);
    --knopf-voll: #f0b542;
    --knopf-voll-text: #10172b;
    --karte: #1a2440;
    --schatten: 0 1px 2px rgb(0 0 0 / 0.5), 0 12px 32px rgb(0 0 0 / 0.45);
    --rahmen-kante: 0 0 0 1px rgb(190 205 255 / 0.12);

    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(120% 90% at 50% 20%, var(--grund-licht), var(--grund) 70%) var(--grund);
  color: var(--tinte);
  font: 400 1.0625rem/1.4 "Outfit", 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.1rem;
  min-width: 0;
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.25rem max(1.25rem, env(safe-area-inset-left));
}

.titel {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.status {
  margin: 0;
  color: var(--tinte-leise);
}

.leiste {
  grid-area: leiste;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  padding: max(0.75rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) 0.25rem 0;
}

.knopf {
  min-height: 44px;
  padding: 0 1.05rem;
  border: 1.5px solid var(--knopf-rand);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}

.knopf-rund {
  display: inline-grid;
  place-items: center;
  width: 44px;
  padding: 0;
}

.leiste #anleitung-knopf {
  font-size: 1.3rem;
}

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

.knopf-klein {
  min-height: 40px;
  padding: 0 0.9rem;
  font-size: 0.95rem;
}

@media (hover: hover) {
  .knopf:hover:not(:disabled, .knopf-voll) {
    background: var(--knopf-hover);
  }
}

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

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

.tisch {
  grid-area: tisch;
  container-type: size;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0.25rem max(0.75rem, env(safe-area-inset-right)) 0.25rem max(0.75rem, env(safe-area-inset-left));
}

.spiel {
  --brett-groesse: min(100cqw - 0.5rem, 100cqh - 6.25rem, 680px);

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.zaehler {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  width: var(--brett-groesse);
}

.partei {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.2rem 0.15rem 0.35rem;
}

.partei[data-farbe="-1"] {
  flex-direction: row-reverse;
  text-align: right;
}

.partei::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  border-radius: 2px;
  background: var(--safran);
  transform: scaleX(0);
  transition: transform 220ms ease;
}

.partei.am-zug::after {
  transform: scaleX(1);
}

.mini {
  flex: none;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.35);
}

.mini-schwarz,
.seite-schwarz {
  background: radial-gradient(circle at 34% 28%, #5a6070 0, #23262e 38%, #0d0f13 75%);
}

.mini-weiss,
.seite-weiss {
  background: radial-gradient(circle at 34% 28%, #ffffff 0, #f3eee3 40%, #d6cebd 82%);
}

.zahl {
  min-width: 1.4em;
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.wer {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.farbname {
  font-weight: 700;
}

.rolle {
  color: var(--tinte-leise);
  font-size: 0.92rem;
}

.brett-rahmen {
  position: relative;
  width: var(--brett-groesse);
  aspect-ratio: 1;
  padding: calc(var(--brett-groesse) * 0.018);
  border-radius: calc(var(--brett-groesse) * 0.03);
  background: var(--rahmen);
  box-shadow: var(--rahmen-kante, 0 0 0 transparent), var(--schatten);
}

.brett {
  position: relative;
  display: grid;
  grid-template: repeat(8, 1fr) / repeat(8, 1fr);
  width: 100%;
  height: 100%;
  border-radius: calc(var(--brett-groesse) * 0.016);
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, rgb(255 255 255 / 0.025) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(0deg, rgb(0 0 0 / 0.05) 0 1px, transparent 1px 3px),
    radial-gradient(120% 120% at 30% 20%, var(--brett), var(--brett-tief));
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.brett::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(circle at 25% 25%, var(--linie) 0 0.45%, transparent 0.55%),
    radial-gradient(circle at 75% 25%, var(--linie) 0 0.45%, transparent 0.55%),
    radial-gradient(circle at 25% 75%, var(--linie) 0 0.45%, transparent 0.55%),
    radial-gradient(circle at 75% 75%, var(--linie) 0 0.45%, transparent 0.55%);
  filter: brightness(2);
}

.feld {
  position: relative;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: inset 0 0 0 0.5px var(--linie);
  perspective: 300px;
  cursor: default;
  font: inherit;
  color: inherit;
}

.feld:focus-visible {
  z-index: 3;
  outline: 3px solid var(--fokus);
  outline-offset: -3px;
}

.feld.erlaubt {
  cursor: pointer;
}

.zeige-zuege .feld.erlaubt::after {
  content: "";
  width: 24%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--punkt);
  box-shadow: 0 0 0 1.5px rgb(8 14 36 / 0.35);
}

.brett[data-am-zug="1"] {
  --geist: radial-gradient(circle at 34% 28%, #5a6070 0, #0d0f13 75%);
}

.brett[data-am-zug="-1"] {
  --geist: radial-gradient(circle at 34% 28%, #fff 0, #d6cebd 82%);
}

@media (hover: hover) {
  .brett.aktiv .feld.erlaubt:hover::after {
    content: "";
    width: 78%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--geist);
    opacity: 0.4;
  }
}

.stein {
  grid-area: 1 / 1;
  position: relative;
  width: 80%;
  aspect-ratio: 1;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
}

.feld[data-farbe="-1"] .stein {
  transform: rotateY(180deg);
}

.seite {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  box-shadow: 0 1.5px 2px rgb(0 0 0 / 0.45), inset 0 -2px 3px rgb(0 0 0 / 0.18);
}

.seite-weiss {
  transform: rotateY(180deg);
}

@media (prefers-color-scheme: dark) {
  .seite-schwarz {
    box-shadow: 0 1.5px 2px rgb(0 0 0 / 0.5), inset 0 0 0 1px rgb(200 210 240 / 0.14);
  }
}

.feld.dreht .stein {
  transition: transform 380ms cubic-bezier(0.45, 0, 0.3, 1) var(--verz, 0ms);
}

.feld.neu .stein {
  animation: setzen 220ms ease-out;
}

@keyframes setzen {
  from {
    scale: 1.25;
    opacity: 0;
  }
}

.feld.letzter::before {
  content: "";
  grid-area: 1 / 1;
  z-index: 1;
  width: 16%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--safran);
  box-shadow: 0 0 0 1.5px rgb(0 0 0 / 0.25);
}

.brett .feld.hinweis::after {
  content: "";
  grid-area: 1 / 1;
  width: 74%;
  aspect-ratio: 1;
  border: 3px solid var(--safran);
  border-radius: 50%;
  background: none;
  animation: hinweis 900ms ease-in-out 3;
}

@keyframes hinweis {
  50% {
    scale: 0.82;
  }
}

@media (prefers-reduced-motion: reduce) {
  .feld.dreht .stein,
  .partei::after {
    transition: none;
  }

  .feld.neu .stein,
  .feld.hinweis::after {
    animation: none;
  }
}

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

.meldung {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 5;
  width: min(24rem, 92%);
  translate: -50% -50%;
  padding: 1.25rem 1.4rem 1.3rem;
  border-radius: 1rem;
  background: var(--karte);
  box-shadow: var(--schatten);
  text-align: center;
}

.meldung[hidden] {
  display: none;
}

.meldung h2 {
  margin: 0 0 0.3rem;
  font-size: 1.6rem;
  line-height: 1.15;
}

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

.meldung-statistik {
  color: var(--tinte-leise);
  font-size: 0.95rem;
}

.meldung-aktionen,
.wahl-aktionen {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.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: 1rem;
  background: var(--karte);
  color: var(--tinte);
  box-shadow: var(--schatten);
  overscroll-behavior: contain;
}

.wahl::backdrop {
  background: rgb(8 12 28 / 0.45);
}

.wahl h2 {
  margin: 0 0 0.6rem;
  font-size: 1.4rem;
}

.gruppe {
  margin: 0 0 0.7rem;
  padding: 0;
  border: 0;
}

.gruppe legend {
  margin-bottom: 0.3rem;
  padding: 0;
  color: var(--tinte-leise);
  font-size: 0.95rem;
}

.gruppe[disabled] {
  opacity: 0.45;
}

.pillen {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pillen label {
  position: relative;
}

.pillen input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
}

.pillen span {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 0.95rem;
  border: 1.5px solid var(--knopf-rand);
  border-radius: 999px;
  cursor: pointer;
}

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

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

.schalter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 44px;
  margin-bottom: 0.4rem;
  cursor: pointer;
}

.schalter input {
  width: 1.4rem;
  height: 1.4rem;
  accent-color: var(--knopf-voll);
}

.statistik h3 {
  margin: 0.4rem 0 0.3rem;
  font-size: 1rem;
}

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

.statistik th,
.statistik td {
  padding: 0.25rem 0.3rem;
  border-bottom: 1px solid var(--knopf-rand);
  text-align: right;
}

.statistik th:first-child,
.statistik td:first-child {
  text-align: left;
}

.statistik thead th {
  color: var(--tinte-leise);
  font-size: 0.85rem;
  font-weight: 400;
}

.statistik .knopf {
  margin-top: 0.5rem;
}

.tasten {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.8rem;
  margin: 0.8rem 0 0;
  color: var(--tinte-leise);
  font-size: 0.92rem;
}

.tasten dd {
  margin: 0;
}

kbd {
  padding: 0 0.3em;
  border: 1px solid var(--knopf-rand);
  border-radius: 4px;
  font: inherit;
  font-size: 0.85em;
}

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

.teilen {
  min-height: 40px;
  margin: -0.75rem 0 -0.35rem -0.35rem;
  padding: 0 0.35rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.anleitung[open] {
  display: flex;
  width: min(34rem, calc(100vw - 1.5rem));
  padding: 0;
}

.anleitung form {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: calc(100dvh - 1.5rem);
}

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

.anleitung .anleitung-kopf h2 {
  margin: 0;
}

.anleitung-kopf .knopf-rund {
  padding: 0;
}

.anleitung-inhalt {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.2rem 1.25rem 0.8rem;
}

.anleitung-inhalt:focus {
  outline: none;
}

.anleitung h3 {
  margin: 1rem 0 0.35rem;
  font-size: 1.1rem;
}

.anleitung h4 {
  margin: 0.7rem 0 0.25rem;
  color: var(--tinte-leise);
  font-size: 0.95rem;
}

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

.anleitung ul {
  padding-left: 1.2rem;
}

.anleitung li + li {
  margin-top: 0.25rem;
}

.anleitung .tasten {
  margin: 0.3rem 0 0;
}

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

.beispiel {
  margin: 0.8rem 0 0.4rem;
}

.beispiel svg {
  display: block;
  width: min(100%, 20rem);
  margin: 0 auto;
}

.beispiel figcaption {
  margin-top: 0.4rem;
  color: var(--tinte-leise);
  font-size: 0.92rem;
}

.bsp-rahmen {
  fill: var(--rahmen);
}

.bsp-brett {
  fill: var(--brett);
}

.bsp-linie {
  stroke: rgb(214 225 255 / 0.35);
  stroke-width: 1;
}

.bsp-schwarz {
  fill: #191c22;
}

.bsp-weiss {
  fill: #f1ece1;
}

.bsp-gedreht {
  stroke: var(--safran);
  stroke-width: 2;
}

.bsp-neu {
  fill: var(--safran);
}

.bsp-ziel {
  fill: none;
  stroke: var(--safran);
  stroke-width: 2;
  stroke-dasharray: 3 2.5;
}

.bsp-pfeil {
  fill: none;
  stroke: var(--tinte-leise);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(max(0.45rem, env(safe-area-inset-bottom)) + 2.4rem);
  z-index: 20;
  max-width: calc(100vw - 2rem);
  margin: 0;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: var(--tinte);
  color: var(--grund-licht);
  box-shadow: var(--schatten);
  text-align: center;
  translate: -50% 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease, visibility 0s 180ms;
}

.toast.sichtbar {
  opacity: 1;
  visibility: visible;
  transition: opacity 180ms ease;
}

.link-feld {
  position: fixed;
  left: max(1rem, env(safe-area-inset-left));
  bottom: calc(max(0.45rem, env(safe-area-inset-bottom)) + 2.4rem);
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem 0.5rem;
  width: min(26rem, calc(100vw - 2rem));
  padding: 0.75rem 0.85rem;
  border-radius: 0.8rem;
  background: var(--karte);
  box-shadow: var(--schatten);
}

.link-feld[hidden] {
  display: none;
}

.link-feld label {
  grid-column: 1 / -1;
  color: var(--tinte-leise);
  font-size: 0.9rem;
}

.link-feld input {
  min-width: 0;
  min-height: 40px;
  padding: 0 0.6rem;
  border: 1.5px solid var(--knopf-rand);
  border-radius: 0.5rem;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.9rem;
}

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

  .kopf {
    padding-right: calc(max(1rem, env(safe-area-inset-right)) + 104px);
  }

  .leiste {
    justify-content: flex-start;
    gap: 0.4rem;
    padding: 0.3rem max(1rem, env(safe-area-inset-right)) 0.2rem max(1rem, env(safe-area-inset-left));
  }

  .knopf {
    padding: 0 0.8rem;
    font-size: 1rem;
  }

  .leiste .knopf-rund {
    position: absolute;
    top: max(0.55rem, env(safe-area-inset-top));
    right: max(1rem, env(safe-area-inset-right));
    padding: 0;
  }

  .leiste #anleitung-knopf {
    right: calc(max(1rem, env(safe-area-inset-right)) + 52px);
  }

  .zahl {
    font-size: 1.8rem;
  }

  .tisch {
    padding-inline: max(0.5rem, env(safe-area-inset-left)) max(0.5rem, env(safe-area-inset-right));
  }

  .spiel {
    --brett-groesse: min(100cqw, 100cqh - 6.25rem, 680px);
  }
}

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

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

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

  .knopf {
    padding: 0 0.8rem;
    font-size: 1rem;
  }

  .fuss {
    padding-right: 0.5rem;
  }

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

@container (min-aspect-ratio: 5 / 4) {
  .spiel {
    --brett-groesse: min(100cqh - 0.5rem, 100cqw - 11.5rem, 760px);

    display: grid;
    grid-template: "zaehler brett" auto "tipp brett" 1fr / 10.5rem auto;
    align-items: start;
    column-gap: 1rem;
  }

  .zaehler {
    grid-area: zaehler;
    flex-direction: column;
    width: auto;
  }

  .partei[data-farbe="-1"] {
    flex-direction: row;
    text-align: left;
  }

  .brett-rahmen {
    grid-area: brett;
  }

  .tipp {
    grid-area: tipp;
    text-align: left;
  }
}
