:root {
  --frost: #0e1b2a;
  --frost-deep: #071019;
  --ice: #57a3dd;
  --amber: #d9762e;
  --gold: #ffd24d;
  --good: #5adf87;
  --danger: #ff4d5e;
  --text: #eaf3fb;
  --muted: #7f9bb2;
  --font: 'Rajdhani', system-ui, sans-serif;
  --font-head: 'Space Grotesk', var(--font);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--frost);
  color: var(--text);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
}

#game { position: fixed; inset: 0; }
#game canvas { display: block; touch-action: none; }

.hidden { display: none !important; }

/* ── HUD ── */
.hud { position: fixed; top: 0; left: 0; right: 0; z-index: 5; pointer-events: none; }
.hud-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 0.6rem) 1rem 0;
}
.hud-block { display: flex; flex-direction: column; line-height: 1; gap: 0.2rem; }
.hud-right { align-items: flex-end; }
.hud-label { font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.hud-value { font-size: 1.5rem; font-weight: 900; font-family: var(--font-head); }
.hud-value.dist { color: var(--ice); }
.hud-value.punch { animation: score-punch .2s ease-out; }
@keyframes score-punch { 0%{transform:scale(1)} 35%{transform:scale(1.3)} 100%{transform:scale(1)} }

.gear-row {
  display: flex; justify-content: center; gap: 0.4rem;
  margin-top: 0.5rem; padding: 0 1rem;
}
.gear-chip {
  display: flex; align-items: center; gap: 0.32rem;
  padding: 0.22rem 0.6rem; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  background: rgba(10,20,32,0.55); border: 1.5px solid rgba(255,255,255,0.1);
  color: var(--muted); opacity: 0.5; transition: opacity .15s, border-color .15s, color .15s;
}
.gear-chip.has { opacity: 1; color: var(--text); border-color: currentColor; }
.gear-ic { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.gear-ic--shield { background: var(--ice); }
.gear-ic--sword { background: #dfe8f2; }
.gear-ic--helm { background: var(--gold); }
#gear-shield.has { color: var(--ice); }
#gear-sword.has { color: #dfe8f2; }
#gear-helm.has { color: var(--gold); }

/* ── Horde-Meter ── */
.horde-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 0.7rem); z-index: 5;
  width: min(70vw, 340px); display: flex; align-items: center; gap: 0.5rem; pointer-events: none;
}
.horde-label { font-size: 0.6rem; font-weight: 900; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.horde-track {
  flex: 1; height: 12px; border-radius: 6px; overflow: hidden;
  background: rgba(0,0,0,0.45); border: 1.5px solid rgba(255,255,255,0.12);
}
.horde-fill {
  height: 100%; width: 62%;
  background: linear-gradient(90deg, #2e9e5b, var(--good));
  transition: width .2s ease-out; transform-origin: right;
}
.horde-bar.danger .horde-fill { background: linear-gradient(90deg, #a01e2c, var(--danger)); }
.horde-bar.danger { animation: horde-pulse .5s ease-in-out infinite; }
@keyframes horde-pulse { 0%,100%{opacity:0.85} 50%{opacity:1} }

/* ── zentrale Feier ── */
.pop {
  position: fixed; z-index: 7; pointer-events: none;
  top: 32%; left: 50%; transform: translate(-50%, -50%) scale(0.4);
  font-family: var(--font-head); font-weight: 700;
  font-size: clamp(2rem, 11vw, 3.8rem); color: var(--gold);
  text-shadow: 0 0 28px currentColor; opacity: 0; text-align: center; white-space: nowrap;
}
.pop.show { animation: pop .9s cubic-bezier(.2,.9,.3,1) forwards; }
@keyframes pop {
  0%{ opacity:0; transform: translate(-50%,-50%) scale(0.4);}
  22%{ opacity:1; transform: translate(-50%,-50%) scale(1.12);}
  60%{ opacity:1; transform: translate(-50%,-50%) scale(1);}
  100%{ opacity:0; transform: translate(-50%,-76%) scale(1);}
}
@media (prefers-reduced-motion: reduce) { .pop.show, .hud-value.punch, .horde-bar.danger { animation: none; } }

/* ── Screens ── */
.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center; padding: 1.2rem;
  background: radial-gradient(120% 90% at 50% 22%, rgba(30,70,95,0.42) 0%, rgba(7,16,25,0.92) 72%);
  backdrop-filter: blur(2px);
}
.card { width: 100%; max-width: 360px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }
.logo {
  font-family: var(--font-head); font-weight: 700;
  font-size: clamp(2.8rem, 16vw, 4.4rem); line-height: 0.9; letter-spacing: -0.02em;
  text-shadow: 0 0 34px rgba(87,163,221,0.45);
}
.logo span {
  display: inline-grid; place-items: center; width: 0.95em; height: 0.95em;
  margin-left: 0.14em; border-radius: 0.24em; transform: rotate(-6deg);
  background: linear-gradient(160deg, var(--amber), #8a3d12); color: #10130f;
  box-shadow: 0 0 24px rgba(217,118,46,0.5);
}
.tagline { color: var(--text); font-size: 1.1rem; font-weight: 700; }
.how { color: var(--muted); font-size: 0.88rem; font-weight: 600; line-height: 1.5; }
.tap-hint { margin-top: 0.5rem; color: var(--text); font-weight: 700; font-size: 1.05rem; opacity: 0.85; animation: blink 1.3s ease-in-out infinite; }
@keyframes blink { 0%,100%{opacity:0.35} 50%{opacity:0.95} }
@media (prefers-reduced-motion: reduce) { .tap-hint { animation: none; } }

/* ── Game Over ── */
.go-title { font-family: var(--font-head); font-weight: 700; font-size: 1.5rem; color: var(--danger); }
.go-score { font-family: var(--font-head); font-weight: 700; font-size: clamp(3.4rem, 22vw, 5rem); line-height: 1; }
.go-score.newbest { color: var(--good); text-shadow: 0 0 26px rgba(90,223,135,0.6); }
.go-best { color: var(--muted); font-size: 0.95rem; }
.go-best strong { color: #fff; }
.go-taunt { color: var(--gold); font-size: 1rem; font-weight: 700; min-height: 1.2em; }
.share-btn {
  margin-top: 0.4rem; padding: 0.8rem 1.6rem; border: none; border-radius: 999px;
  background: linear-gradient(160deg, var(--ice), #2c6ea0); color: #06131e;
  font-family: var(--font); font-weight: 900; font-size: 1.05rem; cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,0.3);
}
.share-btn:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(0,0,0,0.3); }

/* ── Registration panel ── */
.reg-panel { width: 100%; display: flex; flex-direction: column; gap: 0.55rem;
  padding: 0.9rem; border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; background: rgba(255,255,255,0.04); }
.reg-panel form { display: flex; flex-direction: column; gap: 0.55rem; }
.reg-hint { font-size: 0.9rem; font-weight: 700; opacity: 0.65; }
.reg-input { width: 100%; padding: 0.65rem 0.9rem; border: 1.5px solid rgba(255,255,255,0.18); border-radius: 8px;
  background: rgba(255,255,255,0.07); color: #fff; font-family: var(--font); font-size: 1rem; outline: none; }
.reg-input::placeholder { opacity: 0.4; }
.reg-input:focus { border-color: rgba(255,255,255,0.45); }
.reg-error { font-size: 0.82rem; font-weight: 700; color: var(--danger); }
.reg-btns { display: flex; gap: 0.55rem; }
.reg-submit-btn { flex: 1; padding: 0.7rem; border: none; border-radius: 8px; background: var(--good); color: #06140c;
  font-family: var(--font); font-weight: 900; font-size: 1rem; cursor: pointer; }
.reg-skip-btn { padding: 0.7rem 1rem; border: 1px solid rgba(255,255,255,0.18); border-radius: 8px;
  background: transparent; color: rgba(255,255,255,0.45); font-family: var(--font); font-weight: 700; font-size: 0.9rem; cursor: pointer; }
.reg-saved { font-size: 0.95rem; font-weight: 700; color: var(--good); }
