@font-face { font-family: 'Jost'; font-weight: 300; font-display: swap; src: url('../fonts/jost-latin-300-normal.woff2') format('woff2'); }
@font-face { font-family: 'Jost'; font-weight: 400; font-display: swap; src: url('../fonts/jost-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Jost'; font-weight: 600; font-display: swap; src: url('../fonts/jost-latin-600-normal.woff2') format('woff2'); }

:root {
  color-scheme: light dark;
  --seite: #dce2e7;
  --flaeche: #eef1f4;
  --tinte: #1d2731;
  --leise: #586674;
  --linie: #bcc6cf;
  --messing: #a8781a;
  --messing-hell: #fff4d2;
  --holz-hell: #f2deb4;
  --holz: #d9b67c;
  --holz-rand: #9c7442;
  --loch: #8c6437;
  --loch-tief: #57391a;
  --loch-rand: #c09663;
  --fokus: #1f63c7;
  --schatten: 0 1px 2px rgb(20 30 40 / 0.12), 0 8px 24px rgb(20 30 40 / 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --seite: #131a21;
    --flaeche: #1c252e;
    --tinte: #e2e8ed;
    --leise: #93a1ae;
    --linie: #33414d;
    --messing: #e0b04f;
    --messing-hell: #fff0c4;
    --holz-hell: #dcc497;
    --holz: #bf9c66;
    --holz-rand: #5f4527;
    --loch: #7a5630;
    --loch-tief: #452c12;
    --loch-rand: #aa8556;
    --fokus: #7fb0ff;
    --schatten: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 30px rgb(0 0 0 / 0.45);
  }
}

* { box-sizing: border-box; }

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

body {
  background: var(--seite);
  color: var(--tinte);
  font-family: 'Jost', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

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

.seite {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

/* Kopf */
.kopf {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  flex-wrap: wrap;
}
.titel {
  margin: 0;
  font-weight: 300;
  font-size: 2rem;
  letter-spacing: 0.06em;
  line-height: 1.1;
}
.status {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--leise);
  min-height: 1.4em;
}
.status[data-zustand="ende"] { color: var(--tinte); font-weight: 600; }

.punkt {
  display: inline-block;
  flex: none;
  width: 0.8em;
  height: 0.8em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgb(255 255 255 / 0.75), transparent 45%), var(--c);
  box-shadow: inset 0 -1px 2px rgb(0 0 0 / 0.35), 0 0 0 1px rgb(0 0 0 / 0.12);
}

/* Knopfleiste */
.leiste {
  display: flex;
  gap: 6px;
  margin: 8px 0 6px;
}
.leiste .knopf { flex: 1 1 0; }
.leiste .knopf-rund { flex: none; }
.knopf {
  min-height: 42px;
  padding: 6px 12px;
  border: 1px solid var(--linie);
  border-radius: 10px;
  background: var(--flaeche);
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}
.knopf:hover:not(:disabled) { border-color: var(--leise); }
.knopf:disabled { opacity: 0.45; cursor: default; }
.knopf-voll { background: var(--tinte); color: var(--seite); border-color: transparent; }
.knopf-klein { min-height: 36px; font-size: 0.9rem; }
.knopf-rund { width: 42px; min-width: 42px; padding: 0; border-radius: 50%; font-weight: 600; font-size: 1.1rem; }
.knopf:focus-visible, .pillen input:focus-visible + span, summary:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--fokus);
  outline-offset: 2px;
}

/* Sitze und Plätze */
.sitze {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 4px;
}
.sitz {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 6px;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  line-height: 1.2;
}
.sitz .punkt { grid-row: 1 / 3; width: 1.1em; height: 1.1em; }
.sitz-name { font-weight: 600; }
.sitz-rolle { grid-column: 2 / 4; grid-row: 2; color: var(--leise); font-size: 0.8rem; }
.sitz-info { font-variant-numeric: tabular-nums; color: var(--leise); }
.sitz.am-zug { border-color: var(--messing); background: var(--flaeche); }
.sitz.fertig .sitz-info { color: var(--messing); font-weight: 600; }

/* Spielfläche */
.tisch {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
}
.brett {
  display: block;
  width: min(100cqw, calc(100cqh * 552 / 626));
  height: auto;
  aspect-ratio: 552 / 626;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
  overflow: visible;
}
.brett.ruhig { cursor: default; }

.stern-rand { fill: var(--holz-rand); stroke: var(--holz-rand); stroke-linejoin: round; }
.stern { stroke-linejoin: round; }
.stern-maserung { fill: #000; stroke: #000; stroke-linejoin: round; opacity: 0.55; pointer-events: none; }
.einlage { fill: var(--c); stroke: var(--c); stroke-width: 36; stroke-linejoin: round; opacity: 0.2; }
.einlage-ziel { opacity: 0.09; }
.mulde { stroke: var(--loch-rand); stroke-width: 1.2; }
.loch { outline: none; }
.loch:focus-visible .mulde { stroke: var(--fokus); stroke-width: 5; }
.loch:focus-visible { outline: none; }

.spur { fill: none; stroke: var(--c); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 0.1 11; opacity: 0.8; }
.spur-start { fill: none; stroke: var(--c); stroke-width: 3; opacity: 0.75; }
.ziel-punkt { fill: var(--messing-hell); stroke: var(--messing); stroke-width: 3.5; }
.auswahl { fill: none; stroke: var(--messing); stroke-width: 4.5; }
.vorschau { fill: none; stroke: var(--messing); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 9 8; }
.vorschau-ziel { fill: none; stroke: var(--messing); stroke-width: 3; }

.schatten { fill: rgb(50 28 4 / 0.32); }
.murmel { stroke: rgb(0 0 0 / 0.28); stroke-width: 1; }
.hub { transform-box: view-box; transform-origin: 0 0; }

/* Lupe */
.lupe {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 20;
  width: var(--lupe, 132px);
  height: var(--lupe, 132px);
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--messing);
  background: var(--seite);
  box-shadow: var(--schatten);
  pointer-events: none;
}
.lupe[hidden] { display: none; }
.lupe-svg { display: block; width: 100%; height: 100%; }
.lupe-ring { fill: none; stroke: var(--messing); stroke-width: 3.5; }
.lupe-finger { fill: var(--fokus); opacity: 0.8; }

/* Meldung */
.meldung {
  position: absolute;
  inset: auto 8px;
  top: 50%;
  translate: 0 -50%;
  margin: 0 auto;
  max-width: 330px;
  padding: 18px 18px 16px;
  border-radius: 14px;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  box-shadow: var(--schatten);
  text-align: center;
  z-index: 5;
}
.meldung[hidden] { display: none; }
.meldung h2 { margin: 0 0 4px; font-weight: 300; font-size: 1.9rem; letter-spacing: 0.03em; }
.meldung p { margin: 0 0 10px; color: var(--leise); }
.rangliste { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 2px; justify-items: center; }
.rangliste:empty { display: none; }
.rangliste li { display: flex; align-items: center; gap: 8px; }
.meldung-aktionen { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* Fußzeile */
.fuss {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--leise);
  min-height: 28px;
}
.teilen { padding: 4px 0; border: none; background: none; color: inherit; font-size: inherit; text-decoration: underline; cursor: pointer; }
.teilen:focus-visible, .link:focus-visible { outline: 3px solid var(--fokus); outline-offset: 2px; }

/* Anleitung */
.anleitung {
  width: min(560px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  padding: 0;
  border: 1px solid var(--linie);
  border-radius: 14px;
  background: var(--flaeche);
  color: var(--tinte);
  box-shadow: var(--schatten);
  overflow: hidden;
}
.anleitung[open] { display: flex; flex-direction: column; }
.anleitung::backdrop { background: rgb(12 18 24 / 0.5); }
.anleitung-kopf { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 8px 18px; border-bottom: 1px solid var(--linie); }
.anleitung-kopf h2 { margin: 0; font-weight: 300; font-size: 1.6rem; letter-spacing: 0.03em; }
.anleitung-inhalt { overflow-y: auto; overscroll-behavior: contain; padding: 4px 18px 12px; min-height: 0; }
.anleitung h3 { margin: 14px 0 4px; font-size: 1.1rem; font-weight: 600; }
.anleitung h4 { margin: 10px 0 2px; font-size: 0.95rem; font-weight: 600; color: var(--leise); }
.anleitung p { margin: 4px 0; }
.anleitung ul { margin: 4px 0; padding-left: 1.2em; }
.anleitung li { margin: 3px 0; }
.anleitung-fuss { display: flex; justify-content: flex-end; padding: 10px 18px 14px; border-top: 1px solid var(--linie); }
.beispiel { display: flex; gap: 14px; align-items: center; margin: 12px 0 4px; }
.beispiel-brett { flex: none; width: 200px; height: auto; aspect-ratio: 5.8 / 4.3; }
.beispiel figcaption { font-size: 0.92rem; color: var(--leise); }
.bsp-holz { stroke: var(--holz-rand); stroke-width: 3; }
.bsp-pfad { fill: none; stroke: var(--messing); stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 9 8; }
.bsp-spitze { fill: var(--messing); }
.bsp-nummer { fill: var(--messing-hell); stroke: var(--messing); stroke-width: 3; }
.bsp-zahl { fill: #3a2a08; font: 600 14px 'Jost', sans-serif; text-anchor: middle; }
@media (max-width: 440px) {
  .beispiel { flex-direction: column; align-items: center; text-align: center; }
  .beispiel-brett { width: 240px; }
}
.verweis { margin: 10px 0 0; color: var(--leise); font-size: 0.95rem; }
.link { padding: 0; border: none; background: none; color: var(--tinte); text-decoration: underline; cursor: pointer; }

/* Teilen */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(34px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--tinte);
  color: var(--seite);
  box-shadow: var(--schatten);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 30;
}
.toast.sichtbar { opacity: 1; }
.link-pop {
  width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 1px solid var(--linie);
  border-radius: 12px;
  background: var(--flaeche);
  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(--linie); border-radius: 8px; background: var(--seite); color: var(--tinte); font: inherit; }

/* Einstellungen */
.wahl {
  width: min(420px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  padding: 18px;
  border: 1px solid var(--linie);
  border-radius: 14px;
  background: var(--flaeche);
  color: var(--tinte);
  box-shadow: var(--schatten);
}
.wahl::backdrop { background: rgb(12 18 24 / 0.5); }
.wahl h2 { margin: 0 0 10px; font-weight: 300; font-size: 1.6rem; }
.gruppe { border: none; margin: 0 0 12px; padding: 0; }
.gruppe legend { padding: 0; margin-bottom: 6px; color: var(--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;
  min-width: 44px;
  justify-content: center;
  padding: 4px 14px;
  border: 1px solid var(--linie);
  border-radius: 999px;
  cursor: pointer;
}
.pillen input:checked + span { background: var(--tinte); color: var(--seite); border-color: transparent; }
.pillen input:disabled + span { opacity: 0.4; cursor: default; }
.sitzwahl { display: grid; gap: 6px; }
.sitzzeile, .zeile {
  display: grid;
  grid-template-columns: auto 1fr minmax(130px, auto);
  align-items: center;
  gap: 8px;
}
.zeile { grid-template-columns: 1fr minmax(130px, auto); margin-bottom: 12px; color: var(--leise); }
.sitzzeile .punkt { width: 1.1em; height: 1.1em; }
select {
  min-height: 40px;
  padding: 4px 8px;
  border: 1px solid var(--linie);
  border-radius: 8px;
  background: var(--seite);
}
details { margin: 8px 0; }
summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.regeln p { margin: 6px 0; font-size: 0.95rem; }
.statistik { border-collapse: collapse; width: 100%; margin: 4px 0 8px; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.statistik caption { text-align: left; color: var(--leise); font-size: 0.85rem; padding-bottom: 4px; }
.statistik th, .statistik td { padding: 3px 5px; text-align: right; }
.statistik th:first-child { text-align: left; }
.statistik tr:first-of-type th { color: var(--leise); font-weight: 400; }
.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(--leise); }
kbd { font: inherit; padding: 0 5px; border: 1px solid var(--linie); border-radius: 4px; }
.wahl-aktionen { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }

/* Breite Fenster und Querformat: Seitenleiste links, Brett rechts */
@media (orientation: landscape) and (min-aspect-ratio: 5 / 4) {
  .seite {
    max-width: 1120px;
    grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    column-gap: 20px;
  }
  .oben { grid-column: 1; grid-row: 1; overflow-y: auto; align-self: center; }
  .tisch { grid-column: 2; grid-row: 1 / 3; }
  .fuss { grid-column: 1; grid-row: 2; }
  .kopf { display: block; }
  .titel { font-size: 2.6rem; margin-bottom: 4px; }
  .sitze { grid-template-columns: 1fr; margin-top: 8px; }
  .leiste { display: grid; grid-template-columns: 1fr 1fr; }
  .leiste .knopf-rund { width: auto; border-radius: 10px; }
  .sitz { padding: 5px 10px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .titel { font-size: 1.7rem; }
  .leiste { margin: 6px 0 4px; }
  .knopf { min-height: 40px; padding: 4px 8px; }
  .sitze { grid-template-columns: repeat(2, 1fr); }
  .sitz-rolle { display: none; }
}

@media (max-width: 440px) {
  .leiste .knopf { padding: 6px 6px; }
  .leiste .knopf-rund { padding: 0; }
}

@media (max-width: 380px) {
  .titel { font-size: 1.7rem; }
  .knopf { padding: 6px 6px; }
  .leiste { gap: 5px; }
  .leiste .knopf { padding: 6px 4px; font-size: 15px; }
  .leiste .knopf-rund { padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
