/* Halloween-Overlay — gemeinsame Styles für Overlay (OBS) und Einrichtung. */

:root {
  color-scheme: dark;
  --color-primary: #ff8a1f;
  --color-secondary: #b98cff;
  --color-text: #ffffff;
  --color-text-dim: rgba(255, 255, 255, 0.65);
  --color-bg-panel: rgba(24, 18, 32, 0.88);
  --color-success: #2ecc71;
  --color-warn: #f5b942;
  --color-danger: #ff4d6d;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-ui: 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* overflow: hidden absichtlich NICHT hier, sondern nur auf .overlay-body —
   sonst lässt sich die Einrichtung (gleiche CSS-Datei) nicht scrollen. */
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  color: var(--color-text);
}

/* ================= Overlay (OBS Browser-Quelle) ================= */

body.overlay-body {
  background: transparent;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

.crawl-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.web-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.web-corner {
  position: absolute;
  animation: web-sway 7s ease-in-out infinite alternate;
}
@keyframes web-sway {
  from { transform: rotate(-0.6deg); }
  to   { transform: rotate(0.6deg); }
}
.web-svg { display: block; overflow: visible; }

.web-fly { position: absolute; }
.web-fly svg { width: 100%; height: 100%; display: block; overflow: visible; }
.web-fly .fly-body {
  transform-box: fill-box;
  transform-origin: 50% 10%;
  animation: fly-struggle 5s ease-in-out infinite;
}
@keyframes fly-struggle {
  0%, 70%, 100% { transform: rotate(0); }
  74% { transform: rotate(9deg); }
  78% { transform: rotate(-8deg); }
  82% { transform: rotate(7deg); }
  86% { transform: rotate(-5deg); }
  90% { transform: rotate(0); }
}
.web-fly .fly-wings {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: fly-buzz .09s linear infinite alternate;
}
@keyframes fly-buzz {
  from { transform: scaleY(1); }
  to   { transform: scaleY(.55); }
}

/* Die fette, nette Spinne */
.fs-wrap { position: absolute; }
.fs-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform-origin: 50% 85%;
  animation: fs-bob 2.6s ease-in-out infinite;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .35));
}
@keyframes fs-bob {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  50%      { transform: translateY(1.5%) scale(1.025, .975); }
}
.fs-arm {
  animation: fs-tap 1.7s ease-in-out infinite;
}
.fs-arm-r { animation-delay: .85s; }
@keyframes fs-tap {
  0%, 36%, 100% { transform: translateY(0); }
  9%  { transform: translateY(-11px); }
  18% { transform: translateY(0); }
  27% { transform: translateY(-6px); }
}
.fs-eyes {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: fs-blink 4.6s infinite;
}
@keyframes fs-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(.08); }
}
.fs-pupils { animation: fs-look 9s ease-in-out infinite; }
@keyframes fs-look {
  0%, 22%, 100% { transform: translate(0, 0); }
  28%, 48% { transform: translate(-4px, 1px); }
  54%, 74% { transform: translate(4px, 1px); }
  80%, 92% { transform: translate(0, -2px); }
}
.fs-tongue {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: fs-lick 6s ease-in-out infinite;
}
@keyframes fs-lick {
  0%, 78%, 100% { transform: translate(0, 0); }
  84% { transform: translate(7px, -3px) rotate(-15deg); }
  90% { transform: translate(11px, -5px) rotate(-25deg); }
  95% { transform: translate(0, 0); }
}
.fs-drool {
  transform-box: fill-box;
  transform-origin: 50% 0;
  animation: fs-drool 4.2s ease-in infinite;
}
@keyframes fs-drool {
  0%   { transform: translateY(0) scaleY(.3); opacity: 0; }
  15%  { opacity: .9; }
  70%  { transform: translateY(0) scaleY(1.5); opacity: .9; }
  88%  { transform: translateY(14px) scaleY(1.1); opacity: 0; }
  100% { transform: translateY(0) scaleY(.3); opacity: 0; }
}

/* Sprechblase */
.web-bubble {
  position: absolute;
  width: max-content;
  padding: .55em .85em;
  background: #fffaf2;
  color: #2a1530;
  border: .12em solid #2a1530;
  border-radius: 1em;
  font-family: 'Comic Sans MS', 'Segoe Print', 'Chalkboard SE', cursive;
  font-weight: 700;
  line-height: 1.25;
  box-shadow: 0 .2em .5em rgba(0, 0, 0, .35);
  opacity: 0;
  transform: scale(.4);
  transition: opacity .25s ease, transform .35s cubic-bezier(.2, 1.4, .4, 1);
  white-space: normal;
}
.web-bubble.from-left { transform-origin: 0 50%; }
.web-bubble.from-right { transform-origin: 100% 50%; }
.web-bubble.show { opacity: 1; transform: scale(1); }
.web-bubble::after {
  content: '';
  position: absolute;
  top: 1.1em;
  width: .9em;
  height: .9em;
  background: #fffaf2;
  border: .12em solid #2a1530;
  border-top: none;
  border-right: none;
}
.web-bubble.from-left::after { left: -.52em; transform: rotate(45deg); }
.web-bubble.from-right::after { right: -.52em; transform: rotate(-135deg); }
.web-bubble.above::after { top: auto; bottom: .7em; }

/* ================= Einrichtung ================= */

body.dashboard-body {
  min-height: 100vh;
  background: radial-gradient(circle at top, #2d1d3d 0%, #0c0910 65%);
  padding: 24px;
}

.dashboard-shell { max-width: 1560px; margin: 0 auto; }
.dashboard-shell h1 { font-size: 26px; margin: 0 0 4px; }
.subtitle { color: var(--color-text-dim); margin: 0 0 20px; }

.statusbar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  background: var(--color-bg-panel);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 18px;
  font-size: 13px;
}
.statusbar .dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--color-danger);
  margin-right: 6px;
  vertical-align: -1px;
}
.statusbar .dot.ok { background: var(--color-success); }
.statusbar .dot.warn { background: var(--color-warn); }
.statusbar code { user-select: all; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
@media (min-width: 1200px) {
  .layout { grid-template-columns: minmax(460px, 1fr) minmax(0, 1.2fr); }
  .col-preview { position: sticky; top: 16px; }
}

.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tab-btn { background: rgba(255, 255, 255, .06); color: var(--color-text-dim); }
.tab-btn.active { background: linear-gradient(90deg, var(--color-primary), var(--color-secondary)); color: #14101c; }
.tab-panel[hidden] { display: none; }

.card {
  background: var(--color-bg-panel);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-bottom: 18px;
}
.card h2 { font-size: 16px; margin: 0 0 12px; color: var(--color-primary); }
.card h3 { font-size: 14px; margin: 14px 0 8px; color: var(--color-secondary); }

.field-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 150px; }
.field[hidden] { display: none; }
.field label, .field .lbl { font-size: 12px; color: var(--color-text-dim); }
.field .lbl b { color: var(--color-text); font-weight: 600; }
.field input[type="text"],
.field input[type="number"],
.field textarea,
.field select {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--color-text);
  font-family: inherit;
  font-size: 14px;
}
.field textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
select option { background: #1b1424; color: #fff; }
.field input[type="color"] {
  width: 100%; height: 36px;
  border: none; border-radius: var(--radius-sm);
  background: transparent; cursor: pointer; padding: 0;
}
.field input[type="range"] { width: 100%; accent-color: var(--color-primary); }
.field.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.field.checkbox label { font-size: 14px; color: var(--color-text); cursor: pointer; }
.field.checkbox input { width: 18px; height: 18px; accent-color: var(--color-primary); cursor: pointer; }

button {
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text);
  transition: transform .1s ease, opacity .2s ease, background .2s;
}
button:active { transform: scale(.97); }
button.primary { background: linear-gradient(90deg, var(--color-primary), var(--color-secondary)); color: #14101c; }
button.secondary { background: rgba(255, 255, 255, .1); }
button.secondary:hover { background: rgba(255, 255, 255, .16); }
button.danger { background: rgba(255, 77, 109, .18); color: #ffb3c1; }
button.danger:hover { background: rgba(255, 77, 109, .3); }
button.small { padding: 6px 10px; font-size: 12px; }
button:disabled { opacity: .4; cursor: not-allowed; }

.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button { flex: 1; padding: 7px 8px; font-size: 13px; background: rgba(255, 255, 255, .07); color: var(--color-text-dim); }
.seg button.active { background: rgba(255, 138, 31, .3); color: #fff; }

.button-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.hint { font-size: 12px; color: var(--color-text-dim); margin: 6px 0 0; line-height: 1.5; }
.hint code, .card code { background: rgba(255, 255, 255, .08); padding: 1px 5px; border-radius: 4px; }
.save-status { font-size: 13px; margin-left: auto; }
.save-status.ok { color: var(--color-success); }
.save-status.err { color: var(--color-danger); }

/* Kacheln (Krabbeltiere, Spinnenarten) */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.tile {
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius-md);
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: opacity .2s, border-color .2s;
}
.tile.off { opacity: .5; }
.tile.off:hover { opacity: .8; }
.tile .tile-head { display: flex; align-items: center; gap: 8px; }
.tile .tile-head label { font-weight: 600; font-size: 14px; cursor: pointer; flex: 1; }
.tile .tile-head input { width: 18px; height: 18px; accent-color: var(--color-primary); cursor: pointer; }
.tile canvas {
  width: 100%;
  height: 74px;
  border-radius: var(--radius-sm);
  background: repeating-conic-gradient(#2a2234 0% 25%, #30283c 0% 50%) 50% / 18px 18px;
}
.tile .field { min-width: 0; }
.tile .field-row { margin-bottom: 0; gap: 10px; }

.style-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.style-grid canvas { height: 96px; }

/* Seilpunkt-Liste */
.anchor-list { display: flex; flex-direction: column; gap: 10px; }
.anchor-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.anchor-row.selected { border-color: var(--color-primary); }
.anchor-num {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #14101c;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.anchor-row .field-row { margin-bottom: 0; gap: 10px; }
.anchor-row .field { min-width: 110px; }
.empty-note {
  border: 2px dashed rgba(255, 255, 255, .15);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  color: var(--color-text-dim);
  font-size: 13px;
}

/* Vorschau */
.preview-frame-wrap {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .1);
  background: repeating-conic-gradient(#1c1724 0% 25%, #241e2e 0% 50%) 50% / 24px 24px;
  aspect-ratio: 16 / 9;
  position: relative;
}
.preview-frame-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.preview-frame-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 1920px; height: 1080px;
  border: none;
  transform-origin: 0 0;
  pointer-events: none;
  background: transparent;
}
.anchor-layer {
  position: absolute;
  inset: 0;
  display: none;
}
.anchor-layer.active { display: block; cursor: crosshair; }
.anchor-marker {
  position: absolute;
  width: 26px; height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid #fff;
  color: #14101c;
  font-weight: 800;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
  touch-action: none;
  user-select: none;
}
.anchor-marker.selected { background: #fff; border-color: var(--color-primary); }
.anchor-marker.off { opacity: .45; }
.anchor-marker:active { cursor: grabbing; }
.anchor-marker .len {
  position: absolute;
  left: 50%;
  top: 24px;
  width: 0;
  border-left: 2px dashed rgba(255, 138, 31, .8);
  pointer-events: none;
}
.preview-hint {
  position: absolute;
  left: 50%; bottom: 8px;
  transform: translateX(-50%);
  white-space: nowrap;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
}

.steps { margin: 0; padding-left: 20px; line-height: 1.8; font-size: 14px; }
.steps code { user-select: all; }
