:root {
  --bg: #0b0d1a;
  --panel: rgba(16, 19, 38, 0.88);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e9ecff;
  --muted: #8d93b8;
  --gold: #ffcc4d;
  --red: #ff4d6d;
  --cyan: #5ce1ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  /* App-Gefühl: kein grauer Tipp-Blitz, kein Lupen-/Kopiermenü beim langen Drücken, kein Doppeltipp-Zoom */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

.stage {
  position: fixed;
  inset: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 20px;
}
.hud div { display: flex; flex-direction: column; }
.hud div:nth-child(2) { align-items: center; }
.hud div:nth-child(3) { align-items: flex-end; }
.label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* Kombo hüpft kurz, wenn ein Funke gefangen wird */
.hud div.bump #combo { animation: bump .32s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bump {
  0% { transform: scale(1); color: var(--text); }
  35% { transform: scale(1.45); color: var(--gold); text-shadow: 0 0 14px rgba(255, 204, 77, .8); }
  100% { transform: scale(1); color: var(--text); }
}
#combo { display: inline-block; }

/* Level unter den Punkten */
.lvl-line { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.lvl-line b { color: var(--cyan); font-weight: 800; }
.hud div.lvl .lvl-line b { display: inline-block; animation: lvl .7s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes lvl {
  0% { transform: scale(1); }
  40% { transform: scale(1.8); text-shadow: 0 0 12px rgba(92, 225, 255, .9); }
  100% { transform: scale(1); }
}
.violet { color: #c9a8ff; }
.sun { color: #ffb347; }
.pink { color: #ff7dc3; }
.lime { color: #b4ff5a; }
.jup { color: #e8ba84; }
/* Extraleben unter dem Rekord */
.lives { font-size: 14px; letter-spacing: 2px; color: #6ef5a0; text-shadow: 0 0 8px rgba(110, 245, 160, .7); min-height: 1.2em; margin-top: 2px; }
.reached { margin-top: -12px; }

/* Kombo sinkt eine Stufe: kurz kleiner und blasser */
.hud div.drop #combo { animation: drop .4s ease-out; }
@keyframes drop {
  0% { transform: scale(1); opacity: 1; }
  40% { transform: scale(.8); opacity: .45; }
  100% { transform: scale(1); opacity: 1; }
}

/* Kombo-Zeit: dünner Balken, der abläuft */
.combo-track {
  display: block;
  width: 56px;
  height: 3px;
  margin-top: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .08);
  overflow: hidden;
}
.combo-track i {
  display: block;
  height: 100%;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(255, 204, 77, .8);
  transform: scaleX(0);
  transform-origin: center;
}
.combo-track i.low { background: #ffe9a8; animation: blink .3s ease-in-out infinite alternate; }
@keyframes blink { to { opacity: .45; } }

/* Ton an/aus */
.sound-btn {
  position: absolute;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(16, 19, 38, .6);
  color: var(--muted);
  cursor: pointer;
  z-index: 2;
  touch-action: manipulation;
}
.sound-btn:hover { color: var(--text); }
.sound-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.sound-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sound-btn .spk { fill: currentColor; stroke: none; }
.sound-btn .mute { display: none; }
.sound-btn.off .wave { display: none; }
.sound-btn.off .mute { display: inline; }

.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 32px));
  max-height: calc(100% - 96px);
  overflow-y: auto;
  padding: 28px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  user-select: text;
  -webkit-user-select: text;
  touch-action: auto;
}
.hidden { display: none; }

h1 { margin: 0 0 8px; font-size: 44px; line-height: 1.1; letter-spacing: -0.02em; }
h1 span { color: var(--gold); }
h2 { margin: 24px 0 8px; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h2.big { margin-top: 0; font-size: 32px; letter-spacing: -0.01em; text-transform: none; color: var(--text); }
p { color: var(--muted); margin: 0 0 20px; }
.red { color: var(--red); }
.gold { color: var(--gold); }
.result { font-size: 22px; color: var(--text); }
.result span { font-weight: 800; color: var(--gold); font-size: 36px; }
.muted { color: var(--muted); }

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 36px;
  font: inherit;
  font-weight: 700;
  font-size: 18px;
  color: #1a1300;
  background: var(--gold);
  cursor: pointer;
  box-shadow: 0 0 24px rgba(255, 204, 77, .35);
}
.btn:hover { filter: brightness(1.08); }
.btn:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.btn.small { padding: 10px 18px; font-size: 15px; }

form { margin: 0 0 16px; text-align: left; }
form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.row { display: flex; gap: 8px; }
input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
  border-radius: 999px;
}
input:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
form p { margin: 8px 0 0; font-size: 14px; min-height: 1.5em; }

.board {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.board li {
  display: flex;
  gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}
.board li:last-child { border-bottom: 0; }
.board .rank { width: 1.8em; color: var(--muted); }
.board .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .pts { font-weight: 700; color: var(--gold); }
.board li.me { background: rgba(92, 225, 255, .10); border-radius: 8px; }
.board li.muted { justify-content: center; }
