:root {
  --bg: #0f1220;
  --bg-card: #171b2e;
  --bg-card-2: #1e2340;
  --border: #2a2f4d;
  --text: #eef0fb;
  --text-dim: #9aa0c3;
  --accent-1: #7c5cff;
  --accent-2: #21d4fd;
  --accent-grad: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  --danger: #ff5c7a;
  --success: #2ee6a6;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at top, #171c33 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 4px;
}

.brand {
  font-weight: 700;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.2px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-grad);
  box-shadow: 0 0 12px rgba(124, 92, 255, 0.8);
}

.online-indicator {
  font-size: 12px;
  color: var(--text-dim);
}

.view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0 40px;
}

.view.hidden {
  display: none;
}

.card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.card.center {
  text-align: center;
}

h1 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.3;
}

.subtitle {
  margin: 0 0 24px;
  color: var(--text-dim);
  font-size: 15px;
}

.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card-2);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease;
}

input[type="text"]:focus {
  border-color: var(--accent-1);
}

.hint {
  margin: 8px 0 24px;
  font-size: 12px;
  color: var(--text-dim);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

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

.btn-primary {
  width: 100%;
  background: var(--accent-grad);
  color: #0b0d19;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-secondary {
  background: var(--bg-card-2);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-secondary:hover,
.btn-ghost:hover {
  border-color: var(--accent-1);
  color: var(--text);
}

.rules {
  margin: 24px 0 0;
  padding-left: 18px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.8;
}

.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 20px;
  border-radius: 50%;
  border: 4px solid var(--border);
  border-top-color: var(--accent-1);
  animation: spin 0.9s linear infinite;
}

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

.card.center p {
  color: var(--text-dim);
  margin: 0 0 20px;
}

.chat-card {
  width: 100%;
  height: 78vh;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.chat-status {
  font-size: 14px;
  color: var(--text-dim);
}

.chat-actions {
  display: flex;
  gap: 8px;
}

.chat-actions .btn {
  padding: 9px 14px;
  font-size: 13px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message-me {
  align-self: flex-end;
  background: var(--accent-grad);
  color: #0b0d19;
  border-bottom-right-radius: 4px;
}

.message-stranger {
  align-self: flex-start;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message-system {
  align-self: center;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  max-width: 100%;
}

.typing-indicator {
  padding: 0 18px 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.typing-indicator.hidden {
  display: none;
}

.message-form {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.message-form input {
  flex: 1;
}

.message-form .btn {
  padding: 12px 18px;
}

@media (max-width: 480px) {
  .card {
    padding: 22px;
  }

  h1 {
    font-size: 22px;
  }

  .chat-card {
    height: 82vh;
    border-radius: 12px;
  }
}
