:root {
  --bg: #07080d;
  --surface: rgba(17, 19, 28, 0.82);
  --surface-solid: #11131c;
  --surface-2: rgba(27, 31, 44, 0.85);
  --border: rgba(255, 255, 255, 0.085);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f6fa;
  --text-muted: #8f96aa;
  --brand-a: #8b5cf6;
  --brand-b: #6366f1;
  --brand-c: #ec4899;
  --ambient-glow: rgba(114, 92, 246, 0.18);
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 14px;
  --radius-sm: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font-family: inherit;
  color: inherit;
}

/* Subtle cinematic ambient glow */
.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(640px circle at 50% 8%, var(--ambient-glow), transparent 68%),
    radial-gradient(480px circle at 85% 90%, rgba(236, 72, 153, 0.08), transparent 65%),
    radial-gradient(420px circle at 15% 85%, rgba(99, 102, 241, 0.08), transparent 65%);
  transition: background 0.45s ease;
}

/* Home Page */
.home-shell {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px 40px;
}

.home-topbar {
  width: 100%;
  max-width: 540px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-logo {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(139, 92, 246, 0.35));
}

.brand-logo svg {
  width: 100%;
  height: 100%;
}

.lang-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px 5px 11px;
  backdrop-filter: blur(12px);
  transition: border-color 0.15s;
}

.lang-picker:hover {
  border-color: var(--border-strong);
}

.lang-picker svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.lang-select {
  background: transparent;
  border: none;
  outline: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.lang-select option {
  background: #12141e;
  color: #f5f6fa;
}

.home-card {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.hero-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.subtitle {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 14px;
}

.platforms-section {
  margin-top: 20px;
}

.platforms-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.platform-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.platform-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 6px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.platform-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--border-strong);
}

.platform-card.active {
  background: rgba(255, 255, 255, 0.075);
  border-color: var(--plat-color, var(--brand-a));
  box-shadow: 0 0 0 1px var(--plat-color, var(--brand-a)), 0 8px 20px -6px var(--plat-glow, rgba(139, 92, 246, 0.35));
}

.platform-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.platform-icon svg {
  width: 100%;
  height: 100%;
}

.platform-card-name {
  font-size: 11px;
  font-weight: 500;
  color: #d6dae6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: rgba(7, 8, 13, 0.72);
  padding: 4px;
  border-radius: 12px;
  margin-top: 22px;
  border: 1px solid var(--border);
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.detected-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.detected-tag svg {
  width: 14px;
  height: 14px;
}

.input {
  width: 100%;
  background: rgba(7, 8, 13, 0.78);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.input:focus {
  border-color: rgba(139, 92, 246, 0.65);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.14);
}

.input::placeholder {
  color: #545b70;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, opacity 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-a), var(--brand-b) 60%, var(--brand-c));
  color: #ffffff;
  box-shadow: 0 8px 22px -6px rgba(114, 92, 246, 0.6);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.94;
  box-shadow: 0 10px 26px -5px rgba(139, 92, 246, 0.72);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-strong);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
}

.error-text {
  font-size: 13px;
  color: #f87171;
  min-height: 18px;
}

.ext-status-bar {
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6b7280;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
}

.ext-download-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.16);
  border: 1px solid rgba(139, 92, 246, 0.42);
  color: #ddd6fe;
  font-size: 11.5px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.14s;
}

.ext-download-pill:hover {
  background: rgba(139, 92, 246, 0.28);
  border-color: rgba(167, 139, 250, 0.75);
  transform: translateY(-1px);
}

.hidden {
  display: none !important;
}

/* Room Layout */
.room-shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 58px;
  flex-shrink: 0;
  padding: 0 16px;
  background: rgba(14, 16, 24, 0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.room-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.badge-svg {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.badge-svg svg {
  width: 100%;
  height: 100%;
}

.room-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-muted);
  font-size: 12px;
}

.room-main {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #050609;
  position: relative;
}

.player-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#yt-player-container {
  width: 100%;
  height: 100%;
}

#yt-player-container iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.stage-toolbar {
  padding: 10px 16px;
  background: rgba(15, 17, 25, 0.94);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.stage-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 220px;
}

.stage-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.media-change-input {
  flex: 1;
  max-width: 420px;
  padding: 7px 11px;
  font-size: 13px;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.toggle-label input {
  accent-color: var(--brand-a);
}

/* External DRM Platform Card */
.external-card {
  width: 100%;
  max-width: 470px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px 28px;
  text-align: center;
  margin: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.external-icon-orb {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
}

.external-icon-orb svg {
  width: 32px;
  height: 32px;
}

.external-platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

.external-card h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.external-card p {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.external-actions {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-box {
  margin-top: 18px;
  text-align: start;
  background: rgba(7, 8, 13, 0.72);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.guide-box strong {
  color: var(--text);
  display: block;
  margin-bottom: 6px;
}

.guide-box ol {
  padding-inline-start: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Floating reactions */
.reaction-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 15;
}

.floating-reaction {
  position: absolute;
  bottom: 24px;
  font-size: 28px;
  animation: floatUp 2.2s ease-out forwards;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.floating-reaction span {
  font-size: 10px;
  background: rgba(0, 0, 0, 0.76);
  padding: 2px 7px;
  border-radius: 999px;
  margin-top: 2px;
  color: #fff;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) scale(0.8);
    opacity: 0;
  }
  15% {
    opacity: 1;
    transform: translateY(-20px) scale(1.08);
  }
  100% {
    transform: translateY(-220px) scale(0.95);
    opacity: 0;
  }
}

/* Sidebar */
.sidebar {
  width: 348px;
  flex-shrink: 0;
  background: rgba(15, 17, 25, 0.96);
  border-inline-start: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.users-panel {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 9px;
}

.users-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 92px;
  overflow-y: auto;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 5px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  max-width: 100%;
  transition: border-color 0.15s;
}

.user-chip.is-self {
  border-color: rgba(139, 92, 246, 0.45);
  cursor: pointer;
}

.user-chip.is-self:hover {
  border-color: rgba(139, 92, 246, 0.8);
}

.avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.host-star {
  color: #fbbf24;
  font-size: 11px;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-empty {
  margin: auto;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.msg-system {
  align-self: center;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  padding: 3px 10px;
}

.msg-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 8px 11px;
}

.msg-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.msg-author {
  font-weight: 600;
}

.msg-time {
  font-size: 10px;
  color: var(--text-muted);
}

.msg-text {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.reaction-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
}

.reaction-btn {
  background: transparent;
  border: none;
  font-size: 17px;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 8px;
  transition: background 0.12s, transform 0.12s;
}

.reaction-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(1.18);
}

.chat-form {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  padding: 9px 12px;
  font-size: 13px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}

.modal-card h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

@media (max-width: 860px) {
  .room-main {
    flex-direction: column;
  }
  .stage {
    min-height: 44vh;
  }
  .sidebar {
    width: 100%;
    flex: 1;
    border-inline-start: none;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 520px) {
  .platform-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .home-card {
    padding: 22px 18px;
  }
}
