/* ==================================================================
   GALOPP — Endless-Runner (2026)
   Du hast den Zuckerkristall gestohlen — das Einhorn will ihn zurück.
   Springen, ducken, Spur wechseln. Wie weit kommst du?
   ================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --card: rgba(250, 242, 255, 0.05);
  --card-hi: rgba(250, 242, 255, 0.1);
  --edge: rgba(232, 193, 90, 0.16);
  --edge-soft: rgba(250, 242, 255, 0.09);
  --ink: #f6eefc;
  --muted: #a08fb4;
  --gold: #e8c15a;
  --pink: #ff7ac2;
  --violet: #b678ff;
  --mint: #6fe3c1;
  --gold-glow: rgba(232, 193, 90, 0.4);
  --pink-glow: rgba(255, 122, 194, 0.45);
  --foil: linear-gradient(115deg, #8a6a1c 0%, #e8c15a 25%, #fff3c4 50%, #e8c15a 75%, #8a6a1c 100%);
  --rainbow: linear-gradient(90deg, #ff6b6b, #ffa14d, #ffe066, #69d98a, #56d5e8, #b678ff);
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Outfit", system-ui, -apple-system, sans-serif;
  --ease-spring: cubic-bezier(0.34, 1.4, 0.5, 1);
}

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  background: radial-gradient(130% 100% at 50% -20%, #2b1440 0%, #1c0d2e 45%, #120818 100%);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  height: 100vh;
  height: 100dvh;
  max-width: 620px;
  margin: 0 auto;
  padding: 12px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar / HUD ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.topbar h1 {
  flex: 1;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: 1.5rem;
}
.foil {
  background: var(--foil);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: foil-sheen 5.5s ease-in-out infinite;
}
@keyframes foil-sheen {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.btn-back {
  display: grid; place-items: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  font-size: 1.15rem;
  box-shadow: 0 0 0 1px var(--edge-soft) inset;
  flex-shrink: 0;
}
button {
  font-family: inherit;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.15s var(--ease-spring);
}
button:active { transform: scale(0.94); }
.btn-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font-size: 1.05rem;
  box-shadow: 0 0 0 1px var(--edge-soft) inset;
  flex-shrink: 0;
}

/* HUD liegt AUF der Bühne — maximale Spielfläche */
.hud {
  position: absolute;
  left: 12px; right: 12px; top: 10px;
  display: flex;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
}
.hud-item {
  flex: 1;
  background: rgba(18, 8, 30, 0.55);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 5px 10px;
  text-align: center;
  box-shadow: 0 0 0 1px var(--edge-soft) inset;
}
.hud-item span {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
#hud-coins { color: var(--gold); }
.hud-item label {
  color: var(--muted);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

/* ---------- Bühne ---------- */
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--edge) inset, 0 14px 40px -18px rgba(0,0,0,0.9);
  background: linear-gradient(180deg, #1a0c28 0%, #2b1440 60%, #45215c 100%);
  touch-action: none;
}
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- Einhorn-Abstandsleiste ---------- */
#chase-ui {
  position: absolute;
  left: 12px; right: 12px; top: 68px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.chase-label { font-size: 1rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6)); }
#chase-bar {
  position: relative;
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(250, 242, 255, 0.1);
  box-shadow: 0 0 0 1px var(--edge-soft) inset;
}
#chase-fill {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 50%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffe066, var(--pink), #ff5a7a);
  box-shadow: 0 0 12px -2px var(--pink-glow);
  transition: width 0.15s linear;
}
#chase-horse {
  position: absolute;
  top: 50%;
  right: 50%;
  transform: translate(50%, -54%);
  font-size: 1.25rem;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,0.65));
  transition: right 0.15s linear;
}
#chase-bar.danger #chase-fill { animation: chase-throb 0.5s ease-in-out infinite; }
@keyframes chase-throb {
  0%, 100% { box-shadow: 0 0 10px -2px var(--pink-glow); }
  50% { box-shadow: 0 0 22px 0 rgba(255, 90, 122, 0.7); }
}

/* ---------- Power-up-Anzeigen ---------- */
#power-pills {
  position: absolute;
  left: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  pointer-events: none;
}
.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(20, 10, 34, 0.72);
  box-shadow: 0 0 0 1px var(--edge) inset;
  backdrop-filter: blur(6px);
  font-size: 0.82rem;
  font-weight: 700;
  animation: pill-in 0.3s var(--ease-spring);
}
@keyframes pill-in { from { transform: translateY(12px) scale(0.7); opacity: 0; } }
.pill .p-time { font-variant-numeric: tabular-nums; color: var(--gold); }

/* ---------- Zonen-Banner ---------- */
#zone-banner {
  position: absolute;
  left: 50%; top: 30%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: 1.7rem;
  white-space: nowrap;
  text-align: center;
  background: var(--foil);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: banner-in 2.4s ease forwards, foil-sheen 2.4s linear;
  pointer-events: none;
}
#zone-banner small {
  display: block;
  font-family: var(--font-ui);
  font-style: normal;
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
@keyframes banner-in {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  22% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 4, 14, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 18px;
  animation: overlay-in 0.25s ease;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.panel {
  background: linear-gradient(180deg, #241238, #140a20);
  border-radius: 22px;
  box-shadow: 0 0 0 1px var(--edge) inset, 0 24px 70px -24px rgba(0,0,0,0.95);
  padding: 26px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 420px;
  max-height: 86vh;
  overflow-y: auto;
  animation: panel-up 0.4s var(--ease-spring);
  text-align: center;
}
@keyframes panel-up {
  from { transform: translateY(46px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.panel h2 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: 1.7rem;
  margin-bottom: 6px;
}
.panel .sub { color: var(--muted); font-size: 0.92rem; margin-bottom: 16px; line-height: 1.55; }
.panel .sub b { color: var(--gold); font-weight: 600; }

.ctrl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0 18px;
}
.ctrl {
  background: var(--card);
  border-radius: 12px;
  padding: 10px 8px;
  box-shadow: 0 0 0 1px var(--edge-soft) inset;
  font-size: 0.8rem;
  color: var(--muted);
}
.ctrl b { display: block; font-size: 1.3rem; margin-bottom: 2px; }

.go-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 3.2rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: var(--foil);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: foil-sheen 5.5s ease-in-out infinite;
  margin: 6px 0 2px;
}
.go-best-badge {
  display: inline-block;
  background: rgba(232, 193, 90, 0.14);
  color: var(--gold);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 5px 14px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(232,193,90,0.3) inset;
  margin-bottom: 10px;
}
.go-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 0.88rem;
  margin: 8px 0 10px;
}
.go-rank { color: var(--muted); font-size: 0.95rem; margin-bottom: 16px; min-height: 1.3em; }
.go-rank b { color: var(--gold); }

.btn-primary {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #f0cd6e 0%, var(--gold) 40%, #c39a30 100%);
  color: #1a1508;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 15px;
  width: 100%;
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(255, 230, 160, 0.35) inset, 0 10px 30px -10px var(--gold-glow);
  margin-bottom: 10px;
}
.btn-secondary {
  background: var(--card-hi);
  color: var(--ink);
  font-size: 1rem;
  padding: 13px;
  width: 100%;
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--edge-soft) inset;
}
.panel input[type="text"] {
  font-family: inherit;
  font-size: 1.15rem;
  text-align: center;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--edge-soft);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  margin-bottom: 14px;
}
.panel input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232, 193, 90, 0.18);
}

.lb-list { list-style: none; text-align: left; margin: 6px 0 16px; }
.lb-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--edge-soft);
  font-size: 0.98rem;
}
.lb-list li:last-child { border-bottom: 0; }
.lb-rank { width: 34px; flex-shrink: 0; text-align: center; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-list li:nth-child(-n+3) .lb-rank { font-size: 1.15rem; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-list li.me .lb-name { color: var(--gold); font-weight: 700; }
.lb-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-empty { color: var(--muted); padding: 18px 0; }

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}
