:root {
  --bg: #f4f1ea; --fg: #1c1c1e; --muted: #5d5a54; --gelb: #f5b700; --gelb-dunkel: #d99e00;
  --karte: #fffdf8; --rand: #d9d3c5; --gruen: #2e7d32; --warn: #c62828; --fund: #8d6e1f;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151514; --fg: #f1efe9; --muted: #a8a49b; --karte: #22211f; --rand: #3a3833; --warn: #ef5350; --fund: #e0b84c; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
.warnband { height: 14px; flex: none; background: repeating-linear-gradient(-45deg, var(--gelb) 0 18px, #1c1c1e 18px 36px); }
a { color: inherit; text-decoration-color: var(--gelb); text-decoration-thickness: 2px; text-underline-offset: 3px; }

.kopf {
  width: 100%; max-width: 780px; margin: 0 auto; padding: 14px 16px 6px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
}
.kopf .heim { font-size: .9rem; color: var(--muted); justify-self: start; white-space: nowrap; }
.kopf h1 { margin: 0; font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.kopf h1 span { color: var(--gelb); }
.kopf h1 small { font-size: .8rem; font-weight: 600; color: var(--muted); letter-spacing: .05em; }
.kopf .rund { justify-self: end; }

section { width: 100%; max-width: 780px; margin: 0 auto; padding: 4px 16px 16px; flex: 1; }

button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.rund { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--rand); background: var(--karte); font-size: 1.1rem; }
.knopf {
  border: 2px solid var(--fg); background: var(--karte); border-radius: 12px; padding: 9px 12px;
  font-weight: 600; font-size: .95rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.knopf:active, .dpad button:active { transform: translateY(1px); }
.knopf.klein { padding: 6px 10px; font-size: .85rem; }
.knopf.gelb { background: var(--gelb); color: #1c1c1e; border-color: #1c1c1e; }
.knopf.gruen { background: var(--gruen); color: #fff; border-color: var(--gruen); }
.knopf:disabled { opacity: .45; cursor: default; }
kbd {
  font: 600 .7rem ui-monospace, monospace; padding: 1px 5px; border-radius: 5px;
  border: 1px solid currentColor; opacity: .6;
}

/* ---------- Levelauswahl ---------- */
.einleitung { color: var(--muted); line-height: 1.5; margin: 6px 0 4px; text-align: center; }
.gesamt { text-align: center; font-weight: 700; margin: 4px 0 18px; }
.welten { display: grid; gap: 16px; }
.welt { background: var(--karte); border: 2px solid var(--rand); border-radius: 16px; overflow: hidden; }
.welt h2 { margin: 0; padding: 10px 14px; font-size: 1.05rem; color: #fff; display: flex; justify-content: space-between; }
.welt h2 small { font-weight: 600; opacity: .9; }
.welt .levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 12px; }
.lvknopf {
  border: 2px solid var(--rand); border-radius: 12px; background: var(--bg); padding: 10px 4px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 92px;
}
.lvknopf b { font-size: 1.3rem; }
.lvknopf .lvn { font-size: .72rem; color: var(--muted); text-align: center; line-height: 1.2; min-height: 2.4em; }
.lvknopf .st { color: var(--gelb); letter-spacing: 1px; font-size: .95rem; }
.lvknopf .st i { color: var(--rand); font-style: normal; }
.lvknopf:not(:disabled):hover { border-color: var(--gelb); }
.lvknopf:disabled { opacity: .5; }
@media (max-width: 520px) {
  .welt .levels { grid-template-columns: repeat(5, 1fr); gap: 5px; padding: 8px; }
  .lvknopf { padding: 8px 2px 6px; min-height: 76px; }
  .lvknopf .lvn { display: none; }
}

/* ---------- Spiel ---------- */
.leiste { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-bottom: 8px; }
.titel { display: flex; flex-direction: column; min-width: 0; text-align: center; }
.titel small { color: var(--muted); font-size: .75rem; }
.titel b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.werte { display: flex; flex-direction: column; align-items: flex-end; font-size: .85rem; font-variant-numeric: tabular-nums; }
.werte #ziel { color: var(--muted); font-size: .75rem; }

.feldrahmen { position: relative; width: fit-content; max-width: 100%; margin: 0 auto; }
#feld {
  display: block; border-radius: 10px; border: 3px solid #1c1c1e; touch-action: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18); max-width: 100%;
}
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px;
  background: rgba(20, 20, 18, .45); border-radius: 10px;
}
.karte {
  background: var(--karte); border: 3px solid #1c1c1e; border-radius: 16px; padding: 18px 18px 16px;
  max-width: 380px; width: 100%; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  animation: rein .25s ease-out;
}
@keyframes rein { from { transform: scale(.92); opacity: 0; } }
.karte h2 { margin: 2px 0 8px; font-size: 1.4rem; }
.karte p { margin: 0 0 12px; line-height: 1.45; color: var(--muted); }
.karte .welt-name { font-size: .75rem; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); }
.karte .sterne { font-size: 2.4rem; letter-spacing: 6px; color: var(--gelb); margin: 4px 0 6px; }
.karte .sterne i { color: var(--rand); font-style: normal; }
.karte .sterne span { display: inline-block; animation: stern .5s cubic-bezier(.2, 1.6, .5, 1) backwards; }
.karte .sterne span:nth-child(2) { animation-delay: .15s; }
.karte .sterne span:nth-child(3) { animation-delay: .3s; }
@keyframes stern { from { transform: scale(0) rotate(-90deg); } }
.karte .knoepfe { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.meldung { min-height: 2.6em; margin: 8px 0 6px; text-align: center; font-size: .95rem; line-height: 1.3; color: var(--muted); }
.meldung.warn { color: var(--warn); font-weight: 600; }
.meldung.fund { color: var(--fund); font-weight: 700; }
.meldung.gut { color: var(--gruen); font-weight: 700; }

.material { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: stretch; margin-bottom: 10px; }
.stueck {
  position: relative; border: 2px solid var(--rand); background: var(--karte); border-radius: 12px;
  padding: 4px 6px 3px; display: flex; flex-direction: column; align-items: center; min-width: 62px;
}
.stueck canvas { width: 40px; height: 40px; }
.stueck span { font-size: .68rem; color: var(--muted); }
.stueck .anz {
  position: absolute; top: -7px; right: -7px; min-width: 22px; height: 22px; border-radius: 11px; padding: 0 5px;
  background: #1c1c1e; color: #fff; font-size: .75rem; font-weight: 700; display: grid; place-items: center;
}
.stueck.aktiv { border-color: var(--gelb); background: color-mix(in srgb, var(--gelb) 18%, var(--karte)); }
.stueck.leer { opacity: .4; }
.stueck kbd { position: absolute; top: 3px; left: 4px; font-size: .6rem; padding: 0 3px; }
.drehen { display: flex; flex-direction: column; gap: 4px; }
.drehen button { flex: 1; min-width: 44px; border: 2px solid var(--rand); background: var(--karte); border-radius: 10px; font-size: 1.1rem; }
.info { border: 2px dashed var(--rand); border-radius: 12px; padding: 6px 8px; font-size: .78rem; display: flex; flex-direction: column; justify-content: center; align-items: center; min-width: 62px; }
.info b { font-size: 1.05rem; }

.steuer { display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap; }
.dpad { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); gap: 4px; }
.dpad button { border: 2px solid var(--fg); background: var(--karte); border-radius: 12px; font-size: 1.15rem; }
.dpad .hoch { grid-area: 1 / 2; } .dpad .links { grid-area: 2 / 1; } .dpad .mitte { grid-area: 2 / 2; background: var(--gelb); color: #1c1c1e; }
.dpad .rechts { grid-area: 2 / 3; } .dpad .runter { grid-area: 3 / 2; }
.aktionen { display: grid; grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 6px; }
.aktionen .gelb { display: none; }
@media (hover: none), (max-width: 560px) {
  kbd { display: none; }
}
@media (max-width: 560px) {
  .kopf { grid-template-columns: auto 1fr auto; padding-top: 10px; }
  .kopf .heim { font-size: 0; }
  .kopf .heim::before { content: "← Start"; font-size: .85rem; }
  .kopf h1 { font-size: 1.3rem; text-align: center; }
  .kopf h1 small { display: none; }
  .steuer { flex-wrap: nowrap; gap: 10px; align-items: flex-start; }
  .dpad { grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(3, 50px); }
  .aktionen { grid-template-columns: 1fr 1fr; flex: 1; gap: 5px; }
  .aktionen .knopf { padding: 8px 4px; font-size: .85rem; }
  .aktionen .gruen { grid-column: 1 / -1; padding: 12px 4px; font-size: 1rem; }
  .drehen { flex-direction: row; }
  .drehen button { min-height: 44px; }
}

.hilfe { margin: 16px auto 0; max-width: 620px; background: var(--karte); border: 2px solid var(--rand); border-radius: 12px; padding: 8px 14px; }
.hilfe summary { cursor: pointer; font-weight: 700; }
.hilfe ul { padding-left: 18px; line-height: 1.5; font-size: .9rem; }

footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 18px 16px 22px; }
