:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --accent: #5b8cff;
  --text: #e7e9ee;
  --muted: #8a90a0;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }
.wrap { max-width: 520px; margin: 6vh auto; padding: 0 16px; text-align: center; }
h1 { font-size: 2.4rem; margin-bottom: 4px; }
.tagline { color: var(--muted); margin-top: 0; }
.card { background: var(--card); border-radius: 14px; padding: 20px; margin-top: 20px; text-align: left; }
.hidden { display: none !important; }
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs button { flex: 1; background: transparent; color: var(--muted); border: 1px solid #2a2e38; padding: 8px; border-radius: 8px; cursor: pointer; }
.tabs button.active { color: var(--text); border-color: var(--accent); }
.pane { display: none; flex-direction: column; gap: 10px; }
.pane.active { display: flex; }
input, button { font-size: 0.95rem; }
input { background: #11141a; border: 1px solid #2a2e38; color: var(--text); padding: 10px 12px; border-radius: 8px; width: 100%; }
form button[type=submit], #create-room button, #join-room button, #load-media {
  background: var(--accent); color: #fff; border: none; padding: 10px 14px; border-radius: 8px; cursor: pointer;
}
.muted { color: var(--muted); font-size: 0.85rem; }
.msg { color: var(--muted); font-size: 0.9rem; min-height: 1.2em; }
h3 { margin: 18px 0 8px; }
#create-room, #join-room { display: flex; flex-direction: column; gap: 8px; }

/* Room layout */
.room { height: 100vh; display: flex; flex-direction: column; }
.room-head { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--card); flex-wrap: wrap; }
.room-head .room-id { color: var(--muted); font-size: 0.85rem; }
.room-head code { color: var(--text); }
#copy-id { background: transparent; border: 1px solid #2a2e38; color: var(--muted); border-radius: 6px; cursor: pointer; }
.room-main { flex: 1; display: flex; min-height: 0; }
.player-col { flex: 1; display: flex; flex-direction: column; padding: 16px; gap: 12px; min-width: 0; }
.player-wrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; flex: 1; min-height: 360px; }
video { width: 100%; height: 100%; display: block; background: #000; position: relative; z-index: 1; }
#yt, #yt iframe, #embed { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; z-index: 1; }
.embed-note { position: absolute; top: 0; left: 0; right: 0; z-index: 4; padding: 6px 12px; font-size: 0.8rem;
  background: rgba(0,0,0,0.55); color: #cfe0ff; }
.embed-note a { color: #9ec1ff; }
#reactions-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.owner-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.owner-bar #media-input { flex: 1; min-width: 180px; }
.upload-btn { background: #2a2e38; color: var(--text); padding: 10px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.upload-btn:hover { background: #353a47; }
#share-screen { background: #3a2e5a; color: #fff; border: none; padding: 10px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
#share-screen:hover { background: #4a3a72; }
#unmute-btn {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  background: var(--accent); color: #fff; border: none; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-size: 0.95rem;
}
.reactions { display: flex; gap: 8px; flex-wrap: wrap; }
.reactions button {
  font-size: 1.6rem; background: var(--card); border: 1px solid #2a2e38; border-radius: 12px;
  padding: 6px 12px; cursor: pointer; transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.reactions button:hover { border-color: var(--accent); transform: translateY(-3px) scale(1.18) rotate(-6deg); background: #23283a; }
.reactions button:active { transform: scale(0.9); }

/* Fullscreen button (top-right of the player) */
.fs-btn {
  position: absolute; top: 10px; right: 10px; z-index: 7; font-size: 1.1rem;
  background: rgba(10, 12, 16, 0.55); color: var(--text); border: 1px solid #2a2e38;
  border-radius: 10px; padding: 4px 10px; cursor: pointer; opacity: 0.55; transition: opacity 0.2s;
}
.player-wrap:hover .fs-btn { opacity: 1; }
.fs-btn:hover { border-color: var(--accent); }

/* Reaction dock (bottom-right), collapsible into an arrow */
.react-dock { position: absolute; right: 12px; bottom: 62px; z-index: 7; display: flex; align-items: center; gap: 6px; }
.react-dock .reactions {
  display: flex; gap: 4px; flex-wrap: nowrap; background: rgba(10, 12, 16, 0.6);
  backdrop-filter: blur(4px); padding: 5px 8px; border-radius: 14px;
}
.react-dock.collapsed .reactions { display: none; }
.react-dock .reactions button { font-size: 1.3rem; padding: 3px 6px; background: transparent; border-color: transparent; border-radius: 8px; }
.react-dock .reactions button:hover { background: #23283a; border-color: var(--accent); }
.react-toggle {
  width: 42px; height: 42px; border-radius: 50%; font-size: 1.05rem;
  background: rgba(10, 12, 16, 0.65); color: var(--text); border: 1px solid #2a2e38; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.react-toggle:hover { border-color: var(--accent); }
.player-wrap:fullscreen { min-height: 100vh; border-radius: 0; }

.side-col { width: 320px; border-left: 1px solid #2a2e38; display: flex; flex-direction: column; }
.members { padding: 12px 16px; border-bottom: 1px solid #2a2e38; }
.members h4 { margin: 0 0 8px; }
.members ul { margin: 0; padding-left: 18px; color: var(--muted); }
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#messages { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.msg-line { font-size: 0.92rem; }
.msg-line.mine { color: #cfe0ff; }
.msg-sys { color: var(--muted); font-size: 0.8rem; font-style: italic; }
#chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid #2a2e38; }
#chat-form button { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 0 16px; cursor: pointer; }

.react-fly {
  position: absolute; bottom: 8%; font-size: 2.7rem; will-change: transform, opacity;
  animation: fly 2.6s cubic-bezier(.2, .7, .25, 1) forwards;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.55));
}
@keyframes fly {
  0%   { transform: translate(0, 0) scale(0.2) rotate(0deg); opacity: 0; }
  12%  { transform: translate(calc(var(--x) * 0.15), -26px) scale(calc(var(--s) * 1.25)) rotate(calc(var(--r) * 0.3)); opacity: 1; }
  30%  { transform: translate(calc(var(--x) * 0.4), -120px) scale(var(--s)) rotate(calc(var(--r) * -0.4)); }
  75%  { opacity: 1; }
  100% { transform: translate(var(--x), -340px) scale(calc(var(--s) * 0.9)) rotate(var(--r)); opacity: 0; }
}

/* Password field with eye toggle */
.pwd-field { position: relative; display: flex; }
.pwd-field input { padding-right: 44px; }
.pwd-field .eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; cursor: pointer; font-size: 1.1rem;
  opacity: 0.6; padding: 4px;
}
.pwd-field .eye:hover, .pwd-field .eye.on { opacity: 1; }

/* Player message / error overlay */
.player-msg {
  position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px; background: rgba(0,0,0,0.82); color: var(--text);
  font-size: 0.95rem; line-height: 1.5;
}
.player-msg code { background: #2a2e38; padding: 2px 5px; border-radius: 4px; word-break: break-all; }
.player-msg-inner { max-width: 520px; text-align: center; line-height: 1.6; }

/* Chat emoji picker */
#emoji-btn { background: transparent; border: none; font-size: 1.3rem; cursor: pointer; padding: 0 6px; }
.emoji-palette { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px 12px; border-top: 1px solid #2a2e38; max-height: 168px; overflow-y: auto; }
.emoji-palette button { background: transparent; border: none; font-size: 1.4rem; cursor: pointer; padding: 4px; border-radius: 6px; line-height: 1; }
.emoji-palette button:hover { background: #2a2e38; }

@media (max-width: 760px) {
  .room-main { flex-direction: column; }
  .side-col { width: 100%; border-left: none; border-top: 1px solid #2a2e38; height: 40vh; }
}
