:root {
  --black: #070307;
  --black-soft: #10080f;
  --maroon: #5d102e;
  --maroon-bright: #97194d;
  --purple: #4b1768;
  --purple-bright: #8f3fc1;
  --cream: #fff4ec;
  --muted: #bfaebd;
  --line: rgba(255, 255, 255, .11);
  --panel: rgba(24, 10, 22, .88);
  --danger: #ce3157;
  --success: #56d6a0;
  --radius: 20px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }
html { background: var(--black); color-scheme: dark; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--cream);
  background:
    radial-gradient(circle at 12% 5%, rgba(115, 19, 64, .28), transparent 35%),
    radial-gradient(circle at 90% 15%, rgba(75, 23, 104, .28), transparent 35%),
    linear-gradient(160deg, #080307, #120711 48%, #070307);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 35rem;
  height: 35rem;
  border-radius: 50%;
  filter: blur(110px);
  opacity: .18;
}
.ambient-one { top: -15rem; left: -10rem; background: var(--maroon-bright); }
.ambient-two { right: -15rem; bottom: -15rem; background: var(--purple-bright); }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  padding: 12px clamp(18px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 3, 7, .78);
  backdrop-filter: blur(22px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, var(--maroon-bright), var(--purple));
  box-shadow: 0 8px 30px rgba(151, 25, 77, .35);
}
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.header-status { display: flex; align-items: center; gap: 10px; }
.identity { color: var(--muted); font-size: 13px; }

.page {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(42px, 6vw, 90px) 0 80px;
}
body.room-active .page { padding-top: clamp(20px, 3vw, 42px); }
.view { animation: reveal .35s ease; }
@keyframes reveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.hero { max-width: 900px; padding: 8vh 0 4vh; }
.eyebrow {
  color: #e88aba;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.hero h1 {
  max-width: 850px;
  margin: 18px 0;
  font-size: clamp(54px, 9vw, 112px);
  line-height: .91;
  letter-spacing: -.065em;
}
.hero h1 span {
  color: transparent;
  background: linear-gradient(90deg, #ff7bab, #b977e7);
  -webkit-background-clip: text;
  background-clip: text;
}
.hero > p {
  max-width: 720px;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.65;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.feature-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  margin-top: 54px;
  color: var(--muted);
  font-size: 13px;
}
.feature-strip span::before { content: "✦"; margin-right: 8px; color: #d45a9b; }

.button {
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--cream);
  background: rgba(255, 255, 255, .06);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.24); }
.button:disabled { opacity: .5; cursor: wait; transform: none; }
.button-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--maroon-bright), var(--purple));
  box-shadow: 0 10px 32px rgba(107, 15, 62, .28);
}
.button-secondary { background: rgba(105, 34, 108, .25); }
.button-danger { color: #ffdce5; border-color: rgba(206,49,87,.45); }
.button-quiet { min-height: 36px; padding: 7px 12px; }
.button-small { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.button-wide { width: 100%; }

.badge {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
}
.badge.online { color: var(--success); border-color: rgba(86,214,160,.32); }

.panel, .auth-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.auth-card { width: min(480px, 100%); margin: 5vh auto; padding: 32px; }
.auth-card h2, .section-heading h2, .room-heading h2 {
  margin: 10px 0;
  font-size: clamp(30px, 4vw, 48px);
}
.auth-card > p { color: var(--muted); line-height: 1.55; }

.form-stack { display: grid; gap: 16px; }
.form-stack label, .compact-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  color: var(--cream);
  background: rgba(2, 1, 3, .58);
}
input { min-height: 48px; padding: 10px 13px; }
textarea { resize: none; padding: 11px 13px; line-height: 1.45; }
input:focus, textarea:focus, select:focus {
  border-color: rgba(208, 87, 157, .7);
  box-shadow: 0 0 0 3px rgba(151, 25, 77, .14);
}
.form-error { min-height: 18px; color: #ff8ca8; font-size: 12px; }
.inline-form { max-width: 680px; margin-top: 28px; }
.inline-form label { display: block; margin-bottom: 8px; color: var(--muted); }
.inline-form > div { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

.dashboard { max-width: 700px; margin: 0 auto; }
.dashboard .panel { margin-top: 24px; padding: 24px; }

.room-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.invite-panel {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(220, 85, 158, .28);
  border-radius: 14px;
  background: rgba(105, 16, 66, .22);
}
.invite-panel span { color: var(--muted); font-size: 11px; }
.invite-panel strong { font-size: 18px; letter-spacing: .12em; }
.invite-panel button { grid-column: 1 / -1; }
.invite-panel button + button { margin-top: 4px; }

.cinema-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 390px);
  gap: 18px;
  align-items: start;
}
.cinema-column { display: grid; gap: 18px; }
.screen-shell {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 22px;
  background: #000;
  box-shadow: 0 32px 100px rgba(0,0,0,.62);
}
.screen-top-glow {
  position: absolute;
  z-index: 2;
  top: -1px;
  left: 12%;
  width: 76%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #dd5ba0, transparent);
  filter: blur(1px);
}
#player {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}
.reaction-layer {
  position: absolute;
  z-index: 7;
  inset: 8% 0 58px;
  overflow: hidden;
  pointer-events: none;
  --reaction-travel: -420px;
}
.floating-reaction {
  position: absolute;
  bottom: -10px;
  left: var(--reaction-left, 50%);
  font-size: clamp(30px, 4.4vw, 54px);
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .55));
  opacity: 0;
  transform: translate3d(-50%, 20px, 0) scale(.72) rotate(-8deg);
  animation: reaction-rise var(--reaction-duration, 3.6s) cubic-bezier(.2,.72,.25,1) forwards;
  will-change: transform, opacity;
}
@keyframes reaction-rise {
  0% {
    opacity: 0;
    transform: translate3d(-50%, 22px, 0) scale(.7) rotate(-10deg);
  }
  12% { opacity: 1; }
  55% {
    opacity: .96;
    transform: translate3d(calc(-50% + var(--reaction-sway, 18px)), calc(var(--reaction-travel) * .55), 0) scale(1.08) rotate(8deg);
  }
  100% {
    opacity: 0;
    transform: translate3d(calc(-50% - var(--reaction-sway, 18px)), var(--reaction-travel), 0) scale(1.24) rotate(-6deg);
  }
}
.tap-to-sync {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 82px;
  transform: translateX(-50%);
}
.tap-to-sync:hover { transform: translateX(-50%) translateY(-1px); }
.screen-empty {
  position: absolute;
  inset: 0 0 58px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  text-align: center;
  background:
    radial-gradient(circle, rgba(90,23,77,.28), transparent 45%),
    #030103;
}
.screen-empty small { color: var(--muted); }
.screen-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--maroon-bright), var(--purple));
}
.screen-footer {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}
.reaction-dock,
.local-controls { display: flex; align-items: center; gap: 7px; }
.reaction-dock {
  justify-content: center;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.04);
}
.reaction-dock button {
  display: grid;
  width: 31px;
  height: 31px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}
.reaction-dock button:hover {
  transform: translateY(-2px) scale(1.12);
  background: rgba(255,255,255,.1);
}
.local-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}
.local-controls input { width: 90px; min-height: 0; padding: 0; }
.compact-select {
  min-height: 36px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--cream);
  background: #170b16;
}

.admin-controls, .seats-panel, .chat-panel { padding: 18px; }
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-title span { color: var(--muted); font-size: 11px; }
.host-playback-controls {
  display: grid;
  grid-template-columns: repeat(4, auto) minmax(150px, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0,0,0,.2);
}
.player-host-controls {
  position: absolute;
  z-index: 10;
  right: 10px;
  bottom: 68px;
  left: 10px;
  margin: 0;
  background: rgba(7,3,7,.88);
  backdrop-filter: blur(12px);
}
.host-seek {
  min-height: 0;
  padding: 0;
}
#hostTimeLabel {
  min-width: 88px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.compact-form {
  display: grid;
  grid-template-columns: 1fr 1.5fr minmax(120px, auto) auto;
  gap: 8px;
  margin-bottom: 10px;
}
#uploadMediaForm { grid-template-columns: 1fr 1.5fr auto; }
.media-library-section {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0,0,0,.16);
}
.media-library-title { margin-bottom: 10px; }
.media-library { display: grid; gap: 8px; }
.media-library-empty { margin: 2px 0; color: var(--muted); font-size: 12px; }
.media-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.04);
}
.media-chip.current {
  border-color: rgba(86,214,160,.48);
  background: rgba(35,115,86,.18);
}
.media-chip span {
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.seats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(82px, 1fr));
  gap: 10px;
}
.seat {
  position: relative;
  min-height: 92px;
  padding: 10px 7px;
  border: 1px solid var(--line);
  border-radius: 14px 14px 8px 8px;
  text-align: center;
  background: rgba(255,255,255,.035);
}
.seat.occupied {
  border-color: rgba(204, 71, 143, .38);
  background: linear-gradient(160deg, rgba(111,20,70,.42), rgba(65,25,90,.32));
}
.seat-number { color: var(--muted); font-size: 10px; }
.seat-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  margin: 7px auto 4px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  font-weight: 800;
}
.seat-name {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seat-actions { display: flex; justify-content: center; gap: 3px; margin-top: 6px; }
.seat-actions button {
  padding: 3px 5px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: rgba(0,0,0,.3);
  cursor: pointer;
  font-size: 9px;
}

.chat-panel {
  position: sticky;
  top: 92px;
  display: flex;
  height: min(760px, calc(100vh - 112px));
  flex-direction: column;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding-right: 5px;
  scrollbar-color: var(--maroon) transparent;
}
.chat-message {
  margin: 0 0 10px;
  padding: 10px 11px;
  border-radius: 12px;
  background: rgba(255,255,255,.045);
}
.chat-message.mentioned {
  border: 1px solid rgba(218,83,157,.44);
  background: rgba(112,20,75,.26);
}
.chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
}
.chat-body { overflow-wrap: anywhere; line-height: 1.4; font-size: 13px; }
.chat-actions { margin-top: 5px; }
.chat-actions button {
  margin-right: 8px;
  padding: 0;
  border: 0;
  color: #d78bb6;
  background: none;
  cursor: pointer;
  font-size: 10px;
}
.reply-banner {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 2px solid var(--maroon-bright);
  color: var(--muted);
  background: rgba(255,255,255,.04);
  font-size: 11px;
}
.reply-banner button { border: 0; color: white; background: none; cursor: pointer; }
.emoji-bar { display: flex; gap: 3px; margin: 8px 0; overflow-x: auto; }
.emoji-bar button {
  border: 0;
  padding: 5px;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}
.emoji-bar button:hover { background: rgba(255,255,255,.08); }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.toast {
  position: fixed;
  z-index: 50;
  right: 20px;
  bottom: 20px;
  max-width: min(380px, calc(100% - 40px));
  padding: 12px 16px;
  border: 1px solid rgba(210,81,151,.45);
  border-radius: 12px;
  background: #2b0d22;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .cinema-layout { grid-template-columns: 1fr; }
  .chat-panel { position: static; height: min(560px, 70vh); }
  .seats-grid { grid-template-columns: repeat(5, 1fr); }
  .screen-footer { flex-wrap: wrap; }
  .host-playback-controls { grid-template-columns: repeat(4, 1fr); }
  .host-seek { grid-column: 1 / -1; }
}
@media (max-width: 680px) {
  .page { width: calc(100% - 12px); padding-top: 24px; padding-bottom: 36px; }
  body.room-active .page { padding-top: 12px; }
  .topbar { min-height: 64px; padding: 9px 12px; }
  .brand small, .identity { display: none; }
  .hero { padding-top: 4vh; }
  .hero h1 { font-size: clamp(50px, 17vw, 78px); }
  .auth-card { padding: 22px; }
  .room-heading { align-items: stretch; flex-direction: column; }
  .compact-form, #uploadMediaForm { grid-template-columns: 1fr; }
  .seats-grid { grid-template-columns: repeat(2, 1fr); }
  .seat:first-child { grid-column: 1 / -1; }
  .cinema-column { gap: 10px; }
  .screen-shell, .panel { border-radius: 14px; }
  .screen-footer { align-items: stretch; flex-direction: column; gap: 8px; padding: 8px; }
  .reaction-layer { inset: 4% 0 112px; --reaction-travel: -250px; }
  .reaction-dock { width: 100%; justify-content: space-around; order: 3; }
  .reaction-dock button { width: 38px; height: 38px; font-size: 20px; }
  .local-controls { width: 100%; flex-wrap: wrap; justify-content: space-between; }
  .host-playback-controls { grid-template-columns: repeat(2, 1fr); }
  .player-host-controls { position: relative; inset: auto; margin: 0; border-radius: 0; }
  .host-playback-controls .button { width: 100%; }
  #hostTimeLabel { min-width: 0; }
  .media-chip { grid-template-columns: minmax(0, 1fr) auto; }
  .media-chip span { grid-column: 1 / -1; }
  .chat-panel { height: min(500px, 68vh); }
}
@media (prefers-reduced-motion: reduce) {
  .floating-reaction {
    animation-name: reaction-fade;
    animation-duration: 1.4s;
  }
  @keyframes reaction-fade {
    0% { opacity: 0; transform: translate3d(-50%, 8px, 0) scale(.9); }
    25% { opacity: 1; }
    100% { opacity: 0; transform: translate3d(-50%, -60px, 0) scale(1.05); }
  }
}
@media (min-width: 1600px) {
  body { font-size: 18px; }
  .page { width: min(1700px, calc(100% - 80px)); }
  .cinema-layout { grid-template-columns: 1fr 430px; }
  .chat-body { font-size: 15px; }
}
