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

[hidden] { display: none !important; }

:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --panel-2: #1d232e;
  --border: #2a3140;
  --text: #e8ecf3;
  --muted: #8b94a7;
  --accent: #e05a4e;
  --accent-2: #f0785f;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

button, input, label.btn { font: inherit; color: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s;
  user-select: none;
}
.btn:hover:not(:disabled) { background: #262e3c; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.big { padding: 12px 28px; font-size: 17px; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.icon { padding: 8px 12px; font-size: 16px; min-width: 44px; justify-content: center; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}

/* ---------- Landing ---------- */
#landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.landing-card { max-width: 460px; text-align: center; }
.landing-card h1 { font-size: 34px; margin-bottom: 8px; }
.tagline { color: var(--muted); margin-bottom: 24px; }
.steps { text-align: left; margin: 28px 0 0 20px; color: var(--muted); }
.steps li { margin: 6px 0; }

/* ---------- Room layout ---------- */
#room-view { display: flex; flex-direction: column; height: 100vh; }

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.logo { font-weight: 700; }
.room-label { color: var(--muted); font-size: 13px; }
.roster { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 13px;
}
.chip.host { border-color: var(--accent); }

main { display: flex; flex: 1; min-height: 0; }

/* ---------- Player ---------- */
#player {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px;
  gap: 10px;
}

#video-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
}
#video { width: 100%; height: 100%; object-fit: contain; }

#video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 16, .85);
  text-align: center;
  padding: 24px;
  white-space: pre-line;
  color: var(--muted);
  font-size: 17px;
}

#tap-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: fit-content;
  height: fit-content;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  padding: 16px 32px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
}

#controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.time-label {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

#progress {
  position: relative;
  flex: 1;
  height: 22px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
}
#progress.seekable { cursor: pointer; }
#buffered {
  position: absolute; inset: 0 auto 0 0;
  width: 0;
  background: #2c3444;
}
#progress-fill {
  position: absolute; inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
#markers { position: absolute; inset: 0; pointer-events: auto; }
.marker {
  position: absolute;
  top: 3px;
  width: 6px;
  height: 16px;
  margin-left: -3px;
  border-radius: 3px;
  background: #ffd166;
  opacity: .9;
}

#volume { width: 90px; accent-color: var(--accent); }

#host-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  min-height: 24px;
}
.toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; font-size: 14px; }
.toggle input { accent-color: var(--accent); }
.sync-stats { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- Chat ---------- */
#chat {
  width: 320px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--panel);
}
.chat-title {
  padding: 12px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg { font-size: 14px; overflow-wrap: break-word; }
.msg .who { font-weight: 600; color: var(--accent-2); margin-right: 6px; }
.msg .tc {
  background: #2c3444;
  border: none;
  border-radius: 4px;
  padding: 0 6px;
  font-size: 12px;
  color: #ffd166;
  cursor: pointer;
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}
#chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}
#chat-form input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  outline: none;
}
#chat-form input:focus { border-color: var(--accent); }

/* ---------- Modal / toast ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, .8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.modal[hidden] { display: none; }
.modal .card { width: 340px; display: flex; flex-direction: column; gap: 16px; text-align: center; }
.modal input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  outline: none;
  text-align: center;
  font-size: 16px;
}
.modal input:focus { border-color: var(--accent); }

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 20px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  z-index: 20;
  max-width: 90vw;
}

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
  main { flex-direction: column; }
  #chat { width: 100%; height: 260px; border-left: none; border-top: 1px solid var(--border); }
  #player { padding: 10px; }
}
