:root {
  color-scheme: dark;
  --bg: #070b16;
  --bg-soft: #0c1224;
  --panel: rgba(18, 25, 47, 0.82);
  --panel-solid: #12192f;
  --panel-dark: #080d1a;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #f8fafc;
  --muted: #9ba9c1;
  --primary: #8b5cf6;
  --primary-strong: #7c3aed;
  --secondary: #22d3ee;
  --success: #34d399;
  --danger: #fb7185;
  --warning: #fbbf24;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  --radius: 22px;
  --radius-small: 14px;
  --focus: 0 0 0 3px rgba(139, 92, 246, 0.3);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 15%, rgba(139, 92, 246, 0.12), transparent 32rem),
    radial-gradient(circle at 85% 30%, rgba(34, 211, 238, 0.08), transparent 28rem),
    linear-gradient(180deg, #090e1d 0%, var(--bg) 46%, #050812 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

[hidden] {
  display: none !important;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 34rem;
  height: 34rem;
  border-radius: 999px;
  filter: blur(110px);
  opacity: 0.12;
  pointer-events: none;
}

.ambient-one {
  top: -14rem;
  left: -10rem;
  background: var(--primary);
}

.ambient-two {
  right: -12rem;
  bottom: -16rem;
  background: var(--secondary);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
}

.shell-wide {
  width: min(1460px, calc(100% - 32px));
  margin-inline: auto;
}

.site-header,
.room-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 84px;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: linear-gradient(145deg, var(--primary), var(--secondary));
  box-shadow: 0 10px 32px rgba(139, 92, 246, 0.28);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
}

.brand > span:last-child {
  display: flex;
  flex-direction: column;
  line-height: 1.08;
}

.brand strong {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.page-main {
  padding: 42px 0 80px;
}

.center-card {
  display: flex;
  min-height: 55vh;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  color: var(--muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-layout {
  display: grid;
  min-height: calc(100vh - 210px);
  align-items: center;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
  gap: clamp(42px, 8vw, 110px);
}

.hero-copy h1,
.dashboard-hero h1 {
  margin: 12px 0 18px;
  max-width: 790px;
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.hero-copy p,
.dashboard-hero p {
  max-width: 690px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.eyebrow {
  display: inline-block;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.feature-row span,
.host-chip,
.counter-badge,
.code-badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.feature-row span {
  padding: 10px 13px;
  color: #cbd5e1;
  font-size: 13px;
}

.panel,
.panel-dark {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.panel {
  background: var(--panel);
}

.panel-dark {
  background: var(--panel-dark);
}

.auth-panel {
  padding: 26px;
}

.tab-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 28px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.tab-button {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.tab-button.is-active {
  background: rgba(139, 92, 246, 0.18);
  color: #fff;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stack h2,
.section-heading h2,
.participants-panel h2 {
  margin: 7px 0 0;
  font-size: 24px;
  letter-spacing: -0.025em;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #dbe4f0;
  font-size: 14px;
  font-weight: 700;
}

.field small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.field input {
  width: 100%;
  min-height: 49px;
  padding: 0 15px;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: rgba(5, 8, 18, 0.66);
  color: var(--text);
  transition:
    border-color 0.2s ease,
    background 0.2s ease;
}

.field input:hover {
  border-color: rgba(148, 163, 184, 0.42);
}

.field input:focus {
  border-color: var(--primary);
  background: rgba(5, 8, 18, 0.9);
  outline: none;
  box-shadow: var(--focus);
}

.field input::placeholder {
  color: #66738b;
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 0.18s ease,
    filter 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.44;
}

.button-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  box-shadow: 0 12px 28px rgba(124, 58, 237, 0.28);
  color: #fff;
}

.button-secondary {
  border-color: rgba(34, 211, 238, 0.28);
  background: rgba(34, 211, 238, 0.1);
  color: #bcf4fb;
}

.button-ghost {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: #dbe4f0;
}

.button-danger {
  border-color: rgba(251, 113, 133, 0.3);
  background: rgba(251, 113, 133, 0.1);
  color: #fecdd3;
}

.button-small {
  min-height: 36px;
  padding-inline: 12px;
  border-radius: 11px;
  font-size: 13px;
}

.button-wide {
  width: 100%;
}

.form-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.form-status.is-error {
  color: #fda4af;
}

.form-status.is-success {
  color: #6ee7b7;
}

.status-success {
  color: var(--success);
}

.status-error {
  color: var(--danger);
}

.dashboard {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  padding: clamp(28px, 5vw, 52px);
}

.dashboard-hero h1 {
  margin-bottom: 10px;
  font-size: clamp(36px, 5vw, 58px);
}

.identity-card {
  display: flex;
  min-width: 220px;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 20px;
  border: 1px solid rgba(139, 92, 246, 0.28);
  border-radius: 18px;
  background: rgba(139, 92, 246, 0.08);
}

.identity-card span {
  color: var(--muted);
  font-size: 12px;
}

.identity-card strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 21px;
  letter-spacing: 0.08em;
}

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

.dashboard-grid > .panel {
  padding: 26px;
}

.dashboard-span-two {
  grid-column: 1 / -1;
}

.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.grow-field {
  flex: 1;
}

.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
  font-size: 22px !important;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.result-list,
.room-list,
.participants-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-item,
.room-list-item,
.participant-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.025);
}

.result-item:hover,
.room-list-item:hover {
  border-color: rgba(139, 92, 246, 0.32);
  background: rgba(139, 92, 246, 0.045);
}

.avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(139, 92, 246, 0.23), rgba(34, 211, 238, 0.13));
  color: #e9d5ff;
  font-weight: 900;
  text-transform: uppercase;
}

.item-copy {
  min-width: 0;
  flex: 1;
}

.item-copy strong,
.item-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-copy strong {
  font-size: 15px;
}

.item-copy span {
  margin-top: 4px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.empty-state {
  padding: 26px;
  border: 1px dashed var(--border-strong);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  max-width: min(390px, calc(100% - 44px));
  padding: 14px 17px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: var(--shadow);
  color: #eef2ff;
  font-size: 14px;
  line-height: 1.45;
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Room */
.room-page {
  background:
    radial-gradient(circle at 50% -20%, rgba(139, 92, 246, 0.17), transparent 40rem),
    var(--bg);
}

.room-header {
  min-height: 76px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.09);
}

.room-title-block {
  position: absolute;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(-50%);
}

.room-title-block > strong {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-badge {
  min-height: 34px;
  padding: 0 12px;
  border-color: rgba(34, 211, 238, 0.25);
  color: #a5f3fc;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.room-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  padding: 24px 0 50px;
}

.watch-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 18px;
}

.player-card {
  overflow: hidden;
}

.player-shell {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.08), transparent 45%),
    #03050a;
}

#youtubePlayer,
#youtubePlayer iframe {
  width: 100%;
  height: 100%;
}

.join-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(4, 7, 15, 0.8), rgba(4, 7, 15, 0.92)),
    radial-gradient(circle at center, rgba(139, 92, 246, 0.18), transparent 60%);
}

.join-overlay-card {
  max-width: 520px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(12, 18, 36, 0.85);
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(18px);
}

.join-overlay-card h1 {
  margin: 10px 0;
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: -0.04em;
}

.join-overlay-card p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.6;
}

.join-overlay-card .form-status {
  margin: 12px 0 0;
}

.local-resume {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 18px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(251, 191, 36, 0.34);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.95);
  color: #fde68a;
  cursor: pointer;
  font-weight: 800;
  transform: translateX(-50%);
}

.timeline-row {
  display: grid;
  align-items: center;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  gap: 12px;
  padding: 14px 18px 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.range {
  width: 100%;
  height: 5px;
  accent-color: var(--primary);
  cursor: pointer;
}

.range:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 18px 16px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 9px;
}

.volume-group {
  min-width: 190px;
}

.volume {
  max-width: 110px;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  font-weight: 900;
}

.icon-button:hover:not(:disabled) {
  border-color: rgba(139, 92, 246, 0.42);
  background: rgba(139, 92, 246, 0.12);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

#hostPanel,
.room-help,
.participants-panel {
  padding: 22px;
}

.host-chip {
  padding: 8px 11px;
  border-color: rgba(52, 211, 153, 0.28);
  background: rgba(52, 211, 153, 0.08);
  color: #a7f3d0;
  font-size: 12px;
  font-weight: 800;
}

.room-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.room-help > div {
  display: flex;
  min-width: 220px;
  flex-direction: column;
  gap: 5px;
}

.room-help p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: right;
}

.participants-panel {
  align-self: start;
  position: sticky;
  top: 20px;
}

.counter-badge {
  padding: 8px 11px;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 800;
}

.participants-list {
  margin: 20px 0;
}

.participant-item {
  padding: 11px;
}

.participant-status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.7);
}

.owner-label {
  margin-left: auto;
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 800;
}

.invite-box {
  padding: 16px;
  border: 1px dashed rgba(34, 211, 238, 0.28);
  border-radius: 16px;
  background: rgba(34, 211, 238, 0.04);
}

.invite-box p {
  margin: 7px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 980px) {
  .auth-layout {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .hero-copy {
    padding-top: 20px;
  }

  .auth-panel {
    width: min(560px, 100%);
  }

  .room-layout {
    grid-template-columns: 1fr;
  }

  .participants-panel {
    position: static;
  }

  .room-title-block {
    position: static;
    transform: none;
  }
}

@media (max-width: 720px) {
  .shell,
  .shell-wide {
    width: min(100% - 22px, 1120px);
  }

  .site-header,
  .room-header {
    min-height: 68px;
  }

  .site-header .header-user > span,
  .room-header .header-user > span {
    display: none;
  }

  .brand small {
    display: none;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .page-main {
    padding-top: 26px;
  }

  .hero-copy h1 {
    font-size: 42px;
  }

  .hero-copy p {
    font-size: 16px;
  }

  .dashboard-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .identity-card {
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-span-two {
    grid-column: auto;
  }

  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .result-item,
  .room-list-item {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .item-actions {
    width: 100%;
    justify-content: flex-start;
    padding-left: 56px;
  }

  .room-header {
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 10px 0;
  }

  .room-title-block {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .room-layout {
    padding-top: 14px;
  }

  .control-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .volume-group {
    width: 100%;
  }

  .volume {
    max-width: none;
    flex: 1;
  }

  .room-help {
    align-items: flex-start;
    flex-direction: column;
  }

  .room-help p {
    text-align: left;
  }
}

@media (max-width: 480px) {
  .auth-panel,
  .dashboard-grid > .panel,
  #hostPanel,
  .room-help,
  .participants-panel {
    padding: 18px;
  }

  .hero-copy h1 {
    font-size: 36px;
  }

  .feature-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .timeline-row {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    gap: 8px;
    padding-inline: 12px;
  }

  .control-row {
    padding-inline: 12px;
  }

  .control-group:first-child {
    width: 100%;
    flex-wrap: wrap;
  }

  #syncButton {
    flex: 1;
  }

  .join-overlay {
    padding: 12px;
  }

  .join-overlay-card {
    padding: 20px;
  }

  .local-resume {
    width: calc(100% - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
