:root {
  --h: 110;
  /* Neon: Farbton wandert mit dem Level */
  --neon: hsl(var(--h) 100% 60%);
  --glow: hsl(var(--h) 100% 55% / 0.55);
  --dark: #04060d;
  --ink: var(--neon);
  --side: var(--glow);
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  color: #fff;
  background: var(--dark);
}

#scene {
  position: fixed;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* --- Leiste oben ---------------------------------------------------------- */

#bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  background: rgb(0 0 0 / 0.22);
  z-index: 5;
}

.icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.14);
  color: #fff;
  font-family: inherit;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  flex: none;
}

.icon:focus-visible,
button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon .speaker { fill: currentColor; }
#sound .mute { display: none; }
#sound.off .mute { display: inline; }
#sound.off .waves { display: none; }

#score {
  flex: 1;
  text-align: center;
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* --- Schrift mit Tiefe (wie die Platten) ---------------------------------- */

.extruded {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 0 4px var(--neon), 0 0 12px var(--neon), 0 0 28px var(--glow), 0 0 60px var(--glow);
}

button.extruded {
  border: 0;
  background: none;
  font-family: inherit;
  cursor: pointer;
}

/* --- Bildschirme ---------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 90px 16px 40px;
  box-sizing: border-box;
  text-align: center;
  z-index: 4;
}

.overlay.dim { background: rgb(0 0 0 / 0.4); justify-content: center; z-index: 6; }
.hidden { display: none; }

#title h1 {
  font-size: clamp(54px, 17vw, 130px);
  line-height: 0.95;
}

/* Neonlinie unter dem Titel */
#title h1::after {
  content: "";
  display: block;
  height: 3px;
  width: 80%;
  margin: 18px auto 0;
  border-radius: 2px;
  background: var(--neon);
  box-shadow: 0 0 10px var(--neon), 0 0 30px var(--glow);
}

.big { font-size: clamp(44px, 13vw, 90px); }

#best-title { margin: 18px 0 0; font-size: 18px; color: rgb(255 255 255 / 0.85); }

#result-info {
  margin: 0;
  font-size: 18px;
  color: rgb(255 255 255 / 0.85);
}


.buttons { display: flex; flex-direction: column; align-items: center; gap: 6px; }

button.plain {
  border: 0;
  border-radius: 999px;
  padding: 10px 22px;
  background: rgb(4 6 13 / 0.7);
  border: 1px solid var(--glow);
  color: #fff;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}


#over { justify-content: center; gap: 12px; background: rgb(0 0 0 / 0.25); }
#over .cta { margin-top: 14px; }
#over .label { margin: 0; font-size: 22px; font-weight: 700; color: rgb(255 255 255 / 0.85); }
#final { font-size: clamp(90px, 30vw, 180px); line-height: 1; }

.card {
  max-width: 420px;
  padding: 22px 22px 18px;
  border-radius: 16px;
  background: rgb(8 12 24 / 0.92);
  border: 1px solid var(--neon);
  box-shadow: 0 0 20px var(--glow);
  text-align: left;
  font-size: 17px;
  line-height: 1.45;
}

.card h2 { margin: 0 0 8px; }
.card p { margin: 0 0 10px; }

.card button {
  margin-top: 6px;
  padding: 12px 22px;
  border: 0;
  border-radius: 10px;
  background: var(--neon);
  color: var(--dark);
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

/* «Genau!» nach einem genauen Treffer */
#combo {
  position: fixed;
  left: 0;
  right: 0;
  top: 22%;
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

#combo.show { animation: pop 0.8s ease-out; }

@keyframes pop {
  0% { opacity: 0; transform: translateY(10px) scale(0.8); }
  20% { opacity: 1; transform: translateY(0) scale(1.08); }
  100% { opacity: 0; transform: translateY(-24px) scale(1); }
}

/* Leben */
#hearts {
  display: flex;
  gap: 2px;
  font-size: 24px;
  line-height: 1;
}

#hearts.hidden { display: none; }
#hearts span { color: #ff3d7f; text-shadow: 0 0 8px #ff3d7f; transition: color 0.3s, transform 0.3s; }
#hearts span.lost { color: rgb(255 255 255 / 0.2); text-shadow: none; transform: scale(0.8); }

/* Massband: alle Levels als ein Turm, Neon-Striche alle 5 Lagen */
#tape {
  --ticks: 3%;
  position: fixed;
  left: max(8px, env(safe-area-inset-left));
  top: calc(max(8px, env(safe-area-inset-top)) + 64px);
  bottom: 20px;
  width: 26px;
  border-radius: 4px;
  border: 1px solid var(--glow);
  background:
    linear-gradient(to top, var(--glow) 0 1px, transparent 1px) 0 100% / 40% var(--ticks) repeat-y,
    rgb(4 6 13 / 0.7);
  box-shadow: 0 0 10px var(--glow);
  pointer-events: none;
  z-index: 3;
}

#tape-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(to top, hsl(var(--h) 100% 55% / 0.15), hsl(var(--h) 100% 60% / 0.45));
  transition: height 0.4s;
}

#tape-marks .mark {
  position: absolute;
  left: 0;
  right: 0;
  border-bottom: 2px solid var(--neon);
}

#tape-marks .mark span {
  position: absolute;
  left: 3px;
  bottom: 2px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 6px var(--neon);
}

#tape-marks .mark.current span {
  color: var(--dark);
  background: var(--neon);
  border-radius: 3px;
  padding: 0 3px;
  left: 2px;
}

/* Wo man gerade steht: Pfeil rechts am Band */
#tape-pos {
  position: absolute;
  left: 100%;
  width: 0;
  height: 0;
  margin-left: 3px;
  transform: translateY(50%);
  border: 7px solid transparent;
  border-left: 0;
  border-right-color: var(--neon);
  filter: drop-shadow(0 0 4px var(--neon));
  transition: bottom 0.4s;
}

/* Meldung bei Levelwechsel oder verlorenem Leben */
#banner {
  position: fixed;
  left: 0;
  right: 0;
  top: 30%;
  display: grid;
  gap: 4px;
  text-align: center;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  text-shadow: 0 2px 10px rgb(0 0 0 / 0.3);
}

#banner strong { font-size: 40px; font-weight: 800; }
#banner span { font-size: 20px; font-weight: 700; }
#banner.show { animation: banner 1.6s ease-out; }

@keyframes banner {
  0% { opacity: 0; transform: scale(0.85); }
  12% { opacity: 1; transform: scale(1.05); }
  20% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- Grosser Knopf: unübersehbar, pulsiert leicht --------------------------- */
.cta {
  border: 2px solid var(--neon);
  border-radius: 14px;
  padding: 14px 44px;
  background: rgb(4 6 13 / 0.6);
  color: #fff;
  font-family: inherit;
  font-size: clamp(30px, 9vw, 48px);
  font-weight: 800;
  letter-spacing: 0.1em;
  cursor: pointer;
  text-shadow: 0 0 8px var(--neon), 0 0 20px var(--glow);
  box-shadow: 0 0 12px var(--glow), inset 0 0 12px var(--glow);
  animation: pulse 1.6s ease-in-out infinite;
}

.cta:hover,
.cta:focus-visible { background: hsl(var(--h) 100% 50% / 0.18); }

@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 12px var(--glow), inset 0 0 12px var(--glow); }
  50% { transform: scale(1.05); box-shadow: 0 0 34px var(--neon), inset 0 0 18px var(--glow); }
}

/* Start-Knopf in der Mitte, Titel oben */
#title { justify-content: space-between; }

/* --- Herz zerbricht ---------------------------------------------------------- */
#heartbreak {
  position: fixed;
  left: 50%;
  top: 16%;
  width: 120px;
  height: 120px;
  margin-left: -60px;
  pointer-events: none;
  z-index: 7;
  opacity: 0;
}

#heartbreak .half {
  position: absolute;
  inset: 0;
  font-size: 120px;
  line-height: 120px;
  text-align: center;
  color: #ff4d62;
  text-shadow: 0 4px 18px rgb(255 60 90 / 0.6);
}

/* Bruchkante im Zickzack */
#heartbreak .left { clip-path: polygon(0 0, 52% 0, 44% 28%, 58% 48%, 45% 70%, 52% 100%, 0 100%); }
#heartbreak .right { clip-path: polygon(52% 0, 100% 0, 100% 100%, 52% 100%, 45% 70%, 58% 48%, 44% 28%); }

#heartbreak.show { animation: heart-in 1.5s ease-out forwards; }
#heartbreak.show .left { animation: half-left 1.5s ease-in forwards; }
#heartbreak.show .right { animation: half-right 1.5s ease-in forwards; }

@keyframes heart-in {
  0% { opacity: 0; transform: scale(0.4); }
  15% { opacity: 1; transform: scale(1.15); }
  22% { transform: scale(1); }
  30%, 36% { transform: translateX(-6px); }
  33%, 39% { transform: translateX(6px); }
  42% { transform: none; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes half-left {
  0%, 42% { transform: none; }
  100% { transform: translate(-46px, 90px) rotate(-28deg); }
}

@keyframes half-right {
  0%, 42% { transform: none; }
  100% { transform: translate(46px, 90px) rotate(28deg); }
}

/* Herz oben in der Leiste wackelt, wenn es verloren geht */
#hearts span.breaking { animation: wobble 0.6s ease-out; }

@keyframes wobble {
  0% { transform: scale(1.5); }
  30% { transform: scale(1.3) rotate(-15deg); }
  60% { transform: scale(1) rotate(10deg); }
  100% { transform: scale(0.8); }
}

/* --- Game Over -------------------------------------------------------------- */
#result-title {
  min-height: 1em;
  font-size: clamp(44px, 13vw, 110px);
  line-height: 1.05;
}

#result-title .word { display: inline-block; white-space: nowrap; margin: 0 0.15em; }

#result-title .word span {
  display: inline-block;
  animation: letter-drop 0.7s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}

@keyframes letter-drop {
  0% { opacity: 0; transform: translateY(-120vh) rotate(-20deg); }
  70% { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

#scene.shake { animation: shake 0.5s; }

@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translate(-10px, 6px); }
  40% { transform: translate(9px, -5px); }
  60% { transform: translate(-6px, -4px); }
  80% { transform: translate(4px, 3px); }
}

@media (prefers-reduced-motion: reduce) {
  .cta, #scene.shake, #result-title span { animation: none; }
}
