body { font-family: var(--text); background: var(--bg); color: var(--bone); font-size: 15px; min-height: 100vh; }
h1, h2 { font-family: var(--display); font-weight: 900; }
h2 { font-size: 20px; }
a { color: inherit; text-decoration: none; }

/* ---------- Knöpfe */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 2px solid var(--line); background: var(--panel-2);
  font-weight: 600; white-space: nowrap; transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--violet); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.primary { background: var(--violet); border-color: var(--violet); color: #fff; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.good { background: var(--green); border-color: var(--green); color: var(--ink); }
.btn.bad { background: var(--red); border-color: var(--red); color: var(--ink); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.arming { background: var(--red); border-color: var(--red); color: var(--ink); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--panel); border: 2px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
input[type=number] { width: 72px; }

/* ---------- Login */
.login {
  max-width: 360px; margin: 18vh auto 0; padding: 28px; display: flex; flex-direction: column; gap: 12px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 18px;
}
.login h1 { font-size: 36px; }
.err { color: var(--red); min-height: 1.2em; }

/* ---------- Layout */
.app { display: grid; grid-template-columns: 380px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
.bar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  border-bottom: 2px solid var(--line); background: var(--panel);
}
.bar h1 { font-size: 24px; }
.bar h1 span { color: var(--accent); }
.bar nav { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.conn { font-family: var(--mono); font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--red); color: var(--ink); }
.conn.on { background: var(--green); }
.side { padding: 16px; display: flex; flex-direction: column; gap: 16px; border-right: 2px solid var(--line); }
.main { padding: 16px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card { background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.empty, .help, .q-empty { color: var(--muted); font-size: 14px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { border-right: 0; }
}

/* ---------- Spieler */
.players { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.player { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 10px; border-radius: 12px; background: var(--panel-2); border-left: 6px solid var(--pc); }
.player .name { width: 100%; min-width: 0; }
.player input[type=color] { width: 34px; height: 34px; padding: 0; border: 0; background: none; border-radius: 6px; }
.player .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); opacity: 0.4; }
.player .dot.on { background: var(--green); opacity: 1; }
.player .score { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.player .pts { font-family: var(--mono); font-size: 20px; color: var(--accent); width: 72px; text-align: center; padding: 4px 6px; }
/* Pfeile der Zahleneingabe ausblenden — dafür gibt es −1/+1 */
.player .pts::-webkit-inner-spin-button, .player .pts::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.player .pts { -moz-appearance: textfield; appearance: textfield; }
.player .links { margin-left: auto; display: flex; gap: 6px; }
.player.first { outline: 3px solid var(--pc); }

/* ---------- Spielauswahl */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.game {
  text-align: left; padding: 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; gap: 4px; min-height: 76px;
}
.game strong { font-family: var(--display); font-weight: 800; font-size: 18px; }
.game small { color: var(--muted); }
.game.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.game:disabled { opacity: 0.5; cursor: default; }

/* ---------- Quiz-Steuerung */
.buzz-state { font-family: var(--display); font-weight: 900; font-size: 26px; padding: 14px 18px; border-radius: 12px; background: var(--panel); border: 2px solid var(--line); }
.buzz-state.armed { border-color: var(--gold); color: var(--gold-ink); }
.buzz-state.locked { border-color: var(--pc); background: color-mix(in srgb, var(--pc) 22%, var(--panel)); }
.q-live { display: flex; flex-direction: column; gap: 12px; border-top: 2px solid var(--line); padding-top: 14px; }
.q-head { display: flex; justify-content: space-between; font-family: var(--mono); color: var(--muted); }
.pill { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); }
.pill.on { background: var(--green); color: var(--ink); border-color: var(--green); }
.q-text { font-family: var(--display); font-weight: 800; font-size: 24px; line-height: 1.25; }
.q-opts { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.q-opts button { width: 100%; text-align: left; justify-content: flex-start; padding: 12px 14px; font-size: 16px; white-space: normal; }
.q-opts .l { font-family: var(--mono); color: var(--accent); margin-right: 6px; }
.q-opts .is-correct::after { content: '★ richtig'; margin-left: auto; font-size: 12px; color: var(--green); }
.q-opts .locked { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.q-opts .wrong { background: var(--red); border-color: var(--red); color: var(--ink); }
.q-opts .correct { background: var(--green); border-color: var(--green); color: var(--ink); }
.q-opts .locked .l, .q-opts .wrong .l, .q-opts .correct .l,
.q-opts .locked::after, .q-opts .wrong::after, .q-opts .correct::after { color: var(--ink); }
.q-sol { color: var(--green); font-weight: 600; }
.q-sol:empty { display: none; }
.q-list-wrap summary { cursor: pointer; color: var(--muted); }
.q-list { margin-top: 8px; padding-left: 28px; display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow: auto; }
.q-list button { background: none; border: 0; padding: 4px 6px; text-align: left; border-radius: 6px; width: 100%; }
.q-list button:hover { background: var(--panel-2); }
.q-list .cur button { background: var(--panel-2); color: var(--accent); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--bone); color: var(--bg); font-weight: 600; padding: 10px 18px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* ---------- Stop at exact time */
.t-target { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.t-target input[type=number] { width: 110px; font-family: var(--mono); font-size: 18px; }
.t-table { width: 100%; border-collapse: collapse; }
.t-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 2px solid var(--line); }
.t-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t-table .who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.t-table .who::before { content: ''; width: 8px; height: 22px; border-radius: 4px; background: var(--pc); }
.t-table .ms, .t-table .diff { font-family: var(--mono); font-size: 16px; }
.t-table .best .diff { color: var(--green); font-weight: 700; }
.t-table .src { font-size: 11px; color: var(--gold-ink); margin-left: 6px; }
.t-table .acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.t-phase { font-size: 13px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); }
.t-phase.armed { background: var(--gold); color: var(--ink); }
.t-phase.running { background: var(--accent); color: #fff; }
.t-phase.stopped { background: var(--bone); color: var(--bg); }
.t-phase.revealed { background: var(--green); color: var(--ink); }

/* ---------- Overlay-Layout-Editor */
.lprev {
  position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 12px;
  border: 2px solid var(--line); touch-action: none;
  background-color: #33433a;
  background-image: repeating-conic-gradient(#3c4e44 0% 25%, #33433a 0% 50%); background-size: 40px 40px;
}
/* geladener Szenen-Screenshot füllt die Vorschau genau (16:9) */
.lprev.has-bg { background-size: 100% 100%; background-repeat: no-repeat; }
.lstage { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 0 0; }
.lstage .cards { position: absolute; inset: 0; pointer-events: none; }
.lstage .pcard { cursor: grab; pointer-events: auto; }
.lstage .pcard.dragging { cursor: grabbing; outline: 4px dashed #fff; outline-offset: 8px; border-radius: 16px; }
.l-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.l-controls input[type=range] { width: 160px; accent-color: var(--accent); }
#lScaleVal { font-family: var(--mono); min-width: 44px; }

/* Platzhalter Spielbereich: Anker wie im Overlay; Breite/Höhe je Spiel (GAME_AREAS) per Inline-Stil */
.lgame {
  position: absolute; left: 50%; top: 94.8%;
  transform: translate(-50%, -100%) scale(var(--gs, 1)); transform-origin: 50% 100%;
  border: 6px dashed rgba(255, 255, 255, 0.75); border-radius: 30px; background: rgba(211, 235, 218, 0.35);
  display: grid; place-items: center; text-align: center; cursor: grab;
  font-family: var(--display); font-weight: 800; font-size: 54px; color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.lgame small { font-size: 30px; font-weight: 600; }
.lgame.dragging { cursor: grabbing; border-color: #fff; }
#lGameScaleVal { font-family: var(--mono); min-width: 44px; }

/* Hilfslinien beim Ausrichten: Bühnenmitte magenta, bündig mit anderem Element cyan */
.lguides { position: absolute; inset: 0; pointer-events: none; }
.guide { position: absolute; }
.guide.v { top: 0; bottom: 0; width: 0; border-left: 2px dashed; transform: translateX(-1px); }
.guide.h { left: 0; right: 0; height: 0; border-top: 2px dashed; transform: translateY(-1px); }
.guide.center { border-color: #ff3fb4; }
.guide.align { border-color: #2fd4ff; }
.lstage .pcard.selected, .lgame.selected { outline: 4px solid #2fd4ff; outline-offset: 8px; border-radius: 16px; }
.hint-k { color: var(--muted); }

#setVolume { width: 140px; accent-color: var(--accent); }
.mono { font-family: var(--mono); min-width: 44px; }

/* ---------- Slice in half */
.s-objects { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.s-obj { padding: 6px; border-radius: 10px; border: 2px solid var(--line); background: var(--panel-2); display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; }
.s-obj img { width: 64px; height: 64px; object-fit: contain; pointer-events: none; }
.s-obj.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.s-obj.busy { opacity: 0.5; }

/* ---------- Einordnen: Zeitstrahl */
.o-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.o-pool-head { display: flex; align-items: center; gap: 10px; }
.o-pool-head h3 { font-family: var(--display); font-size: 16px; }
.o-pool { display: flex; flex-wrap: wrap; gap: 6px; }
.o-pool small { color: var(--muted); font-family: var(--mono); }
.o-current { font-size: 17px; }
.o-cur { font-family: var(--display); font-weight: 800; color: var(--gold-ink); }
.o-line { display: flex; align-items: stretch; gap: 4px; overflow-x: auto; padding: 6px 2px; }
.o-item { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 96px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); border: 2px solid var(--line); text-align: center; }
.o-item b { font-size: 14px; }
.o-item small { font-family: var(--mono); color: var(--accent); }
.o-item.ok { border-color: var(--green); }
.o-item.bad { border-color: var(--red); }
.o-gap { flex: 0 0 auto; min-width: 22px; border-radius: 8px; border: 2px dashed transparent; background: none; color: var(--muted); padding: 0 4px; }
button.o-gap { border-color: var(--line); }
button.o-gap:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.o-gap.here { background: var(--panel); border: 2px solid var(--accent); color: var(--bone); font-weight: 700; min-width: 96px; }
.o-gap.here.locked { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.o-last { font-weight: 600; padding: 8px 12px; border-radius: 10px; }
.o-last.ok { background: color-mix(in srgb, var(--green) 18%, transparent); }
.o-last.bad { background: color-mix(in srgb, var(--red) 18%, transparent); }

.lgame.anchor-top { transform: translate(-50%, 0) scale(var(--gs, 1)); transform-origin: 50% 0; }
