:root {
  --bg: #070B14;
  --karte: rgba(16, 23, 40, 0.92);
  --linie: rgba(160, 180, 230, 0.18);
  --text: #E6ECFF;
  --text-2: #8E9AC0;
  --akzent: #37E2FF;
  --gold: #F7C548;
  --rot: #FF4D6A;
  --oben: env(safe-area-inset-top, 0px);
  --unten: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
}

canvas#spiel {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

[hidden] { display: none !important; }

/* HUD */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: calc(var(--oben) + 10px) 16px 0;
  display: grid;
  grid-template-columns: 84px 1fr 84px;
  align-items: start;
  pointer-events: none;
}
#hud button { pointer-events: auto; }
.hud-mitte { text-align: center; }
#zeit {
  font-size: 30px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}
#level-info {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
}
#wand { text-align: right; }
#wand-zahl {
  display: inline-block;
  font-size: 30px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #FF8C5A;
  transform-origin: right center;
}
#wand.null #wand-zahl { color: var(--rot); }
.wand-label { font-size: 12px; color: var(--text-2); margin-top: -2px; }

#safe-unten {
  position: fixed;
  left: 0; bottom: 0;
  width: 1px;
  height: var(--unten);
  visibility: hidden;
  pointer-events: none;
}

button.rund {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--linie);
  background: rgba(16, 23, 40, 0.7);
  color: var(--text);
  display: grid; place-items: center;
  padding: 0;
}
button.rund svg { width: 18px; height: 18px; fill: currentColor; }

/* Meldungen in der Bildmitte */
#meldung {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(var(--unten) + 48px);
  text-align: center;
  pointer-events: none;
}
#meldung-titel { font-size: 22px; font-weight: 600; }
#meldung-text { font-size: 14px; color: var(--text-2); margin-top: 6px; max-width: 340px; margin-inline: auto; }
#meldung.fehler #meldung-titel { color: var(--rot); }
#meldung.tor #meldung-titel { color: var(--gold); font-size: 28px; }

/* Menüs und Dialoge */
.bildschirm {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(var(--oben) + 16px) 16px calc(var(--unten) + 16px);
  background: rgba(7, 11, 20, 0.55);
  touch-action: auto;
}
.karte {
  width: 100%;
  max-width: 360px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 20px;
  padding: 24px 20px;
  text-align: center;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
h1 { margin: 0; font-size: 40px; letter-spacing: 2px; }
h2 { margin: 0 0 16px; font-size: 22px; }
.unterzeile { margin: 4px 0 24px; color: var(--text-2); }
.klein { font-size: 13px; color: var(--text-2); margin: 8px 0 16px; }
.anleitung { text-align: left; line-height: 1.45; margin: 20px 0 0; }

.karte button:not(.rund) {
  display: block;
  width: 100%;
  min-height: 48px;
  margin: 8px 0;
  border-radius: 12px;
  border: 1px solid var(--linie);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.karte button.haupt {
  background: var(--akzent);
  border-color: var(--akzent);
  color: #04111A;
  font-weight: 600;
}
.karte button:active { transform: scale(0.98); }
#level-liste button, #optionen-liste button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  text-align: left;
}
#level-liste .best { color: var(--text-2); font-size: 14px; font-variant-numeric: tabular-nums; }
#optionen-liste button { font-size: 15px; }
#optionen-liste .wert { color: var(--akzent); font-weight: 600; }
#optionen-liste .info { text-align: left; margin: -2px 4px 10px; }

#dialog-werte {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  margin: 0 0 16px;
  text-align: left;
}
#dialog-werte dt { color: var(--text-2); }
#dialog-werte dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
#dialog-werte dd.neu { color: var(--gold); font-weight: 600; }
