@import url("https://fonts.googleapis.com/css2?family=Oxanium:wght@500;600;700&family=Space+Grotesk:wght@400;500;700&display=swap");

:root {
  --bg: #050b12;
  --bg-2: #0b1b29;
  --surface: rgba(10, 21, 33, 0.78);
  --surface-2: rgba(15, 31, 47, 0.74);
  --surface-3: rgba(17, 37, 56, 0.62);
  --line: rgba(140, 190, 222, 0.24);
  --line-strong: rgba(46, 214, 197, 0.42);
  --text: #f2fbff;
  --muted: #95b3c9;
  --accent: #ff9448;
  --accent-2: #2ed6c5;
  --danger: #ff6179;
  --warn: #f6b53e;
  --success: #32d289;
  --shadow-lg: 0 26px 60px rgba(0, 0, 0, 0.38);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.26);
  --dur-fast: 170ms;
  --dur-med: 280ms;
  --dur-slow: 520ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-spring: cubic-bezier(0.18, 0.92, 0.24, 1.15);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 82% -8%, rgba(24, 81, 126, 0.52), transparent 36%),
    radial-gradient(circle at 10% 110%, rgba(255, 148, 72, 0.16), transparent 30%),
    linear-gradient(150deg, #040911 0%, #071420 48%, #0a1a28 100%);
}

body {
  overflow-x: hidden;
}

.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 20% 16%, rgba(46, 214, 197, 0.14), transparent 22%),
    radial-gradient(circle at 86% 84%, rgba(255, 148, 72, 0.16), transparent 20%);
}

.ambient-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(161, 211, 237, 0.04) 50%,
    transparent 100%
  );
  background-size: 100% 5px;
  opacity: 0.24;
}

.app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.sidebar,
.main {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(160deg, var(--surface) 0%, rgba(6, 15, 25, 0.9) 100%);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-lg);
}

.sidebar::before,
.main::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.04);
  mask-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.7), transparent);
}

.sidebar {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.brand {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background:
    radial-gradient(circle at 92% 4%, rgba(46, 214, 197, 0.2), transparent 36%),
    linear-gradient(132deg, rgba(255, 148, 72, 0.13), rgba(46, 214, 197, 0.08));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.brand h1 {
  margin: 0;
  font-family: "Oxanium", "Space Grotesk", sans-serif;
  font-size: 1.72rem;
  letter-spacing: 0.01em;
}

.brand-tag {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.brand-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: linear-gradient(180deg, var(--surface-2), rgba(9, 21, 34, 0.78));
}

.card h2 {
  margin: 0 0 8px;
  font-family: "Oxanium", "Space Grotesk", sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.11em;
}

.stack {
  display: grid;
  gap: 7px;
}

input,
button {
  font: inherit;
}

input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid rgba(154, 201, 230, 0.3);
  background: rgba(7, 21, 33, 0.68);
  color: var(--text);
  outline: none;
  font-size: 0.9rem;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

input:focus {
  border-color: rgba(255, 148, 72, 0.82);
  background: rgba(8, 27, 40, 0.92);
  box-shadow: 0 0 0 3px rgba(255, 148, 72, 0.14);
}

input::placeholder {
  color: rgba(149, 179, 201, 0.86);
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition:
    transform var(--dur-fast) var(--ease-spring),
    box-shadow var(--dur-fast) var(--ease-out),
    filter var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out);
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.01);
  filter: brightness(1.07);
}

.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

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

.btn-primary {
  background: linear-gradient(120deg, var(--accent), #f5b13d);
  color: #1a1006;
  box-shadow: 0 8px 18px rgba(255, 148, 72, 0.25);
}

.btn-secondary {
  background: linear-gradient(120deg, #2094d1, var(--accent-2));
  color: #032430;
  box-shadow: 0 8px 18px rgba(46, 214, 197, 0.2);
}

.btn-danger {
  background: linear-gradient(120deg, #ff6d84, #ff5d76);
  color: #29050b;
}

.btn-ghost {
  background: rgba(157, 198, 223, 0.12);
  border: 1px solid rgba(157, 198, 223, 0.2);
  color: var(--text);
}

.rooms-card {
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

.rooms-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rooms-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  overflow: auto;
}

.room-item {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  border: 1px solid rgba(138, 192, 225, 0.2);
  border-radius: 11px;
  padding: 9px;
  background: linear-gradient(130deg, rgba(4, 18, 29, 0.76), rgba(9, 27, 39, 0.68));
  display: grid;
  gap: 5px;
  transform: perspective(760px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x));
  transition:
    transform var(--dur-med) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
  animation: roomEntry 420ms var(--ease-out) both;
  animation-delay: var(--room-delay, 0s);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.01);
}

.room-item.hovered {
  border-color: rgba(46, 214, 197, 0.36);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.24),
    0 0 0 1px rgba(46, 214, 197, 0.14);
}

.room-item.pressed {
  transform: perspective(760px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x)) scale(0.985);
}

.room-item-lobby {
  min-height: 92px;
  align-content: space-between;
  padding: 9px;
  gap: 6px;
  background: linear-gradient(150deg, rgba(8, 30, 43, 0.92), rgba(7, 22, 34, 0.84));
}

.room-item-lobby .room-row strong {
  font-size: 0.9rem;
}

.room-item-lobby .room-code {
  font-size: 0.68rem;
}

.room-item-lobby .room-lock,
.room-item-lobby .room-count {
  font-size: 0.72rem;
}

.room-item-lobby .btn {
  justify-self: flex-start;
  margin-top: auto;
}

.room-item-empty {
  opacity: 0.92;
}

.room-item-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

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

.room-code {
  font-size: 0.75rem;
  color: var(--accent-2);
  letter-spacing: 0.06em;
}

.room-lock {
  color: var(--warn);
  font-size: 0.72rem;
  font-weight: 700;
}

.room-count {
  color: var(--muted);
  font-size: 0.72rem;
}

.main {
  min-height: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.main-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.kicker {
  margin: 0;
  color: var(--accent-2);
  text-transform: uppercase;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
}

.main-head h2 {
  margin: 3px 0;
  font-family: "Oxanium", "Space Grotesk", sans-serif;
  font-size: 1.32rem;
  letter-spacing: 0.03em;
}

.room-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

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

.status {
  min-height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: linear-gradient(120deg, rgba(13, 34, 48, 0.65), rgba(8, 23, 35, 0.66));
  display: flex;
  align-items: center;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.status.success {
  border-color: rgba(50, 210, 137, 0.5);
  color: var(--success);
}

.status.warning {
  border-color: rgba(246, 181, 62, 0.5);
  color: var(--warn);
}

.status.error {
  border-color: rgba(255, 93, 111, 0.5);
  color: var(--danger);
}

.lobby-view {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(8, 24, 36, 0.82), rgba(8, 19, 29, 0.9));
  padding: 12px;
  display: none;
  grid-template-rows: auto 1fr;
  gap: 10px;
  overflow: hidden;
}

.lobby-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.lobby-kicker {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.lobby-head h3 {
  margin: 4px 0;
  font-family: "Oxanium", "Space Grotesk", sans-serif;
  font-size: 1.16rem;
  letter-spacing: 0.03em;
}

.lobby-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.lobby-rooms-list {
  margin: 0;
  padding: 0;
  list-style: none;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 280px));
  justify-content: flex-start;
  align-content: flex-start;
  gap: 10px;
}

.content {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 285px;
  gap: 10px;
  overflow: hidden;
}

.chat,
.people {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(8, 24, 36, 0.82), rgba(8, 19, 29, 0.9));
  overflow: hidden;
}

.chat {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
}

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

.msg {
  align-self: flex-start;
  width: fit-content;
  max-width: min(76%, 620px);
  border: 1px solid rgba(147, 198, 227, 0.24);
  border-radius: 13px;
  padding: 6px 9px;
  background: linear-gradient(145deg, rgba(6, 22, 33, 0.9), rgba(4, 16, 24, 0.82));
  box-shadow: var(--shadow-md);
  animation: messageIn var(--dur-fast) var(--ease-out);
}

.msg.self {
  align-self: flex-end;
  border-color: rgba(46, 214, 197, 0.48);
  background: linear-gradient(145deg, rgba(16, 70, 62, 0.5), rgba(8, 38, 34, 0.72));
}

.msg.system {
  border-style: dashed;
  border-color: rgba(246, 181, 62, 0.44);
}

.msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.66rem;
  margin-bottom: 3px;
  letter-spacing: 0.02em;
}

.msg-author {
  color: var(--accent-2);
  font-weight: 700;
}

.msg-time {
  color: var(--muted);
  opacity: 0.84;
}

.msg.system .msg-author {
  color: var(--warn);
}

.msg p {
  margin: 0;
  line-height: 1.35;
  font-size: 0.87rem;
  word-break: break-word;
}

.chat-form {
  border-top: 1px solid var(--line);
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.people {
  padding: 10px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}

.people h3 {
  margin: 0 0 6px;
  font-family: "Oxanium", "Space Grotesk", sans-serif;
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.members-list {
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
}

.member-item {
  position: relative;
  border: 1px solid rgba(134, 191, 222, 0.22);
  border-radius: 999px;
  padding: 6px 9px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
  background: linear-gradient(120deg, rgba(7, 27, 40, 0.84), rgba(8, 31, 44, 0.6));
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.member-item.self {
  border-color: rgba(255, 148, 72, 0.34);
}

.member-item.speaking {
  border-color: rgba(46, 214, 197, 0.62);
  box-shadow:
    0 0 0 1px rgba(46, 214, 197, 0.18),
    0 0 20px rgba(46, 214, 197, 0.18);
  transform: translateX(1px);
}

.member-item.speaking::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent-2);
  transform: translateY(-50%);
  box-shadow: 0 0 0 6px rgba(46, 214, 197, 0.12);
  animation: speakerPulse 1.1s ease-out infinite;
}

.member-name {
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-audio {
  font-size: 0.62rem;
  color: #093529;
  background: rgba(142, 246, 223, 0.92);
  border-radius: 999px;
  padding: 2px 7px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition:
    transform var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.member-audio.muted {
  background: rgba(130, 154, 170, 0.3);
  color: #9cbcd3;
}

.member-audio.live {
  background: rgba(46, 214, 197, 0.95);
  color: #032f29;
  transform: translateY(-0.5px);
}

.mic-box {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.mic-box p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.remote-audios {
  height: 0;
  overflow: hidden;
}

body:not(.ready) .sidebar,
body:not(.ready) .main {
  opacity: 0;
  transform: translateY(14px) scale(0.985);
}

body.ready .sidebar {
  animation: panelIn var(--dur-slow) var(--ease-out) both;
}

body.ready .main {
  animation: panelIn calc(var(--dur-slow) + 90ms) var(--ease-out) 70ms both;
}

body.ready .brand {
  opacity: 0;
  animation: riseIn 520ms var(--ease-out) 130ms both;
}

body.ready .sidebar .card {
  opacity: 0;
  animation: riseIn 470ms var(--ease-out) both;
}

body.ready .sidebar .card:nth-of-type(1) {
  animation-delay: 180ms;
}

body.ready .sidebar .card:nth-of-type(2) {
  animation-delay: 230ms;
}

body.ready .sidebar .card:nth-of-type(3) {
  animation-delay: 280ms;
}

body.ready .sidebar .card:nth-of-type(4) {
  animation-delay: 330ms;
}

body.room-join .status.success {
  animation: statusSpark 620ms var(--ease-spring);
}

body:not(.in-room) .rooms-card {
  display: none;
}

body:not(.in-room) .content {
  display: none;
}

body:not(.in-room) .lobby-view {
  display: grid;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.985);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes roomEntry {
  from {
    opacity: 0;
    transform: perspective(760px) translateY(9px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: perspective(760px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x));
  }
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(7px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes speakerPulse {
  0% {
    opacity: 0.92;
    box-shadow: 0 0 0 0 rgba(46, 214, 197, 0.36);
  }
  75% {
    opacity: 0.24;
    box-shadow: 0 0 0 9px rgba(46, 214, 197, 0);
  }
  100% {
    opacity: 0;
    box-shadow: 0 0 0 0 rgba(46, 214, 197, 0);
  }
}

@keyframes statusSpark {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(50, 210, 137, 0);
  }
  45% {
    transform: scale(1.01);
    box-shadow: 0 0 0 5px rgba(50, 210, 137, 0.14);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(50, 210, 137, 0);
  }
}

@media (max-width: 1024px) {
  .app {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .content {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .main-head {
    flex-direction: column;
  }

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

  .lobby-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .lobby-rooms-list {
    grid-template-columns: 1fr;
  }
}

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

  .room-item,
  .room-item.pressed,
  .room-item.hovered {
    transform: none !important;
  }
}
