@font-face {
  font-family: 'Big Shoulders Display';
  src: url('../fonts/big-shoulders-display-latin-800-normal.woff2') format('woff2');
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: 'Lexend';
  src: url('../fonts/lexend-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Lexend';
  src: url('../fonts/lexend-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --seite: #e1e5ec;
  --seite-2: #d3d9e2;
  --tinte: #1c2333;
  --tinte-2: #535e72;
  --knopf: #f5f6f8;
  --knopf-rand: #aeb6c4;
  --knopf-druck: #e6e9ef;
  --blei: #2b3242;
  --messing: #d1a752;
  --messing-dunkel: #7e5d1d;
  --messing-hell: #f0dfae;
  --rubin: #c63f53;
  --fokus: #2d5fc4;
  --schatten: 0 1px 0 rgb(28 35 51 / 0.12);
  --sicher-l: env(safe-area-inset-left, 0px);
  --sicher-r: env(safe-area-inset-right, 0px);
  --sicher-o: env(safe-area-inset-top, 0px);
  --sicher-u: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --seite: #10151f;
    --seite-2: #161d2a;
    --tinte: #dfe5ef;
    --tinte-2: #9aa5b8;
    --knopf: #1b2231;
    --knopf-rand: #354057;
    --knopf-druck: #252e40;
    --blei: #05070b;
    --fokus: #7fa6f0;
    --schatten: none;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--seite);
  color: var(--tinte);
  font: 400 1rem/1.45 'Lexend', system-ui, sans-serif;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100dvh;
  overflow: hidden;
  padding: calc(8px + var(--sicher-o)) calc(12px + var(--sicher-r)) calc(4px + var(--sicher-u)) calc(12px + var(--sicher-l));
  -webkit-tap-highlight-color: transparent;
}

.kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.titel {
  margin: 0;
  font: 800 2.3rem/1 'Big Shoulders Display', 'Lexend', sans-serif;
  letter-spacing: 0.01em;
  color: var(--tinte);
}

.status {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--tinte-2);
  font-size: 0.88rem;
  white-space: nowrap;
}

.zahl {
  display: inline-block;
  min-width: 3ch;
  text-align: right;
  font: 800 2rem/1 'Big Shoulders Display', sans-serif;
  color: var(--tinte);
  font-variant-numeric: tabular-nums;
}

.zahl-klein {
  font: 800 1.3rem/1 'Big Shoulders Display', sans-serif;
  color: var(--tinte);
  font-variant-numeric: tabular-nums;
}

.level-status {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-bottom: 1.5px dotted var(--knopf-rand);
  padding: 6px 2px 4px;
  min-height: 40px;
  cursor: pointer;
  touch-action: manipulation;
}
.leben { display: inline-flex; gap: 4px; align-items: center; }
.leben i {
  display: block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff8df 0 22%, var(--messing) 60%, var(--messing-dunkel) 100%);
}

.leiste {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 10px 0 8px;
  flex-wrap: wrap;
}

.knopf {
  font: 600 0.92rem/1 'Lexend', sans-serif;
  color: var(--tinte);
  background: var(--knopf);
  border: 1.5px solid var(--knopf-rand);
  border-radius: 10px;
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
  box-shadow: var(--schatten);
  touch-action: manipulation;
}
.knopf:active { background: var(--knopf-druck); }
.knopf:disabled { opacity: 0.5; cursor: default; }
.knopf[aria-pressed='true'] { background: var(--messing-hell); border-color: var(--messing-dunkel); color: #2a1e05; }
.knopf-rund { width: 42px; padding: 0; font: 800 1.4rem/1 'Big Shoulders Display', sans-serif; }
.knopf-voll { background: var(--messing); border-color: var(--messing-dunkel); color: #2a1e05; }
.knopf-voll:active { background: #bd9442; }

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

.tisch {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 4px 0;
}

.feld {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: contain;
  border-radius: 14px;
}
.feld:focus-visible { outline-offset: 4px; }

.scheibe {
  position: relative;
  padding: 5px;
  background: var(--blei);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgb(20 28 44 / 0.22);
}

#leinwand {
  display: block;
  border-radius: 9px;
  touch-action: none;
}

.zugzone {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 52px;
  border-radius: 12px;
  border: 1.5px dashed var(--knopf-rand);
  color: var(--tinte-2);
  font-size: 0.82rem;
  touch-action: none;
}
.griff {
  width: 34px;
  height: 6px;
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, var(--knopf-rand) 0 4px, transparent 4px 8px);
}
@media (pointer: coarse) {
  .zugzone { display: flex; }
}

.start-tipp {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: calc(100% - 40px);
  margin: 0;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgb(14 20 33 / 0.78);
  color: #edf1f7;
  font-size: 0.92rem;
  text-align: center;
  pointer-events: none;
}
.start-tipp strong {
  display: block;
  font: 800 1.45rem/1.1 'Big Shoulders Display', sans-serif;
  color: var(--messing-hell);
  margin-bottom: 2px;
}
.start-tipp[hidden] { display: none; }

.meldung {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(300px, calc(100% - 32px));
  padding: 18px 18px 16px;
  border-radius: 16px;
  background: var(--knopf);
  color: var(--tinte);
  border: 1.5px solid var(--knopf-rand);
  text-align: center;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.3);
}
.meldung h2 {
  margin: 0 0 4px;
  font: 800 2rem/1.05 'Big Shoulders Display', sans-serif;
}
.meldung p { margin: 0 0 14px; color: var(--tinte-2); }
.meldung-aktionen { display: flex; justify-content: center; }
.meldung .knopf { min-width: 150px; min-height: 48px; font-size: 1.02rem; }

.fuss {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 6px 2px 2px;
  font-size: 0.82rem;
  color: var(--tinte-2);
}
.teilen {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.best #best { font-variant-numeric: tabular-nums; color: var(--tinte); font-weight: 600; }

.wahl {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1.5px solid var(--knopf-rand);
  border-radius: 18px;
  background: var(--seite);
  color: var(--tinte);
}
.wahl::backdrop { background: rgb(10 14 24 / 0.55); }
.wahl form { padding: 18px 18px 16px; }
.wahl h2 { margin: 0 0 12px; font: 800 1.9rem/1.05 'Big Shoulders Display', sans-serif; }

.wahl-gruppe { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.wahl-gruppe legend { font-weight: 600; margin-bottom: 8px; padding: 0; }

.level-raster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
}
.level-knopf {
  min-height: 44px;
  border-radius: 8px;
  border: 1.5px solid var(--knopf-rand);
  background: var(--knopf);
  color: var(--tinte);
  font: 800 1.25rem/1 'Big Shoulders Display', sans-serif;
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
}
.level-knopf[aria-current='true'] { background: var(--messing); border-color: var(--messing-dunkel); color: #2a1e05; }
.level-knopf:disabled {
  cursor: default;
  color: var(--tinte-2);
  background: repeating-linear-gradient(135deg, var(--seite-2) 0 5px, transparent 5px 10px);
  opacity: 0.7;
}

.pillen { display: flex; flex-wrap: wrap; gap: 6px; }
.pille { position: relative; }
.pille input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pille span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1.5px solid var(--knopf-rand);
  background: var(--knopf);
  font-weight: 600;
  font-size: 0.9rem;
}
.pille input:checked + span { background: var(--messing); border-color: var(--messing-dunkel); color: #2a1e05; }
.pille input:focus-visible + span { outline: 3px solid var(--fokus); outline-offset: 2px; }

.wahl-hinweis { margin: 8px 0 12px; font-size: 0.86rem; color: var(--tinte-2); }

.tasten {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0 0 8px;
  font-size: 0.86rem;
  color: var(--tinte-2);
}
.tasten dt { white-space: nowrap; color: var(--tinte); }
.tasten dd { margin: 0; }
kbd {
  font: 600 0.78rem/1 'Lexend', sans-serif;
  padding: 2px 5px;
  border-radius: 5px;
  border: 1px solid var(--knopf-rand);
  background: var(--knopf);
  color: var(--tinte);
}
.wahl-aktionen { display: flex; justify-content: flex-end; }

/* Anleitung: Kopf und Fuß stehen, der Text scrollt in sich. */
.anleitung {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1.5px solid var(--knopf-rand);
  border-radius: 18px;
  background: var(--seite);
  color: var(--tinte);
}
.anleitung[open] { display: flex; flex-direction: column; }
.anleitung::backdrop { background: rgb(10 14 24 / 0.55); }
.anleitung-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px 18px;
  border-bottom: 1.5px solid var(--knopf-rand);
}
.anleitung h2 { margin: 0; font: 800 1.9rem/1.05 'Big Shoulders Display', sans-serif; }
.anleitung-text {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 18px 14px;
  font-size: 0.92rem;
}
.anleitung h3 {
  margin: 14px 0 4px;
  font: 800 1.35rem/1.1 'Big Shoulders Display', sans-serif;
  letter-spacing: 0.02em;
  color: var(--messing-dunkel);
}
@media (prefers-color-scheme: dark) { .anleitung h3 { color: var(--messing); } }
.anleitung h4 { margin: 10px 0 2px; font-size: 0.92rem; font-weight: 600; }
.anleitung p { margin: 4px 0; }
.anleitung ul { margin: 4px 0; padding-left: 20px; }
.anleitung li { margin: 3px 0; }
.anleitung li::marker { color: var(--messing-dunkel); }
.anleitung strong { font-weight: 600; }
.anleitung .tasten { margin: 6px 0; }
.legende { list-style: none; padding-left: 0 !important; }
.legende li { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
.legende .symbol { flex: none; display: block; width: 51px; }
.legende .symbol[data-symbol="breit"], .legende .symbol[data-symbol="mehrball"],
.legende .symbol[data-symbol="langsam"], .legende .symbol[data-symbol="leben"] { margin-inline: 1.5px; }
.anleitung-fuss {
  display: flex;
  justify-content: flex-end;
  padding: 10px 18px 14px;
  border-top: 1.5px solid var(--knopf-rand);
}
.anleitung-fuss .knopf { min-width: 130px; min-height: 46px; font-size: 1rem; }

/* Meldung nach dem Teilen und Ersatzfeld, wenn nichts kopiert werden kann. */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(40px + var(--sicher-u));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 9px 16px;
  border-radius: 12px;
  background: var(--tinte);
  color: var(--seite);
  font-size: 0.9rem;
  text-align: center;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms;
}
.toast.zeigen { opacity: 1; }
.linkfeld {
  position: fixed;
  left: calc(12px + var(--sicher-l));
  bottom: calc(36px + var(--sicher-u));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  width: min(420px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--knopf);
  border: 1.5px solid var(--knopf-rand);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.3);
  font-size: 0.86rem;
}
.linkfeld[hidden] { display: none; }
.linkfeld label { flex-basis: 100%; font-weight: 600; }
.linkfeld input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  font: inherit;
  padding: 0 10px;
  border-radius: 8px;
  border: 1.5px solid var(--knopf-rand);
  background: var(--seite);
  color: var(--tinte);
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

@media (max-width: 420px) {
  .titel { font-size: 1.95rem; }
  .zahl { font-size: 1.75rem; }
  .status { gap: 12px; font-size: 0.82rem; }
  .knopf { padding: 0 11px; font-size: 0.88rem; }
  .knopf-rund { width: 40px; padding: 0; font-size: 1.35rem; }
  .leiste { gap: 6px; flex-wrap: nowrap; }
  .tasten { grid-template-columns: 1fr; }
  .tasten dt { white-space: normal; }
  .tasten dd { margin-bottom: 4px; }
}

@media (max-width: 370px) {
  .knopf { padding: 0 9px; }
  .knopf-rund { padding: 0; flex: none; }
}
@media (max-width: 345px) {
  .leiste { flex-wrap: wrap; }
}

@media (max-height: 500px) {
  body { grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: auto minmax(0, 1fr); }
  .kopf { grid-column: 1; grid-row: 1; flex-direction: column; align-items: flex-start; gap: 6px; width: auto; }
  .leiste { grid-column: 1; grid-row: 2; display: grid; grid-template-columns: minmax(0, 1fr) 42px; align-content: start; gap: 6px; padding: 8px 12px 0 0; }
  .leiste .knopf { grid-column: 1 / -1; }
  .leiste #einstellungen { grid-column: 1; }
  .leiste .knopf-rund { grid-column: 2; width: 42px; }
  .tisch { grid-column: 2; grid-row: 1 / 3; }
  .fuss { grid-column: 1 / 3; grid-row: 3; }
  .feld { flex-direction: row; }
  .zugzone { width: 112px; height: auto; align-self: stretch; flex-direction: column; }
  .zug-text { writing-mode: vertical-rl; }
}
