/* Valhalla Discovery – bewusst ohne externe Schriften (DSGVO, kein Google-Fonts-Aufruf) */
:root {
  --bg: #121016;
  --panel-bg: rgba(16, 13, 20, 0.86);
  --panel-edge: #050407;
  --panel-hi: #3b2f3e;
  --text: #ece6dc;
  --muted: #a39a90;
  --blood: #c0262f;
  --blood-dark: #7d1219;
  --gold: #d9ae4a;
  --ok: #7fd650;
  --warn: #f0a33a;
  --font: ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 12px/1.45 var(--font);
  user-select: none;
  -webkit-user-select: none;
}

button, input { font: inherit; color: inherit; }

#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  cursor: pointer;
}

/* Spiel-UI erst nach dem Login zeigen */
body:not(.ingame) #hud,
body:not(.ingame) #online,
body:not(.ingame) #hotbar,
body:not(.ingame) #help { display: none; }

/* ---------- Pixel-Panel ---------- */
.panel {
  background: var(--panel-bg);
  border: 2px solid var(--panel-edge);
  box-shadow: inset 0 0 0 1px var(--panel-hi), 3px 3px 0 rgba(0, 0, 0, 0.4);
  padding: 6px 9px;
}
.head {
  color: var(--gold);
  letter-spacing: 2px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

/* ---------- Logo ---------- */
.logo {
  font-weight: 900;
  font-size: 26px;
  letter-spacing: 4px;
  color: var(--blood);
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #3a0a0e;
  line-height: 1.05;
  text-align: center;
}
.logo span {
  display: block;
  font-size: 13px;
  letter-spacing: 7px;
  color: var(--gold);
  text-shadow: 1px 1px 0 #000;
}
.logo.small { font-size: 14px; letter-spacing: 2px; text-align: left; margin-bottom: 4px; }
.logo.small span { display: inline; font-size: 10px; letter-spacing: 3px; margin-left: 2px; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 10px; left: 10px;
  min-width: 210px;
}
#hud .row { display: flex; gap: 8px; white-space: nowrap; }
#hud .lbl { color: var(--muted); width: 56px; flex: none; }
#hud .hl { color: var(--gold); }
.dot {
  width: 8px; height: 8px; margin-top: 4px; flex: none;
  background: var(--warn);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.3);
}
.dot.on { background: var(--ok); }
.link {
  background: none; border: 0; padding: 0; margin-top: 4px;
  color: var(--muted); text-decoration: underline; cursor: pointer;
}
.link:hover { color: var(--text); }

/* ---------- Online-Liste ---------- */
#online {
  position: fixed; top: 10px; right: 10px;
  width: 230px;
  max-height: 45vh;
  overflow: auto;
}
#online ul { list-style: none; margin: 0; padding: 0; }
#online li {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 1px 0;
  white-space: nowrap;
}
#online li::before { content: '■'; color: var(--ok); margin-right: 5px; font-size: 9px; line-height: 17px; }
#online li .n { overflow: hidden; text-overflow: ellipsis; flex: 1; }
#online li .d { color: var(--muted); }
#online li.me .n { color: var(--gold); }
#online li.note { color: var(--muted); white-space: normal; font-size: 11px; }
#online li.note::before { content: ''; margin: 0; }

/* ---------- Inventar ---------- */
#hotbar {
  position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 5px;
  padding: 6px 8px;
}
.vitals { display: flex; justify-content: space-between; gap: 12px; }
.bar { display: flex; gap: 1px; }
.bar img { width: 20px; height: 18px; image-rendering: pixelated; }
#food.low img { animation: hunger 1.2s steps(2) infinite; }
#food.pulse { animation: pulse 0.25s steps(2) 3; }
@keyframes hunger { 50% { opacity: 0.55; } }
@keyframes pulse { 50% { transform: translateY(-3px); } }

.slots { display: flex; align-items: center; gap: 6px; }
.slot {
  position: relative;
  width: 40px; height: 40px;
  background: #0b090e;
  border: 2px solid #2b2330;
  display: grid; place-items: center;
  padding: 0;
}
.slot img { width: 32px; height: 32px; image-rendering: pixelated; }
.slot .n {
  position: absolute; right: 2px; bottom: 0;
  font-weight: bold; font-size: 12px;
  text-shadow: 1px 1px 0 #000, -1px 0 0 #000;
}
.slot.eat { cursor: pointer; border-color: #4a2a30; }
.slot.eat:hover { border-color: var(--blood); }
.slot.eat.empty img { opacity: 0.3; filter: grayscale(1); }
.slot.eat kbd { position: absolute; left: 1px; top: 0; margin: 0; padding: 0 2px; font-size: 9px; border: 0; color: var(--muted); }
.slot.tool img { opacity: 0.22; filter: grayscale(1); }
.slot.tool .n { top: 0; bottom: auto; right: 2px; font-size: 11px; color: var(--gold); }
.slot.tool .wear { position: absolute; left: 3px; right: 3px; bottom: 2px; height: 3px; background: #2b2330; display: none; }
.slot.tool .wear i { display: block; height: 100%; width: 0; }
.slot.tool.owned { border-color: var(--gold); }
.slot.tool.owned img { opacity: 1; filter: none; }
.slot.tool.owned .wear { display: block; }
.sep { width: 2px; align-self: stretch; background: #2b2330; margin: 2px 2px; }

#btn-craft, .make, .primary, .tabs button, .name-roll button {
  background: var(--blood-dark);
  border: 2px solid #000;
  box-shadow: inset 0 0 0 1px #b8323b;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: bold;
  letter-spacing: 1px;
}
#btn-craft:hover, .make:hover:not(:disabled), .primary:hover:not(:disabled) { background: var(--blood); }
kbd {
  font: inherit; font-size: 10px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 0 3px; margin-left: 3px;
}
button:disabled { opacity: 0.45; cursor: default; }

/* ---------- Herstellen ---------- */
#craft {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 20px));
  padding: 10px 12px;
  background: #120f16;
  z-index: 5;
}
#craft-close {
  background: none; border: 0; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted);
}
.recipe {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-top: 2px solid #2b2330;
}
.recipe img.big { width: 48px; height: 48px; image-rendering: pixelated; flex: none; }
.recipe .info { flex: 1; min-width: 0; }
.recipe .name { color: var(--gold); font-weight: bold; }
.recipe .desc { color: var(--muted); font-size: 11px; }
.recipe .cost { display: flex; gap: 10px; margin-top: 3px; flex-wrap: wrap; }
.recipe .c { display: inline-flex; align-items: center; gap: 3px; }
.recipe .c img { width: 16px; height: 16px; image-rendering: pixelated; }
.recipe .c.missing { color: #ff6b6b; }
.recipe .have { color: var(--ok); font-weight: normal; font-size: 11px; }
label .sub { font-size: 10px; opacity: 0.8; }

/* ---------- Meldungen ---------- */
#toasts {
  position: fixed; left: 50%; top: 12px; transform: translateX(-50%);
  z-index: 6;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  pointer-events: none;
  width: max-content; max-width: calc(100vw - 20px);
}
.toast {
  background: var(--panel-bg);
  border: 2px solid var(--panel-edge);
  box-shadow: inset 0 0 0 1px var(--panel-hi);
  padding: 4px 10px;
  transition: opacity 0.4s;
  text-align: center;
}
.toast.ok { color: var(--ok); }
.toast.error { color: #ff7b7b; }
.toast.out { opacity: 0; }

/* ---------- Namensschilder & schwebende Texte ---------- */
#overlay { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag, .floater {
  position: absolute; left: 0; top: 0;
  white-space: nowrap;
  font-size: 11px;
  text-shadow: 1px 0 0 #000, -1px 0 0 #000, 0 1px 0 #000, 0 -1px 0 #000;
  will-change: transform;
}
.tag { color: #f2ede4; }
.tag.self { color: var(--gold); }
.floater { color: var(--gold); font-weight: bold; font-size: 13px; }

/* ---------- Hilfe ---------- */
#help {
  position: fixed; right: 10px; bottom: 10px;
  color: var(--muted);
  pointer-events: none;
  font-size: 11px;
}
#help b { color: var(--text); font-weight: normal; }

/* ---------- Vollbild-Screens ---------- */
.screen {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(125, 18, 25, 0.35), transparent 60%),
    linear-gradient(#17121b, #0b090d);
  padding: 10px;
}
#loading .panel { font-size: 14px; padding: 10px 16px; }

.auth-box { width: min(380px, 100%); padding: 18px 18px 14px; user-select: text; }
.auth-box .logo { margin-bottom: 14px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { flex: 1; background: #1d1722; box-shadow: inset 0 0 0 1px #3b2f3e; }
.tabs button.active { background: var(--blood-dark); box-shadow: inset 0 0 0 1px #b8323b; }
form { display: flex; flex-direction: column; gap: 4px; }
form label { color: var(--muted); margin-top: 6px; }
form input {
  background: #0b090e;
  border: 2px solid #2b2330;
  padding: 7px 8px;
  outline: none;
  width: 100%;
}
form input:focus { border-color: var(--gold); }
.name-roll { display: flex; gap: 6px; }
.name-roll input { color: var(--gold); font-weight: bold; }
.name-roll button { flex: none; background: #1d1722; box-shadow: inset 0 0 0 1px #3b2f3e; }
.hint { color: var(--muted); font-size: 11px; margin: 8px 0 4px; }
.primary { margin-top: 8px; padding: 9px; }
.error { color: #ff7b7b; min-height: 18px; margin-top: 8px; }

.hidden { display: none !important; }

/* ---------- mittlere Breiten: Hilfe über die Inventarleiste schieben ---------- */
@media (max-width: 1300px) {
  #help { bottom: 112px; }
}

/* ---------- schmale Bildschirme ---------- */
@media (max-width: 640px) {
  #hud { min-width: 0; max-width: 48vw; font-size: 11px; }
  #hud .lbl { width: 46px; }
  #online { width: 46vw; font-size: 11px; }
  #hotbar { gap: 4px; padding: 5px 6px; width: calc(100vw - 16px); }
  .vitals { flex-direction: column; gap: 2px; align-items: center; }
  .bar img { width: 16px; height: 15px; }
  .slots { gap: 4px; justify-content: center; }
  .slot { width: 36px; height: 36px; }
  .slot img { width: 28px; height: 28px; }
  #btn-craft { padding: 6px 7px; }
  #btn-craft kbd, .slot.eat kbd { display: none; }
  #help { left: 10px; bottom: 140px; right: auto; }
  #toasts { top: auto; bottom: 150px; }
}
