:root {
  --gradient: linear-gradient(135deg, #25b0d6 0%, #7c47d6 100%);
  --bg: #000;
  --surface: rgba(255, 255, 255, 0.04);
  --border: rgba(156, 172, 172, 0.2);
  --muted: rgb(180, 190, 190);
  --danger: rgb(255, 120, 120);
}

* {
  box-sizing: border-box;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  min-height: 100dvh;
  background-color: var(--bg);
  color: white;
  padding-top: 64px;
}

[hidden] {
  display: none !important;
}

/* header section */
.fixed-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(6px);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 999;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo {
  width: 40px;
  height: auto;
  border-radius: 50%;
}
.app-title {
  font-weight: bold;
  font-size: 20px;
  font-family: monospace, fantasy, 'Source Code Pro';
  margin: 0;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.status-pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgb(220, 180, 60);
  transition: background 0.2s ease;
}
.status-pill[data-state="waiting"] .status-pill__dot {
  background: rgb(220, 180, 60);
}
.status-pill[data-state="connecting"] .status-pill__dot {
  background: rgb(37, 176, 214);
  animation: pulse 1.2s infinite;
}
.status-pill[data-state="connected"] .status-pill__dot {
  background: rgb(60, 210, 120);
}
.status-pill[data-state="disconnected"] .status-pill__dot {
  background: var(--danger);
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* landing screen */
.landing {
  width: 100vw;
  max-width: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
}
.landing__card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px 28px;
  text-align: center;
}
.landing__title {
  margin: 0 0 8px;
  font-size: 22px;
}
.landing__subtitle {
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.landing__label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  text-align: left;
}
.landing__input {
  width: 100%;
  height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 14px;
  background: white;
  color: #222;
  margin-bottom: 8px;
}
.landing__input:focus {
  outline: none;
  border-color: rgb(124, 71, 214);
  box-shadow: 0 0 0 3px rgba(124, 71, 214, 0.25);
}
.landing__choice {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}
.landing__btn {
  height: 48px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: white;
  font-size: 15px;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.landing__btn:hover {
  filter: brightness(1.15);
}
.landing__btn:focus-visible {
  outline: 2px solid rgb(37, 176, 214);
  outline-offset: 2px;
}
.landing__btn--primary {
  background: var(--gradient);
  border: none;
}
.landing__join {
  text-align: left;
  margin-top: 18px;
}
.landing__join-actions {
  display: flex;
  gap: 10px;
}
.landing__join-actions .landing__btn {
  flex: 1;
}
.landing__error {
  color: var(--danger);
  font-size: 12px;
  margin: 6px 0 0;
  text-align: left;
}

/* chat screen */
.content {
  border-radius: 6px;
  height: 100dvh;
  max-height: 620px;
  width: 100vw;
  max-width: 400px;
  display: flex;
  flex-direction: column;
}

.room-bar {
  flex-shrink: 0;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.room-bar__code {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.room-bar__label {
  font-size: 12px;
  color: var(--muted);
}
.room-bar__value {
  font-family: monospace;
  font-size: 14px;
  font-weight: bold;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--gradient);
  color: #05070a;
  letter-spacing: 0.5px;
}
.room-bar__row {
  display: flex;
  gap: 8px;
}
.room-bar__input {
  flex-grow: 1;
  min-width: 0;
  height: 38px;
  border: none;
  border-radius: 4px;
  padding: 0 12px;
  font-size: 13px;
  background: white;
  color: #222;
}
.room-bar__copy {
  border: none;
  border-radius: 4px;
  background: rgb(11, 206, 11);
  color: white;
  padding: 0 16px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}
.room-bar__copy.copied {
  background: rgb(37, 176, 214);
}
.room-bar__copy:focus-visible,
input:focus-visible,
button:focus-visible {
  outline: 2px solid rgb(37, 176, 214);
  outline-offset: 2px;
}

.messages {
  flex-grow: 1;
  padding: 20px 24px;
  overflow-y: auto;
  position: relative;
}
.messages__empty {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 0 20px;
}

.message {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
  animation: rise 0.2s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.message--mine {
  align-items: flex-end;
}
.message--theirs {
  align-items: flex-start;
}
.message__meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 4px 6px;
  font-size: 12px;
}
.message__name {
  color: var(--muted);
}
.message__time {
  color: rgba(180, 190, 190, 0.6);
  font-size: 11px;
}
.message__bubble {
  padding: 14px 18px;
  border-radius: 14px;
  max-width: 240px;
  word-wrap: break-word;
}
.message--theirs .message__bubble {
  background: rgb(37, 176, 214);
  border-bottom-left-radius: 4px;
}
.message--mine .message__bubble {
  background: rgb(124, 71, 214);
  color: white;
  border-bottom-right-radius: 4px;
}

.full-banner {
  padding: 10px 20px;
  background: rgba(255, 120, 120, 0.12);
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  border-top: 1px solid var(--border);
}

/* message input footer */
.footer {
  line-height: 76px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
}
.footer input {
  height: 76px;
  border: none;
  flex-grow: 1;
  padding: 0 24px;
  font-size: 16px;
  background: white;
}
.footer button {
  border: none;
  background: rgb(11, 206, 11);
  color: white;
  padding: 0 30px;
  font-size: 16px;
  cursor: pointer;
}
.footer button:disabled {
  background: rgb(80, 100, 100);
  cursor: not-allowed;
}

@media (max-width: 420px) {
  .content, .landing {
    max-width: 100vw;
  }
}
