:root {
  --obsidian: #0f172a;
  --obsidian-soft: #17223c;
  --card: rgba(20, 29, 50, 0.58);
  --card-border: rgba(190, 206, 246, 0.2);
  --text: #e5ebff;
  --text-muted: #9caed9;
  --accent: #7dd3fc;
  --accent-strong: #38bdf8;
  --danger: #f87171;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 8% 12%, #1f2e52 0, transparent 45%),
    radial-gradient(circle at 88% 92%, #15324e 0, transparent 42%), var(--obsidian);
}

.app-shell {
  width: 100%;
  margin: 16px auto 20px;
  padding: 0 2vw;
  transition: opacity 200ms ease, transform 240ms cubic-bezier(0.22, 1, 0.36, 1), filter 240ms ease;
  transform-origin: top center;
}

.app-shell.screen-out,
.app-shell.screen-in {
  opacity: 0;
  transform: translateY(10px) scale(0.995);
  filter: blur(2px);
  pointer-events: none;
}

.app-screen {
  min-height: calc(100vh - 36px);
}

.settings-screen {
  width: min(980px, 100%);
  margin: 0 auto;
}

.settings-header,
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(18, 26, 45, 0.75);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
}

.settings-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-panel .drawer-group {
  margin-bottom: 0;
}

.settings-panel .room-browser-list {
  min-height: 180px;
  max-height: 300px;
}

.create-actions-row {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr);
  gap: 12px;
  align-items: start;
}

.create-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0.03em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.brand-logo {
  display: block;
  height: clamp(34px, 5vw, 52px);
  width: auto;
  max-width: min(44vw, 300px);
  object-fit: contain;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(165, 188, 238, 0.35);
  color: var(--text);
  background: rgba(37, 55, 92, 0.65);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.96rem;
}

.icon-btn:hover {
  background: rgba(55, 78, 122, 0.78);
}

.leave-btn {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

.leave-btn:hover {
  background: rgba(111, 42, 52, 0.8);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(125, 211, 252, 0.35);
  color: var(--accent);
  background: rgba(26, 45, 69, 0.76);
  font-size: 0.84rem;
  font-weight: 700;
}

.drawer-group {
  border: 1px solid rgba(156, 174, 217, 0.24);
  background: rgba(16, 23, 38, 0.45);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
}

.drawer-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.drawer-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.status-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
  color: var(--text-muted);
  font-size: 0.84rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border-radius: 9px;
  border: 1px solid rgba(171, 189, 229, 0.35);
  background: rgba(10, 16, 31, 0.65);
  color: var(--text);
  padding: 8px 10px;
  margin-bottom: 8px;
}

input::placeholder {
  color: #8396c3;
}

button {
  border: 1px solid rgba(171, 189, 229, 0.35);
  background: rgba(40, 59, 95, 0.75);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 10px;
  cursor: pointer;
}

button:hover {
  background: rgba(55, 78, 122, 0.84);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-actions > input {
  margin-bottom: 0;
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 0.85rem;
}

.toggle-inline input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
}

.room-screen {
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .app-shell {
    transition: none;
  }

  .app-shell.screen-out,
  .app-shell.screen-in {
    opacity: 1;
    transform: none;
    filter: none;
    pointer-events: auto;
  }
}

.cinema-layout {
  min-height: calc(100vh - 116px);
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(300px, 1fr);
  gap: 12px;
}

.player-stage {
  position: relative;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: rgba(14, 21, 36, 0.82);
  padding: 12px;
}

.player-badges {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  gap: 8px;
  z-index: 2;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(190, 206, 246, 0.35);
  background: rgba(11, 16, 29, 0.78);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 700;
}

#room-role.badge {
  color: #bfdbfe;
}

#host-controls-badge.badge {
  color: #93c5fd;
}

video {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border-radius: 12px;
  background: #000;
  object-fit: contain;
}

.player-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.right-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-card {
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: var(--card);
  backdrop-filter: blur(14px);
  padding: 11px;
}

.users-card {
  min-height: 200px;
  max-height: 34vh;
  display: flex;
  flex-direction: column;
}

.chat-card {
  flex: 1;
  min-height: 340px;
  display: flex;
  flex-direction: column;
}

.sidebar-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.user-list,
.room-browser-list,
.library-list {
  border: 1px solid rgba(156, 174, 217, 0.25);
  border-radius: 10px;
  background: rgba(8, 13, 24, 0.62);
  overflow-y: auto;
}

.user-list {
  flex: 1;
  min-height: 140px;
}

.user-entry,
.room-browser-entry,
.library-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(121, 140, 183, 0.22);
}

.user-entry:last-child,
.room-browser-entry:last-child,
.library-entry:last-child {
  border-bottom: none;
}

.user-name,
.room-browser-title,
.library-entry-name {
  font-weight: 700;
  word-break: break-word;
}

.user-meta,
.room-browser-meta,
.library-entry-meta,
.library-meta {
  color: var(--text-muted);
  font-size: 0.79rem;
}

.user-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-action {
  font-size: 0.72rem;
  padding: 6px 7px;
}

.user-empty,
.room-browser-empty,
.library-empty {
  padding: 11px;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.chat-log {
  flex: 1;
  min-height: 0;
  border: 1px solid rgba(156, 174, 217, 0.25);
  border-radius: 10px;
  background: rgba(8, 13, 24, 0.6);
  padding: 10px;
  overflow-y: auto;
  margin-bottom: 9px;
}

.chat-line {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  align-items: flex-start;
}

.chat-user {
  font-weight: 700;
  color: #93c5fd;
}

.chat-body {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-form {
  position: relative;
}

.chat-editor {
  min-height: 42px;
  max-height: 104px;
  overflow-y: auto;
  padding: 8px 9px;
  border-radius: 10px;
  border: 1px solid rgba(156, 174, 217, 0.25);
  background: rgba(8, 13, 24, 0.68);
}

.chat-editor:empty::before {
  content: attr(data-placeholder);
  color: #7f93c3;
}

.chat-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}

.gif-btn {
  width: auto;
  min-width: 42px;
  padding: 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
}

.emote-picker {
  position: absolute;
  right: 0;
  bottom: 86px;
  width: min(420px, calc(100vw - 44px));
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid rgba(156, 174, 217, 0.35);
  border-radius: 10px;
  background: rgba(9, 14, 26, 0.95);
  padding: 8px;
  z-index: 20;
}

.gif-picker {
  position: absolute;
  right: 0;
  bottom: 86px;
  width: min(520px, calc(100vw - 44px));
  max-height: 320px;
  border: 1px solid rgba(156, 174, 217, 0.35);
  border-radius: 10px;
  background: rgba(9, 14, 26, 0.95);
  padding: 8px;
  z-index: 21;
}

.gif-picker-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#gif-search-input {
  margin: 0;
}

.gif-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(106px, 1fr));
  gap: 7px;
  max-height: 248px;
  overflow-y: auto;
}

.gif-option {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: stretch;
  padding: 6px;
}

.gif-option-image {
  width: 100%;
  height: 86px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid rgba(156, 174, 217, 0.25);
}

.gif-option-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gif-picker-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 8px 5px;
}

.hidden {
  display: none !important;
}

.emote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 7px;
}

.emote-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 5px;
}

.emote-option-image,
.chat-emote,
.chat-editor-emote {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.chat-gif {
  display: block;
  max-width: min(280px, 60vw);
  max-height: 180px;
  border-radius: 8px;
  border: 1px solid rgba(156, 174, 217, 0.25);
  object-fit: cover;
}

.emote-option-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.emote-picker-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 5px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 18, 0.68);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 14px;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: min(84vh, 760px);
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: rgba(11, 18, 31, 0.96);
  padding: 12px;
}

.modal-header,
.modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.modal-toolbar {
  flex-wrap: wrap;
}

.library-list {
  flex: 1;
  min-height: 200px;
}

@media (max-width: 1120px) {
  .cinema-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .right-sidebar {
    min-height: 520px;
  }

}

@media (max-width: 900px) {
  .settings-panel {
    grid-template-columns: 1fr;
  }

  .create-actions-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar,
  .settings-header {
    flex-wrap: wrap;
  }

  .player-meta {
    flex-direction: column;
    gap: 6px;
  }

  .user-entry,
  .room-browser-entry,
  .library-entry {
    grid-template-columns: 1fr;
  }

  .user-actions {
    justify-content: flex-start;
  }
}
