:root {
  --grund: #f4f1ea;
  --flaeche: #ffffff;
  --text: #1b2430;
  --leise: #6b7480;
  --rand: #d9d3c7;
  --start: #1d3557;
  --ziel: #e07a2f;
  --neu: #2a9d8f;
  --fehler: #c0392b;
  --taste: #e3ded3;
  --auswahl: #f2c14e;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --grund: #11161d;
    --flaeche: #1a2129;
    --text: #eef1f4;
    --leise: #95a0ab;
    --rand: #2f3a46;
    --start: #4f7cac;
    --ziel: #e8873d;
    --neu: #2fb3a3;
    --fehler: #e05a4b;
    --taste: #2a333d;
    --auswahl: #f2c14e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--grund);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }

.kopf {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--rand);
}
.kopf h1 { margin: 0; font-size: 1.5rem; letter-spacing: .02em; color: var(--start); }
.kopf h1 span { color: var(--ziel); }
.rund {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--rand);
  background: var(--flaeche); font-size: 1.1rem; font-weight: 700;
}

main { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 16px; }
.info { display: flex; justify-content: space-between; color: var(--leise); font-size: .9rem; padding: 10px 0 6px; }

.brett {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 6px 0 10px;
}
.reihe { display: flex; gap: 6px; align-items: center; position: relative; }
.reihe .marke { position: absolute; left: -30px; width: 24px; text-align: center; font-size: .8rem; color: var(--leise); }
.feld {
  width: 54px; height: 54px; border-radius: 10px; display: grid; place-items: center;
  font-size: 1.7rem; font-weight: 800; text-transform: uppercase;
  background: var(--flaeche); border: 2px solid var(--rand);
}
.reihe.start .feld { background: var(--start); border-color: var(--start); color: #fff; }
.reihe.ziel .feld { background: var(--ziel); border-color: var(--ziel); color: #fff; }
.reihe.kette .feld.neu { background: var(--neu); border-color: var(--neu); color: #fff; }
.reihe.eingabe .feld { border-style: dashed; cursor: pointer; color: var(--leise); }
.reihe.eingabe .feld.gewaehlt { border-style: solid; border-color: var(--auswahl); color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--auswahl) 35%, transparent); }
.reihe.eingabe .feld.tipp { animation: puls 1s ease-in-out 3; }
.reihe.eingabe.wackeln { animation: wackeln .35s; }
.reihe.ziel.geschafft .feld { animation: hupf .5s ease both; }
.reihe.ziel.geschafft .feld:nth-child(2) { animation-delay: .08s; }
.reihe.ziel.geschafft .feld:nth-child(3) { animation-delay: .16s; }
.reihe.ziel.geschafft .feld:nth-child(4) { animation-delay: .24s; }
.reihe.ziel.geschafft .feld:nth-child(5) { animation-delay: .32s; }
.luecke { color: var(--leise); font-size: 1.2rem; line-height: 1; }

@keyframes wackeln { 20%,60% { transform: translateX(-7px); } 40%,80% { transform: translateX(7px); } }
@keyframes puls { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--auswahl) 60%, transparent); } }
@keyframes hupf { 40% { transform: translateY(-12px); } }

.aktionen { display: flex; gap: 10px; justify-content: center; padding: 6px 0 8px; }
.aktion {
  border: 1px solid var(--rand); background: var(--flaeche); border-radius: 999px;
  padding: 8px 16px; font-weight: 600;
}
.aktion:disabled { opacity: .4; cursor: default; }

.meldung {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--grund); padding: 10px 16px; border-radius: 10px;
  font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10;
  max-width: calc(100% - 32px); text-align: center;
}
.meldung.sichtbar { opacity: 1; }

.tastatur { padding: 6px 6px 10px; display: flex; flex-direction: column; gap: 6px; }
.tastatur .zeile { display: flex; gap: 5px; justify-content: center; }
.taste {
  flex: 1; max-width: 44px; height: 52px; border: 0; border-radius: 7px;
  background: var(--taste); font-weight: 700; font-size: 1.05rem; text-transform: uppercase;
}
.taste:active { filter: brightness(.9); }

dialog {
  border: 0; border-radius: 16px; padding: 20px; width: min(92vw, 420px);
  background: var(--flaeche); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog h2 { margin: 0 0 10px; }
dialog p { line-height: 1.45; }
.klein { font-size: .85rem; color: var(--leise); }
.haupt {
  width: 100%; padding: 12px; border: 0; border-radius: 10px; margin-top: 8px;
  background: var(--neu); color: #fff; font-weight: 700; font-size: 1rem;
}
.neben {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--rand);
  background: transparent; font-weight: 600;
}
.erg-bild { display: block; height: 220px; margin: 8px auto; border-radius: 10px; box-shadow: 0 2px 10px rgb(0 0 0 / .25); }
.erg-bild:not([src]) { display: none; }
.neben.breit { width: 100%; margin-top: 8px; }
.reihe-knoepfe { display: flex; gap: 10px; justify-content: space-between; margin-top: 12px; }
.reihe-knoepfe form { margin: 0; }

.beispiel { display: flex; flex-direction: column; gap: 4px; align-items: center; margin: 8px 0; }
.bsp-reihe { display: flex; gap: 4px; }
.bsp-reihe i {
  font-style: normal; width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 7px; border: 2px solid var(--rand); font-weight: 800;
}
.bsp-reihe i.neu { background: var(--neu); border-color: var(--neu); color: #fff; }

.sterne { font-size: 2rem; text-align: center; letter-spacing: .2em; }
.kette { text-align: center; font-size: 1.3rem; letter-spacing: .1em; margin: 6px 0; word-break: break-all; }
.statgitter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; margin: 12px 0; }
.statgitter b { display: block; font-size: 1.5rem; }
.statgitter span { font-size: .75rem; color: var(--leise); }
.balken { display: grid; grid-template-columns: 70px 1fr; gap: 4px 8px; align-items: center; font-size: .85rem; }
.balken div { background: var(--neu); color: #fff; padding: 2px 6px; border-radius: 4px; min-width: 22px; text-align: right; font-weight: 700; }

@media (max-height: 680px) {
  .feld { width: 46px; height: 46px; font-size: 1.4rem; }
  .taste { height: 46px; }
}
