:root {
  --bg: transparent;
  --panel: rgba(16, 18, 28, 0.86);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #f2f3f7;
  --muted: #9aa0b4;
  --p1: #4cc2ff;
  --p2: #ff7a59;
  --ok: #4ade80;
  --dead: #f87171;
  --open: #6b7280;
  --hp: #4ade80;
  --hp-mid: #facc15;
  --hp-low: #f87171;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

body.edit { background: #0b0d14; }

.stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1080px;
  transform-origin: 0 0;
}

body.edit .stage {
  background:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px) 0 0 / 40px 40px,
    #12141c;
  outline: 1px solid rgba(255,255,255,0.15);
}

.slot {
  position: absolute;
  overflow: hidden;
}

.slot.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
}

.slot.hidden { display: none; }

body.edit .slot {
  outline: 1px dashed rgba(255,255,255,0.35);
  cursor: move;
  user-select: none;
}
body.edit .slot.hidden { display: block; opacity: 0.35; }
body.edit .slot.selected { outline: 2px solid #ffd166; }
body.edit .slot .label {
  position: absolute;
  left: 6px;
  top: 4px;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0,0,0,0.6);
  color: #ffd166;
  pointer-events: none;
  z-index: 5;
}
body.edit .slot .handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  background: #ffd166;
  cursor: nwse-resize;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  z-index: 5;
}

/* ---------- Video ---------- */

.slot.video {
  background: rgba(8, 9, 14, 0.9);
  border-radius: var(--radius);
}
.slot.video .frame {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--radius);
}
.slot.video video {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
}
.slot.video.pixelated video { image-rendering: pixelated; }
.slot.video .placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 22px;
  letter-spacing: 0.02em;
}
.slot.video.live .placeholder { display: none; }
.slot.video.p1 { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--p1) 60%, transparent); }
.slot.video.p2 { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--p2) 60%, transparent); }

/* ---------- Kopfzeile ---------- */

.head {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  font-size: 20px;
}
.head .name { font-weight: 700; font-size: 22px; }
.head.p1 .name { color: var(--p1); }
.head.p2 .name { color: var(--p2); }
.head .loc { color: var(--muted); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head .phase {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(250, 204, 21, 0.18); color: #fde68a; border: 1px solid rgba(250, 204, 21, 0.4);
}
.head .stats { display: flex; gap: 14px; color: var(--muted); font-size: 17px; }
.head .stats b { color: var(--text); font-weight: 600; }
.head .conn {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--dead);
  box-shadow: 0 0 8px var(--dead);
}
.head .conn.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

.badges { display: flex; gap: 5px; align-items: center; }
.badge {
  width: 28px; height: 28px;
  object-fit: contain;
  filter: grayscale(1) brightness(0.55) contrast(0.8);
  opacity: 0.45;
  transition: filter 0.4s, opacity 0.4s, transform 0.4s;
}
.badge.on {
  filter: none;
  opacity: 1;
  transform: scale(1.08);
  filter: drop-shadow(0 0 6px rgba(255, 220, 130, 0.7));
}

/* ---------- Team ---------- */

.team {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: min-content;
  align-content: start;
  gap: 5px;
  padding: 6px;
}
.mon {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 66px;
  box-sizing: border-box;
  background: rgba(255,255,255,0.04);
  border-radius: 7px;
  padding: 6px 7px;
  min-width: 0;
}
.mon.empty { opacity: 0.25; }
.mon .lvl {
  position: absolute; right: 7px; top: 6px;
  font-size: 10px; line-height: 1; color: var(--muted);
}
.mon .top { display: flex; align-items: center; gap: 5px; min-width: 0; height: 28px; padding-right: 34px; }
.mon .sprite {
  width: 28px; height: 28px;
  object-fit: contain;
  object-position: center;
  image-rendering: pixelated;
  flex: none;
}
.mon .names { min-width: 0; flex: 1; line-height: 1.2; }
.mon .nick {
  font-weight: 700; font-size: 11px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mon .sub { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mon .hp { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.1); overflow: hidden; }
.mon .hp i { display: block; height: 100%; background: var(--hp); transition: width 0.3s; }
.mon .hp.mid i { background: var(--hp-mid); }
.mon .hp.low i { background: var(--hp-low); }
.mon .partner {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; line-height: 1; color: var(--text);
  height: 16px;
  min-width: 0;
}
.mon .partner .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mon .partner .muted { color: var(--muted); }
.mon .partner img { width: 16px; height: 16px; object-fit: contain; image-rendering: pixelated; flex: none; }
.mon .pair {
  flex: none;
  font-size: 9px; font-weight: 800;
  padding: 0 4px; border-radius: 999px;
  background: rgba(255,255,255,0.12);
}
.mon .pair.linked { background: color-mix(in srgb, var(--ok) 35%, transparent); color: #d9fbe5; }
.mon .pair.broken { background: color-mix(in srgb, var(--dead) 40%, transparent); color: #ffe1e1; }
.mon.dead .sprite, .mon.dead .partner img { filter: grayscale(1) brightness(0.6); }
.mon.dead .nick { text-decoration: line-through; color: var(--muted); }
.mon.dead::after {
  content: "✝";
  position: absolute; left: 7px; top: 3px;
  font-size: 16px; color: var(--dead);
  text-shadow: 0 0 6px rgba(0,0,0,0.8);
}
.mon.partner-dead .pair { background: color-mix(in srgb, var(--dead) 40%, transparent); }
.mon .tag {
  position: absolute; right: 5px; top: 20px;
  font-size: 9px; font-weight: 800; letter-spacing: 0.06em;
  padding: 1px 5px; border-radius: 4px; z-index: 2;
}
.mon .tag.release { background: var(--dead); color: #fff; animation: v-pulse 1s ease-in-out infinite alternate; }
.mon .tag.sync { background: var(--warn); color: #1a1200; }
.mon.release { outline: 2px solid var(--dead); }
.head .stats .over b { color: var(--dead); }
.pair-row .mid { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.pair-row .area { font-size: 9px; color: var(--muted); white-space: nowrap; }
.pair-row.sync .area { color: var(--warn); font-weight: 700; }

/* ---------- Paare ---------- */

.pairs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px;
}
.pairs .title {
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.pair-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
}
.pair-row img { width: 36px; height: 36px; object-fit: contain; image-rendering: pixelated; justify-self: center; }
.pair-row .dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  background: var(--open); color: #fff;
}
.pair-row.linked .dot { background: var(--ok); color: #0b2e18; }
.pair-row.broken .dot { background: var(--dead); color: #fff; }
.pair-row .dead { filter: grayscale(1) brightness(0.5); }
.pair-row .none { width: 36px; height: 36px; justify-self: center; border-radius: 8px; border: 1px dashed rgba(255,255,255,0.15); }

/* ---------- Regelverstoß / Run gescheitert ---------- */

.violation.side {
  position: absolute;
  top: 300px;
  width: 760px;
  padding: 22px 26px;
  border-radius: 18px;
  background: rgba(60, 8, 8, 0.94);
  border: 3px solid #ff3b3b;
  box-shadow: 0 0 0 6px rgba(255, 59, 59, 0.25), 0 20px 60px rgba(0,0,0,0.7);
  z-index: 50;
  animation: v-pulse 1.2s ease-in-out infinite alternate;
}
.violation.side.p1 { left: 60px; }
.violation.side.p2 { left: 1100px; }
.violation.hidden, .failed-banner.hidden { display: none; }
.violation .v-title {
  font-size: 44px; font-weight: 900; letter-spacing: 0.06em;
  color: #ff4d4d; text-shadow: 0 0 18px rgba(255, 77, 77, 0.8);
}
.violation .v-rule { margin-top: 6px; font-size: 22px; font-weight: 700; color: #ffd166; }
.violation .v-text { margin-top: 10px; font-size: 19px; line-height: 1.35; color: var(--text); }
.violation .v-hint {
  margin-top: 16px; display: flex; flex-direction: column; gap: 6px;
  font-size: 17px; color: var(--muted);
}
.violation kbd {
  display: inline-block; padding: 1px 8px; border-radius: 6px;
  background: #fff; color: #111; font-family: inherit; font-weight: 700; font-size: 15px;
}
.violation .v-more { margin-top: 10px; font-size: 14px; color: var(--muted); }
@keyframes v-pulse { from { box-shadow: 0 0 0 4px rgba(255,59,59,0.18), 0 20px 60px rgba(0,0,0,0.7); } to { box-shadow: 0 0 0 10px rgba(255,59,59,0.35), 0 20px 60px rgba(0,0,0,0.7); } }

.failed-banner {
  position: absolute;
  left: 260px; top: 380px; width: 1400px;
  padding: 36px 40px;
  text-align: center;
  border-radius: 24px;
  background: rgba(10, 10, 14, 0.96);
  border: 4px solid #ff3b3b;
  box-shadow: 0 30px 90px rgba(0,0,0,0.8);
  z-index: 60;
}
.failed-banner .f-title { font-size: 92px; font-weight: 900; letter-spacing: 0.1em; color: #ff3b3b; text-shadow: 0 0 30px rgba(255,59,59,0.7); }
.failed-banner .f-sub { margin-top: 10px; font-size: 28px; font-weight: 700; color: #ffd166; }
.failed-banner .f-text { margin-top: 10px; font-size: 20px; color: var(--muted); }

/* ---------- Titel ---------- */

.titlebox {
  display: grid; place-items: center;
  font-size: 15px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Editor-Panel ---------- */

.editor {
  position: fixed;
  right: 16px;
  top: 16px;
  width: 320px;
  background: #1a1d29;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 14px;
  font-size: 13px;
  z-index: 100;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.editor-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.editor-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 8px 0; }
.editor label { display: flex; flex-direction: column; gap: 2px; color: var(--muted); }
.editor-row label { flex-direction: row; align-items: center; gap: 6px; }
.editor input[type=number], .editor select {
  background: #0f111a; color: var(--text); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px; padding: 4px 6px; font: inherit; width: 100%;
}
.editor button {
  background: #ffd166; color: #2b1d0e; border: 0; border-radius: 8px;
  padding: 6px 12px; font: inherit; font-weight: 600; cursor: pointer;
}
.editor button.secondary { background: rgba(255,255,255,0.1); color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.4; }
