:root {
  --accent: #ff8a2a;
  --accent-dim: #b85a12;
  --text: #e8e4dc;
  --muted: #9b968c;
  --panel: rgba(18, 20, 18, 0.88);
  --line: rgba(255, 255, 255, 0.12);
  --hp: #c9402c;
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #111311;
  color: var(--text);
  font-family: var(--font);
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

body.post #grade { display: none; }
#grade {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(5, 8, 10, 0.45) 100%);
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

#crosshair {
  position: absolute; left: 50%; top: 50%; width: 22px; height: 22px;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(var(--text), var(--text)) center / 2px 8px no-repeat,
    linear-gradient(var(--text), var(--text)) center / 8px 2px no-repeat;
  border: 2px solid rgba(232, 228, 220, 0.55); border-radius: 50%;
  opacity: 0.85;
}
#hud[data-mode="titan"] #crosshair { width: 34px; height: 34px; border-color: rgba(255, 138, 42, 0.6); }

#hitmarker {
  position: absolute; left: 50%; top: 50%; width: 30px; height: 30px;
  transform: translate(-50%, -50%) rotate(45deg);
  background:
    linear-gradient(#fff, #fff) center / 2px 100% no-repeat,
    linear-gradient(#fff, #fff) center / 100% 2px no-repeat;
  opacity: 0; transition: opacity 0.15s;
}
#hitmarker.show { opacity: 0.9; transition: none; }
#hitmarker.weak { filter: drop-shadow(0 0 4px var(--accent)); background:
    linear-gradient(var(--accent), var(--accent)) center / 3px 100% no-repeat,
    linear-gradient(var(--accent), var(--accent)) center / 100% 3px no-repeat; }

#vignette {
  position: absolute; inset: 0; opacity: 0; transition: opacity 0.5s;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(170, 20, 10, 0.75) 100%);
}
#vignette.show { opacity: 1; transition: none; }

#dmgdir {
  position: absolute; left: 50%; top: 50%; width: 220px; height: 220px; margin: -110px 0 0 -110px;
  opacity: 0; transition: opacity 0.6s;
}
#dmgdir.show { opacity: 1; transition: none; }
#dmgdir .arc {
  position: absolute; left: 50%; top: 0; width: 90px; height: 26px; margin-left: -45px;
  border-top: 6px solid rgba(220, 40, 20, 0.85); border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  filter: drop-shadow(0 0 6px rgba(255, 40, 10, 0.7));
}

#compass {
  position: absolute; top: max(40px, calc(env(safe-area-inset-top) + 28px)); left: 50%; transform: translateX(-50%);
  width: min(420px, 60vw); height: 22px; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}
#compass .strip { position: absolute; inset: 0; }
#compass .lbl, #compass .mk {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: bold;
  letter-spacing: 0.05em; color: rgba(232, 228, 220, 0.75); text-shadow: 0 1px 3px #000; white-space: nowrap;
}
#compass .lbl.main { color: var(--text); font-size: 14px; }
#compass .mk { top: 2px; width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 11px solid #ff4a2a; }
#compass .mk.search { border-top-color: #ffc24a; }
#compass .mk.idle { border-top-color: rgba(200, 200, 200, 0.6); }
#compass .mk.boss { border-top-color: #ff1a00; transform: translateX(-50%) scale(1.4); }
#compass .mk.vehicle { border-top-color: #ffa040; }
#compass .tick { position: absolute; left: 50%; bottom: 0; width: 2px; height: 6px; margin-left: -1px; background: var(--accent); }
body.touch #compass { top: 64px; }

#topbar {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  font-weight: bold; letter-spacing: 0.08em; text-shadow: 0 2px 4px #000;
}
#top-left, #top-right { font-size: 18px; min-width: 120px; }
#top-right { text-align: right; }
#detect {
  font-size: 14px; padding: 4px 12px; border-radius: 4px; background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line);
}
#detect:empty { display: none; }
#detect.seen { color: #ff5a3c; border-color: #ff5a3c; }
#detect.search { color: #ffc24a; border-color: #ffc24a; }
#detect.hidden-state { color: #8fb38a; }

#bossbar {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%);
  width: min(460px, 70vw); text-align: center; text-shadow: 0 2px 4px #000;
}
#bossbar .name { font-size: 15px; letter-spacing: 0.12em; margin-bottom: 4px; }
#bossbar.boss .name { color: var(--accent); font-size: 17px; }
#bossbar .bar { height: 10px; background: rgba(0, 0, 0, 0.55); border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
#bossbar .fill { height: 100%; width: 100%; background: linear-gradient(90deg, #8a1e12, #d8502c); transition: width 0.15s; }

#message {
  position: absolute; top: 28%; left: 50%; transform: translateX(-50%);
  font-size: clamp(20px, 3.4vw, 34px); font-weight: bold; letter-spacing: 0.06em;
  text-align: center; text-shadow: 0 3px 8px #000; opacity: 0; transition: opacity 0.6s;
  width: 90vw;
}
#message.show { opacity: 1; transition: opacity 0.15s; }

#countdown {
  position: absolute; top: calc(28% + 52px); left: 50%; transform: translateX(-50%);
  font-size: 18px; letter-spacing: 0.1em; color: var(--accent); text-shadow: 0 2px 6px #000;
}
#countdown:empty { display: none; }
#tip {
  position: absolute; left: 50%; bottom: calc(max(20px, env(safe-area-inset-bottom)) + 64px); transform: translateX(-50%);
  max-width: min(640px, 80vw); padding: 8px 14px; border-radius: 6px; text-align: center;
  background: rgba(0, 0, 0, 0.55); border: 1px solid var(--line); font-size: 15px; line-height: 1.4;
  opacity: 0; transition: opacity 0.6s;
}
#tip.show { opacity: 1; }
body.touch #tip { bottom: auto; top: 130px; }

#bottom-left {
  position: absolute; left: 20px; bottom: max(20px, env(safe-area-inset-bottom));
  width: min(300px, 34vw);
}
#bottom-left .label { font-size: 12px; letter-spacing: 0.2em; color: var(--muted); margin-bottom: 4px; }
#hpbar { height: 14px; background: rgba(0, 0, 0, 0.55); border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
#hpbar .fill { height: 100%; width: 100%; background: linear-gradient(90deg, #7d2016, var(--hp)); transition: width 0.15s; }
#hpbar .fill.low { animation: pulse 0.6s infinite alternate; }
@keyframes pulse { to { filter: brightness(1.8); } }

#info {
  position: absolute; right: 20px; bottom: max(20px, env(safe-area-inset-bottom));
  font-size: 20px; font-weight: bold; text-align: right; text-shadow: 0 2px 4px #000; white-space: pre-line;
}

#wbar {
  position: absolute; right: 20px; bottom: calc(max(20px, env(safe-area-inset-bottom)) + 58px);
  display: flex; gap: 4px; justify-content: flex-end;
}
#wbar .w {
  font-size: 11px; padding: 3px 6px; border-radius: 3px; background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
#wbar .w b { color: var(--text); margin-right: 3px; }
#wbar .w.on { border-color: var(--accent); color: var(--text); background: rgba(184, 90, 18, 0.55); }
#wbar .w.empty { opacity: 0.45; }
body.touch #wbar { bottom: auto; top: 96px; right: 16px; }

#scope {
  position: fixed; inset: 0; pointer-events: none; z-index: 4;
  background:
    linear-gradient(rgba(0,0,0,0.85), rgba(0,0,0,0.85)) center / 1px 100% no-repeat,
    linear-gradient(rgba(0,0,0,0.85), rgba(0,0,0,0.85)) center / 100% 1px no-repeat,
    radial-gradient(circle at center, transparent 0, transparent min(38vh, 38vw), #000 calc(min(38vh, 38vw) + 2px));
}
body.scoped #crosshair { display: none; }

#cooldowns {
  position: absolute; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: 10px;
}
.cd {
  position: relative; width: 74px; padding: 6px 0; text-align: center; font-size: 11px; letter-spacing: 0.08em;
  background: rgba(0, 0, 0, 0.5); border: 1px solid var(--line); border-radius: 4px; overflow: hidden;
}
.cd .k { display: block; font-size: 15px; font-weight: bold; color: var(--accent); }
.cd .shade { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.65); }

/* Auf Touch-Geräten liegen Infos oben, damit die Daumen frei sind */
body.touch #info { bottom: auto; top: 44px; right: 16px; font-size: 16px; }
body.touch #bottom-left { bottom: auto; top: 44px; left: 16px; }
body.touch #cooldowns { display: none; }
body.touch #bossbar { top: 96px; }
body.touch #hud[data-mode="hunter"] #bossbar { top: 124px; }

/* ---------- Touch ---------- */
#touch { position: fixed; inset: 0; z-index: 8; touch-action: none; }
#joy-zone { position: absolute; left: 0; top: 0; bottom: 0; width: 42%; }
#joy-base {
  position: absolute; left: 120px; top: calc(100% - 140px); width: 150px; height: 150px; margin: -75px 0 0 -75px;
  border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.28); background: rgba(0, 0, 0, 0.22);
  pointer-events: none; opacity: 0.7;
}
#joy-base.active { opacity: 1; }
#joy-knob {
  position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.35); border: 2px solid rgba(255, 255, 255, 0.6);
}
#look-hint {
  position: absolute; right: 30%; top: 40%; color: rgba(255, 255, 255, 0.35); font-size: 14px;
  pointer-events: none; transition: opacity 1s;
}
#look-hint.gone { opacity: 0; }

.tb {
  position: absolute; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.45);
  background: rgba(20, 20, 20, 0.45); color: var(--text); font: bold 13px var(--font); letter-spacing: 0.05em;
  width: 78px; height: 78px; padding: 0; overflow: hidden; touch-action: none;
}
.tb.down { background: rgba(255, 138, 42, 0.55); border-color: var(--accent); }
.tb.big { width: 120px; height: 120px; right: 36px; bottom: 40px; font-size: 17px; border-color: rgba(255, 138, 42, 0.8); }
.tb.b1 { right: 172px; bottom: 30px; }
.tb.b2 { right: 160px; bottom: 132px; }
.tb.b3 { right: 60px; bottom: 182px; }
.tb.b5 { right: 262px; bottom: 172px; }
.tb.b4 { right: 262px; bottom: 70px; font-size: 11px; line-height: 1.2; border-color: rgba(255, 90, 60, 0.7); }
.tb[data-cd]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--cd, 0) * 100%); background: rgba(0, 0, 0, 0.6);
}
#pausebtn { width: 48px; height: 48px; left: 50%; top: max(8px, env(safe-area-inset-top)); margin-left: -24px; font-size: 16px; }
#viewbtn { width: 48px; height: 48px; left: 50%; top: max(8px, env(safe-area-inset-top)); margin-left: 34px; font-size: 18px; }
#touch[data-mode="hunter"] .titan-only, #touch[data-mode="titan"] .hunter-only { display: none; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  padding: 16px; overflow: auto; touch-action: pan-y;
  background: linear-gradient(180deg, rgba(10, 12, 10, 0.2), rgba(10, 12, 10, 0.75));
}
.panel {
  width: min(760px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 26px 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); margin: auto;
}
.panel.small { width: min(380px, 100%); text-align: center; }
h1.logo { margin: -6px 0 0; text-align: center; line-height: 0; }
h1.logo img { width: min(440px, 80%); height: auto; max-height: 26vh; object-fit: contain; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.6)); }
.logo + .sub { text-align: center; }
h1 { margin: 0; font-size: clamp(34px, 6vw, 56px); letter-spacing: 0.14em; color: var(--accent); text-shadow: 0 4px 18px rgba(255, 120, 30, 0.35); }
h2 { margin: 0 0 16px; letter-spacing: 0.08em; }
.sub { margin: 4px 0 20px; color: var(--muted); }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .modes { grid-template-columns: 1fr; } }
.mode {
  text-align: left; padding: 18px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer;
  background: linear-gradient(160deg, #2a2d27, #1a1c19); color: var(--text); font-family: var(--font);
  transition: transform 0.1s, border-color 0.15s;
}
.mode:hover, .mode:active { border-color: var(--accent); transform: translateY(-2px); }
.mode-title { display: block; font-size: 22px; font-weight: bold; color: var(--accent); margin-bottom: 6px; }
.mode-desc { display: block; font-size: 14px; line-height: 1.4; color: #cfcac0; }

.settings { margin-top: 20px; display: grid; gap: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 15px; }
.row input[type="range"] { width: min(260px, 50%); accent-color: var(--accent); touch-action: none; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { background: transparent; color: var(--text); border: 0; padding: 8px 14px; font: 14px var(--font); cursor: pointer; }
.seg button.on { background: var(--accent-dim); color: #fff; }

#best { margin-top: 16px; color: var(--muted); font-size: 14px; }

.help { margin-top: 16px; font-size: 14px; line-height: 1.6; color: #cfcac0; }
.help summary { cursor: pointer; color: var(--text); font-weight: bold; }
.help-touch { display: none; }
body.touch .help-touch { display: block; }
body.touch .help-desktop { display: none; }

.btn {
  display: block; width: 100%; margin-top: 10px; padding: 14px; font: bold 17px var(--font); letter-spacing: 0.05em;
  border-radius: 6px; border: 1px solid var(--accent); background: var(--accent-dim); color: #fff; cursor: pointer;
}
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
#over-lines { margin-bottom: 12px; line-height: 1.8; font-size: 17px; }
#over-lines .new { color: var(--accent); font-weight: bold; }

#rotate {
  display: none; position: fixed; inset: 0; z-index: 50; background: #111311; color: var(--text);
  align-items: center; justify-content: center; font-size: 22px; text-align: center; padding: 20px;
}
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }
