:root {
  --yellow: #f5b800;
  --yellow-dark: #b78700;
  --steel: #14141c;
  --ember: #ff7a1a;
  --card: #14141c;
  --text: #f2eadf;
  --muted: #b9ae9d;
  --jib-y: 150px;
  --jib-h: 14px;
  --fire: 1; /* 0..1, wird von fire.js gesetzt */
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; background: #04050c; }

body {
  margin: 0;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(#04050c 0%, #0d0a1d 45%, #26101a 78%, #4a170f 100%);
  background-attachment: fixed;
}

/* ---------- Himmel, Stadt, Feuer ---------- */
body::before { /* Sterne */
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 120px 80px, #fffa, transparent),
    radial-gradient(1.5px 1.5px at 200px 150px, #fff, transparent),
    radial-gradient(1px 1px at 70px 190px, #fff8, transparent);
  background-size: 260px 220px;
  mask-image: linear-gradient(#000 20%, transparent 70%);
  -webkit-mask-image: linear-gradient(#000 20%, transparent 70%);
}
.moon {
  position: fixed; top: 70px; right: 9%; width: 70px; height: 70px; border-radius: 50%; z-index: 0;
  background: radial-gradient(circle at 35% 35%, #fff7e0, #d9c9a0 60%, #a89a76);
  box-shadow: 0 0 40px 10px rgba(255, 240, 200, .25), 0 0 120px 40px rgba(255, 200, 140, .12);
}
.skyline {
  position: absolute; left: 0; bottom: 22px; width: 100%; height: 260px; z-index: 0;
  pointer-events: none;
}
.glow {
  position: absolute; left: 0; right: 0; bottom: 0; height: 75vh; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse 70% 100% at 50% 100%, rgba(255, 110, 20, .6), rgba(200, 40, 10, .22) 45%, transparent 75%);
  opacity: calc(.1 + var(--fire) * .9);
}
.fire {
  position: absolute; left: 0; bottom: 22px; width: 100%; height: 380px; z-index: 1; pointer-events: none;
}

header { padding: 28px 16px 0 88px; text-align: center; position: relative; z-index: 2; }
h1 {
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", "Arial Black", sans-serif;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: clamp(1.7rem, 5.4vw, 3.4rem);
  line-height: 1.05;
  background: linear-gradient(#fff3b0, var(--yellow) 45%, #ff6a00);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 0 14px rgba(255, 140, 0, .55)) drop-shadow(0 3px 0 #000);
  animation: flicker 5s infinite;
}
h1 span { display: block; font-size: .55em; letter-spacing: .3em; }
@keyframes flicker {
  0%, 100% { opacity: 1; } 46% { opacity: 1; } 47% { opacity: .75; } 48% { opacity: 1; } 71% { opacity: .9; } 72% { opacity: 1; }
}

/* ---------- Kran ---------- */
.crane {
  position: absolute; inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 10;
}
.crane > * { filter: drop-shadow(0 0 5px rgba(245, 184, 0, .3)); }
.tower {
  position: absolute; left: 24px; width: 40px;
  top: var(--jib-y); bottom: 0;
  border-inline: 5px solid var(--yellow);
  background:
    repeating-linear-gradient(45deg, transparent 0 14px, var(--yellow) 14px 17px),
    repeating-linear-gradient(-45deg, transparent 0 14px, var(--yellow) 14px 17px);
}
.counterweight {
  position: absolute; left: 0; top: calc(var(--jib-y) + var(--jib-h));
  width: 26px; height: 34px; background: #3a3a46; border-radius: 0 0 4px 4px;
}
.jib {
  position: absolute; left: 0; right: 0; top: var(--jib-y); height: var(--jib-h);
  background:
    repeating-linear-gradient(90deg, transparent 0 12px, var(--yellow-dark) 12px 14px),
    var(--yellow);
  border-block: 3px solid var(--yellow-dark);
}
.jib::after { /* Warnlicht */
  content: ""; position: absolute; left: 36px; top: -16px; width: 9px; height: 9px; border-radius: 50%;
  background: #ff2d2d; box-shadow: 0 0 12px 4px rgba(255, 45, 45, .8);
  animation: blink 1.4s steps(1) infinite;
}
@keyframes blink { 50% { opacity: .15; } }
.trolley {
  position: absolute; left: 60%;
  top: calc(var(--jib-y) + var(--jib-h));
  width: 0;
}
.trolley::before { /* Laufkatze */
  content: ""; position: absolute; left: -14px; top: -8px; width: 28px; height: 10px;
  background: #3a3a46; border-radius: 2px;
}
.cable {
  position: absolute; left: -1px; top: 0; width: 2px; height: 60px;
  background: #9aa0ad;
  transform-origin: 50% 0;
}
.hook {
  position: absolute; left: 50%; top: 100%;
  width: 40px; margin-left: -20px;
}
.hook svg { display: block; }
.load {
  position: absolute; left: 50%; top: 62px;
  transform: translateX(-50%);
  display: none;
}
.load .card { visibility: visible; pointer-events: none; box-shadow: 0 0 30px rgba(255, 140, 0, .5), 0 12px 24px rgba(0, 0, 0, .6); }
.load::before { /* Anschlagketten */
  content: ""; position: absolute; left: 50%; top: -8px; width: 70%; height: 10px;
  transform: translateX(-50%);
  border: 2px solid #9aa0ad; border-bottom: 0; border-radius: 40px 40px 0 0;
}

.sway { animation: sway 2.8s ease-in-out infinite; }
.swing-once { animation: sway 1s ease-out 1; }
.shake { animation: shake .5s; }
@keyframes sway { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-9px); } 40%,80% { transform: translateX(9px); } }

/* ---------- Inhalt ---------- */
main {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  min-height: 100vh;
  max-width: 980px; margin: 0 auto;
  padding: 120px 16px 150px;
}
@media (max-width: 1100px) { main { padding-left: 88px; } }

.gate {
  width: 100%; max-width: 560px; margin: 0 auto auto;
  background: rgba(16, 16, 26, .9); border: 2px solid var(--yellow); border-radius: 14px;
  padding: 22px 22px 18px;
  box-shadow: 0 0 40px rgba(255, 120, 20, .35), 0 20px 40px rgba(0, 0, 0, .6);
  backdrop-filter: blur(4px);
  position: relative;
}
.gate::before { /* Warnstreifen */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 12px;
  border-radius: 11px 11px 0 0;
  background: repeating-linear-gradient(-45deg, var(--yellow) 0 14px, #14141c 14px 28px);
}
.gate .label { margin: 14px 0 14px; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ember); }
form { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
#fields { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.q { display: flex; flex-direction: column; gap: 8px; font-size: 1.1rem; font-weight: 600; }
input {
  width: 100%; font: inherit; padding: 11px 12px;
  border: 2px solid #4a4a5c; border-radius: 8px; background: #0b0b12; color: var(--text);
}
input::placeholder { color: #6d6a78; }
input:focus-visible, button:focus-visible, .card:focus-visible { outline: 3px solid #5aa9ff; outline-offset: 2px; }
input:focus { border-color: var(--yellow); }
button {
  font: inherit; font-weight: 800; padding: 11px 20px; cursor: pointer;
  background: linear-gradient(#ffd24a, var(--yellow)); color: #14141c;
  border: 0; border-radius: 8px;
  box-shadow: 0 4px 0 var(--yellow-dark), 0 0 20px rgba(245, 184, 0, .35);
}
button:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--yellow-dark); }
button:disabled { opacity: .6; cursor: progress; }
.msg { min-height: 1.4em; margin: 10px 0 0; color: #ff7a6e; font-weight: 600; }
.hintbtn { margin-top: 4px; padding: 6px 10px; font-size: .85rem; box-shadow: none; background: #2a2a38; color: var(--text); }

.grid {
  display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-top: auto;
  padding-top: 80px;
}
.card {
  display: flex; flex-direction: column; gap: 4px;
  min-height: 130px; padding: 16px 18px;
  background: linear-gradient(160deg, #1d1d2a, var(--card)); color: inherit; text-decoration: none;
  border: 2px solid var(--yellow); border-radius: 12px;
  box-shadow: 0 0 22px rgba(255, 130, 20, .3), inset 0 0 18px rgba(245, 184, 0, .06);
  transition: transform .15s, box-shadow .15s;
}
.grid .card { visibility: hidden; }
.grid .card.placed { visibility: visible; }
.grid .card.placed:hover { transform: translateY(-4px); box-shadow: 0 0 34px rgba(255, 150, 30, .6), inset 0 0 18px rgba(245, 184, 0, .12); }
.card .icon { font-size: 2rem; line-height: 1; }
.card .t { font-weight: 800; font-size: 1.15rem; color: #ffd24a; }
.card .d { font-size: .92rem; color: var(--muted); flex: 1; }
.card .u { font-size: .78rem; color: #8f8577; word-break: break-all; }
.card .status { display: flex; align-items: center; gap: 7px; margin-top: 6px; font-size: .8rem; color: var(--muted); }
.card .status b { font-weight: 600; }
.card .status i { width: 9px; height: 9px; border-radius: 50%; background: #8f8577; flex: none; }
.card .status[data-state="checking"] i { animation: pulse 1s ease-in-out infinite; }
.card .status[data-state="up"] { color: #7ee08a; }
.card .status[data-state="up"] i { background: #3ddc5a; box-shadow: 0 0 8px #3ddc5a; }
.card .status[data-state="down"] { color: #ff8a80; }
.card .status[data-state="down"] i { background: #ff4d3d; box-shadow: 0 0 8px #ff4d3d; }
@keyframes pulse { 50% { opacity: .25; } }
.card.land { animation: land .5s cubic-bezier(.3,1.6,.5,1); }
@keyframes land { 0% { transform: translateY(-14px); } 100% { transform: none; } }

footer {
  position: absolute; left: 0; right: 0; bottom: 0; height: 22px;
  background: repeating-linear-gradient(-45deg, var(--yellow) 0 18px, #14141c 18px 36px);
  z-index: 11;
}
.nojs { text-align: center; padding: 20px; position: relative; z-index: 20; }

@media (prefers-reduced-motion: reduce) {
  .sway, .swing-once, .shake, .card.land, h1, .jib::after, .card .status i { animation: none; }
  html { scroll-behavior: auto; }
}
