:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #08111f;
  color: #edf7ff;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(21, 164, 255, 0.16), transparent 34rem),
    radial-gradient(circle at 85% 80%, rgba(245, 129, 36, 0.13), transparent 28rem),
    #08111f;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.card {
  width: min(100%, 46rem);
  padding: clamp(2rem, 7vw, 5rem);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 2rem;
  background: rgba(10, 25, 43, 0.78);
  box-shadow: 0 2rem 7rem rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

.lobby-card {
  width: min(100%, 42rem);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #9fc4de;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pulse {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: #6ee7a8;
  box-shadow: 0 0 0 0.35rem rgba(110, 231, 168, 0.12);
}

h1 {
  max-width: 10ch;
  margin: 1.5rem 0 1rem;
  font-size: clamp(3rem, 10vw, 6.4rem);
  font-weight: 720;
  letter-spacing: -0.065em;
  line-height: 0.93;
}

.join-form {
  display: grid;
  gap: 0.7rem;
}

label {
  margin-top: 0.55rem;
  color: #9fc4de;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-width: 0;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0.9rem;
  outline: none;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  font: inherit;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:focus {
  border-color: #6cc6ff;
  box-shadow: 0 0 0 3px rgba(108, 198, 255, 0.14);
}

.room-input {
  display: flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.06);
}

.room-input:focus-within {
  border-color: #6cc6ff;
  box-shadow: 0 0 0 3px rgba(108, 198, 255, 0.14);
}

.room-input span {
  padding-left: 1rem;
  color: #7693a8;
}

.room-input input {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.join-form button {
  margin-top: 0.8rem;
}

.tech-note {
  margin: 2rem 0 0;
  color: #7693a8;
  font-size: 0.78rem;
}

.chat-page {
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.chat-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(100%, 58rem);
  height: min(86vh, 52rem);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1.5rem;
  background: rgba(10, 25, 43, 0.88);
  box-shadow: 0 2rem 7rem rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

.chat-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header h1 {
  max-width: none;
  margin: 0.3rem 0 0;
  font-size: clamp(1.7rem, 5vw, 2.6rem);
  letter-spacing: -0.045em;
  line-height: 1;
}

.back-link {
  color: #8ba8bc;
  font-size: 0.78rem;
  text-decoration: none;
}

.back-link:hover {
  color: #d5ecfb;
}

.room-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 0.55rem;
}

.connection-status,
.presence {
  padding: 0.38rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: #adc6d7;
  font-size: 0.74rem;
  white-space: nowrap;
}

.connection-status::before {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: #f5c66d;
  content: "";
}

.connection-status[data-state="connected"]::before {
  background: #6ee7a8;
}

.connection-status[data-state="error"]::before {
  background: #ff8177;
}

.messages {
  overflow-y: auto;
  padding: 1.4rem 1.5rem;
  scrollbar-color: #345269 transparent;
}

.message {
  max-width: 78%;
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  border-radius: 0.35rem 1rem 1rem;
  background: rgba(255, 255, 255, 0.07);
}

.message header {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.message strong {
  color: #84d3ff;
  font-size: 0.86rem;
}

.message time {
  color: #6f899c;
  font-size: 0.68rem;
}

.message p {
  margin: 0.28rem 0 0;
  overflow-wrap: anywhere;
  line-height: 1.5;
  white-space: pre-wrap;
}

.system-message {
  margin: 0.7rem 0;
  color: #7895aa;
  font-size: 0.78rem;
  font-style: italic;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.composer button {
  border-radius: 0.9rem;
}

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

.intro {
  max-width: 34rem;
  margin: 0 0 2rem;
  color: #b8cddd;
  font-size: 1.05rem;
  line-height: 1.7;
}

button {
  appearance: none;
  padding: 0.9rem 1.2rem;
  border: 0;
  border-radius: 999px;
  background: #f48124;
  color: #1e1005;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  transition: transform 150ms ease, background 150ms ease;
}

button:hover:not(:disabled) {
  background: #ff9b4b;
  transform: translateY(-2px);
}

button:focus-visible {
  outline: 3px solid #9edbff;
  outline-offset: 4px;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.result {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 2rem 0 0;
}

.result[hidden],
.error[hidden] {
  display: none;
}

.result div {
  min-width: 0;
  padding: 1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.055);
}

dt {
  margin-bottom: 0.4rem;
  color: #7895aa;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

dd {
  overflow-wrap: anywhere;
  margin: 0;
  font-size: 0.9rem;
}

.error {
  margin: 1.5rem 0 0;
  color: #ffaaa2;
}

@media (max-width: 620px) {
  .shell {
    padding: 1rem;
  }

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

  .chat-page {
    display: block;
    padding: 0;
  }

  .chat-shell {
    width: 100%;
    height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .chat-header,
  .messages,
  .composer {
    padding-right: 1rem;
    padding-left: 1rem;
  }

  .message {
    max-width: 92%;
  }
}
