.player-wrapper.fullscreen #fullscreenToggle {
  opacity: 0;
  pointer-events: none;
}
:root {
  color-scheme: light dark;
  font-family: 'Segoe UI', Roboto, sans-serif;
  background-color: #0f1729;
  color: #f9fafb;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #1d2a4a, #0f1729);
  display: flex;
  justify-content: center;
}

.container {
  width: min(1200px, 96vw);
  padding: 32px 0 64px;
}

.app-header {
  text-align: center;
  margin-bottom: 32px;
}

.app-header h1 {
  margin: 0;
  font-size: 40px;
}

.app-header p {
  margin: 8px 0 0;
  color: rgba(249, 250, 251, 0.7);
}

.join-card,
.panel {
  background: rgba(15, 23, 41, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  padding: 24px;
  backdrop-filter: blur(24px);
}

.join-card {
  max-width: 640px;
  margin: 0 auto 32px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.field label {
  font-size: 14px;
  color: rgba(226, 232, 240, 0.8);
}

.field input,
.field select {
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.9);
  color: #f9fafb;
  padding: 0 12px;
  width: 100%;
}

#newRoomId,
#roomId {
  min-height: 40px;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(94, 234, 212, 0.7);
  border-color: transparent;
}

.inline {
  display: flex;
  gap: 12px;
}

.inline input {
  flex: 1;
}

.primary,
.secondary {
  border-radius: 10px;
  border: none;
  height: 42px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.primary {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #0f172a;
}

.secondary {
  background: rgba(148, 163, 184, 0.2);
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.primary:hover,
.secondary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.hidden {
  display: none !important;
}

.helper {
  margin: 4px 0 0;
  font-size: 13px;
  color: rgba(148, 163, 184, 0.8);
}

.card-group {
  display: grid;
  gap: 20px;
}

.feedback {
  min-height: 20px;
  margin: 4px 0 16px;
  font-size: 13px;
  color: #f87171;
}

.feedback.success {
  color: #4ade80;
}

.existing-rooms {
  margin-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  padding-top: 16px;
}

.existing-rooms ul {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.existing-rooms li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.existing-rooms li strong {
  font-size: 15px;
  color: #f9fafb;
}

.existing-rooms li span {
  font-size: 13px;
  color: rgba(148, 163, 184, 0.8);
  display: block;
}

.room-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.link-button {
  background: none;
  border: none;
  color: #38bdf8;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 0;
}

.link-button:hover {
  text-decoration: underline;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.section-header h3 {
  margin: 0;
  font-size: 18px;
}

.room {
  display: grid;
  grid-template-columns: 2fr minmax(240px, 320px);
  gap: 24px;
  align-items: flex-start;
}

.video-select {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.library-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.library-search {
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.9);
  color: #f9fafb;
  padding: 0 12px;
}

.library-search:focus {
  outline: 2px solid rgba(94, 234, 212, 0.7);
  border-color: transparent;
}

.library-selects {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.field.compact {
  margin-bottom: 0;
  gap: 6px;
}

.field.compact label {
  font-size: 13px;
  color: rgba(226, 232, 240, 0.7);
}

.library-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.library-actions button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.library-actions button {
  min-width: 140px;
}

.room-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin: 12px 0 20px;
  flex-wrap: wrap;
}

.danger {
  border-radius: 10px;
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
  height: 42px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.danger:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.player-wrapper {
  position: relative;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.2);
  aspect-ratio: 16 / 9;
  display: flex;
  justify-content: center;
  align-items: center;
}

.player {
  width: 100%;
  height: 100%;
  transition: filter 0.2s ease;
}

.player.quality-medium {
  filter: contrast(0.95) saturate(0.9);
}

.player.quality-low {
  filter: blur(0.8px) contrast(0.85) saturate(0.85);
}

#youtubeHolder {
  width: 100%;
  height: 100%;
  transition: filter 0.2s ease;
}

#youtubeHolder.quality-medium iframe {
  filter: contrast(0.95) saturate(0.9);
}

#youtubeHolder.quality-low iframe {
  filter: blur(0.8px) contrast(0.85) saturate(0.85);
}

#youtubePlayer iframe {
  width: 100%;
  height: 100%;
}

.sidebar {
  display: grid;
  gap: 24px;
}

.chat,
.users {
  background: rgba(15, 23, 41, 0.75);
  border-radius: 18px;
  padding: 18px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: clamp(320px, 46vh, 430px);
}

.chat h3,
.users h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 240px;
  max-height: none;
  overflow-y: auto;
  margin-bottom: 0;
  padding-right: 6px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-radius: 16px;
  padding: 10px 14px 9px;
  max-width: 82%;
  position: relative;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
}

.chat-message.other {
  align-self: flex-start;
  background: rgba(30, 41, 59, 0.9);
  border-top-left-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #e2e8f0;
}

.chat-message.self {
  align-self: flex-end;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #0f172a;
  border-top-right-radius: 8px;
}

.chat-message.system {
  align-self: center;
  background: rgba(148, 163, 184, 0.18);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: rgba(226, 232, 240, 0.88);
  max-width: 70%;
  text-align: center;
  box-shadow: none;
}

.chat-message.system .chat-meta {
  display: none;
}

.chat-message.system .chat-text {
  color: inherit;
  font-weight: 500;
  font-size: 12px;
  line-height: 1.4;
}

.chat-system-time {
  margin-top: 4px;
  font-size: 11px;
  color: rgba(148, 163, 184, 0.65);
}

.chat-text {
  font-size: 14px;
  line-height: 1.45;
  color: #f1f5f9;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-message.self .chat-text {
  color: #0f172a;
  text-align: right;
}

.chat-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.chat-meta strong {
  color: #e2e8f0;
  font-weight: 600;
}

.chat-meta span {
  font-size: 12px;
  color: rgba(148, 163, 184, 0.75);
}

.chat-message.self .chat-meta {
  flex-direction: row-reverse;
}

.chat-message.self .chat-meta strong {
  color: #0f172a;
}

.chat-message.self .chat-meta span {
  color: rgba(15, 23, 42, 0.6);
}

.chat-message.other .chat-meta strong {
  color: #38bdf8;
}

.chat-message.other .chat-meta span {
  color: rgba(148, 163, 184, 0.8);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-top: auto;
}

.chat-form input {
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.9);
  color: #f9fafb;
  padding: 0 12px;
}

.chat-form input:focus {
  outline: 2px solid rgba(94, 234, 212, 0.7);
  border-color: transparent;
}

.users ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.users {
  max-height: 320px;
  overflow-y: auto;
}

.users li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.user-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-meta {
  font-size: 12px;
  color: rgba(148, 163, 184, 0.75);
}

.signal-bars {
  display: inline-flex;
  gap: 2px;
  align-items: flex-end;
}

.signal-bar {
  width: 4px;
  border-radius: 2px;
  background: rgba(148, 163, 184, 0.35);
}

.signal-bar:nth-child(1) {
  height: 6px;
}

.signal-bar:nth-child(2) {
  height: 10px;
}

.signal-bar:nth-child(3) {
  height: 14px;
}

.signal-bar:nth-child(4) {
  height: 18px;
}

.signal-bar.active {
  background: #34d399;
}

.users li {
  background: rgba(30, 41, 59, 0.8);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal-dialog {
  position: relative;
  width: min(420px, 92vw);
  background: rgba(15, 23, 42, 0.92);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  padding: 28px 24px 24px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.45);
  display: grid;
  gap: 18px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: rgba(148, 163, 184, 0.9);
  font-size: 20px;
  cursor: pointer;
}

.modal-section {
  display: grid;
  gap: 16px;
}

.modal-section label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: rgba(226, 232, 240, 0.85);
}

.modal-section input {
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.9);
  color: #f8fafc;
  padding: 0 12px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal .feedback {
  margin: 0;
}

@media (max-width: 960px) {
  .room {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .users {
    max-height: none;
  }

  .chat {
    height: clamp(320px, 55vh, 460px);
  }

  .card-group {
    gap: 16px;
  }
}

@media (max-width: 600px) {
  .join-card {
    padding: 20px;
  }

  .inline {
    flex-direction: column;
  }

  .inline input {
    width: 100%;
  }

  .existing-rooms li {
    grid-template-columns: 1fr;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .chat {
    height: clamp(300px, 60vh, 500px);
  }

  .room-actions {
    justify-content: stretch;
  }

  .room-actions button {
    width: 100%;
  }
}

