@font-face {
  font-family: "Orbitron";
  src: url("../fonts/orbitron.woff2") format("woff2");
  font-weight: 500 900;
  font-display: swap;
}

:root {
  --cyan: #5ff3ff; --pink: #ff4fd8; --red: #ff5470; --gold: #ffd23a;
  --panel: rgba(12, 10, 32, .82); --line: rgba(95, 243, 255, .35);

  /* Größen: Desktop */
  --edge: 18px; --radar: 160px; --stick: 140px; --knob: 60px; --fire: 110px;
  --fs-coin: 32px; --fs-small: 12px; --btn: 44px;
}
/* Tablet (Touch oder mittlere Fenster) */
@media (pointer: coarse), (max-width: 1100px), (max-height: 700px) {
  :root { --edge: 14px; --radar: 130px; --stick: 118px; --knob: 50px; --fire: 90px; --fs-coin: 26px; --btn: 40px; }
}
/* Handy */
@media (max-width: 520px), (max-height: 480px) {
  :root { --edge: 10px; --radar: 96px; --stick: 92px; --knob: 40px; --fire: 70px; --fs-coin: 20px; --fs-small: 10px; --btn: 34px; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #2a1740; color: #fff;
  font-family: "Orbitron", "Segoe UI", sans-serif; font-weight: 500;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
button { font-family: inherit; }
.hidden { display: none !important; }

#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; image-rendering: pixelated; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none;
  top: calc(var(--edge) + env(safe-area-inset-top)); left: calc(var(--edge) + env(safe-area-inset-left));
  right: calc(var(--edge) + env(safe-area-inset-right));
  text-shadow: 0 2px 0 #000;
}
#radar { width: var(--radar); height: var(--radar); display: block; }
#hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#hud-coins {
  display: flex; align-items: center; gap: 10px; padding: 6px 18px; border-radius: 30px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: var(--fs-coin); font-weight: 800; color: var(--gold);
}
#hud-coins { transition: background .15s, border-color .15s, box-shadow .15s; }
#hud-coins span { display: inline-block; min-width: 1ch; }
#hud-coins.hot { background: rgba(90, 62, 0, .85); border-color: var(--gold); box-shadow: 0 0 16px rgba(255, 210, 58, .75); }
#hud-coins.pop span { animation: coinpop .3s ease-out; }
#hud-coins.pop .coin { animation: coinpulse .3s ease-out; }
@keyframes coinpop {
  0%   { transform: scale(1);   color: var(--gold); }
  35%  { transform: scale(1.8); color: #fff; text-shadow: 0 0 12px #ffd23a, 0 2px 0 #000; }
  100% { transform: scale(1);   color: var(--gold); }
}
@keyframes coinpulse { 0% { transform: scale(1); } 35% { transform: scale(1.5); } 100% { transform: scale(1); } }
.coin { width: .8em; height: .8em; border-radius: 50%; background: var(--gold); box-shadow: inset -2px -2px 0 #c9951a, 0 0 8px rgba(255,210,58,.6); }
#settings-btn {
  pointer-events: auto; width: var(--btn); height: var(--btn); border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
  background: var(--panel); border: 1px solid var(--line); color: #fff;
}
#settings-btn svg { width: 58%; height: 58%; }
#settings-btn:active { background: rgba(95, 243, 255, .25); }

#hint {
  position: fixed; bottom: 10px; left: 0; right: 0; text-align: center; font-size: var(--fs-small); letter-spacing: .06em;
  opacity: .5; pointer-events: none; text-shadow: 0 1px 0 #000;
}
@media (hover: none), (pointer: coarse) { #hint { display: none; } }

/* ---------- Lebensbalken ---------- */
#shipbar, .ebar {
  position: fixed; left: 0; top: 0; width: 64px; height: 8px; margin: -4px 0 0 -32px;
  background: rgba(0,0,0,.6); border: 2px solid #000; pointer-events: none; will-change: transform;
}
.ebar > div { height: 100%; background: var(--red); }
#shipbar-fill { height: 100%; width: 100%; background: #4cff6a; }

/* ---------- Touch-Steuerung ---------- */
#stick {
  position: fixed; width: var(--stick); height: var(--stick); border-radius: 50%;
  left: calc(var(--edge) + 10px + env(safe-area-inset-left)); bottom: calc(var(--edge) + 10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.3);
}
#stick-knob {
  position: absolute; left: 50%; top: 50%; width: var(--knob); height: var(--knob);
  margin: calc(var(--knob) / -2) 0 0 calc(var(--knob) / -2); border-radius: 50%;
  background: rgba(95,243,255,.5); border: 2px solid var(--cyan);
}
#fire {
  position: fixed; width: var(--fire); height: var(--fire); border-radius: 50%;
  right: calc(var(--edge) + 10px + env(safe-area-inset-right)); bottom: calc(var(--edge) + 14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--fire) * .03);
  background: radial-gradient(circle at 50% 35%, rgba(255,120,140,.55), rgba(190,30,70,.55) 60%, rgba(70,10,40,.7));
  border: 2px solid var(--red); color: #fff;
  box-shadow: 0 0 16px rgba(255,84,112,.45), inset 0 0 14px rgba(255,255,255,.12);
  transition: transform .06s, box-shadow .06s;
}
/* innerer Zierring */
#fire::before {
  content: ""; position: absolute; inset: calc(var(--fire) * .07); border-radius: 50%;
  border: 1px dashed rgba(255,255,255,.45); pointer-events: none;
}
#fire span {
  font-weight: 900; font-size: calc(var(--fire) * .17); letter-spacing: .18em; text-transform: uppercase;
  text-indent: .18em; text-shadow: 0 1px 0 rgba(0,0,0,.6);
}
#fire.down {
  transform: scale(.93);
  background: radial-gradient(circle at 50% 35%, rgba(255,190,200,.85), rgba(255,60,100,.8) 60%, rgba(120,20,60,.85));
  box-shadow: 0 0 26px rgba(255,84,112,.85), inset 0 0 18px rgba(255,255,255,.3);
}

/* ---------- Overlays / Panels ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 5, 24, .85);     /* bewusst ohne backdrop-filter: das legt manche Handy-GPUs lahm */
}
.panel {
  width: min(88vw, 380px); max-height: 92vh; overflow: auto; padding: 22px 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.panel h1, .panel h2 { margin: 0 0 14px; text-align: center; text-transform: uppercase; letter-spacing: .22em; font-weight: 800; }
.panel h2 { font-size: 16px; color: var(--cyan); }
.death-panel { text-align: center; border-color: rgba(255,84,112,.45); width: min(92vw, 520px); overflow: visible; }
.death-panel h1 { font-size: clamp(20px, 5.5vw, 34px); letter-spacing: .12em; color: var(--red); text-shadow: 0 0 18px rgba(255,84,112,.5); margin: 4px 0 22px; white-space: nowrap; }
.note { margin: 6px 0 16px; font-size: 11px; letter-spacing: .08em; opacity: .6; text-align: center; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; }
.row label { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.seg { display: flex; border: 1px solid var(--line); }
.seg button { padding: 8px 12px; background: transparent; border: 0; color: #fff; cursor: pointer; font-size: 12px; font-weight: 700; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--cyan); color: #101030; }
.toggle { padding: 8px 14px; background: transparent; border: 1px solid var(--line); color: #fff; cursor: pointer; font-size: 12px; font-weight: 700; min-width: 64px; }
.toggle.on { background: var(--cyan); color: #101030; }

.primary {
  display: block; width: 100%; margin-top: 6px; padding: 12px 20px; cursor: pointer;
  background: transparent; color: var(--cyan); border: 2px solid var(--cyan);
  font-size: 14px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase;
  transition: background .15s, color .15s;
}
.primary:hover, .primary:active { background: var(--cyan); color: #101030; }
.death-panel .primary { border-color: var(--red); color: var(--red); }
.death-panel .primary:hover, .death-panel .primary:active { background: var(--red); color: #101030; }
