/* KHUD – Überlebens-HUD. Alle Selektoren beginnen mit .kh- (keine Konflikte mit style.css/game.js).
   Farben: Dschungelgrün #0f2a22, Sand #e9d9b0, Signalorange #ff8a3d. Nur Systemschriften.
   Layout: oben rechts Tag/Ort (100px Abstand, Kompass bleibt frei), unten links Status + Vitalwerte,
   unten mitte Hotbar; auf Touch-Geräten (body.touch) und schmalen Fenstern oben mittig, unten links frei. */

.kh-root, .kh-root * { pointer-events: none; }
.kh-root {
  --kh-panel: rgba(8, 22, 18, .84);
  --kh-line: rgba(233, 217, 176, .26);
  --kh-ink: #f3ead2;
  --kh-sand: #e9d9b0;
  --kh-mute: #d2c6a4;
  --kh-acc: #ff8a3d;
  --kh-red: #ff7a85;
  --kh-green: #9fe39a;
  --kh-blue: #8fd8ff;
}
.kh-off { display: none !important; }
.kh-box {
  background: var(--kh-panel);
  border: 1px solid var(--kh-line);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
  color: var(--kh-ink);
}
.kh-ico { width: 16px; height: 16px; flex: none; display: block; color: var(--kh-sand); }
.kh-ico path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kh-track { height: 9px; border-radius: 5px; background: rgba(0, 0, 0, .5); overflow: hidden; }
.kh-fill { display: block; height: 100%; width: 0; transition: width .3s ease-out; }
.kh-f-hunger { background: #ffa94d; }
.kh-f-thirst { background: #41b6ff; }
.kh-f-energy { background: #f2d64b; }
.kh-f-health { background: #ff5c72; }
.kh-f-wet { background: #7fd0ff; }
.kh-f-build { background: var(--kh-acc); }

/* Tag, Uhrzeit, Ort */
.kh-time {
  position: absolute; right: 100px; top: 14px;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 8px; max-width: 250px;
}
.kh-dial { position: relative; width: 34px; height: 34px; flex: none; border-radius: 50%; border: 1px dashed var(--kh-line); }
.kh-dial::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--kh-line); }
.kh-dot { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: #ffd23f; box-shadow: 0 0 8px 2px rgba(255, 210, 63, .7); }
.kh-dot.kh-moon { background: #e8edf7; box-shadow: 0 0 6px 1px rgba(200, 215, 240, .5); }
.kh-tbody { min-width: 0; }
.kh-tline { display: flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 700; line-height: 1.25; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kh-rain { width: 16px; height: 16px; color: var(--kh-blue); }
.kh-place { font-size: 13px; color: var(--kh-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kh-night .kh-tline { color: #dfe6f7; }

/* Bau-Karte */
.kh-build { position: absolute; right: 16px; top: 96px; width: 262px; padding: 10px 12px; display: grid; gap: 6px; font-size: 14px; }
.kh-bhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 700; }
.kh-bcount { font-variant-numeric: tabular-nums; color: var(--kh-sand); }
.kh-bnext { font-size: 13px; color: var(--kh-mute); }
.kh-bmiss { font-size: 13px; color: #ffc2c6; font-weight: 600; }

/* Statuseffekte und Vitalwerte, unten links */
.kh-left { position: absolute; left: 16px; bottom: 16px; width: 288px; display: flex; flex-direction: column; gap: 8px; }
.kh-status { display: flex; flex-wrap: wrap; gap: 6px; }
.kh-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; line-height: 1.2; padding: 4px 9px 4px 7px; border-radius: 999px;
  background: rgba(8, 22, 18, .9); border: 1px solid var(--kh-line); color: var(--kh-ink);
}
.kh-chip .kh-ico { width: 14px; height: 14px; }
.kh-chip.kh-bad { background: rgba(120, 12, 24, .92); border-color: var(--kh-red); }
.kh-chip.kh-warn { background: rgba(110, 62, 8, .92); border-color: #ffc35a; }
.kh-chip.kh-good { background: rgba(38, 72, 30, .92); border-color: var(--kh-green); }
.kh-mini { display: inline-block; width: 40px; height: 6px; border-radius: 3px; background: rgba(0, 0, 0, .5); overflow: hidden; }
.kh-mini i { display: block; height: 100%; width: 0; background: #ffc35a; }

.kh-vitals { padding: 8px 10px; display: grid; gap: 6px; }
.kh-row {
  display: grid; grid-template-columns: 16px 1fr auto; gap: 3px 8px; align-items: center;
  font-size: 14px; padding: 2px 4px; border-radius: 6px;
}
.kh-lg { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; }
.kh-lab { color: var(--kh-mute); }
.kh-pill { font-size: 11px; font-weight: 800; line-height: 1; padding: 3px 6px; border-radius: 4px; background: #8f1420; color: #fff; text-transform: uppercase; letter-spacing: .03em; }
.kh-vg { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kh-val { font-weight: 700; min-width: 46px; text-align: right; }
.kh-trend { min-width: 22px; font-size: 11px; text-align: left; color: var(--kh-mute); }
.kh-up .kh-trend { color: var(--kh-green); }
.kh-down .kh-trend { color: var(--kh-red); }
.kh-fast .kh-trend { font-size: 12px; font-weight: 800; letter-spacing: -.1em; }
.kh-row .kh-track { grid-column: 1 / -1; }
.kh-crit .kh-val { color: #ffc2c6; }

/* Hotbar und Vorräte, unten mitte */
.kh-hot { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: stretch; gap: 8px; padding: 6px 8px; }
.kh-slots { display: flex; gap: 4px; }
.kh-sep { width: 1px; background: var(--kh-line); }
.kh-slot {
  position: relative; width: 62px; min-height: 58px; padding: 16px 2px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px;
  border: 1px solid transparent; border-radius: 8px; color: var(--kh-sand);
}
.kh-slot.kh-held { border: 2px solid var(--kh-acc); background: rgba(255, 138, 61, .18); padding: 15px 1px 3px; }
.kh-slot.kh-held .kh-sn { font-weight: 700; }
.kh-slot.kh-held .kh-sn::before { content: "▸ "; }
.kh-slot .kh-ico { width: 22px; height: 22px; }
.kh-sn { font-size: 11px; line-height: 1.15; text-align: center; white-space: nowrap; }
.kh-key { position: absolute; top: 4px; left: 6px; font-size: 12px; font-weight: 800; color: var(--kh-acc); }
.kh-sc { font-size: 16px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; color: var(--kh-ink); }
.kh-quick.kh-zero .kh-sc { color: #b9ad8a; font-weight: 500; }

/* Kurze Meldungen, oben mitte */
.kh-toasts { position: absolute; left: 50%; top: 60px; transform: translateX(-50%); width: min(520px, 92vw); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.kh-toast {
  display: flex; align-items: baseline; gap: 8px; max-width: 100%; padding: 6px 12px; border-radius: 8px;
  background: var(--kh-panel); border: 1px solid var(--kh-line); box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
  font-size: 15px; color: var(--kh-ink); animation: kh-toast 3.2s ease forwards;
}
.kh-tag { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--kh-sand); white-space: nowrap; }
.kh-tt { overflow-wrap: anywhere; }
.kh-t-pickup { border-color: var(--kh-sand); }
.kh-t-craft { border-color: var(--kh-green); }
.kh-t-craft .kh-tag { color: var(--kh-green); }
.kh-t-warn { border-color: var(--kh-acc); }
.kh-t-warn .kh-tag { color: var(--kh-acc); }

/* Bildschirmeffekte (liegen unter den Panels) */
.kh-vig { position: absolute; inset: 0; opacity: 0; box-shadow: inset 0 0 140px 50px rgba(200, 10, 25, .8); }
.kh-vig.kh-on { animation: kh-beat 1.1s ease-in-out infinite; }
.kh-wet { position: absolute; inset: 0; opacity: 0; background: rgba(80, 150, 225, .16); transition: opacity 1.5s ease; }
.kh-wet.kh-on { opacity: 1; }
.kh-flash { position: absolute; inset: 0; opacity: 0; box-shadow: inset 0 0 90px 30px rgba(255, 30, 40, .85); }
.kh-flash.kh-flash-go { animation: kh-hit .5s ease-out; }
.kh-row.kh-crit { animation: kh-crit 1s ease-in-out infinite alternate; }

@keyframes kh-beat { 0%, 100% { opacity: .5; } 12% { opacity: 1; } 24% { opacity: .6; } 36% { opacity: .95; } 50% { opacity: .5; } }
@keyframes kh-hit { from { opacity: .9; } to { opacity: 0; } }
@keyframes kh-hit-soft { from { opacity: .5; } to { opacity: 0; } }
@keyframes kh-toast { 0% { opacity: 0; transform: translateY(-6px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; transform: none; } }
@keyframes kh-toast-fade { 0% { opacity: 0; } 8%, 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes kh-crit { from { background: rgba(120, 10, 20, .25); } to { background: rgba(190, 30, 40, .5); } }

/* Kleine Bildschirme und Touch: Hotbar oben mitte (zweizeilig), Vitalwerte unten links über dem Stick */
/* Layout-Schalter: Zeit unter den Kompass, Hotbar zweizeilig unter die Zeit, Bau-Karte darunter */
@media (max-width: 900px) {
  .kh-time { right: 16px; top: 86px; max-width: 210px; }
  .kh-hot { top: 140px; bottom: auto; flex-direction: column; gap: 6px; }
  .kh-hot .kh-sep { display: none; }
  .kh-slot { width: 64px; min-height: 56px; }
  .kh-build { left: 16px; right: 16px; top: 280px; width: auto; padding: 8px 10px; gap: 4px; }
  .kh-toasts { top: 56px; width: min(300px, 56vw); }
}
body.touch .kh-time { right: 16px; top: 86px; max-width: 210px; }
body.touch .kh-hot { top: 140px; bottom: auto; flex-direction: column; gap: 6px; }
body.touch .kh-hot .kh-sep { display: none; }
body.touch .kh-slot { width: 64px; min-height: 56px; }
body.touch .kh-build { left: 16px; right: 16px; top: 280px; width: auto; padding: 8px 10px; gap: 4px; }
body.touch .kh-vitals { gap: 4px; padding: 6px 8px; }
body.touch .kh-toasts { top: 56px; width: min(300px, 56vw); }
body.touch .kh-left { bottom: 180px; width: 240px; }

@media (prefers-reduced-motion: reduce) {
  .kh-vig.kh-on { animation: none; opacity: .6; }
  .kh-row.kh-crit { animation: none; background: rgba(150, 20, 35, .42); }
  .kh-flash.kh-flash-go { animation-name: kh-hit-soft; }
  .kh-toast { animation-name: kh-toast-fade; }
  .kh-wet, .kh-fill { transition: none; }
}
