:root {
  --bg: #0d0e12;
  --text: #f4f4f7;
  --muted: #9a9cab;
  --btn: rgba(255, 255, 255, 0.08);
  --btn-line: rgba(255, 255, 255, 0.16);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* Kein Scrollen, kein Zoomen, kein Markieren, kein Kontextmenü beim langen Drücken */
body {
  position: fixed;
  inset: 0;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* --- Hinweistext --- */

.hint {
  position: fixed;
  left: 16px;
  right: 16px;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.hint-center { top: 60%; }

.hint-top { top: calc(env(safe-area-inset-top) + 72px); }

.hint.hidden { opacity: 0; transform: scale(0.96); }

.hint-main {
  font-size: clamp(22px, 6vw, 34px);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.hint-sub {
  margin-top: 6px;
  font-size: clamp(14px, 3.8vw, 18px);
  color: var(--muted);
  min-height: 1.4em;
}

.hint.alert .hint-main { color: #ff8a8a; }

/* --- Gewinner-Schriftzug --- */

.winner-text {
  position: fixed;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(44px, 13vw, 110px);
  font-weight: 800;
  letter-spacing: 0.02em;
  pointer-events: none;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  animation: winner-pop 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

.winner-text { color: #ffffff; }
.winner-text.dark { color: #16171c; text-shadow: 0 2px 14px rgba(255, 255, 255, 0.35); }

.winner-text.at-top { top: calc(env(safe-area-inset-top) + 12%); }
.winner-text.at-bottom { bottom: calc(env(safe-area-inset-bottom) + 12%); }

.winner-text.fade { opacity: 0; transition: opacity 0.4s ease; }

@keyframes winner-pop {
  0%   { opacity: 0; transform: scale(0.3) rotate(-8deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* --- Knöpfe oben (nur sichtbar, solange kein Finger liegt) --- */

.controls {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: calc(env(safe-area-inset-left) + 12px);
  right: calc(env(safe-area-inset-right) + 12px);
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.controls .round-btn { pointer-events: auto; }

body.playing .controls { opacity: 0; }
body.playing .controls .round-btn { pointer-events: none; }

.round-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--btn-line);
  background: var(--btn);
  color: var(--text);
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

.round-btn .icon-off { display: none; }
.round-btn[aria-pressed="false"] .icon-on { display: none; }
.round-btn[aria-pressed="false"] .icon-off { display: block; }

/* --- Hinweis am PC --- */

.desktop-note {
  position: fixed;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 32px));
  padding: 16px 20px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--btn-line);
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}

.desktop-note p { margin: 6px 0; }
.desktop-note a { color: #8ab4ff; }

/* --- Anleitung --- */

.help-dialog {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  overflow: auto;
  border: 1px solid var(--btn-line);
  border-radius: 16px;
  background: #1a1c23;
  color: var(--text);
  padding: 20px 22px;
  touch-action: pan-y;
  user-select: text;
  -webkit-user-select: text;
}

.help-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

.help-dialog h2 { margin: 0 0 10px; font-size: 22px; }
.help-dialog h3 { margin: 18px 0 6px; font-size: 17px; }
.help-dialog ol, .help-dialog ul { margin: 0; padding-left: 22px; }
.help-dialog li { margin: 6px 0; }

.dialog-close {
  margin-top: 18px;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 0;
  background: #f4f4f7;
  color: #111;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
