:root {
  color-scheme: dark;
  --bg: #0d0d10;
  --panel: #16161c;
  --border: #26262e;
  --text: #eeeeee;
  --muted: #9a9aa6;
  --accent: #8b6cff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Kopfzeile */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.site-header h1 {
  font-size: 1.05rem;
  margin: 0;
}

#chat-toggle {
  font: inherit;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

/* Layout: Hochformat (Standard) */
.layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.player-section {
  flex: 0 0 auto;
}

.player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Chat-Panel */
.chat-panel {
  flex: 1;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

.chat-status {
  font-size: 0.8rem;
  padding: 6px 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.chat-status[data-state="online"] {
  color: #6fd38a;
}

.chat-status[data-state="fehler"],
.chat-status[data-state="offline"] {
  color: #e88a8a;
}

.messages {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 8px 12px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.messages li {
  margin-bottom: 6px;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.msg-name {
  color: var(--accent);
  font-weight: 600;
  margin-right: 6px;
}

.chat-form {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--border);
}

.chat-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px; /* verhindert Zoom auf iOS */
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.chat-form #name {
  flex: 0 0 30%;
}

.chat-form button {
  font: inherit;
  padding: 8px 14px;
  border-radius: 8px;
  border: 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.chat-form button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Querformat: Chat rechts */
@media (orientation: landscape) and (min-width: 720px) {
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
  }

  .player-section {
    display: flex;
    align-items: center;
  }

  .player {
    width: 100%;
  }

  .chat-panel {
    min-height: 0;
    border-top: 0;
    border-left: 1px solid var(--border);
  }
}

/* Chat ausgeblendet */
body.chat-collapsed .chat-panel {
  display: none;
}

@media (orientation: landscape) and (min-width: 720px) {
  body.chat-collapsed .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}