:root {
  --bg: #0b0d12;
  --bg-soft: #121620;
  --bg-card: #161b26;
  --line: #232a38;
  --text: #e8ecf5;
  --muted: #8e99ae;
  --accent: #ff5f6d;
  --accent-2: #ffc371;
  --good: #4fd1c5;
  --warn: #ffc371;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Muss sein: Autoren-CSS schlaegt das Browser-Standard-Stylesheet, sonst
   ueberschreibt jede display-Regel weiter unten das hidden-Attribut und die
   Elemente lassen sich per JS nicht mehr ausblenden. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ------------------------------------------------------------------ Buttons */

.btn {
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  transition: transform .12s ease, background .18s ease, border-color .18s ease, opacity .18s ease;
}
.btn:hover { background: #1c2231; border-color: #2f3849; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #1a0d10;
}
.btn-primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-ghost { background: transparent; }
.btn-lg { padding: 14px 26px; font-size: 16px; border-radius: 12px; }
.btn-block { width: 100%; margin-top: auto; }

/* ---------------------------------------------------------------- Startseite */

.landing {
  position: relative;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 24px;
  overflow-y: auto;
}
.landing-glow {
  position: fixed;
  inset: -30% -10% auto -10%;
  height: 70vh;
  background: radial-gradient(50% 60% at 30% 40%, rgba(255, 95, 109, .22), transparent 70%),
              radial-gradient(45% 55% at 75% 30%, rgba(99, 179, 237, .18), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
}
.landing-inner { position: relative; max-width: 720px; width: 100%; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .18em; font-size: 14px; }
.brand-mark { font-size: 18px; }
.brand.small { letter-spacing: .12em; font-size: 12px; color: var(--muted); }

.landing h1 {
  font-size: clamp(34px, 6vw, 58px);
  line-height: 1.06;
  margin: 22px 0 14px;
  letter-spacing: -.02em;
}
.landing h1 em {
  font-style: normal;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { color: var(--muted); font-size: 17px; max-width: 52ch; margin: 0 0 30px; }

.landing-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.join-form { display: flex; gap: 8px; }
.join-form input {
  width: 116px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  text-transform: uppercase;
  letter-spacing: .22em;
  font-weight: 700;
  text-align: center;
}
.join-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.features {
  list-style: none;
  padding: 0;
  margin: 44px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}
.features li {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.features b { display: block; margin-bottom: 5px; }
.features span { color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- Raum-Shell */

.room { height: 100%; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  flex-shrink: 0;
}
.spacer { flex: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  color: var(--text);
  transition: background .18s ease, border-color .18s ease;
  max-width: 200px;
}
.chip:hover { background: #1c2231; }
.chip-label { color: var(--muted); }
.chip-code b { letter-spacing: .16em; font-weight: 700; }
.chip-danger:hover { border-color: var(--accent); color: var(--accent); }
.chip > span:not(.chip-label):not(.dot) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip-sync .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .05);
  transition: background .3s ease;
}
.chip-sync.ok .dot { background: var(--good); }
.chip-sync.drift .dot { background: var(--warn); }
.chip-sync.bad .dot { background: var(--accent); }

.stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

/* -------------------------------------------------------------------- Player */

.player-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.player-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.player-wrap iframe, #player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Klicks gehen an unsere Steuerung, nicht an YouTube - sonst laeuft ein Client aus dem Sync. */
.player-wrap iframe { pointer-events: none; }
.player-wrap { cursor: pointer; }

.player-idle, .gate {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 6px;
  padding: 24px;
  background: radial-gradient(60% 60% at 50% 45%, #151a25, #0b0d12);
  z-index: 3;
}
.player-idle h2, .gate h2 { margin: 0; font-size: 20px; }
.player-idle p, .gate p { margin: 0; color: var(--muted); }
.idle-art { font-size: 46px; margin-bottom: 6px; }
.gate { background: rgba(6, 8, 12, .82); backdrop-filter: blur(6px); z-index: 5; cursor: default; }
.gate-card { display: grid; gap: 12px; justify-items: center; }
.gate-code { font-size: 12px; color: var(--muted); letter-spacing: .1em; }
.gate-code b { color: var(--text); letter-spacing: .22em; }
#gateName {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  text-align: center;
  min-width: 220px;
}
#gateName:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Vollbild umfasst auch die Steuerleiste. */
.player-col:fullscreen { background: var(--bg); padding: 0 0 8px; gap: 8px; }
.player-col:fullscreen .player-wrap { border: 0; border-radius: 0; }
.player-col:fullscreen .controls { border: 0; border-radius: 0; }
.player-col:fullscreen .now-playing { display: none; }

.reactions { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.float-emoji {
  position: absolute;
  bottom: 8%;
  font-size: 34px;
  animation: floatUp 2.6s ease-out forwards;
  text-shadow: 0 4px 14px rgba(0, 0, 0, .6);
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translateY(20px) scale(.6); }
  15%  { opacity: 1; transform: translateY(0) scale(1.15); }
  100% { opacity: 0; transform: translateY(-260px) scale(.9) rotate(var(--spin, 12deg)); }
}

.wait-badge {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 13, 18, .88);
  border: 1px solid var(--warn);
  color: var(--warn);
  padding: 7px 15px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 4;
  backdrop-filter: blur(6px);
}

/* ------------------------------------------------------------------ Controls */

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  flex-shrink: 0;
}
.ctrl {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  transition: background .16s ease, color .16s ease, opacity .16s ease;
  flex-shrink: 0;
}
.ctrl:hover { background: #212837; }
.ctrl:disabled { opacity: .35; cursor: not-allowed; }
.ctrl-main {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a0d10;
  width: 42px; height: 42px;
}
.ctrl-main:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.ctrl.muted { color: var(--muted); }

.time { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); flex-shrink: 0; }

.scrub { flex: 1; min-width: 60px; padding: 8px 0; cursor: pointer; }
.scrub:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.scrub-track { position: relative; height: 5px; background: #262e3d; border-radius: 999px; }
.scrub-fill {
  position: absolute; inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
}
.scrub-knob {
  position: absolute; top: 50%; left: 0;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity .16s ease;
}
.scrub:hover .scrub-knob, .scrub:focus-visible .scrub-knob { opacity: 1; }
.scrub.locked { cursor: not-allowed; opacity: .5; }

.volume { width: 82px; accent-color: var(--accent); flex-shrink: 0; }

.react-bar { display: flex; gap: 2px; flex-shrink: 0; }
.react {
  border: 0; background: transparent;
  font-size: 17px; line-height: 1;
  padding: 6px; border-radius: 8px;
  transition: transform .12s ease, background .16s ease;
}
.react:hover { background: #212837; transform: scale(1.2); }

.now-playing {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  flex-shrink: 0;
}
.now-playing h2 { margin: 0 0 3px; font-size: 15px; }
.now-playing p { margin: 0; color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------------ Sidebar */

.side {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.tab {
  flex: 1;
  border: 0; background: transparent;
  color: var(--muted);
  padding: 13px 8px;
  font-weight: 600; font-size: 13px;
  border-bottom: 2px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: color .16s ease, border-color .16s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.badge {
  background: #262e3d;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  color: var(--muted);
}
.badge-dot { width: 7px; height: 7px; padding: 0; background: var(--accent); }

.panel { display: none; flex: 1; min-height: 0; flex-direction: column; padding: 12px; gap: 10px; }
.panel.active { display: flex; }

.add-form, .chat-form { display: flex; gap: 8px; flex-shrink: 0; }
.add-form input, .chat-form input {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.add-form input:focus, .chat-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.add-form .btn, .chat-form .btn { padding: 10px 15px; flex-shrink: 0; }
.add-error { color: var(--accent); font-size: 13px; }

.queue-list, .chat-list, .people-list {
  list-style: none;
  margin: 0; padding: 0;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  scrollbar-width: thin;
  scrollbar-color: #2f3849 transparent;
}

.q-item {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 9px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 7px;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}
.q-item:hover { border-color: #2f3849; }
.q-item.current { border-color: var(--accent); background: #1d1620; }
.q-item img { width: 62px; height: 35px; object-fit: cover; border-radius: 6px; display: block; background: #000; }
.q-body { min-width: 0; }
.q-title {
  font-size: 13px; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.q-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.q-actions { display: flex; flex-direction: column; gap: 1px; opacity: 0; transition: opacity .16s ease; }
.q-item:hover .q-actions, .q-item:focus-within .q-actions { opacity: 1; }
.q-actions button {
  border: 0; background: transparent; color: var(--muted);
  width: 22px; height: 18px; border-radius: 5px; font-size: 11px; line-height: 1;
}
.q-actions button:hover { background: #262e3d; color: var(--text); }

.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 8px; }

.chat-list { gap: 9px; }
.chat-msg { font-size: 14px; word-break: break-word; }
.chat-msg .who { font-weight: 700; margin-right: 6px; }
.chat-msg.system { color: var(--muted); font-size: 12px; font-style: italic; }

.people-list li {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-card);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #10131a;
  flex-shrink: 0;
}
.tag {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}
.tag.host { color: var(--accent-2); border-color: var(--accent-2); }
.tag.buffering { color: var(--warn); border-color: var(--warn); }
.tag.make-host { cursor: pointer; }
.tag.make-host:hover { color: var(--text); border-color: var(--text); }

.host-settings { border-top: 1px solid var(--line); padding-top: 12px; flex-shrink: 0; }
.host-settings h3 { margin: 0 0 9px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 14px; cursor: pointer; }
.switch input { accent-color: var(--accent); width: 16px; height: 16px; }

/* -------------------------------------------------------------------- Toasts */

.toasts {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 50;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toastIn .22s ease;
}
.toast.err { border-color: var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* --------------------------------------------------------------- Responsive */

@media (max-width: 1000px) {
  body { overflow: auto; }
  .stage { grid-template-columns: 1fr; }
  .side { height: 62vh; }
  .player-wrap { aspect-ratio: 16 / 9; flex: none; }
  .controls { flex-wrap: wrap; }
  .volume, .react-bar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
