@font-face {
  font-family: 'Bodoni Moda';
  src: url('../fonts/bodoni-moda-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Alegreya Sans';
  src: url('../fonts/alegreya-sans-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Alegreya Sans';
  src: url('../fonts/alegreya-sans-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --grund: #cfd6dc;
  --grund-licht: #e4e8ec;
  --tinte: #1b2430;
  --tinte-leise: #4c5868;
  --flaeche: rgb(255 255 255 / 0.38);
  --flaeche-stark: rgb(255 255 255 / 0.7);
  --rand: rgb(27 36 48 / 0.22);
  --knopf-voll: #26364a;
  --knopf-voll-text: #f2eee4;
  --kalk: #ebe3d0;
  --schiefer-a: #5a6d7e;
  --schiefer-b: #435565;
  --rahmen: #2b3846;
  --rahmen-kante: #18212b;
  --koord: #aebccb;
  --messing: #c08f31;
  --messing-dunkel: #6f4f12;
  --ziel: #127a72;
  --ziel-hell: #5fe0d2;
  --pflicht: #d2442c;
  --fokus: #1b4fb0;
  --karte: #eef1f4;
  --schatten: 0 2px 4px rgb(15 25 35 / 0.22), 0 14px 34px rgb(15 25 35 / 0.24);
  --w-licht: #fffdf6;
  --w-mitte: #eee4cc;
  --w-rand: #b9a67c;
  --w-rille: rgb(120 96 50 / 0.35);
  --s-licht: #4b5a70;
  --s-mitte: #1f2836;
  --s-rand: #0c1118;
  --s-strich: #5e6f88;
  --s-rille: rgb(190 210 235 / 0.2);
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #10161d;
    --grund-licht: #1b2430;
    --tinte: #e2e7ec;
    --tinte-leise: #9eaab8;
    --flaeche: rgb(226 231 236 / 0.06);
    --flaeche-stark: rgb(226 231 236 / 0.13);
    --rand: rgb(226 231 236 / 0.2);
    --knopf-voll: #d6b46a;
    --knopf-voll-text: #191510;
    --kalk: #c9bfa8;
    --schiefer-a: #3e4f5f;
    --schiefer-b: #2f3e4c;
    --rahmen: #0b1016;
    --rahmen-kante: #000;
    --koord: #7e8d9c;
    --messing: #e2b452;
    --messing-dunkel: #6f4f12;
    --ziel: #3fc9bb;
    --pflicht: #ff6b52;
    --fokus: #9cc3ff;
    --karte: #1d2632;
    --schatten: 0 2px 4px rgb(0 0 0 / 0.5), 0 14px 34px rgb(0 0 0 / 0.5);
    --s-strich: #7d8fa8;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  display: grid;
  grid-template-rows: 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: radial-gradient(110% 80% at 50% 40%, var(--grund-licht), var(--grund) 72%) var(--grund);
  color: var(--tinte);
  font-family: 'Alegreya Sans', 'Segoe UI', sans-serif;
  font-size: 1.0625rem;
  line-height: 1.35;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

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

.oben {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 8px 16px 0;
}

.kopf {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  flex-wrap: wrap;
}

.titel {
  margin: 0;
  font-family: 'Bodoni Moda', Didot, serif;
  font-weight: 600;
  font-size: 2.5rem;
  line-height: 1;
  letter-spacing: -0.01em;
}

.status {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 1.5em;
  font-size: 1.05rem;
}

.status-phase {
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--flaeche-stark);
  color: var(--tinte-leise);
  font-size: 0.9rem;
  white-space: nowrap;
}

.status[data-zustand='pflicht'] .status-phase { background: var(--pflicht); color: #fff; font-weight: 700; }
.status[data-zustand='pflicht'] .status-text,
.status[data-zustand='ende'] .status-text { font-weight: 700; }

.leiste {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.knopf {
  min-height: 40px;
  padding: 6px 14px;
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: var(--flaeche);
  cursor: pointer;
  touch-action: manipulation;
  font-size: 1rem;
}
.knopf:hover:not(:disabled) { background: var(--flaeche-stark); }
.knopf:disabled { opacity: 0.45; cursor: default; }
.knopf[aria-pressed='true'] { background: var(--flaeche-stark); border-color: var(--tinte-leise); }
.knopf:focus-visible, .pillen input:focus-visible + span, .schalter input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--fokus);
  outline-offset: 2px;
}
.knopf-voll { background: var(--knopf-voll); color: var(--knopf-voll-text); border-color: transparent; font-weight: 700; }
.knopf-voll:hover:not(:disabled) { background: var(--knopf-voll); filter: brightness(1.12); }
.knopf-klein { min-height: 34px; padding: 4px 10px; font-size: 0.92rem; }
.knopf-icon { margin-left: auto; width: 44px; padding: 0; display: grid; place-items: center; }
.knopf-rund { width: 40px; min-width: 40px; padding: 0; border-radius: 50%; font-weight: 700; font-size: 1.15rem; }
.knopf-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* Spielfläche */

.tisch {
  position: relative;
  container-type: size;
  min-height: 0;
  margin: 8px 16px 4px;
}

.spiel {
  --leiste-h: 44px;
  --luecke: 8px;
  --b: min(100cqw, 100cqh - 2 * var(--leiste-h) - 2 * var(--luecke), 780px);
  display: grid;
  grid-template-rows: var(--leiste-h) var(--b) var(--leiste-h);
  justify-content: center;
  align-content: center;
  gap: var(--luecke);
  height: 100%;
}

.brett-rahmen { width: var(--b); height: var(--b); }

.brett {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  filter: drop-shadow(0 4px 4px rgb(10 20 30 / 0.25)) drop-shadow(0 16px 24px rgb(10 20 30 / 0.22));
}
.brett.ruhig { cursor: default; }

.spieler {
  display: flex;
  align-items: center;
  gap: 10px;
  width: var(--b);
  min-width: 0;
  overflow: hidden;
  padding: 3px 12px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: var(--flaeche);
}
.spieler.am-zug { border-color: var(--messing); background: var(--flaeche-stark); }

.spieler-name { display: flex; flex-direction: column; min-width: 4.4em; line-height: 1.1; }
.spieler-seite { font-weight: 700; }
.spieler-rolle { font-size: 0.85rem; color: var(--tinte-leise); }
.spieler-rolle:empty { display: none; }

.spieler-steine { display: grid; grid-template-columns: repeat(6, 14px); gap: 3px 4px; flex: 1; justify-content: center; }

.spieler-zahl {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin: 0 0 0 auto;
  line-height: 1.05;
  color: var(--tinte-leise);
  white-space: nowrap;
}
.spieler-zahl b { font-size: 1.15rem; color: var(--tinte); }
.spieler-zahl span { font-size: 0.78rem; }

.mini {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: block;
}
.mini-weiss { --m-a: var(--w-licht); --m-b: var(--w-mitte); --m-r: var(--w-rand); }
.mini-schwarz { --m-a: var(--s-licht); --m-b: var(--s-mitte); --m-r: var(--s-strich); }
.mini-stein, .mini-dame { background: radial-gradient(circle at 38% 32%, var(--m-a), var(--m-b) 60%); border: 1.5px solid var(--m-r); }
.mini-dame { box-shadow: 0 0 0 2px var(--messing); }
.mini-weg { border: 1.5px dashed var(--tinte-leise); opacity: 0.35; transform: scale(0.7); }

@container (min-aspect-ratio: 6 / 5) {
  .spiel {
    --leiste-w: clamp(96px, 16cqw, 150px);
    --b: min(100cqh, 100cqw - 2 * var(--leiste-w) - 2 * var(--luecke), 780px);
    grid-template-rows: var(--b);
    grid-template-columns: var(--leiste-w) var(--b) var(--leiste-w);
  }
  .spieler {
    width: auto;
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 12px;
  }
  #spieler-oben { align-self: start; }
  #spieler-unten { align-self: end; }
  .spieler-steine { display: grid; grid-template-columns: repeat(4, 14px); gap: 5px; flex: none; }
  .spieler-zahl { margin: 0; flex-direction: row; align-items: baseline; gap: 5px; white-space: normal; }
}

/* Brett (SVG) */

.rahmen { fill: var(--rahmen); }
.rahmen-kante { fill: var(--rahmen-kante); }
.hell { fill: var(--kalk); }
.dunkel { fill: url(#g-schiefer); }
.schiefer-a { stop-color: var(--schiefer-a); }
.schiefer-b { stop-color: var(--schiefer-b); }
.koord { fill: var(--koord); font: 700 18px 'Alegreya Sans', sans-serif; text-anchor: middle; }

.w-licht { stop-color: var(--w-licht); }
.w-mitte { stop-color: var(--w-mitte); }
.w-rand { stop-color: var(--w-rand); }
.s-licht { stop-color: var(--s-licht); }
.s-mitte { stop-color: var(--s-mitte); }
.s-rand { stop-color: var(--s-rand); }

.stein > * { transition: transform 0.15s ease-out, opacity 0.2s; }
.stein-schatten { fill: rgb(5 10 20 / 0.38); }
.weiss .stein-koerper { stroke: var(--w-rand); stroke-width: 2; }
.schwarz .stein-koerper { stroke: var(--s-strich); stroke-width: 2; }
.stein-rille { fill: none; stroke-width: 2.5; }
.weiss .stein-rille { stroke: var(--w-rille); }
.schwarz .stein-rille { stroke: var(--s-rille); }
.stein-rille-innen { stroke-width: 1.5; }
.krone path, .krone rect { fill: var(--messing); stroke: var(--messing-dunkel); stroke-width: 1.5; stroke-linejoin: round; }
.dame .stein-rille-innen { opacity: 0; }
.krone-spaeter .krone { opacity: 0; }
.gekroent .krone { animation: kroenen 0.4s ease-out; }

.gleitet { transition: transform 0.21s cubic-bezier(0.35, 0.6, 0.3, 1); }
.faehrt { filter: drop-shadow(0 6px 4px rgb(0 0 0 / 0.25)); }
.weg { animation: weg 0.35s ease-in forwards; }
.gewaehlt > :not(.stein-schatten):not(.mark-pflicht) { transform: translateY(-5px) scale(1.07); }
.gewaehlt .stein-koerper { stroke: var(--ziel); stroke-width: 6; }
.gezogen > :not(.stein-schatten) { transform: scale(1.14); }
.gezogen .stein-schatten { transform: translate(4px, 10px) scale(1.1); opacity: 0.6; }

.mark-von { fill: none; stroke: var(--messing); stroke-width: 4; stroke-dasharray: 10 8; opacity: 0.75; }
.mark-zu { fill: rgb(255 255 255 / 0.06); stroke: var(--messing); stroke-width: 5; }
.mark-pfad { fill: none; stroke: var(--messing); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.6; }
.mark-weg line { stroke: var(--messing); stroke-width: 5; stroke-linecap: round; opacity: 0.75; }
.mark-pflicht { fill: none; stroke: var(--pflicht); stroke-width: 6; animation: puls 1.1s ease-in-out infinite alternate; }
.mahnen .mark-pflicht { animation: mahnen 0.18s ease-in-out 4 alternate; }
.mark-ziel { fill: var(--ziel-hell, var(--ziel)); stroke: var(--ziel); stroke-width: 4; pointer-events: none; }
.mark-schritt { fill: none; stroke: var(--ziel-hell, var(--ziel)); stroke-width: 6; stroke-dasharray: 9 7; pointer-events: none; }
.mark-zwischen { fill: var(--ziel); pointer-events: none; }
.mark-eingabe { fill: none; stroke: var(--ziel-hell, var(--ziel)); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; pointer-events: none; }

.feld { outline: none; }
.feld-flaeche { fill: transparent; }
.feld-fokus { fill: none; stroke: none; }
.feld:focus-visible .feld-fokus { stroke: var(--fokus); stroke-width: 5; }
.ueber, .unter, .steine, .koordinaten { pointer-events: none; }

@keyframes weg { to { transform: scale(0.4); opacity: 0; } }
@keyframes puls { from { opacity: 1; } to { opacity: 0.35; } }
@keyframes mahnen { from { stroke-width: 6; } to { stroke-width: 14; } }
@keyframes kroenen { from { transform: scale(0.3) translateY(-20px); opacity: 0; } }

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

/* Meldung */

.meldung {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(320px, 100%);
  padding: 18px 20px 16px;
  border-radius: 12px;
  background: var(--karte);
  box-shadow: var(--schatten);
  border-top: 5px solid var(--messing);
  text-align: center;
  z-index: 2;
}
.meldung h2 { margin: 0 0 4px; font-family: 'Bodoni Moda', Didot, serif; font-weight: 600; font-size: 2rem; }
.meldung p { margin: 0 0 14px; color: var(--tinte-leise); }
.meldung-aktionen { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* Dialog */

.wahl {
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 18px 20px;
  border: none;
  border-radius: 12px;
  background: var(--karte);
  color: var(--tinte);
  box-shadow: var(--schatten);
}
.wahl::backdrop { background: rgb(10 16 24 / 0.5); }
.wahl h2 { margin: 0 0 10px; font-family: 'Bodoni Moda', Didot, serif; font-weight: 600; font-size: 1.5rem; }

.gruppe { border: none; margin: 0 0 12px; padding: 0; }
.gruppe:disabled { opacity: 0.45; }
.gruppe legend { padding: 0; margin-bottom: 6px; color: var(--tinte-leise); }

.pillen { display: flex; flex-wrap: wrap; gap: 6px; }
.pillen label { position: relative; }
.pillen input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.pillen span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid var(--rand);
  cursor: pointer;
}
.pillen input:checked + span { background: var(--knopf-voll); color: var(--knopf-voll-text); border-color: transparent; }

.schalter { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-bottom: 8px; }
.schalter input { flex: none; width: 22px; height: 22px; accent-color: var(--ziel); }

details { margin: 6px 0; border-top: 1px solid var(--rand); padding-top: 6px; }
summary { cursor: pointer; min-height: 36px; display: flex; align-items: center; }
details p { margin: 4px 0 8px; max-width: 62ch; }

.statistik { border-collapse: collapse; width: 100%; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.statistik th, .statistik td { padding: 3px 6px; text-align: right; }
.statistik th:first-child { text-align: left; }
.statistik tr:has(> th + th) th { color: var(--tinte-leise); font-weight: 400; padding-top: 8px; }

.tasten { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; font-size: 0.95rem; }
.tasten dt { white-space: nowrap; }
.tasten dd { margin: 0; color: var(--tinte-leise); }
kbd { font: inherit; padding: 0 5px; border: 1px solid var(--rand); border-radius: 4px; }

.wahl-aktionen { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }

/* Anleitung */

.anleitung {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: none;
  border-radius: 12px;
  border-top: 5px solid var(--messing);
  background: var(--karte);
  color: var(--tinte);
  box-shadow: var(--schatten);
  overflow: hidden;
}
.anleitung[open] { display: flex; flex-direction: column; }
.anleitung::backdrop { background: rgb(10 16 24 / 0.5); }
.anleitung-kopf { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px 8px 20px; border-bottom: 1px solid var(--rand); }
.anleitung-kopf h2 { margin: 0; font-family: 'Bodoni Moda', Didot, serif; font-weight: 600; font-size: 1.6rem; line-height: 1.15; }
.anleitung-inhalt { overflow-y: auto; overscroll-behavior: contain; padding: 4px 20px 12px; min-height: 0; }
.anleitung h3 { margin: 14px 0 4px; font-size: 1.15rem; font-weight: 700; }
.anleitung h4 { margin: 10px 0 2px; font-size: 1rem; font-weight: 700; color: var(--tinte-leise); }
.anleitung p { margin: 4px 0; }
.anleitung .klein { color: var(--tinte-leise); }
.anleitung ul { margin: 4px 0; padding-left: 1.2em; }
.anleitung li { margin: 3px 0; }
.anleitung-fuss { display: flex; justify-content: flex-end; padding: 10px 20px 14px; border-top: 1px solid var(--rand); }
.beispiel { display: flex; gap: 14px; align-items: center; margin: 12px 0 4px; }
.beispiel-brett { flex: none; width: 160px; height: 160px; }
.beispiel figcaption { font-size: 0.95rem; color: var(--tinte-leise); }
.bsp-geschlagen { opacity: 0.7; }
.beispiel-brett .mark-eingabe { stroke: var(--ziel); stroke-width: 11; opacity: 1; }
.beispiel-brett .mark-weg line { stroke-width: 7; opacity: 1; }
.bsp-spitze { fill: var(--ziel); }
.bsp-nummer { fill: var(--ziel); stroke: #fff; stroke-width: 3; }
.bsp-zahl { fill: #fff; font: 700 30px 'Alegreya Sans', sans-serif; text-anchor: middle; }
@media (max-width: 420px) {
  .beispiel { flex-direction: column; align-items: center; text-align: center; }
  .beispiel-brett { width: 200px; height: 200px; }
}

.verweis { margin: 10px 0 0; color: var(--tinte-leise); font-size: 0.95rem; }
.link { padding: 0; border: none; background: none; color: var(--tinte); text-decoration: underline; cursor: pointer; }
.link:focus-visible, .teilen:focus-visible { outline: 3px solid var(--fokus); outline-offset: 2px; }

/* Teilen */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(36px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--knopf-voll);
  color: var(--knopf-voll-text);
  box-shadow: var(--schatten);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 5;
}
.toast.sichtbar { opacity: 1; }
.link-pop {
  width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border: none;
  border-radius: 10px;
  background: var(--karte);
  color: var(--tinte);
  box-shadow: var(--schatten);
}
.link-pop label { display: block; margin-bottom: 6px; }
.link-pop input { width: 100%; min-height: 40px; padding: 4px 8px; margin-bottom: 10px; border: 1px solid var(--rand); border-radius: 6px; background: var(--flaeche-stark); }

/* Fußzeile */

.fuss {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 2px 16px 6px;
  font-size: 0.9rem;
  color: var(--tinte-leise);
}
.teilen { padding: 0; border: none; background: none; color: inherit; font-size: inherit; text-decoration: underline; cursor: pointer; }

@media (max-width: 380px) {
  .tisch { margin-left: 6px; margin-right: 6px; }
  .titel { font-size: 2.2rem; }
  .knopf { padding: 6px 10px; }
  .leiste { gap: 4px; }
  .leiste .knopf { padding: 6px 6px; font-size: 0.97rem; white-space: nowrap; }
  .leiste .knopf-icon, .leiste .knopf-rund { width: 40px; padding: 0; }
  .spieler { gap: 8px; padding: 3px 10px; }
  .spieler-name { min-width: 0; }
  .spieler-steine { grid-template-columns: repeat(6, 12px); gap: 3px; }
  .mini { width: 12px; height: 12px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  body {
    grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .oben { grid-column: 1; grid-row: 1; padding: 6px 0 0 16px; max-width: none; }
  .kopf { flex-direction: column; align-items: flex-start; gap: 4px; }
  .titel { font-size: 1.9rem; }
  .status { flex-wrap: wrap; gap: 4px 8px; font-size: 1rem; }
  .leiste { flex-direction: column; gap: 6px; margin-top: 10px; }
  .knopf-icon { margin-left: 0; width: auto; }
  .leiste .knopf-rund { width: auto; border-radius: 8px; }
  .tisch { grid-column: 2; grid-row: 1 / span 2; margin: 4px 12px 4px 8px; }
  .fuss { grid-column: 1; grid-row: 2; flex-direction: column; gap: 2px; padding: 0 0 6px 16px; max-width: none; }
}
