/* =========================================================
   Animal Hunt - UI Styles
   Mobile-first, funktioniert genauso am Desktop.
   ========================================================= */

:root {
  --bg: #101119;
  --bg-2: #171927;
  --panel: #1e2133;
  --panel-2: #262a40;
  --line: #333852;
  --text: #eef1ff;
  --dim: #9aa1c4;
  --accent: #ffc247;
  --accent-2: #ff8a3d;
  --good: #63e6a0;
  --bad: #ff6b6b;
  --hud-h: 52px;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ============================ HUD ============================ */

#hud {
  height: var(--hud-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: linear-gradient(180deg, var(--bg-2), rgba(23, 25, 39, .82));
  border-bottom: 1px solid var(--line);
  z-index: 5;
}

.hud-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-center { flex: 1 1 auto; justify-content: center; }
.hud-right { margin-left: auto; gap: 6px; }

.stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  white-space: nowrap;
}
.stat-icon { font-size: 15px; opacity: .95; }
.stat-val { font-weight: 700; letter-spacing: .3px; }
.dim { color: var(--dim); font-weight: 500; }

.lives { display: flex; gap: 3px; font-size: 17px; line-height: 1; }
.lives .heart { transition: transform .18s ease, opacity .18s ease; }
.lives .heart.lost { opacity: .22; filter: grayscale(1); transform: scale(.82); }

.effects { display: flex; gap: 4px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px 2px 5px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  animation: pop .2s ease;
}
.chip.good { border-color: rgba(99, 230, 160, .5); color: var(--good); }
.chip.bad  { border-color: rgba(255, 107, 107, .5); color: var(--bad); }
.chip .ico { font-size: 13px; filter: none; }

@keyframes pop { from { transform: scale(.7); opacity: 0 } to { transform: scale(1); opacity: 1 } }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.icon-btn:hover { background: #303552; }
.icon-btn:active { transform: scale(.93); }

/* ============================ Stage ============================ */

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #0b0c12;
  /* Ausdrücklich auch hier: sonst deutet der mobile Browser das Ziehen
     am Joystick als Wischgeste und bricht sie mit pointercancel ab. */
  touch-action: none;
}

#game { display: block; width: 100%; height: 100%; touch-action: none; }

.minimap {
  position: absolute;
  top: 10px; right: 10px;
  width: 108px; height: 108px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(10, 11, 18, .55);
  box-shadow: var(--shadow);
  backdrop-filter: blur(2px);
  pointer-events: none;
  opacity: .92;
}

/* Fliegende Texte */
.toasts { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.toast {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 15px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .8);
  white-space: nowrap;
  animation: floatUp 1s ease-out forwards;
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -40%) scale(.7); }
  20%  { opacity: 1; transform: translate(-50%, -60%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

/* Wirkungs-Anzeige nach dem Einsammeln (Ecke links oben) */
.pickup {
  position: absolute;
  left: 10px; top: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(300px, 68vw);
  padding: 8px 13px 8px 9px;
  border-radius: 13px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  background: rgba(22, 25, 39, .88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(5px);
  pointer-events: none;
  animation: pickupIn .32s cubic-bezier(.15, .9, .3, 1.35);
}
.pickup.hidden { display: none; }
.pickup.out { animation: pickupOut .3s ease forwards; }
.pickup.good { border-left-color: var(--good); }
.pickup.bad  { border-left-color: var(--bad); }

.pickup canvas { width: 36px; height: 36px; flex: 0 0 auto; }
.pickup-name { font-size: 13.5px; font-weight: 800; line-height: 1.25; }
.pickup.good .pickup-name { color: var(--good); }
.pickup.bad  .pickup-name { color: var(--bad); }
.pickup-desc { font-size: 11.5px; color: var(--dim); line-height: 1.35; margin-top: 1px; }

@keyframes pickupIn {
  from { opacity: 0; transform: translateX(-28px) scale(.9); }
}
@keyframes pickupOut {
  to { opacity: 0; transform: translateX(-18px) scale(.96); }
}

/* Mittige Statusmeldung (Countdown, "Level 2", ...) */
.center-msg {
  position: absolute;
  left: 50%; top: 46%;
  transform: translate(-50%, -50%);
  font-size: clamp(34px, 12vw, 90px);
  font-weight: 900;
  letter-spacing: -1px;
  color: #fff;
  text-shadow: 0 6px 26px rgba(0, 0, 0, .75);
  pointer-events: none;
  z-index: 6;
  animation: beat .5s ease;
}
.center-msg.small { font-size: clamp(20px, 6vw, 40px); }
.center-msg.hidden { display: none; }
@keyframes beat { from { transform: translate(-50%, -50%) scale(1.5); opacity: 0 } }

/* ========================== Joystick ==========================
   Kein fester Platz: der Stick sitzt dort, wo der Finger aufsetzt.
   Position setzt input.js per transform, hier steht nur das Aussehen.
   Der Ursprung liegt in der Mitte, damit `translate(x, y)` direkt die
   Fingerposition ist. */

.stick {
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s ease;
}
.stick.on { opacity: 1; }

/* Beide sitzen im Ursprung und werden über negative Ränder um ihren
   eigenen Mittelpunkt zentriert. Das transform des Knaufs aus input.js
   ist dadurch direkt seine Auslenkung. */
.stick-ring,
.stick-knob {
  position: absolute;
  left: 0; top: 0;
  border-radius: 50%;
}

.stick-ring {
  width: 116px; height: 116px;
  margin: -58px 0 0 -58px;
  border: 2px solid rgba(255, 255, 255, .28);
  background: radial-gradient(circle, rgba(20, 22, 34, .40), rgba(20, 22, 34, .12));
  backdrop-filter: blur(2px);
}

.stick-knob {
  width: 54px; height: 54px;
  margin: -27px 0 0 -27px;
  background: radial-gradient(circle at 35% 30%, var(--accent), var(--accent-2));
  border: 2px solid rgba(255, 255, 255, .45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
}

/* ============================ Overlays ============================ */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(9, 10, 16, .72);
  backdrop-filter: blur(6px);
  overflow-y: auto;
  animation: fade .18s ease;
}
.overlay.hidden { display: none; }
@keyframes fade { from { opacity: 0 } }

.panel {
  width: min(400px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
  animation: rise .22s cubic-bezier(.2, .9, .3, 1.2);
}
.panel.wide { width: min(520px, 100%); text-align: left; }
@keyframes rise { from { transform: translateY(14px) scale(.97); opacity: 0 } }

.panel h1 {
  margin: 4px 0 2px;
  font-size: 34px;
  letter-spacing: -1px;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.panel h2 { margin: 0 0 6px; font-size: 24px; }
.panel h3 { margin: 16px 0 6px; font-size: 14px; color: var(--accent); text-transform: uppercase; letter-spacing: .8px; }
.tagline { margin: 0 0 16px; color: var(--dim); font-size: 13.5px; line-height: 1.5; }
.hint { margin: 12px 0 0; font-size: 11.5px; color: var(--dim); }

/* Version: da, aber leise – sie soll auffindbar sein, nicht auffallen. */
.version {
  margin: 6px 0 0;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .4px;
  color: var(--dim);
  opacity: .6;
}

.logo { display: flex; justify-content: center; align-items: flex-end; gap: 0; }
.logo-sprite {
  width: 58px; height: 58px;
  animation: bob 1.8s ease-in-out infinite;
}
.logo-sprite.mid { animation-delay: .25s; width: 70px; height: 70px; }
.logo-sprite:last-child { animation-delay: .5s; width: 48px; height: 48px; }
@keyframes bob { 50% { transform: translateY(-7px) } }

.big-emoji { font-size: 52px; line-height: 1; margin-bottom: 6px; }

/* Formularelemente */
.field { margin: 14px 0; text-align: left; }
.field > label {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--dim);
  margin-bottom: 6px;
  font-weight: 700;
}

select {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  appearance: none;
}

.sliders { display: flex; flex-direction: column; gap: 8px; }
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-tag { width: 14px; font-size: 11px; color: var(--dim); font-weight: 700; }

input[type=range] {
  flex: 1;
  appearance: none;
  height: 5px;
  border-radius: 4px;
  background: var(--panel-2);
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--panel);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--panel);
  cursor: pointer;
}

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--dim);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.segmented { display: flex; gap: 6px; }
.segmented button {
  flex: 1;
  padding: 9px 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--dim);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: .15s;
}
.segmented button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1500;
}

/* Buttons */
.btn-row { margin-top: 9px; }
.btn {
  width: 100%;
  padding: 12px 16px;
  font-size: 14.5px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: transform .1s, filter .15s, background .15s;
}
.btn:hover { background: #303552; }
.btn:active { transform: scale(.98); }
.btn.big { padding: 14px 16px; font-size: 16px; }
.btn.primary {
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  color: #1a1500;
  border-color: transparent;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--bad); border-color: rgba(255, 107, 107, .35); }
.btn.danger:hover { background: rgba(255, 107, 107, .12); }

.scoreline {
  display: flex;
  gap: 10px;
  margin: 14px 0 4px;
}
.scoreline > div {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.scoreline span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; }
.scoreline strong { font-size: 22px; font-variant-numeric: tabular-nums; }

/* Anleitung */
.list { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.65; color: var(--dim); }
.list strong { color: var(--text); }

.legend { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 9px;
  font-size: 12.5px;
}
.legend-row.good { border-left-color: var(--good); }
.legend-row.bad  { border-left-color: var(--bad); }
.legend-row canvas { width: 26px; height: 26px; flex: 0 0 auto; image-rendering: auto; }
.legend-row .lg-name { font-weight: 700; }
.legend-row .lg-desc { color: var(--dim); }

/* Schmale Handys: HUD kompakter */
@media (max-width: 400px) {
  :root { --hud-h: 46px; }
  .stat { font-size: 12.5px; }
  .lives { font-size: 14px; }
  .minimap { width: 84px; height: 84px; }
}

/* Sehr niedrige Fenster (Landscape-Handy) */
@media (max-height: 460px) {
  .panel { padding: 14px; }
  .panel h1 { font-size: 26px; }
  .logo { font-size: 30px; }
  .field { margin: 9px 0; }
}

/* =========================================================
   Nur 3D-Variante
   ========================================================= */

/* Vollflaechige Stimmungen als DOM-Ebenen. In 3D ist das deutlich
   guenstiger als eine Post-Processing-Pipeline und sieht identisch aus. */
.fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 2;
  transition: opacity .12s linear;
}

/* Gefahrenrand: aussen rot, Mitte frei */
#fxDanger {
  background: radial-gradient(ellipse at center,
    rgba(0, 0, 0, 0) 32%,
    rgba(190, 20, 20, .28) 62%,
    rgba(210, 25, 25, .92) 100%);
  transition: opacity .2s linear;
}

#fxFlash { background: #fff; transition: opacity .08s linear; }
#fxTint { transition: opacity .3s linear; }

/* Grundvignette liegt fest auf dem 3D-Bild */
#stage.three::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(ellipse at center,
    rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, .45) 100%);
}

.badge3d {
  display: inline-block;
  vertical-align: middle;
  margin-left: 4px;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .5px;
  color: #1a1500;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  border-radius: 7px;
  -webkit-text-fill-color: #1a1500;
}

/* Buttons, die in Wahrheit Links sind */
.linkbtn {
  display: block;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}

/* Hinweis, wenn der Browser kein WebGL kann */
.nowebgl {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(9, 10, 16, .92);
}
.nowebgl.hidden { display: none; }
