:root {
  --bg: #313338;
  --surface: #2b2d31;
  --surface2: #1e1f22;
  --text: #dbdee1;
  --text-muted: #949ba4;
  --accent: #5865f2;
}

.light {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface2: #e3e5e8;
  --text: #2e3338;
  --text-muted: #5c5f66;
  --accent: #5865f2;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  font-size: 14px;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

#container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  gap: 4px;
  background: var(--surface2);
  padding: 4px 4px 0;
}

#container.swapped-h {
  flex-direction: row-reverse;
}

#stream-pane,
#game-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: #000;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
}

#stream-pane iframe,
#stream-pane video {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

#game-pane iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.stream-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 1rem;
  white-space: pre-line;
}

/* Bottom bar — two rows */
#bottom-bar {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-top: 1px solid var(--surface2);
}

#stream-row {
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--surface2);
}

#stream-input {
  flex: 1;
  min-width: 0;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

#stream-input:focus {
  border-color: var(--accent);
}

#stream-input::placeholder {
  color: var(--text-muted);
}

#control-row {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
}

#room-code-display {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.05em;
  color: var(--text);
  white-space: nowrap;
}

.spacer {
  flex: 1;
}

#bottom-bar a,
#bottom-bar button {
  background: var(--surface2);
  color: var(--text);
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
  line-height: 1.4;
}

#bottom-bar a:hover,
#bottom-bar button:hover {
  background: var(--accent);
  color: #fff;
}

.hidden {
  display: none !important;
}

/* Help overlay */
#help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#help-content {
  background: var(--surface);
  border-radius: 8px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  color: var(--text);
  max-height: 80dvh;
  overflow-y: auto;
}

#help-content h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

#help-content h3 {
  margin: 16px 0 6px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

#help-content code {
  display: block;
  background: var(--surface2);
  padding: 8px 12px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  word-break: break-all;
}

#help-content ul {
  padding-left: 20px;
  margin: 0 0 4px;
  line-height: 1.8;
}

#help-close-btn {
  margin-top: 16px;
  width: 100%;
  padding: 8px !important;
}

#help-footer {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--surface2);
}

#help-footer a {
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  padding: 0;
  text-decoration: underline;
}

#help-footer a:hover {
  background: none;
  color: var(--accent);
}

/* Portrait — override horizontal swap so only vertical swap applies */
@media (orientation: portrait) {
  #container,
  #container.swapped-h {
    flex-direction: column;
  }

  #container.swapped-v,
  #container.swapped-h.swapped-v {
    flex-direction: column-reverse;
  }

  #stream-pane {
    max-height: 35%;
    flex: none;
  }

  #game-pane {
    flex: 1;
  }
}
