/* ═══════════════════════════════════════════════════════════
   ROOT & RESET
═══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0a0012;
  --bg2:        #130020;
  --glass:      rgba(255,255,255,0.05);
  --glass-b:    rgba(255,255,255,0.10);
  --pink:       #ff6b9d;
  --purple:     #c77dff;
  --gold:       #ffd166;
  --text:       #f0e6ff;
  --text2:      rgba(240,230,255,0.60);
  --r:          14px;
  --transition: 0.25s ease;
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

#heartCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
}

/* ═══════════════════════════════════════════════════════════
   SHARED COMPONENTS
═══════════════════════════════════════════════════════════ */
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.65rem 1.4rem;
  border: none; border-radius: 100px;
  font-family: inherit; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: transform var(--transition), box-shadow var(--transition);
}
.btn:active { transform: scale(0.96); }
.btn.sm { padding: 0.45rem 1rem; font-size: 0.85rem; }

.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff;
  box-shadow: 0 4px 24px rgba(255,107,157,0.35);
}
.btn-primary:hover { box-shadow: 0 6px 32px rgba(199,125,255,0.45); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--glass-b);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--pink); color: var(--pink); }

.icon-btn {
  background: var(--glass);
  border: 1px solid var(--glass-b);
  border-radius: 50%;
  width: 38px; height: 38px;
  font-size: 1.1rem;
  cursor: pointer; color: var(--text);
  transition: background var(--transition);
}
.icon-btn:hover { background: rgba(255,107,157,0.2); }
.icon-btn.tiny { width: 28px; height: 28px; font-size: 0.75rem; }

input[type="text"], input[type="datetime-local"] {
  background: var(--glass);
  border: 1.5px solid var(--glass-b);
  border-radius: var(--r);
  padding: 0.6rem 1rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}
input::placeholder { color: var(--text2); }
input:focus { border-color: var(--purple); }

.heart-icon { color: var(--pink); font-size: 1.8rem; }
.heart-icon.small { font-size: 1.1rem; }

.mt { margin-top: 1rem; }

/* ═══════════════════════════════════════════════════════════
   LOBBY
═══════════════════════════════════════════════════════════ */
#lobby {
  position: relative; z-index: 10;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}

.lobby-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-b);
  border-radius: 24px;
  padding: 3rem 2.5rem;
  width: 100%; max-width: 440px;
  backdrop-filter: blur(20px);
  box-shadow: 0 32px 80px rgba(0,0,0,0.5), 0 0 60px rgba(199,125,255,0.07);
  text-align: center;
}

.logo h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2.8rem;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin: 0.3rem 0 0.4rem;
}
.tagline { color: var(--text2); font-size: 0.95rem; margin-bottom: 2.5rem; }

.room-actions { display: flex; flex-direction: column; gap: 1rem; }
.room-actions .btn-primary { width: 100%; padding: 0.8rem; }

.divider {
  display: flex; align-items: center; gap: 0.8rem;
  color: var(--text2); font-size: 0.85rem;
}
.divider::before, .divider::after {
  content: ''; flex: 1;
  height: 1px; background: var(--glass-b);
}

.join-row { display: flex; gap: 0.5rem; }
.join-row input { flex: 1; font-size: 1rem; letter-spacing: 2px; text-transform: uppercase; }

.lobby-status {
  margin-top: 1.2rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  background: rgba(199,125,255,0.12);
  border: 1px solid rgba(199,125,255,0.25);
  color: var(--purple);
}

/* ═══════════════════════════════════════════════════════════
   TOP BAR
═══════════════════════════════════════════════════════════ */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  background: rgba(10,0,18,0.85);
  border-bottom: 1px solid var(--glass-b);
  backdrop-filter: blur(16px);
}
.topbar-left { display: flex; align-items: center; gap: 0.5rem; }
.brand { font-family: 'Playfair Display', serif; font-size: 1.2rem; color: var(--pink); }
.room-badge {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text2);
  background: var(--glass); border: 1px solid var(--glass-b);
  padding: 0.2rem 0.6rem; border-radius: 100px;
}
.topbar-right { display: flex; align-items: center; gap: 0.6rem; }
.conn-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #888;
}
.conn-dot.connected { background: #4ade80; box-shadow: 0 0 8px #4ade80; }
.conn-dot.disconnected { background: #f87171; }

/* Tabs */
.tabs { display: flex; gap: 0.3rem; }
.tab {
  padding: 0.4rem 0.9rem; font-size: 0.88rem; font-weight: 500;
  background: transparent; border: none; border-radius: 100px;
  color: var(--text2); cursor: pointer;
  transition: all var(--transition);
}
.tab:hover { color: var(--text); background: var(--glass); }
.tab.active {
  background: linear-gradient(135deg, rgba(255,107,157,0.2), rgba(199,125,255,0.2));
  border: 1px solid rgba(199,125,255,0.35);
  color: var(--purple);
}

/* ═══════════════════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════════════════ */
.layout {
  display: flex;
  min-height: calc(100vh - 60px);
  position: relative;
}
.tab-content {
  flex: 1;
  padding: 2rem;
  max-width: 900px;
  margin: 0 auto;
}
.section-header { margin-bottom: 1.5rem; }
.section-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  background: linear-gradient(135deg, var(--pink), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.section-header p { color: var(--text2); font-size: 0.9rem; margin-top: 0.3rem; }

/* ═══════════════════════════════════════════════════════════
   MOVIES
═══════════════════════════════════════════════════════════ */
.video-loader {
  display: flex; gap: 0.6rem; margin-bottom: 1.5rem;
}
.video-loader input { flex: 1; }

#playerWrap {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--glass-b);
  border-radius: var(--r);
  overflow: hidden;
}
#ytPlayer { width: 100%; aspect-ratio: 16/9; }
#ytPlayer iframe { width: 100% !important; height: 100% !important; }

.player-controls {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.8rem 1rem;
  background: rgba(0,0,0,0.3);
}
.ctrl-btn {
  background: var(--glass); border: 1px solid var(--glass-b);
  border-radius: 50%; width: 36px; height: 36px;
  font-size: 0.9rem; cursor: pointer; color: var(--text);
  transition: background var(--transition);
}
.ctrl-btn:hover { background: rgba(255,107,157,0.25); }
.ctrl-btn.sm { width: 28px; height: 28px; font-size: 0.75rem; }

.seek-bar {
  flex: 1; height: 4px; cursor: pointer;
  accent-color: var(--pink);
}
.time-display { color: var(--text2); font-size: 0.8rem; white-space: nowrap; }
.sync-note { padding: 0.5rem 1rem; font-size: 0.78rem; color: var(--text2); text-align: center; }

/* ═══════════════════════════════════════════════════════════
   GAMES
═══════════════════════════════════════════════════════════ */
.game-picker {
  display: flex; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap;
}
.game-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  padding: 1rem 1.5rem; min-width: 130px;
  background: var(--glass); border: 1.5px solid var(--glass-b);
  border-radius: var(--r); cursor: pointer; color: var(--text);
  font-family: inherit; font-size: 0.88rem;
  transition: all var(--transition);
}
.game-card:hover { border-color: var(--purple); }
.game-card.active-game {
  border-color: var(--pink);
  background: rgba(255,107,157,0.1);
}
.game-icon { font-size: 1.8rem; }
.game-area { animation: fadeIn 0.3s ease; }

/* Tic-Tac-Toe */
.ttt-status {
  text-align: center; font-size: 1rem; color: var(--gold);
  margin-bottom: 1rem; min-height: 1.4em;
}
.ttt-board {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 8px; max-width: 300px; margin: 0 auto 1rem;
}
.ttt-cell {
  aspect-ratio: 1; background: var(--glass);
  border: 2px solid var(--glass-b); border-radius: 10px;
  font-size: 2.4rem; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background var(--transition);
  user-select: none;
}
.ttt-cell:hover:empty { background: rgba(199,125,255,0.15); }
.ttt-cell.x { color: var(--pink); }
.ttt-cell.o { color: var(--purple); }
.ttt-cell.win { background: rgba(255,209,102,0.2); border-color: var(--gold); }
.ttt-score { text-align: center; color: var(--text2); margin-bottom: 1rem; font-size: 0.9rem; }

/* Would You Rather */
.wyr-card {
  background: var(--glass); border: 1px solid var(--glass-b);
  border-radius: var(--r); padding: 2rem; max-width: 560px;
  text-align: center;
}
.wyr-card h3 {
  font-family: 'Playfair Display', serif; font-size: 1.4rem;
  color: var(--gold); margin-bottom: 1.5rem;
}
.wyr-options { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.wyr-btn {
  flex: 1; min-width: 150px; padding: 1rem;
  background: rgba(199,125,255,0.1); border: 2px solid rgba(199,125,255,0.25);
  border-radius: var(--r); color: var(--text); font-family: inherit; font-size: 0.9rem;
  cursor: pointer; transition: all var(--transition); line-height: 1.4;
}
.wyr-btn:hover { background: rgba(255,107,157,0.15); border-color: var(--pink); }
.wyr-btn.chosen { background: rgba(255,107,157,0.25); border-color: var(--pink); color: var(--pink); font-weight: 600; }
.wyr-or { font-weight: 700; color: var(--text2); }
.wyr-result { margin-top: 1rem; color: var(--purple); font-size: 0.9rem; font-style: italic; }

/* Trivia */
.trivia-card {
  background: var(--glass); border: 1px solid var(--glass-b);
  border-radius: var(--r); padding: 2rem; max-width: 560px;
}
.trivia-header {
  display: flex; justify-content: space-between;
  color: var(--text2); font-size: 0.85rem; margin-bottom: 1rem;
}
.trivia-card h3 {
  font-family: 'Playfair Display', serif; font-size: 1.3rem; margin-bottom: 1.5rem; line-height: 1.5;
}
.trivia-options { display: flex; flex-direction: column; gap: 0.6rem; }
.trivia-opt {
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.04); border: 1.5px solid var(--glass-b);
  border-radius: 10px; color: var(--text); font-family: inherit; font-size: 0.9rem;
  cursor: pointer; text-align: left; transition: all var(--transition);
}
.trivia-opt:hover:not(:disabled) { border-color: var(--purple); }
.trivia-opt.correct { border-color: #4ade80; background: rgba(74,222,128,0.1); }
.trivia-opt.wrong   { border-color: #f87171; background: rgba(248,113,113,0.1); }
.trivia-feedback { margin-top: 1rem; font-size: 0.9rem; text-align: center; }

/* ═══════════════════════════════════════════════════════════
   MUSIC
═══════════════════════════════════════════════════════════ */
.music-add { display: flex; gap: 0.6rem; margin-bottom: 1.5rem; }
.music-add input { flex: 1; }

.music-player {
  background: var(--glass); border: 1px solid var(--glass-b);
  border-radius: var(--r); padding: 1.2rem; margin-bottom: 1rem;
}
.now-playing { display: flex; align-items: center; gap: 1rem; }
.np-art {
  width: 52px; height: 52px; border-radius: 10px;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; flex-shrink: 0;
}
.np-info { flex: 1; }
.np-title { font-weight: 600; margin-bottom: 0.5rem; font-size: 0.95rem; }
.np-controls { display: flex; gap: 0.5rem; }
.yt-music-hidden { width: 1px; height: 1px; overflow: hidden; position: absolute; }

.playlist { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.playlist-item {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.7rem 1rem;
  background: var(--glass); border: 1px solid var(--glass-b); border-radius: 10px;
  transition: background var(--transition);
}
.playlist-item:hover { background: rgba(255,107,157,0.08); }
.playlist-item.active { border-color: var(--pink); }
.pl-num { color: var(--text2); font-size: 0.8rem; width: 20px; }
.pl-title { flex: 1; font-size: 0.9rem; }
.pl-del { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 0.9rem; }
.pl-del:hover { color: #f87171; }

/* ═══════════════════════════════════════════════════════════
   COUNTDOWN
═══════════════════════════════════════════════════════════ */
.countdown-set { display: flex; gap: 0.6rem; max-width: 400px; margin-bottom: 2.5rem; }
input[type="datetime-local"] { color-scheme: dark; }

.countdown-display {
  display: flex; align-items: center; gap: 1rem;
  justify-content: center; flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.cd-unit {
  display: flex; flex-direction: column; align-items: center;
  background: var(--glass); border: 1px solid var(--glass-b);
  border-radius: var(--r); padding: 1.2rem 1.8rem;
  min-width: 100px;
}
.cd-unit span {
  font-size: 3rem; font-weight: 700; font-family: 'Playfair Display', serif;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  line-height: 1;
}
.cd-unit label { color: var(--text2); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 1px; margin-top: 0.4rem; }
.cd-sep { font-size: 2rem; color: var(--text2); }
.countdown-msg { text-align: center; font-size: 1.1rem; color: var(--gold); font-family: 'Playfair Display', serif; }

/* ═══════════════════════════════════════════════════════════
   CHAT SIDEBAR
═══════════════════════════════════════════════════════════ */
.chat-sidebar {
  width: 300px; flex-shrink: 0;
  background: rgba(10,0,18,0.9);
  border-left: 1px solid var(--glass-b);
  display: flex; flex-direction: column;
  height: calc(100vh - 60px);
  position: sticky; top: 60px;
  animation: slideInRight 0.25s ease;
}
.chat-header {
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--glass-b);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.chat-msg {
  max-width: 85%; padding: 0.5rem 0.8rem;
  border-radius: 12px; font-size: 0.875rem; line-height: 1.4;
  word-break: break-word;
}
.chat-msg.me {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(255,107,157,0.25), rgba(199,125,255,0.25));
  border: 1px solid rgba(199,125,255,0.3);
}
.chat-msg.them {
  align-self: flex-start;
  background: var(--glass); border: 1px solid var(--glass-b);
}
.chat-input-row {
  display: flex; gap: 0.5rem; padding: 0.8rem;
  border-top: 1px solid var(--glass-b);
}
.chat-input-row input { flex: 1; }

/* ═══════════════════════════════════════════════════════════
   VIDEO CHAT OVERLAY
═══════════════════════════════════════════════════════════ */
.video-overlay {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 200;
  animation: fadeIn 0.3s ease;
}
.video-container {
  position: relative; width: 320px;
  background: #000; border-radius: 16px; overflow: hidden;
  border: 1.5px solid var(--glass-b);
  box-shadow: 0 16px 60px rgba(0,0,0,0.7);
}
.remote-video { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.local-video {
  position: absolute; bottom: 60px; right: 8px;
  width: 80px; border-radius: 8px; border: 1.5px solid rgba(255,255,255,0.2);
}
.video-controls {
  display: flex; justify-content: center; gap: 0.7rem;
  padding: 0.6rem;
  background: rgba(0,0,0,0.7);
}
.vc-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.15);
  font-size: 1rem; cursor: pointer; color: #fff;
  transition: background var(--transition);
}
.vc-btn:hover { background: rgba(255,255,255,0.2); }
.vc-btn.danger { background: rgba(248,113,113,0.3); }
.vc-btn.danger:hover { background: rgba(248,113,113,0.6); }
.vc-btn.muted { background: rgba(248,113,113,0.3); }

/* Topbar media buttons — lit up when active */
.icon-btn.media-active {
  background: rgba(255,107,157,0.25);
  border-color: var(--pink);
  box-shadow: 0 0 10px rgba(255,107,157,0.4);
}

/* Mic-only floating pill */
.mic-indicator {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 200;
  display: flex; align-items: center; gap: 0.6rem;
  background: rgba(10,0,18,0.92);
  border: 1.5px solid rgba(255,107,157,0.4);
  border-radius: 100px;
  padding: 0.45rem 0.9rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: fadeIn 0.25s ease;
  font-size: 0.88rem;
}
.mic-indicator #micIndIcon { font-size: 1.1rem; }
.mic-indicator #micIndLabel { color: var(--text2); }
.mic-ind-btn {
  padding: 0.25rem 0.65rem; border-radius: 100px;
  background: var(--glass); border: 1px solid var(--glass-b);
  color: var(--text); font-family: inherit; font-size: 0.78rem;
  cursor: pointer; transition: background var(--transition);
}
.mic-ind-btn:hover { background: rgba(255,107,157,0.2); }
.mic-ind-btn.danger { border-color: rgba(248,113,113,0.4); }
.mic-ind-btn.danger:hover { background: rgba(248,113,113,0.25); }

/* ═══════════════════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ═══════════════════════════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-b); border-radius: 3px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Topbar: stack into two rows */
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 0.5rem 1rem;
    gap: 0.4rem;
  }
  .topbar-left  { flex: 1; }
  .topbar-right { flex-shrink: 0; }

  /* Tabs move to a full-width scrollable row below the top row */
  .topbar-center {
    display: flex;
    width: 100%;
    order: 3;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
    /* hide scrollbar visually */
    scrollbar-width: none;
  }
  .topbar-center::-webkit-scrollbar { display: none; }

  .tabs {
    display: flex;
    gap: 0.3rem;
    width: max-content;   /* lets tabs scroll rather than wrap */
    padding: 0 0.1rem;
  }
  .tab { white-space: nowrap; font-size: 0.82rem; padding: 0.35rem 0.75rem; }

  /* Adjust main content top offset since topbar is now taller */
  .layout { min-height: calc(100vh - 100px); }
  .chat-sidebar { width: 100%; position: fixed; bottom: 0; left: 0; right: 0; height: 60vh; z-index: 150; }
  .tab-content { padding: 1.2rem 1rem; }
  .countdown-display { gap: 0.5rem; }
  .cd-unit { padding: 0.8rem 1rem; min-width: 70px; }
  .cd-unit span { font-size: 2rem; }
  .video-container { width: 260px; }
}
