*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --surface2: #1c1c27;
  --border: #2a2a3a;
  --accent: #7c6aff;
  --accent2: #ff6a9b;
  --text: #e8e8f0;
  --muted: #6b6b85;
  --msg-own: #2d2060;
  --msg-other: #1c1c27;
  --radius: 14px;
  --font-ui: 'Syne', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  overflow: hidden;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .35s ease, transform .35s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

#screen-home {
  justify-content: center;
  align-items: center;
}

.home-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

.grain {
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.5;
  animation: grain 8s steps(10) infinite;
}

@keyframes grain {

  0%,
  100% {
    transform: translate(0, 0);
  }

  10% {
    transform: translate(-2%, -3%);
  }

  20% {
    transform: translate(3%, 2%);
  }

  30% {
    transform: translate(-1%, 4%);
  }

  40% {
    transform: translate(4%, -1%);
  }

  50% {
    transform: translate(-3%, 1%);
  }

  60% {
    transform: translate(2%, -4%);
  }

  70% {
    transform: translate(-4%, 3%);
  }

  80% {
    transform: translate(1%, -2%);
  }

  90% {
    transform: translate(3%, -3%);
  }
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  animation: float 12s ease-in-out infinite;
}

.blob1 {
  width: 500px;
  height: 500px;
  background: var(--accent);
  top: -150px;
  left: -100px;
  animation-delay: 0s;
}

.blob2 {
  width: 400px;
  height: 400px;
  background: var(--accent2);
  bottom: -100px;
  right: -80px;
  animation-delay: -6s;
}

@keyframes float {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  50% {
    transform: translate(30px, 20px) scale(1.05);
  }
}

.home-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
}

.logo {
  text-align: center;
}

.logo-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 8px;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

.logo h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -2px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.6;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: .8rem;
}

.home-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: .8rem;
  font-family: var(--font-mono);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-group {
  display: flex;
  gap: 10px;
}

.join-group input {
  flex: 1;
}

.disclaimer {
  color: var(--muted);
  font-size: .72rem;
  font-family: var(--font-mono);
  text-align: center;
  line-height: 1.5;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--accent), #9b59f5);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 24px rgba(124, 106, 255, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(124, 106, 255, 0.45);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary.wide {
  width: 100%;
  margin-top: 8px;
}

.btn-secondary {
  padding: 14px 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--border);
  border-color: var(--accent);
}

.btn-back {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .85rem;
  cursor: pointer;
  padding: 4px 0;
  align-self: flex-start;
  transition: color .15s;
}

.btn-back:hover {
  color: var(--text);
}

.btn-copy {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  transition: color .15s;
}

.btn-copy:hover {
  color: var(--accent);
}

input[type="text"],
textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .95rem;
  padding: 13px 16px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}

input[type="text"]:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 106, 255, 0.15);
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: var(--muted);
}

#input-room-code {
  font-family: var(--font-mono);
  letter-spacing: 3px;
  text-transform: uppercase;
}

#screen-nick {
  justify-content: center;
  align-items: center;
}

.nick-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 380px;
  padding: 24px;
}

.nick-content h2 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
}

.nick-content p {
  color: var(--muted);
  font-size: .85rem;
  font-family: var(--font-mono);
  margin-top: -8px;
}

#screen-chat {
  flex-direction: column;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.room-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.room-label {
  font-size: .65rem;
  color: var(--muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.room-code {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--accent);
}

.users-count {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
}

#user-count {
  color: #5dffb0;
}

.messages-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.messages-wrap::-webkit-scrollbar {
  width: 4px;
}

.messages-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.messages-wrap::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

#messages-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 72%;
  animation: msgIn .25s ease;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg.own {
  align-self: flex-end;
  align-items: flex-end;
}

.msg.other {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-meta {
  font-size: .68rem;
  font-family: var(--font-mono);
  color: var(--muted);
  margin-bottom: 4px;
  padding: 0 4px;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .9rem;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.msg.own .msg-bubble {
  background: var(--msg-own);
  border: 1px solid rgba(124, 106, 255, 0.3);
  border-bottom-right-radius: 4px;
  color: #ddd8ff;
}

.msg.other .msg-bubble {
  background: var(--msg-other);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-time {
  font-size: .62rem;
  font-family: var(--font-mono);
  color: var(--muted);
  margin-top: 3px;
  padding: 0 4px;
}

.sys-msg {
  text-align: center;
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--muted);
  padding: 4px 12px;
  background: var(--surface2);
  border-radius: 20px;
  align-self: center;
  border: 1px solid var(--border);
  animation: msgIn .25s ease;
}

.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 6px 12px;
  background: var(--msg-other);
  border: 1px solid var(--border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  margin-top: 4px;
}

.typing.hidden {
  display: none;
}

.typing span {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: blink 1.2s infinite;
}

.typing span:nth-child(2) {
  animation-delay: .2s;
}

.typing span:nth-child(3) {
  animation-delay: .4s;
}

@keyframes blink {

  0%,
  80%,
  100% {
    transform: scale(1);
    opacity: .5;
  }

  40% {
    transform: scale(1.3);
    opacity: 1;
  }
}

.chat-footer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#input-msg {
  flex: 1;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  border-radius: 12px;
}

.btn-send {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #9b59f5);
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 2px 12px rgba(124, 106, 255, 0.35);
}

.btn-send:hover {
  transform: scale(1.07);
}

.btn-send:active {
  transform: scale(0.95);
}

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text);
  z-index: 999;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.hidden {
  display: none;
}

#screen-config {
  justify-content: center;
  align-items: center;
}

.config-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 460px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  margin: 24px;
}

.config-content h2 {
  font-size: 1.4rem;
  font-weight: 800;
}

.config-content p {
  font-size: .8rem;
  color: var(--muted);
  font-family: var(--font-mono);
  line-height: 1.6;
}

.config-content label {
  font-size: .8rem;
  color: var(--muted);
  font-family: var(--font-mono);
  display: block;
  margin-bottom: 4px;
}

.config-content input {
  font-family: var(--font-mono);
  font-size: .8rem;
}

.config-content a {
  color: var(--accent);
}

.config-note {
  background: rgba(124, 106, 255, 0.1);
  border: 1px solid rgba(124, 106, 255, 0.3);
  border-radius: 10px;
  padding: 12px;
  font-size: .75rem;
  font-family: var(--font-mono);
  color: #b8b0ff;
  line-height: 1.6;
}


#lang-switcher {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 1000;
}

#btn-lang-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: .75rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

#btn-lang-toggle:hover {
  border-color: var(--accent);
  background: var(--surface);
}

#lang-flag {
  font-size: 1rem;
  line-height: 1;
}

.lang-arrow {
  color: var(--muted);
  font-size: .6rem;
  transition: transform .2s;
}

#lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  min-width: 170px;
  max-height: 340px;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#lang-dropdown.hidden {
  display: none;
}

#lang-dropdown::-webkit-scrollbar {
  width: 3px;
}

#lang-dropdown::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.lang-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .85rem;
  padding: 7px 10px;
  cursor: pointer;
  text-align: left;
  transition: background .12s;
}

.lang-opt:hover {
  background: var(--surface2);
}

.lang-opt span {
  font-size: 1rem;
  line-height: 1;
}

.msg {
  max-width: 85%;
}

.logo h1 {
  font-size: 2.5rem;
}