:root {
  --good: #3f8f3a;
  --good-light: #6dbd5f;
  --bad: #b4322c;
  --bad-light: #e0625a;
  --ink: #23301f;
  --paper: #fdfcf7;
  --shadow: 0 18px 45px rgba(20, 32, 18, 0.35);
  --font: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: #0f1a10;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: default;
}
#scene.grabbable { cursor: grab; }
#scene.grabbing  { cursor: grabbing; }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: linear-gradient(to bottom, rgba(12, 22, 12, 0.72), rgba(12, 22, 12, 0));
  color: #fff;
  pointer-events: none;
}
#hud .icon-btn { pointer-events: auto; }

.hud-label {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-right: 6px;
}
.hud-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

.hud-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
  max-width: 420px;
}
#progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--good-light), #cfe08a);
  transition: width 0.35s ease;
}

.hud-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(4px);
}
.pill-good { color: #b9edad; }
.pill-bad  { color: #ffb3ad; }

.icon-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.25); }
.icon-btn.off { opacity: 0.45; }

/* ---------- Hinweis unten ---------- */
#hint {
  position: fixed;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(12, 22, 12, 0.55);
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  backdrop-filter: blur(4px);
  pointer-events: none;
  white-space: nowrap;
}
#hint kbd {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: inherit;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  top: 84px; left: 50%;
  transform: translate(-50%, -14px);
  padding: 12px 26px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  background: rgba(30, 30, 30, 0.9);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: min(90vw, 520px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.good { background: linear-gradient(135deg, var(--good), var(--good-light)); }
#toast.bad  { background: linear-gradient(135deg, var(--bad), var(--bad-light)); }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 20, 10, 0.62);
  backdrop-filter: blur(6px);
  z-index: 10;
  padding: 20px;
}
.overlay.hidden, .hidden { display: none !important; }

.panel {
  background: var(--paper);
  border-radius: 22px;
  padding: 34px 38px;
  max-width: 540px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
}

.panel h1 {
  margin: 0 0 6px;
  font-size: 32px;
  letter-spacing: -0.01em;
  color: var(--good);
}
.panel .sub { margin: 0 0 22px; color: #5a6555; font-size: 16px; }

.rules {
  text-align: left;
  margin: 0 auto 26px;
  padding-left: 20px;
  line-height: 1.7;
  color: #404b3d;
  max-width: 400px;
}
.c-good { color: var(--good); }
.c-bad  { color: var(--bad); }

button.primary {
  border: 0;
  border-radius: 999px;
  padding: 14px 38px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, var(--good), var(--good-light));
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(63, 143, 58, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
button.primary:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(63, 143, 58, 0.42); }
button.primary:active { transform: translateY(0); }

.score-line { font-size: 20px; margin: 4px 0 20px; }
.score-line b { font-size: 26px; }

#result-wrong { text-align: left; margin-bottom: 26px; }
#result-wrong h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #7a8577;
  margin: 0 0 10px;
}
#result-wrong ul { margin: 0; padding-left: 18px; line-height: 1.8; color: #404b3d; }
#result-wrong .tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
  padding: 1px 8px;
  margin-left: 6px;
  color: #fff;
}
#result-wrong .tag.bad  { background: var(--bad); }
#result-wrong .tag.good { background: var(--good); }

/* ---------- Spinner ---------- */
.spinner {
  width: 44px; height: 44px;
  margin: 0 auto 18px;
  border: 4px solid rgba(63, 143, 58, 0.2);
  border-top-color: var(--good);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 620px) {
  .panel { padding: 26px 22px; }
  .panel h1 { font-size: 26px; }
  #hint { font-size: 11px; padding: 7px 12px; }
  .hud-label { display: none; }
}
