:root {
  --violet: #a855f7;
  --violet-deep: #7c3aed;
  --cyan: #22e0ff;
  --pink: #ff3d7f;
  --gold: #ffe14d;
  --gem: #39ff88;
  --bg: #0a0616;
  --text: #ece7ff;
  --muted: #9d8fc9;
  --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(--bg);
  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; }

/* ── Joystick (fix im unteren Drittel, feste Steuerzone für den Daumen) ── */
.joy { position: fixed; z-index: 4; width: 120px; height: 120px;
  left: 50%; bottom: calc(env(safe-area-inset-bottom) + 16vh); transform: translateX(-50%);
  border-radius: 50%; background: rgba(255,255,255,0.06); border: 2px solid rgba(168,85,247,0.35);
  pointer-events: none; }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: rgba(34,224,255,0.25); border: 2px solid rgba(34,224,255,0.55); }

/* ── XP-Balken (M5) ── */
.xp-bar {
  position: fixed; z-index: 6; pointer-events: none;
  top: env(safe-area-inset-top); left: 0; right: 0; height: 5px;
  background: rgba(255,255,255,0.07);
}
.xp-fill {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, #22c974, var(--gem));
  box-shadow: 0 0 10px var(--gem);
  transition: width .12s ease-out;
}

/* ── Aktiver Karten-Build (M5) ── */
.build-strip {
  position: fixed; z-index: 5; pointer-events: none;
  bottom: calc(env(safe-area-inset-bottom) + 4.2rem); left: 50%; transform: translateX(-50%);
  width: min(94vw, 460px);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem;
}
.bchip {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.1rem 0.4rem; border-radius: 999px;
  border: 1px solid var(--rar); color: var(--rar);
  background: rgba(10,6,22,0.6);
  font-family: var(--font-head); font-weight: 700; font-size: 0.56rem;
  letter-spacing: 0.04em; white-space: nowrap;
}
.bchip b { color: #fff; font-size: 0.6rem; }
.bchip-fusion { box-shadow: 0 0 10px -2px var(--rar); }

/* ── HUD ── */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 0.7rem) 1.2rem 0;
  pointer-events: none;
}
.hud-block { display: flex; flex-direction: column; line-height: 1; }
.hud-mid { align-items: center; flex: 1; }
.hud-right { align-items: flex-end; }
.hud-label {
  font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
}
.hud-value { font-size: 1.9rem; font-weight: 900; font-family: var(--font-head); }
.hud-mult {
  font-size: 2.3rem; font-weight: 900; font-family: var(--font-head);
  color: var(--cyan); text-shadow: 0 0 18px currentColor;
}
.hud-value.punch { animation: score-punch .2s ease-out; }
.hud-mult.punch { animation: score-punch .2s ease-out; }
@keyframes score-punch {
  0% { transform: scale(1); } 35% { transform: scale(1.28); } 100% { transform: scale(1); }
}

/* ── Combo-Balken ── */
.combo-bar {
  position: fixed; z-index: 5; pointer-events: none;
  top: calc(env(safe-area-inset-top) + 4.4rem); left: 50%; transform: translateX(-50%);
  width: min(54vw, 280px); height: 5px; border-radius: 999px;
  background: rgba(255,255,255,0.08); overflow: hidden;
}
.combo-fill {
  width: 0%; height: 100%; border-radius: 999px;
  background: var(--cyan); transition: width .1s ease-out, box-shadow .12s ease-out;
}

/* ── HP-Balken (M3: löst Ein-Treffer-Tod ab) ── */
.hp-bar {
  position: fixed; z-index: 5; pointer-events: none;
  bottom: calc(env(safe-area-inset-bottom) + 1.1rem); left: 50%; transform: translateX(-50%);
  width: min(60vw, 320px); height: 10px; border-radius: 999px;
  background: rgba(255,255,255,0.08); overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
}
.hp-fill {
  width: 100%; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #ff4d6d, #ff8a9e);
  box-shadow: 0 0 12px rgba(255,77,109,0.5);
  transition: width .15s ease-out;
}
.hp-fill.low { animation: hp-pulse 0.6s ease-in-out infinite; }
@keyframes hp-pulse { 0%,100%{ opacity: 1 } 50%{ opacity: 0.4 } }
@media (prefers-reduced-motion: reduce) { .hp-fill.low { animation: none; } }

/* ── Boss „Der Schwarmkern" (M4) ── */
.boss-bar {
  position: fixed; z-index: 5; pointer-events: none;
  top: calc(env(safe-area-inset-top) + 5.6rem); left: 50%; transform: translateX(-50%);
  width: min(78vw, 400px); display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
}
.boss-label {
  font-family: var(--font-head); font-weight: 700; font-size: 0.68rem;
  letter-spacing: 0.18em; color: #ff5f8a; text-shadow: 0 0 12px currentColor;
}
.boss-track {
  width: 100%; height: 7px; border-radius: 999px;
  background: rgba(255,255,255,0.08); overflow: hidden;
  border: 1px solid rgba(255,31,95,0.35);
}
.boss-fill {
  width: 100%; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #ff1f5f, #ff7a9c);
  box-shadow: 0 0 14px rgba(255,31,95,0.7);
  transition: width .12s ease-out;
}

/* ── Aktive Waffen-Evolution ── */
.weapon-pip {
  position: fixed; z-index: 5; pointer-events: none;
  bottom: calc(env(safe-area-inset-bottom) + 2.6rem); left: 50%; transform: translateX(-50%);
  font-family: var(--font-head); font-weight: 700; font-size: 0.78rem;
  letter-spacing: 0.16em; padding: 0.3rem 0.9rem; border-radius: 999px;
  border: 1.5px solid currentColor; background: rgba(10,6,22,0.55);
  text-shadow: 0 0 10px currentColor; box-shadow: 0 0 16px currentColor;
  animation: weapon-pulse 1s ease-in-out infinite;
}
@keyframes weapon-pulse { 0%,100%{ opacity: 0.85 } 50%{ opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .weapon-pip { animation: none; } }

/* ── Multiplikator-Feier ── */
.mult-pop {
  position: fixed; z-index: 7; pointer-events: none;
  top: 40%; left: 50%; transform: translate(-50%, -50%) scale(0.4);
  font-family: var(--font-head); font-weight: 700;
  font-size: clamp(3rem, 18vw, 6rem); color: var(--cyan);
  text-shadow: 0 0 28px currentColor; opacity: 0;
}
.mult-pop.show { animation: mult-pop .7s cubic-bezier(.2,.9,.3,1) forwards; }
@keyframes mult-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  25%  { opacity: 1; transform: translate(-50%, -50%) scale(1.18); }
  60%  { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -90%) scale(1.0); }
}
@media (prefers-reduced-motion: reduce) {
  .hud-value.punch, .hud-mult.punch, .mult-pop.show { animation: none; }
}

/* ── Level-Up: Karten-Auswahl (M5) + Fusion-Radar (M7) ──
   2/3 oben = Radar, 1/3 unten = Karten (Daumen-Zone). Braucht die volle
   Screen-Höhe, deshalb überschreibt #screen-cards das zentrierte .screen-Padding. */
#screen-cards { align-items: stretch; padding: calc(env(safe-area-inset-top) + 0.6rem) 0.9rem calc(env(safe-area-inset-bottom) + 0.6rem); }
.cards-wrap {
  width: 100%; max-width: 460px; margin: 0 auto; height: 100%;
  display: flex; flex-direction: column; gap: 0.5rem; min-height: 0;
}
.cards-head { text-align: center; flex: 0 0 auto; }
.cards-lv {
  font-family: var(--font-head); font-weight: 700; font-size: 1.7rem;
  color: var(--gem); text-shadow: 0 0 22px currentColor;
}
.cards-sub { color: var(--muted); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }

/* ── Fusion Radar (M7): 8 Rollen × 4 Karten-Ringe + Ring 5 (Fusion, 22,5° versetzt) ── */
.fusion-radar {
  flex: 3 1 0; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
.radar-svg { width: 100%; height: 100%; max-width: min(88vw, 420px); max-height: 100%; }
.radar-pulse { animation: radar-pulse 1.1s ease-in-out infinite; }
@keyframes radar-pulse { 0%,100% { opacity: 0.95; } 50% { opacity: 0.6; } }
.radar-fusion-glow { animation: radar-fusion-glow 1.6s ease-in-out infinite; filter: drop-shadow(0 0 6px currentColor); }
@keyframes radar-fusion-glow { 0%,100% { opacity: 1; } 50% { opacity: 0.75; } }
@media (prefers-reduced-motion: reduce) { .radar-pulse, .radar-fusion-glow { animation: none; } }

.card-list { flex: 2 1 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 0.35rem; padding-bottom: 0.2rem; }
.card {
  display: flex; flex-direction: column; gap: 0.15rem;
  width: 100%; padding: 0.4rem 0.8rem; text-align: left; cursor: pointer;
  border: 1.5px solid var(--rar); border-left-width: 5px; border-radius: 12px;
  background: rgba(12,7,26,0.9); color: var(--text); font-family: var(--font);
  box-shadow: 0 0 18px -6px var(--rar);
}
.card:active { transform: translateY(2px); background: rgba(24,14,46,0.95); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; }
.card-cat, .card-rar {
  font-family: var(--font-head); font-weight: 700; font-size: 0.56rem; letter-spacing: 0.16em;
}
.card-cat { color: var(--muted); }
.card-rar { color: var(--rar); }
.card-name {
  display: flex; align-items: baseline; gap: 0.5rem;
  font-family: var(--font-head); font-weight: 700; font-size: 0.95rem; color: #fff;
}
.card-lv { font-size: 0.7rem; color: var(--rar); }
.card-desc { font-size: 0.78rem; font-weight: 600; color: var(--muted); line-height: 1.2; }

/* ── Screens ── */
.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  background: radial-gradient(120% 90% at 50% 30%, rgba(124,58,237,0.28) 0%, rgba(5,3,13,0.86) 70%);
  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(168,85,247,0.5);
}
.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(--violet), var(--cyan)); color: #0a0414;
  box-shadow: 0 0 24px rgba(168,85,247,0.6);
}
.tagline { color: var(--text); font-size: 1.1rem; font-weight: 700; }
.how { color: var(--muted); font-size: 0.9rem; font-weight: 600; line-height: 1.4; }

/* Big Play button (Deflect-style pill), tinted in the game's own accent */
.play-btn {
  width: 100%; max-width: 300px; margin-top: 0.5rem;
  padding: 1.2rem 1.5rem; border: none; border-radius: 999px;
  font-family: var(--font-head); font-weight: 700; font-size: 1.25rem; letter-spacing: 0.02em;
  cursor: pointer; box-shadow: 0 5px 0 rgba(0,0,0,0.3);
  background: linear-gradient(160deg, var(--cyan), #1aa7ff); color: #05202c;
}
.play-btn:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(0,0,0,0.3); }

.tap-hint {
  margin-top: 0.6rem; 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} }

.go-title { font-family: var(--font-head); font-weight: 700; font-size: 1.5rem; color: var(--pink); }
.go-score { font-family: var(--font-head); font-weight: 700; font-size: clamp(3.4rem, 22vw, 5rem); line-height: 1; }
.go-score.newbest { color: #39ff88; text-shadow: 0 0 26px rgba(57,255,136,0.6); }
.go-best { color: var(--muted); font-size: 1.05rem; }
.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(--cyan), #1aa7ff); color: #05202c;
  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); }
@media (prefers-reduced-motion: reduce) { .tap-hint { animation: none; } }

/* ── 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: #ff4d6d; }
.reg-btns { display: flex; gap: 0.55rem; }
.reg-submit-btn {
  flex: 1; padding: 0.7rem; border: none; border-radius: 8px;
  background: var(--cyan); color: #05202c;
  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: #39ff88; }
