:root {
  --bg:       #0e0e10;
  --surface:  #18181b;
  --surface2: #1f1f23;
  --border:   #2a2a2d;
  --text:     #efeff1;
  --text-dim: #adadb8;
  --twitch:   #9147ff;
  --youtube:  #ff0000;
  --green:    #2ecc71;
  --chat-w:   300px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 13px;
}

/* ── App shell — always the same two-column frame ────────────── */

#app-shell {
  display: flex;
  height: 100vh;
}

.hidden { display: none !important; }

/* ── Sign-in card (sits inside main-col, left of chat) ───────── */

.login-card {
  text-align: center;
  padding: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 440px;
  width: 90%;
}

.platform-choices {
  display: flex;
  flex-direction: row;
  gap: 16px;
}

.offline-block.hidden { display: none; }

.offline-label {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

.vod-link {
  display: inline-block;
  margin-top: 18px;
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: underline;
}
.vod-link:hover { color: var(--text); }

.btn-platform {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 16px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: 8px;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.15s;
}
.btn-platform:hover { opacity: 0.85; transform: translateY(-1px); }

.btn-platform svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.btn-twitch  { background: var(--twitch); }
.btn-youtube { background: var(--youtube); }

/* ── Main column — login card OR video player(s) ─────────────── */

.main-col {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: #000;
  gap: 10px;
  overflow: hidden;
}

#bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.8s;
}
#bg-video.playing { opacity: 1; }

.bg-overlay {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(0, 0, 0, 0.55);
}

.main-col > .login-card,
.main-col > #players-row,
.main-col > #connect-other {
  position: relative;
  z-index: 1;
}

.players-row {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: flex-start;
}

.player-slot {
  flex: 1;
  aspect-ratio: 16 / 9;
  background: #111;
  position: relative;
}

.player-slot iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.connect-other-link {
  display: none;
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: color 0.15s, border-color 0.15s;
}
.connect-other-link:hover { color: var(--text); border-color: var(--text-dim); }
.connect-other-link.visible { display: inline-block; }

/* Right column — chat */
.chat-col {
  width: var(--chat-w);
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.chat-top {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.chat-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.chat-indicators {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.platform-dot {
  display: inline-flex;
  opacity: 0.3;
  filter: grayscale(1);
  transition: opacity 0.15s, filter 0.15s;
}
.platform-dot.connected {
  opacity: 1;
  filter: none;
}

.platform-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  display: block;
}
.icon-twitch  { color: var(--twitch); }
.icon-youtube { color: var(--youtube); }

.signout-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
}
.signout-btn:hover { color: var(--text); background: var(--surface2); }

.auth-banner {
  display: none;
  padding: 8px 12px;
  background: rgba(255, 0, 0, 0.1);
  border-bottom: 1px solid var(--border);
  color: var(--youtube);
  font-size: 11px;
  flex-shrink: 0;
}
.auth-banner.visible { display: block; }

/* Chat feed */
#chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
#chat-feed::-webkit-scrollbar { width: 4px; }
#chat-feed::-webkit-scrollbar-track { background: transparent; }
#chat-feed::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

.chat-msg {
  padding: 3px 12px;
  line-height: 1.45;
  word-break: break-word;
}
.chat-msg:hover { background: rgba(255,255,255,0.03); }

.msg-platform { display: inline-flex; margin-right: 4px; vertical-align: middle; }
.msg-platform .platform-icon { width: 11px; height: 11px; }
.msg-author   { font-weight: 700; }
.msg-text     { color: var(--text); }

.chat-emote {
  height: 1.6em;
  width: auto;
  vertical-align: middle;
  margin: -2px 1px;
}

/* Chat input row */
.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  padding: 6px 8px;
  font-size: 12px;
  outline: none;
}

.send-btn {
  padding: 6px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: not-allowed;
}
.send-btn:not(:disabled) {
  color: var(--text);
  cursor: pointer;
}
.send-btn:not(:disabled):hover {
  background: var(--border);
}

.send-platform-toggle {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.send-platform-toggle.hidden { display: none; }

.platform-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px;
  cursor: pointer;
  opacity: 0.4;
  filter: grayscale(1);
}
.platform-toggle-btn .platform-icon {
  width: 14px;
  height: 14px;
}
.platform-toggle-btn.active {
  opacity: 1;
  filter: none;
  border-color: var(--text-dim);
}
.platform-toggle-btn.unavailable {
  display: none;
}

.send-error {
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  color: var(--youtube);
  font-size: 11px;
  padding: 0 10px;
  transition: max-height 0.15s;
}
.send-error.visible {
  max-height: 20px;
  padding: 4px 10px 8px;
}

/* ── VOD grid modal ───────────────────────────────────────── */

.vod-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  padding: 24px;
}
.vod-modal.hidden { display: none; }

.vod-modal-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.vod-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  flex-shrink: 0;
}

.vod-modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 3px;
}
.vod-modal-close:hover { color: var(--text); background: var(--surface2); }

.vod-grid {
  overflow-y: auto;
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}

.vod-grid-loading,
.vod-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 40px 0;
}

.vod-tile {
  display: block;
  text-decoration: none;
  color: var(--text);
}

.vod-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface2);
  display: block;
}

.vod-tile-title {
  font-size: 12px;
  margin-top: 6px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.vod-tile-duration {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

@media (max-width: 720px) {
  .vod-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 460px) {
  .vod-grid { grid-template-columns: repeat(2, 1fr); }
}
