:root {
  /* GIOTTV: Lila / Weiss / Schwarz */
  --bg: #08060e;
  --surface: #120d1d;
  --surface-2: #1c1430;
  --border: #2e2347;
  --text: #f5f2ff;
  --muted: #a99cc7;
  --accent: #8b1cff;
  --accent-2: color-mix(in srgb, var(--accent) 45%, #ffffff);
  --accent-deep: color-mix(in srgb, var(--accent) 55%, #000000);
  --ok: var(--accent-2);
  --danger: #ff4f8b;
  --display: 'Rajdhani', sans-serif;
  --body: 'Inter', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--body);
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 12px; }
h2 { font-size: 20px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
h3 { font-size: 15px; color: var(--muted); margin-top: 16px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12.5px; }
p { margin: 0 0 12px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.login-logo { width: 120px; height: 120px; object-fit: contain; margin: 0 auto 4px; }
.login-card h1 { font-size: 34px; margin: 0; letter-spacing: 0.14em; }
.login-card p { color: var(--muted); margin: 0 0 8px; }
.error { color: var(--danger); min-height: 1.2em; }

/* Kopfzeile */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px 0;
}
.brandbar { display: flex; align-items: center; gap: 10px; }
.brandbar-logo { width: 34px; height: 34px; object-fit: contain; }
.brandbar > b { font: 700 20px/1 var(--display); letter-spacing: 0.12em; }
.tt-status { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; margin-left: auto; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #666; flex: none; }
.dot.connected { background: var(--ok); box-shadow: 0 0 10px var(--accent); }
.dot.connecting, .dot.waiting { background: #fff; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
.stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 6px 0 8px; }
.stats b { color: var(--text); font-variant-numeric: tabular-nums; }
/* Alle Tabs sichtbar: auf schmalen Handys in zwei Reihen statt seitlich versteckt */
.tabs { display: flex; flex-wrap: wrap; justify-content: center; column-gap: 2px; margin: 0 -16px; padding: 0 8px; }
.tabs button {
  flex: none;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font: 700 15px/1 var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 9px 9px 10px;
  cursor: pointer;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 6px; font-size: 11px; margin-left: 2px; }
.badge:empty { display: none; }

/* Inhalte */
.tab { max-width: 720px; margin: 0 auto; padding: 14px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.row.tight { gap: 6px; flex-wrap: wrap; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid2 + .grid2, .grid2 + .btn, .card > .btn.block { margin-top: 10px; }

input, select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  font-size: 16px; /* verhindert Zoom auf iOS */
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type="color"] { padding: 4px; height: 44px; }
input[type="range"] { padding: 0; accent-color: var(--accent); border: 0; background: none; }
textarea { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.field > span { font-size: 13px; color: var(--muted); }
.field.inline-num { flex-direction: row; align-items: center; gap: 10px; margin: 0; }
.field.inline-num input { width: 90px; }
.inline { font: 400 13px/1 var(--body); text-transform: none; letter-spacing: 0; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
.inline input { width: auto; }

.switch { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.switch input {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 26px;
  flex: none;
  padding: 0;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.switch input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #bbb;
  transition: transform 0.2s, background 0.2s;
}
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(18px); background: #fff; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: 700 15px/1.1 var(--display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.btn.gold { color: #1a0b33; background: #ffffff; border-color: #ffffff; }
.btn.sm { min-height: 40px; min-width: 40px; padding: 8px 10px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button {
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font: 700 16px/1 var(--display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.seg button.active { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); border-color: var(--accent); color: #fff; }

/* Listen */
.list { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; }
.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.list li.empty { color: var(--muted); justify-content: center; padding: 14px; }
.list li.disabled { opacity: 0.5; }
.pos { width: 22px; text-align: center; font: 700 16px/1 var(--display); color: var(--muted); flex: none; }
/* Name + Epic-Name brauchen Platz: wird es zu eng, rutschen die Knoepfe in eine eigene Zeile */
.list li { flex-wrap: wrap; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 190px; }
.list li > .actions { margin-left: auto; }
.who-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.who-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.av {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: none;
  object-fit: cover;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 15px/1 var(--display);
}
.logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: contain;
  background: #fff;
  color: #120a20;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 18px/1 var(--display);
}
.actions { display: flex; gap: 4px; flex: none; }
.actions.wrap { flex-wrap: wrap; justify-content: flex-end; max-width: 50%; }
.chip {
  align-self: flex-start;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 3px 9px;
  font: 600 12.5px/1.3 var(--body);
  cursor: pointer;
}
.logo-preview { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 10px; }

.bar { height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; margin-bottom: 12px; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-deep), var(--accent), var(--accent-2)); transition: width 0.4s; }

/* Vorschau */
.preview {
  width: min(100%, 300px);
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  /* Platzhalter fuers Spielbild hinter dem transparenten Overlay */
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0.45)),
    linear-gradient(150deg, #2b2f4a, #3a2a5c 45%, #5a4a6e);
}
.preview iframe { width: 100%; height: 100%; border: 0; display: block; background: transparent; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: #f5f2ff;
  color: #120a20;
  font-weight: 600;
  z-index: 50;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 420px) {
  .grid2 { grid-template-columns: 1fr; }
  .actions.wrap { max-width: 60%; }
}

/* Alert-Warteschlange */
.aq-current { font-weight: 600; margin-bottom: 6px; overflow-wrap: anywhere; }
.aq-next { margin: 0 0 12px; padding-left: 20px; color: var(--muted); font-size: 13.5px; }
.aq-next:empty { display: none; }
.aq-next li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Layout-Editor: groesser als die normale Vorschau, auf dem Handy volle Breite */
.preview.editor { width: min(100%, 420px); touch-action: none; }

.aq-muted { margin: 4px 0 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--accent); font-weight: 600; }
.aq-row { margin-top: 8px; }
.presets { margin-bottom: 12px; }
