* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { background: #06060b; color: #c8c8d4; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif; overflow: hidden; height: 100vh; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(108, 92, 231, 0.4); color: #fff; }
#particles { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
nav, section, footer, #homepage, #player-container, #oauth-overlay { position: relative; z-index: 1; }
.hidden { display: none !important; }

#loading { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; gap: 1rem; background: #06060b; position: relative; z-index: 1; }
.spinner { width: 40px; height: 40px; border: 3px solid #1a1a2e; border-top-color: #6c5ce7; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading p { color: #8888a0; font-size: .9rem; }

#homepage { min-height: 100vh; background: #06060b; display: flex; flex-direction: column; }

#home-header { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 2rem; max-width: 1200px; margin: 0 auto; width: 100%; }
#home-header .brand a { color: #6c5ce7; text-decoration: none; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.nav-links { display: flex; align-items: center; gap: 2rem; margin-right: auto; margin-left: 2rem; }
.nav-links a { font-size: .875rem; color: #8888a0; transition: color .2s; }
.nav-links a:hover { color: #e8e8f0; }
.discord-link { padding: .4rem 1rem; border: 1px solid #2a2a3e; border-radius: 8px; transition: border-color .2s, background .2s; }
.discord-link:hover { border-color: #6c5ce7; background: rgba(108,92,231,0.08); }

.parties-hero { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem 2rem 1.5rem; text-align: center; position: relative; overflow: hidden; }
.parties-hero .hero-glow { position: absolute; width: 600px; height: 600px; border-radius: 50%; background: radial-gradient(circle, rgba(108,92,231,0.1) 0%, transparent 70%); top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.parties-hero h1 { font-size: 2.75rem; font-weight: 800; line-height: 1.1; letter-spacing: -.03em; color: #f0f0f8; margin-bottom: .75rem; background: linear-gradient(135deg, #f0f0f8 0%, #a88cf0 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; position: relative; }
.parties-hero p { font-size: 1.1rem; color: #8888a0; max-width: 480px; position: relative; }

#home-content { display: flex; gap: 1.5rem; padding: 1.5rem 2rem 4rem; max-width: 1100px; margin: 0 auto; width: 100%; box-sizing: border-box; position: relative; z-index: 1; }
#home-rooms { flex: 1; }
#room-list { display: flex; flex-direction: column; gap: .75rem; }
.room-list-empty { color: #555568; font-size: .9rem; text-align: center; padding: 3rem 2rem; border: 1px dashed #1e1e32; border-radius: 14px; background: linear-gradient(135deg, rgba(20,20,40,0.3) 0%, rgba(12,12,24,0.5) 100%); }

.room-card { display: flex; align-items: center; gap: 1rem; padding: .75rem 1rem; background: linear-gradient(135deg, rgba(20,20,40,0.6) 0%, rgba(12,12,24,0.8) 100%); border: 1px solid #1e1e32; border-radius: 14px; margin-bottom: 0; text-decoration: none; transition: border-color .3s, transform .3s, box-shadow .3s; }
.room-card:hover { border-color: #3a3a5e; transform: translateY(-2px); box-shadow: 0 8px 30px rgba(0,0,0,0.4); }
.room-card-poster { flex-shrink: 0; width: 48px; height: 68px; border-radius: 6px; overflow: hidden; background: rgba(20,20,40,0.8); }
.room-card-poster-img { width: 100%; height: 100%; object-fit: cover; }
.room-card-info { flex: 1; min-width: 0; }
.room-card-title { font-size: .95rem; font-weight: 600; color: #e8e8f0; margin-bottom: .25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-card-meta { font-size: .8rem; color: #8888a0; }
.room-card-users { display: flex; gap: .25rem; flex-shrink: 0; }
.room-card-avatar { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid rgba(20,20,40,0.8); }

#home-sidebar { width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: 1rem; }
.home-card { padding: 1.5rem; background: linear-gradient(135deg, rgba(20,20,40,0.6) 0%, rgba(12,12,24,0.8) 100%); border: 1px solid #1e1e32; border-radius: 14px; transition: border-color .3s; text-align: center; }
.home-card:hover { border-color: #3a3a5e; }
.home-card-icon { font-size: 1.3rem; margin-bottom: .75rem; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: rgba(108,92,231,0.1); border-radius: 10px; color: #6c5ce7; margin-left: auto; margin-right: auto; }
.home-card h3 { font-size: 1rem; font-weight: 600; color: #e8e8f0; margin-bottom: .5rem; }
.home-card p { font-size: .85rem; color: #8888a0; margin-bottom: 1rem; line-height: 1.6; }

#home-user-area { display: flex; align-items: center; gap: .75rem; }
#home-user-info { display: flex; align-items: center; gap: .5rem; }
.home-avatar { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(108,92,231,0.3); }
#home-name { font-size: .85rem; color: #c8c8d4; }
.home-logout { font-size: .75rem; color: #8888a0; text-decoration: none; transition: color .2s; }
.home-logout:hover { color: #f85149; }
.home-login-btn { font-size: .8rem !important; padding: .4rem 1.2rem !important; }

.btn-primary { display: inline-block; padding: .75rem 2rem; background: #6c5ce7; color: #fff; border-radius: 10px; font-weight: 600; font-size: .9rem; border: none; cursor: pointer; transition: background .2s, transform .15s, box-shadow .2s; text-decoration: none; font-family: inherit; }
.btn-primary:hover { background: #7d6ff0; transform: translateY(-1px); box-shadow: 0 6px 24px rgba(108,92,231,0.35); }
.btn-secondary { display: inline-block; padding: .75rem 2rem; border: 1px solid #2a2a3e; color: #c8c8d4; border-radius: 10px; font-weight: 500; font-size: .9rem; cursor: pointer; transition: border-color .2s, color .2s; text-decoration: none; font-family: inherit; background: transparent; }
.btn-secondary:hover { border-color: #6c5ce7; color: #e8e8f0; }

#player-container { display: flex; flex-direction: column; height: 100vh; background: #06060b; position: relative; z-index: 1; }
#header { display: flex; align-items: center; justify-content: space-between; padding: .6rem 1.25rem; background: rgba(8,8,16,0.95); border-bottom: 1px solid #1a1a2e; backdrop-filter: blur(8px); }
#header .brand { font-size: 1rem; font-weight: 700; letter-spacing: -.02em; }
#header .brand a { color: #6c5ce7; text-decoration: none; }

#sync-info { display: flex; align-items: center; gap: .75rem; }
#owner-state { font-size: .6rem; padding: .12rem .4rem; border-radius: 4px; font-weight: 700; letter-spacing: .05em; }
.state-playing { background: rgba(22,101,52,0.6); color: #4ade80; }
.state-paused { background: rgba(120,53,15,0.6); color: #fbbf24; }
.state-idle { background: rgba(31,41,55,0.6); color: #9ca3af; }
.state-owner-gone { background: rgba(127,29,29,0.6); color: #fca5a5; }
.state-owner-loading { background: rgba(120,53,15,0.6); color: #fbbf24; animation: pulse-subtle 2s ease-in-out infinite; }
#owner-ts { font-size: .75rem; color: #8888a0; font-family: 'SFMono-Regular', Consolas, monospace; font-variant-numeric: tabular-nums; }

#header-right { display: flex; align-items: center; gap: 1rem; position: relative; }
#user-area { display: flex; align-items: center; gap: .5rem; cursor: pointer; padding: .15rem .4rem; border-radius: 8px; transition: background .15s; }
#user-area:hover { background: rgba(20,20,40,0.6); }
#user-list { display: flex; align-items: center; gap: .4rem; pointer-events: none; }
#user-count { display: flex; align-items: center; gap: .35rem; pointer-events: none; }

#user-dropdown { position: absolute; top: calc(100% + 8px); right: 0; background: rgba(12,12,24,0.97); border: 1px solid #1e1e32; border-radius: 12px; padding: .4rem; min-width: 220px; max-height: 320px; overflow-y: auto; z-index: 500; box-shadow: 0 8px 32px rgba(0,0,0,0.6); backdrop-filter: blur(8px); }
.user-dropdown-item { display: flex; align-items: center; gap: .5rem; padding: .4rem .5rem; border-radius: 8px; font-size: .85rem; }
.user-dropdown-item:hover { background: rgba(20,20,40,0.6); }
.user-dropdown-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-loaded { background: #22c55e; }
.dot-loading { background: #f59e0b; animation: pulse 2s ease-in-out infinite; }

.user-dropdown-status { font-size: .6rem; padding: .1rem .35rem; border-radius: 4px; font-weight: 600; flex-shrink: 0; }
.status-ready { background: rgba(31,41,55,0.6); color: #9ca3af; }
.status-loading { background: rgba(120,53,15,0.6); color: #fbbf24; animation: pulse-subtle 2s ease-in-out infinite; }
.status-watching { background: rgba(22,101,52,0.6); color: #4ade80; }
.status-paused { background: rgba(113,63,18,0.6); color: #facc15; }
@keyframes pulse-subtle { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.user-dropdown-avatar { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; }
.user-dropdown-name { flex: 1; color: #c8c8d4; }
.user-dropdown-name .owner-star { color: #fbbf24; margin-left: .25rem; }
.user-dropdown-badge { font-size: .6rem; padding: .1rem .3rem; border-radius: 4px; font-weight: 600; background: rgba(55,65,81,0.6); color: #9ca3af; }
.user-dropdown-badge.you { background: #6c5ce7; color: #fff; }

.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,0.6); } 50% { opacity: .7; box-shadow: 0 0 0 6px rgba(34,197,94,0); } }
#user-count-text { font-size: .85rem; color: #8888a0; font-variant-numeric: tabular-nums; }

.user-avatar-wrapper { position: relative; display: inline-flex; flex-shrink: 0; margin-left: -6px; }
.user-avatar-wrapper:first-child { margin-left: 0; }
.user-avatar-dot { position: absolute; bottom: 0; right: 0; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid rgba(8,8,16,0.95); }
.dot-synced { background: #22c55e; }
.dot-buffering { background: #ef4444; animation: pulse 1.5s ease-in-out infinite; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(20,20,40,0.6); }
.user-avatar:first-child { margin-left: 0; }

#sync-btn { font-size: .75rem; padding: .25rem .7rem; border-radius: 8px; border: 1px solid #2a2a3e; background: transparent; color: #c8c8d4; cursor: pointer; font-family: inherit; transition: all .15s; }
#sync-btn:hover { background: #6c5ce7; border-color: #6c5ce7; color: #fff; }

#video-wrapper { flex: 1; display: flex; align-items: center; justify-content: center; background: #06060b; position: relative; }
#vidking-player { width: 100%; height: 100%; border: none; background: #000; }
#vidking-player.visible { display: block; }
#no-media { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #06060b; }
.no-media-content { text-align: center; }
.no-media-content h2 { font-size: 1.4rem; font-weight: 600; margin-bottom: .5rem; color: #e8e8f0; }
.no-media-content code { background: rgba(108,92,231,0.12); padding: .15rem .5rem; border-radius: 6px; color: #a88cf0; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: .85rem; }
.no-media-content p { color: #8888a0; font-size: .9rem; }

#seeking-overlay { position: absolute; inset: 0; background: rgba(6,6,11,0.88); display: flex; align-items: center; justify-content: center; z-index: 100; }
.seeking-content { text-align: center; }
.seeking-spinner { width: 48px; height: 48px; border: 3px solid rgba(20,20,40,0.6); border-top-color: #6c5ce7; border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 1rem; }
.seeking-content p { color: #c8c8d4; font-size: 1.1rem; }

#error-overlay { position: absolute; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 200; pointer-events: none; }
.error-content { background: rgba(237,66,69,0.9); color: #fff; padding: .5rem 1.25rem; border-radius: 10px; font-size: .85rem; max-width: 500px; text-align: center; }

#oauth-overlay { position: fixed; inset: 0; background: rgba(6,6,11,0.96); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.oauth-box { text-align: center; padding: 2.5rem 3rem; max-width: 420px; background: linear-gradient(135deg, rgba(20,20,40,0.8) 0%, rgba(12,12,24,0.95) 100%); border: 1px solid #1e1e32; border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,0.6); }
.oauth-box-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.oauth-box h2 { font-size: 1.5rem; font-weight: 700; color: #f0f0f8; margin-bottom: .5rem; }
.oauth-box p { color: #8888a0; margin-bottom: 1.5rem; font-size: .95rem; }
.oauth-box .btn-primary { font-size: .95rem; padding: .75rem 2.5rem; }

#sync-health { display: flex; align-items: center; }
.health-badge { font-size: .6rem; padding: .15rem .5rem; border-radius: 4px; font-weight: 700; letter-spacing: .04em; }
.health-synced { background: rgba(22,101,52,0.6); color: #4ade80; }
.health-owner-buffering { background: rgba(127,29,29,0.6); color: #fca5a5; }
.health-users-buffering { background: rgba(120,53,15,0.6); color: #fbbf24; }

#dbg-toggle { position: fixed; bottom: 12px; right: 12px; width: 28px; height: 28px; border-radius: 8px; border: 1px solid #2a2a3e; background: rgba(12,12,24,0.8); color: #555568; font-size: .65rem; font-weight: 700; font-family: 'SFMono-Regular', Consolas, monospace; cursor: pointer; z-index: 900; transition: color .15s, border-color .15s; backdrop-filter: blur(4px); }
#dbg-toggle:hover { color: #c8c8d4; border-color: #6c5ce7; }

#debug-menu { position: fixed; bottom: 48px; right: 12px; width: 280px; max-height: 420px; overflow-y: auto; background: rgba(8,8,16,0.97); border: 1px solid #1e1e32; border-radius: 12px; padding: .6rem; z-index: 900; box-shadow: 0 4px 24px rgba(0,0,0,0.7); font-size: .7rem; font-family: 'SFMono-Regular', Consolas, monospace; color: #8888a0; backdrop-filter: blur(8px); }
#debug-menu.hidden { display: none !important; }
.debug-head { text-transform: uppercase; font-size: .55rem; font-weight: 700; letter-spacing: .15em; color: #6c5ce7; margin-bottom: .5rem; padding-bottom: .3rem; border-bottom: 1px solid #1a1a2e; }
.debug-section { margin-bottom: .5rem; padding-bottom: .4rem; border-bottom: 1px solid rgba(20,20,40,0.4); }
.debug-section:last-child { border-bottom: none; margin-bottom: 0; }
.debug-section-title { font-size: .6rem; font-weight: 600; color: #c8c8d4; margin-bottom: .25rem; }
.debug-row { display: flex; justify-content: space-between; padding: .12rem 0; }
.debug-row span:first-child { color: #555568; }
.debug-row span:last-child { color: #c8c8d4; font-variant-numeric: tabular-nums; }
.debug-row-status { margin-top: 2px; }
.debug-row-status span:first-child { color: #555568; font-size: .55rem; }
.debug-status { font-size: .55rem; padding: .08rem .3rem; border-radius: 3px; font-weight: 700; letter-spacing: .04em; }
.status-ok { background: rgba(22,101,52,0.5); color: #4ade80; }
.status-stalled { background: rgba(127,29,29,0.5); color: #fca5a5; }
.debug-err-list { max-height: 80px; overflow-y: auto; margin-top: .2rem; }
.debug-err-item { padding: .12rem 0; border-bottom: 1px solid rgba(20,20,40,0.4); color: #c8c8d4; font-size: .65rem; word-break: break-all; }
.debug-err-item:last-child { border-bottom: none; }
.debug-err-item.empty { color: #484f58; font-style: italic; }
.debug-err-ago { color: #f85149; margin-right: .3rem; font-size: .6rem; }

@media (max-width: 768px) {
  .parties-hero h1 { font-size: 2rem; }
  .parties-hero { padding: 2rem 1.5rem 1rem; }
  #home-content { flex-direction: column; padding: 1rem 1.5rem 3rem; }
  #home-sidebar { width: 100%; }
  #home-header { flex-wrap: wrap; gap: .75rem; padding: .75rem 1rem; }
  .nav-links { order: 3; width: 100%; justify-content: center; gap: 1.25rem; margin-left: 0; }
  #home-user-area { margin-left: auto; }
}
