:root {
  --ink: #07090d;
  --ink-2: #10151e;
  --line: rgba(232, 196, 120, 0.18);
  --text: #f3efe6;
  --muted: #9a9182;
  --signal: #e8c478;
  --signal-deep: #c4923a;
  --danger: #e06b5a;
  --ok: #6dbf8c;
  --font-display: "Bricolage Grotesque", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

button:focus {
  outline: none;
}

button:focus-visible {
  outline: 2px solid rgba(232, 196, 120, 0.55);
  outline-offset: 2px;
}

html {
  height: 100%;
  background-color: var(--ink);
  color-scheme: dark;
}

html,
body {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  background-color: var(--ink);
  background-image:
    radial-gradient(1200px 700px at 70% -10%, rgba(196, 146, 58, 0.16), transparent 55%),
    radial-gradient(900px 600px at -10% 90%, rgba(80, 120, 160, 0.12), transparent 50%),
    linear-gradient(165deg, #0b0f16 0%, var(--ink) 45%, #0a1018 100%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

body.splash-lock {
  overflow: hidden;
}

.ptr {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.15s ease;
  padding-top: env(safe-area-inset-top);
  color: var(--signal);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ptr.is-on {
  opacity: 1;
}

.ptr.is-ready .ptr-label {
  color: #f0d39a;
}

.ptr.is-loading .ptr-ring {
  animation: ptr-spin 0.7s linear infinite;
}

.ptr-ring {
  width: 1.35rem;
  height: 1.35rem;
  border: 2px solid rgba(232, 196, 120, 0.25);
  border-top-color: var(--signal);
  border-radius: 50%;
}

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

body.splash-lock .top,
body.splash-lock main,
body.splash-lock .foot {
  opacity: 0;
  pointer-events: none;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(800px 500px at 50% 40%, rgba(232, 196, 120, 0.14), transparent 60%),
    #05070b;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

.splash.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.splash-logo {
  width: min(260px, 70vw);
  height: auto;
  display: block;
  animation: splash-pop 1.05s cubic-bezier(0.22, 1.2, 0.36, 1) both;
}

.splash-line {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  animation: splash-line 0.7s ease 0.45s both;
}

@keyframes splash-pop {
  0% {
    opacity: 0;
    transform: scale(0.82) translateY(16px);
    filter: blur(8px);
  }
  60% {
    opacity: 1;
    filter: blur(0);
    transform: scale(1.04) translateY(0);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}

@keyframes splash-line {
  from {
    opacity: 0;
    letter-spacing: 0.35em;
  }
  to {
    opacity: 1;
    letter-spacing: 0.14em;
  }
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.glow {
  pointer-events: none;
  position: fixed;
  width: 40vw;
  height: 40vw;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(232, 196, 120, 0.08), transparent 65%);
  z-index: 0;
  animation: breathe 7s ease-in-out infinite;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.55;
    transform: translateX(-50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.08);
  }
}

.top,
main,
.foot {
  position: relative;
  z-index: 1;
  transition: opacity 0.45s ease;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  line-height: 0;
}

.brand-logo {
  height: 1.85rem;
  width: auto;
  display: block;
  /* PNGs ship on black — knock out the black plate */
  mix-blend-mode: screen;
}

.online {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(109, 191, 140, 0.55);
  animation: pulse-dot 2s ease-out infinite;
}

@keyframes pulse-dot {
  0% {
    box-shadow: 0 0 0 0 rgba(109, 191, 140, 0.5);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(109, 191, 140, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(109, 191, 140, 0);
  }
}

main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 0 1.25rem;
  overflow: hidden;
}

.screen {
  flex: 1 1 auto;
  min-height: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.25rem;
  padding: 2rem 0 3rem;
  animation: fade-up 0.45s ease both;
  overflow: hidden;
}

.screen.active {
  display: flex;
}

#lobby.screen {
  justify-content: flex-start;
  padding-top: 0.5rem;
  padding-bottom: 1.25rem;
  gap: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

#lobby .lobby-stage {
  position: relative;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0 0.75rem;
}

#lobby .marquee-stack {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.65rem;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 8%,
    #000 92%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 8%,
    #000 92%,
    transparent 100%
  );
  opacity: 0.9;
}

#lobby .marquee-stack:active {
  cursor: grabbing;
}

#lobby .marquee {
  overflow: hidden;
  width: 100%;
  filter: saturate(1.05) brightness(0.95);
  pointer-events: auto;
}

#lobby .marquee-track {
  display: flex;
  width: max-content;
  gap: 0.75rem;
  will-change: transform;
  animation: none;
}

#lobby .marquee-track img {
  width: min(220px, 58vw);
  height: min(150px, 40vw);
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(232, 196, 120, 0.18);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
  mix-blend-mode: screen;
  opacity: 0.85;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

@keyframes marquee-left {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-50%, 0, 0);
  }
}

@keyframes marquee-right {
  from {
    transform: translate3d(-50%, 0, 0);
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  #lobby .marquee-stack {
    cursor: default;
  }
}

#lobby .hero-stack {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 1.25rem 1rem;
  text-align: center;
  pointer-events: none;
  background: radial-gradient(
    ellipse 70% 65% at 50% 45%,
    rgba(7, 9, 13, 0.82) 0%,
    rgba(7, 9, 13, 0.45) 55%,
    transparent 75%
  );
}

#lobby .hero-stack .hero-brand,
#lobby .hero-stack .tagline {
  pointer-events: auto;
}

#lobby .lobby-bottom {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-top: auto;
  margin-bottom: 0.35rem;
  flex-shrink: 0;
  padding-top: 0.5rem;
}

#lobby #startBtn {
  margin-top: 0.25rem;
  width: min(16rem, 100%);
}

.tags-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  max-width: 22rem;
}

.tag {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(16, 21, 30, 0.75);
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tag:hover {
  border-color: rgba(232, 196, 120, 0.4);
  color: var(--text);
}

.tag:focus,
.tag:focus-visible {
  outline: none;
  border-color: rgba(232, 196, 120, 0.55);
  color: var(--signal);
}

.tag:active {
  background: rgba(232, 196, 120, 0.12);
  border-color: rgba(232, 196, 120, 0.45);
  color: var(--signal);
}

.tag.is-on {
  background: rgba(232, 196, 120, 0.16);
  border-color: rgba(232, 196, 120, 0.55);
  color: var(--signal);
}

.tag.is-on:focus,
.tag.is-on:focus-visible {
  outline: none;
  background: rgba(232, 196, 120, 0.2);
  border-color: var(--signal);
}

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

.hero-brand {
  margin: 0;
  line-height: 0;
  animation: brand-in 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hero-logo {
  width: min(240px, 68vw);
  height: auto;
  display: block;
}

@keyframes brand-in {
  from {
    opacity: 0;
    transform: scale(0.92);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

.tagline {
  margin: 0;
  max-width: 18rem;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  border-radius: 4px;
  padding: 0.9rem 1.6rem;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease,
    border-color 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--signal);
  color: #1a1206;
  min-width: 11rem;
  animation: cta-glow 2.8s ease-in-out infinite;
}

.btn.primary:hover {
  background: #f0d39a;
}

@keyframes cta-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(232, 196, 120, 0.2);
  }
  50% {
    box-shadow: 0 0 28px 2px rgba(232, 196, 120, 0.28);
  }
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn.ghost:hover {
  color: var(--text);
  border-color: rgba(232, 196, 120, 0.4);
}

.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(224, 107, 90, 0.45);
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
}

.btn.danger:hover {
  background: rgba(224, 107, 90, 0.12);
}

.status-line {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--muted);
}

.status-line.connected {
  color: var(--ok);
}

.radar {
  position: relative;
  width: 120px;
  height: 120px;
  margin-bottom: 0.5rem;
}

.radar span {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(232, 196, 120, 0.35);
  border-radius: 50%;
  animation: radar 2.2s ease-out infinite;
}

.radar span:nth-child(2) {
  animation-delay: 0.7s;
}

.radar span:nth-child(3) {
  animation-delay: 1.4s;
}

.radar::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--signal);
}

@keyframes radar {
  from {
    transform: scale(0.25);
    opacity: 0.9;
  }
  to {
    transform: scale(1);
    opacity: 0;
  }
}

.chat-screen {
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
  gap: 0;
  padding: 0.65rem 0 0.85rem;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  height: 100%;
  overflow: hidden;
}

.chat-shell {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(232, 196, 120, 0.22);
  border-radius: 18px;
  background:
    radial-gradient(600px 280px at 80% 0%, rgba(232, 196, 120, 0.1), transparent 55%),
    radial-gradient(500px 260px at 10% 100%, rgba(80, 140, 120, 0.08), transparent 50%),
    linear-gradient(165deg, rgba(18, 22, 32, 0.92), rgba(10, 13, 20, 0.88));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 18px 50px rgba(0, 0, 0, 0.35),
    0 0 40px rgba(232, 196, 120, 0.06);
  animation: shell-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes shell-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  border-bottom: 1px solid rgba(232, 196, 120, 0.14);
  background: linear-gradient(180deg, rgba(232, 196, 120, 0.06), transparent);
  flex-shrink: 0;
}

.chat-presence {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.live-ping {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(109, 191, 140, 0.55);
  animation: live-pulse 1.8s ease-out infinite;
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(109, 191, 140, 0.55);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(109, 191, 140, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(109, 191, 140, 0);
  }
}

.chat-bar .status-line.connected {
  color: #b7e0c4;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.btn.next {
  background: rgba(232, 196, 120, 0.08);
  color: var(--signal);
  border: 1px solid rgba(232, 196, 120, 0.4);
  width: 2.55rem;
  height: 2.55rem;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
  border-radius: 999px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.next:hover {
  background: rgba(232, 196, 120, 0.16);
  box-shadow: 0 0 18px rgba(232, 196, 120, 0.18);
}

.composer {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  padding: 0.75rem 0.85rem 0.9rem;
  border-top: 1px solid rgba(232, 196, 120, 0.14);
  background: linear-gradient(0deg, rgba(232, 196, 120, 0.05), transparent);
}

.btn.sticker-btn {
  flex-shrink: 0;
  width: 2.55rem;
  height: 2.55rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(232, 196, 120, 0.35);
  background: rgba(232, 196, 120, 0.08);
  color: var(--signal);
  font-size: 1.15rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.btn.sticker-btn.is-on,
.btn.sticker-btn:hover {
  background: rgba(232, 196, 120, 0.18);
  border-color: rgba(232, 196, 120, 0.55);
}

.sticker-panel {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem 0.65rem;
  flex-shrink: 0;
  border-top: 1px solid rgba(232, 196, 120, 0.12);
  background: rgba(7, 9, 13, 0.45);
  max-height: 12rem;
  overflow: hidden;
  animation: typing-in 0.2s ease both;
}

.sticker-panel[hidden] {
  display: none;
}

.sticker-tabs {
  display: flex;
  gap: 0.35rem;
}

.sticker-tab {
  appearance: none;
  border: 1px solid rgba(232, 196, 120, 0.22);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sticker-tab.is-on {
  color: var(--signal);
  border-color: rgba(232, 196, 120, 0.5);
  background: rgba(232, 196, 120, 0.12);
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.35rem;
  overflow-y: auto;
  max-height: 8.5rem;
  scrollbar-width: thin;
}

.sticker-grid[hidden] {
  display: none;
}

.sticker-grid button {
  appearance: none;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0.4rem 0.15rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, transform 0.12s ease;
}

.sticker-grid button:hover,
.sticker-grid button:active {
  background: rgba(232, 196, 120, 0.12);
  transform: scale(1.08);
}

.sticker-gif-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

.sticker-gif-grid button {
  padding: 0.35rem;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.sticker-gif-grid img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.msg.sticker {
  font-size: 1.85rem;
  line-height: 1;
  padding: 0.35rem 0.45rem;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.msg.sticker.me,
.msg.sticker.them {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.msg.gif-sticker {
  padding: 0.15rem;
  background: transparent;
  border: none;
  box-shadow: none;
  max-width: 48%;
  animation: sticker-pop 0.45s cubic-bezier(0.22, 1.4, 0.36, 1) both;
}

.msg.gif-sticker img {
  display: block;
  width: min(150px, 42vw);
  height: auto;
  border-radius: 12px;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35));
}

@keyframes sticker-pop {
  0% {
    opacity: 0;
    transform: scale(0.6) translateY(12px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.sticker-gif-grid button {
  background: rgba(232, 196, 120, 0.06);
  border: 1px solid rgba(232, 196, 120, 0.16);
}

.chat-screen .btn.danger {
  border-radius: 999px;
}

.messages {
  flex: 1 1 auto;
  min-height: 0;
  height: 0; /* force flex child to respect parent bounds */
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1rem 0.95rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 196, 120, 0.3) transparent;
}

.messages::before {
  content: "";
  flex: 1 0 auto;
  min-height: 0;
}

.msg {
  max-width: 78%;
  padding: 0.48rem 0.7rem;
  font-size: 0.86rem;
  line-height: 1.35;
  font-weight: 500;
  word-break: break-word;
  transform-origin: bottom center;
  will-change: transform, opacity, filter;
  backdrop-filter: blur(8px);
}

.msg.me {
  align-self: flex-end;
  background: linear-gradient(
    145deg,
    rgba(232, 196, 120, 0.28),
    rgba(196, 146, 58, 0.16)
  );
  border: 1px solid rgba(232, 196, 120, 0.42);
  border-radius: 16px 16px 4px 16px;
  color: #fff6e4;
  box-shadow: 0 8px 22px rgba(196, 146, 58, 0.12);
  transform-origin: bottom right;
  animation: msg-me 0.55s cubic-bezier(0.22, 1.4, 0.36, 1) both;
}

.msg.them {
  align-self: flex-start;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.03)
  );
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  transform-origin: bottom left;
  animation: msg-them 0.55s cubic-bezier(0.22, 1.4, 0.36, 1) both;
}

.msg.system {
  align-self: center;
  max-width: 100%;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(232, 196, 120, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  text-align: center;
  animation: msg-system 0.4s ease both;
}

@keyframes msg-me {
  0% {
    opacity: 0;
    transform: translate3d(28px, 18px, 0) scale(0.72) rotate(4deg);
    filter: blur(4px);
  }
  55% {
    opacity: 1;
    filter: blur(0);
    transform: translate3d(-3px, -4px, 0) scale(1.04) rotate(-1deg);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
  }
}

@keyframes msg-them {
  0% {
    opacity: 0;
    transform: translate3d(-28px, 18px, 0) scale(0.72) rotate(-4deg);
    filter: blur(4px);
  }
  55% {
    opacity: 1;
    filter: blur(0);
    transform: translate3d(3px, -4px, 0) scale(1.04) rotate(1deg);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
  }
}

@keyframes msg-system {
  from {
    opacity: 0;
    letter-spacing: 0.12em;
  }
  to {
    opacity: 1;
    letter-spacing: normal;
  }
}

.msg.me,
.msg.them {
  position: relative;
}

.msg.me::after,
.msg.them::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
}

.msg.me::after {
  animation: msg-flash-me 0.7s ease-out both;
}

.msg.them::after {
  animation: msg-flash-them 0.7s ease-out both;
}

@keyframes msg-flash-me {
  0% {
    box-shadow: 0 0 0 0 rgba(232, 196, 120, 0.65);
    opacity: 1;
  }
  100% {
    box-shadow: 0 0 28px 14px rgba(232, 196, 120, 0);
    opacity: 0;
  }
}

@keyframes msg-flash-them {
  0% {
    box-shadow: 0 0 0 0 rgba(109, 191, 140, 0.55);
    opacity: 1;
  }
  100% {
    box-shadow: 0 0 28px 14px rgba(109, 191, 140, 0);
    opacity: 0;
  }
}

.typing {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 1.4rem;
  padding: 0.15rem 1rem 0.25rem;
  flex-shrink: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  animation: typing-in 0.25s ease both;
}

.typing[hidden] {
  display: none;
}

.quick-replies {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.2rem 0.85rem 0.55rem;
  flex-shrink: 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.quick-replies::-webkit-scrollbar {
  display: none;
}

.quick-replies button {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid rgba(232, 196, 120, 0.22);
  background: rgba(16, 21, 30, 0.75);
  color: var(--signal);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease,
    box-shadow 0.15s ease;
}

.quick-replies button:hover {
  border-color: rgba(232, 196, 120, 0.5);
  background: rgba(232, 196, 120, 0.12);
  box-shadow: 0 0 14px rgba(232, 196, 120, 0.12);
}

.quick-replies button:active {
  transform: scale(0.96);
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--signal);
  opacity: 0.35;
  animation: typing-bounce 1.1s ease-in-out infinite;
}

.typing-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.3;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes typing-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.composer input {
  flex: 1;
  min-width: 0;
  background: rgba(7, 9, 13, 0.55);
  border: 1px solid rgba(232, 196, 120, 0.22);
  border-radius: 999px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1rem;
  padding: 0.78rem 1.05rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer input:focus {
  border-color: rgba(232, 196, 120, 0.65);
  box-shadow: 0 0 0 3px rgba(232, 196, 120, 0.12), 0 0 24px rgba(232, 196, 120, 0.1);
}

.composer input::placeholder {
  color: #6d6558;
}

/* Prevent white autofill flash / password-style fill */
.composer input:-webkit-autofill,
.composer input:-webkit-autofill:hover,
.composer input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  box-shadow: 0 0 0 1000px #0b0f16 inset;
  transition: background-color 99999s ease-out;
}

.btn.send {
  background: linear-gradient(145deg, #f0d39a, var(--signal-deep));
  color: #1a1206;
  border: none;
  width: 2.55rem;
  height: 2.55rem;
  padding: 0;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(196, 146, 58, 0.25);
}

.btn.send:hover {
  border-color: transparent;
  filter: brightness(1.05);
}

.foot {
  text-align: center;
  padding: 0.85rem 1rem 1.25rem;
  color: #5f584c;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  flex-shrink: 0;
  line-height: 1.5;
}

.foot a {
  color: #8a7f6c;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.foot a:hover {
  color: var(--signal);
}

.foot-sub {
  display: block;
  margin-top: 0.25rem;
  color: #4a453c;
}

.legal-note {
  margin: 0.15rem 0 0;
  max-width: 16rem;
  text-align: center;
  font-size: 0.8rem;
  color: #6d6558;
  line-height: 1.4;
}

.legal-note a {
  color: var(--signal);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}

.legal-note a:hover {
  color: #f0d39a;
}

/* Keep chat viewport fixed — hide footer while chatting */
body:has(#chat.active) .foot,
body:has(#searching.active) .foot {
  display: none;
}

.confirm {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  padding-top: max(1.25rem, env(safe-area-inset-top));
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(6px);
  animation: fade-up 0.2s ease both;
}

.confirm[hidden] {
  display: none;
}

.confirm-card {
  width: min(340px, 100%);
  background: #121722;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.35rem 1.25rem 1.2rem;
  text-align: center;
}

.confirm-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.confirm-sub {
  margin: 0.45rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.confirm-actions {
  display: flex;
  gap: 0.55rem;
}

.confirm-actions .btn {
  flex: 1;
  padding: 0.75rem 1rem;
}

.btn.danger.solid {
  background: var(--danger);
  color: #1a0a08;
  border: 1px solid transparent;
}

.btn.danger.solid:hover {
  background: #eb7f70;
}

@media (max-width: 520px) {
  .top {
    padding: 0.9rem 1rem;
  }

  main {
    padding: 0 1rem;
  }

  .chat-screen {
    flex: 1;
    min-height: 0;
    height: auto;
    max-height: none;
  }

  .hero-logo {
    width: min(220px, 70vw);
  }
}
